Skip to content

Commit

Permalink
Fixed a bug with inherited implementations of themeable controls
Browse files Browse the repository at this point in the history
  • Loading branch information
anarchie347 committed Apr 25, 2023
1 parent a7083a5 commit a2b6d14
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Themes/ThemeableForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ private static void ValidateTypesOfThemeableProperties(PropertyInfo themePropert
if (!(editingPropertyType.IsGenericType && (editingPropertyType.GetGenericTypeDefinition() == typeof(Action<,>) || editingPropertyType.IsSubclassOf(typeof(Action<,>)))))
throw new Exception($"{editingProperty.Name} in class {ctrlType.Name} was of type {editingPropertyType.Name}, when it should have been an implementation of Action`2");

if (!(themePropertyType.GetGenericArguments().Length == 1))
if (themePropertyType.GetGenericArguments().Length != 1)
throw new Exception($"{themeProperty.Name} in class {ctrlType.Name} had {themePropertyType.GetGenericArguments().Length} generic arguements. It should have had 1");

if (!(editingPropertyType.GetGenericArguments().Length == 2))
if (editingPropertyType.GetGenericArguments().Length != 2)
throw new Exception($"{editingProperty.Name} in class {ctrlType.Name} had {editingPropertyType.GetGenericArguments().Length} generic arguements. It should have had 2");

//types required and provided by the theme and editing properties
Expand All @@ -172,10 +172,12 @@ private static void ValidateTypesOfThemeableProperties(PropertyInfo themePropert
if (themePropertyReturnType != editingPropertyValueType)
throw new Exception($"{themeProperty.Name} in class {ctrlType.Name} returns type {themePropertyReturnType.Name}, but {editingProperty.Name} accepts a value of type {editingPropertyValueType.Name}");

if (!(editingPropertyThemeableType == ctrlType))
if (editingPropertyThemeableType != ctrlType)
throw new Exception($"The first generic arguement for {editingProperty.Name} was {editingPropertyThemeableType.Name} which did not correspond to the type of the class which was {ctrlType.Name}");

}
if (editingPropertyThemeableType is not IThemeableControl)
throw new Exception($"The first generic arguement for {editingProperty.Name} was {editingPropertyThemeableType.Name} which did not correspond to the type of the class which was {ctrlType.Name}");
}

private List<IThemeableControl> GetAllChildControls(Control control)
{
Expand Down

0 comments on commit a2b6d14

Please sign in to comment.