@@ -157,11 +157,9 @@ public void BindAssetTypesToEnums(AssetDirectory assetDirectory)
157
157
/// </summary>
158
158
public System . Reflection . PropertyInfo GetFieldInfo ( Type prototypeClassType , BlueprintMemberInfo blueprintMemberInfo , bool getPropertyCollection )
159
159
{
160
+ // Return the C# property info the blueprint member is bound to if we are not looking for a property collection
160
161
if ( getPropertyCollection == false )
161
- {
162
- // Return the C# property info the blueprint member is bound to if we are not looking for a property collection
163
162
return blueprintMemberInfo . Member . RuntimeClassFieldInfo ;
164
- }
165
163
166
164
// TODO: look for a property collection field for this prototype
167
165
return null ;
@@ -170,29 +168,32 @@ public System.Reflection.PropertyInfo GetFieldInfo(Type prototypeClassType, Blue
170
168
/// <summary>
171
169
/// Returns a <see cref="System.Reflection.PropertyInfo"/> for a mixin field in a Calligraphy prototype.
172
170
/// </summary>
173
- public System . Reflection . PropertyInfo GetMixinFieldInfo ( Type ownerClassType , Type fieldClassType , Type mixinAttribute )
171
+ public System . Reflection . PropertyInfo GetMixinFieldInfo ( Type ownerClassType , Type fieldClassType , PrototypeFieldType fieldType )
174
172
{
175
- // Make sure we have a valid attribute type
176
- if ( ( mixinAttribute == typeof ( MixinAttribute ) || mixinAttribute == typeof ( ListMixinAttribute ) ) == false )
177
- throw new ArgumentException ( $ "{ mixinAttribute . Name } is not a mixin attribute .") ;
173
+ // Make sure we have a valid field type enum value
174
+ if ( ( fieldType == PrototypeFieldType . Mixin || fieldType == PrototypeFieldType . ListMixin ) == false )
175
+ throw new ArgumentException ( $ "{ fieldType } is not a mixin field type .") ;
178
176
179
177
// Search the entire class hierarchy for a mixin of the matching type
180
178
while ( ownerClassType != typeof ( Prototype ) )
181
179
{
182
180
// We do what PrototypeFieldSet::GetMixinFieldInfo() does right here using reflection
183
181
foreach ( var property in ownerClassType . GetProperties ( ) )
184
182
{
185
- if ( mixinAttribute == typeof ( MixinAttribute ) )
183
+ if ( fieldType == PrototypeFieldType . Mixin )
186
184
{
187
185
// For simple mixins we just return the property if it matches our field type and has the correct attribute
188
186
if ( property . PropertyType != fieldClassType ) continue ;
189
- if ( property . IsDefined ( mixinAttribute ) ) return property ;
187
+ if ( property . IsDefined ( typeof ( MixinAttribute ) ) ) return property ;
190
188
}
191
- else if ( mixinAttribute == typeof ( ListMixinAttribute ) )
189
+ else if ( fieldType == PrototypeFieldType . ListMixin )
192
190
{
193
191
// For list mixins we look for a list that is compatible with our requested field type
194
192
if ( property . PropertyType != typeof ( PrototypeMixinList ) ) continue ;
195
193
194
+ // NOTE: While we check if the field type defined in the attribute matches our field class type argument exactly,
195
+ // the client checks if the argument type is derived from the type defined in the field info.
196
+ // This doesn't seem to cause any issues in 1.52, but may need to be changed if we run into issues with other versions.
196
197
var attribute = property . GetCustomAttribute < ListMixinAttribute > ( ) ;
197
198
if ( attribute . FieldType == fieldClassType )
198
199
return property ;
0 commit comments