From b21171225759d584bd4e1c8480fa1e4e98a0fbfd Mon Sep 17 00:00:00 2001 From: edmondshtogu Date: Mon, 3 Feb 2020 10:35:53 +0100 Subject: [PATCH] more details for localized attribute properties... (#558) If the resources are not visible the parser library throws a useless exception. These extra details help with finding the issue quicker. --- .../Infrastructure/LocalizableAttributeProperty.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CommandLine/Infrastructure/LocalizableAttributeProperty.cs b/src/CommandLine/Infrastructure/LocalizableAttributeProperty.cs index b5a36100..9edd621b 100644 --- a/src/CommandLine/Infrastructure/LocalizableAttributeProperty.cs +++ b/src/CommandLine/Infrastructure/LocalizableAttributeProperty.cs @@ -45,10 +45,10 @@ private string GetLocalizedValue() { // Static class IsAbstract if (!_type.IsVisible) - throw new ArgumentException("Invalid resource type", _propertyName); + throw new ArgumentException($"Invalid resource type '{_type.FullName}'! {_type.Name} is not visible for the parser! Change resources 'Access Modifier' to 'Public'", _propertyName); PropertyInfo propertyInfo = _type.GetProperty(_value, BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Static); if (propertyInfo == null || !propertyInfo.CanRead || propertyInfo.PropertyType != typeof(string)) - throw new ArgumentException("Invalid resource property name", _propertyName); + throw new ArgumentException("Invalid resource property name! Localized value: {_value}", _propertyName); _localizationPropertyInfo = propertyInfo; } return (string)_localizationPropertyInfo.GetValue(null, null);