Skip to content

Commit

Permalink
more details for localized attribute properties... (#558)
Browse files Browse the repository at this point in the history
If the resources are not visible the parser library throws a useless exception.
These extra details help with finding the issue quicker.
  • Loading branch information
edmondshtogu authored Feb 3, 2020
1 parent 58e5391 commit b211712
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b211712

Please sign in to comment.