Clarify type check

This commit is contained in:
Bartłomiej Dach 2023-05-04 19:06:07 +02:00
parent 1f1342b099
commit 485b7282dc
No known key found for this signature in database
1 changed files with 6 additions and 3 deletions

View File

@ -188,10 +188,13 @@ public void CopyCommonSettingsFrom(Mod source)
if (sourceSetting.IsDefault) if (sourceSetting.IsDefault)
continue; continue;
var targetType = targetSetting.GetType(); var targetBindableType = targetSetting.GetType();
var sourceType = sourceSetting.GetType(); var sourceBindableType = sourceSetting.GetType();
if (!targetType.IsAssignableFrom(sourceType) && !sourceType.IsAssignableFrom(targetType)) // if either the target is assignable to the source or the source is assignable to the target,
// then we presume that the data types contained in both bindables are compatible and we can proceed with the copy.
// this handles cases like `Bindable<int>` and `BindableInt`.
if (!targetBindableType.IsAssignableFrom(sourceBindableType) && !sourceBindableType.IsAssignableFrom(targetBindableType))
continue; continue;
// TODO: special case for handling number types // TODO: special case for handling number types