@@ -461,19 +461,13 @@ public void GetComponentData_UsesSharedMaterialInEditMode()
461461 // Assert - Verify that the material property was accessed without instantiation
462462 Assert . IsNotNull ( result , "GetComponentData should return a result" ) ;
463463
464- // Tolerate varying shapes - if properties exist and are a dictionary, ensure keys are reasonable
465- var resultType = result . GetType ( ) ;
466- var propertiesField = resultType . GetField ( "properties" ) ;
467- if ( propertiesField != null )
464+ // Check that result is a dictionary with properties key
465+ if ( result is Dictionary < string , object > resultDict &&
466+ resultDict . TryGetValue ( "properties" , out var propertiesObj ) &&
467+ propertiesObj is Dictionary < string , object > properties )
468468 {
469- var properties = propertiesField . GetValue ( result ) ;
470- Assert . IsNotNull ( properties , "properties should not be null when present" ) ;
471- var dict = properties as Dictionary < string , object > ;
472- if ( dict != null )
473- {
474- Assert . IsTrue ( dict . ContainsKey ( "material" ) || dict . ContainsKey ( "sharedMaterial" ) ,
475- "Serialized data should include 'material' or 'sharedMaterial' when present." ) ;
476- }
469+ Assert . IsTrue ( properties . ContainsKey ( "material" ) || properties . ContainsKey ( "sharedMaterial" ) ,
470+ "Serialized data should include 'material' or 'sharedMaterial' when present." ) ;
477471 }
478472
479473 // Clean up
@@ -501,19 +495,13 @@ public void GetComponentData_UsesSharedMeshInEditMode()
501495 // Assert - Verify that the mesh property was accessed without instantiation
502496 Assert . IsNotNull ( result , "GetComponentData should return a result" ) ;
503497
504- // Tolerate varying shapes - if properties exist and are a dictionary, ensure keys are reasonable
505- var resultType = result . GetType ( ) ;
506- var propertiesField = resultType . GetField ( "properties" ) ;
507- if ( propertiesField != null )
498+ // Check that result is a dictionary with properties key
499+ if ( result is Dictionary < string , object > resultDict &&
500+ resultDict . TryGetValue ( "properties" , out var propertiesObj ) &&
501+ propertiesObj is Dictionary < string , object > properties )
508502 {
509- var properties = propertiesField . GetValue ( result ) ;
510- Assert . IsNotNull ( properties , "properties should not be null when present" ) ;
511- var dict = properties as Dictionary < string , object > ;
512- if ( dict != null )
513- {
514- Assert . IsTrue ( dict . ContainsKey ( "mesh" ) || dict . ContainsKey ( "sharedMesh" ) ,
515- "Serialized data should include 'mesh' or 'sharedMesh' when present." ) ;
516- }
503+ Assert . IsTrue ( properties . ContainsKey ( "mesh" ) || properties . ContainsKey ( "sharedMesh" ) ,
504+ "Serialized data should include 'mesh' or 'sharedMesh' when present." ) ;
517505 }
518506
519507 // Clean up
0 commit comments