From a50eb409691e560a0fdbae04e83c61e76085ca66 Mon Sep 17 00:00:00 2001 From: edmondshtogu Date: Sat, 4 Jan 2020 23:20:00 +0100 Subject: [PATCH] more details for localized attribute properties... 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);