File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed
Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -272,7 +272,9 @@ public virtual object? this[string name]
272272 if ( value != null )
273273 {
274274 var valueType = value . GetType ( ) ;
275- if ( prop . PropertyType != valueType )
275+
276+ // type must be equal, or a superclass
277+ if ( prop . PropertyType != valueType && valueType . IsSubclassOf ( prop . PropertyType ) )
276278 {
277279 throw new InvalidDataException ( $ "class property '{ prop . Name } ' with type '{ prop . PropertyType } ' does not match the type '{ valueType } ' of the value being set, this is likely a mismatch between the real class and the class from the datamodel") ;
278280 }
Original file line number Diff line number Diff line change 1010using DM = Datamodel . Datamodel ;
1111using System . Globalization ;
1212using VMAP ;
13- using Vector3Data = VMAP . CDmePolygonMeshDataStream < System . Numerics . Vector3 > ;
1413
1514namespace Datamodel_Tests
1615{
@@ -322,8 +321,11 @@ private static void Validate_Vmap_Reflection(Datamodel.Datamodel unserialisedVma
322321 Assert . AreEqual ( vertexData . size , 8 ) ;
323322 Assert . AreEqual ( vertexData . streams [ 0 ] [ "semanticName" ] , "position" ) ;
324323
325- // todo: vertexData.streams[0] is not a instance of CDmePolygonMeshDataStream<Vector3>
326- // Assert.AreEqual(((Vector3Data)vertexData.streams[0]).semanticName, "position");
324+ var typedPolygonMeshData = ( VMAP . CDmePolygonMeshDataStream ) vertexData . streams [ 0 ] ;
325+ Assert . AreEqual ( typedPolygonMeshData . semanticName , "position" ) ;
326+
327+ var typedPolygonMeshDataStream = typedPolygonMeshData . data as Vector3Array ;
328+ Assert . IsNotNull ( typedPolygonMeshDataStream ) ;
327329
328330 Assert . That ( unserialisedVmap . PrefixAttributes [ "map_asset_references" ] , Is . Not . Empty ) ;
329331
Original file line number Diff line number Diff line change @@ -359,8 +359,7 @@ internal class CDmePolygonMeshSubdivisionData : DMElement
359359 public Datamodel . ElementArray streams { get ; set ; } = [ ] ;
360360}
361361
362-
363- internal class CDmePolygonMeshDataStream < T > : DMElement
362+ internal class CDmePolygonMeshDataStream : DMElement
364363{
365364 public string standardAttributeName { get ; set ; } = string . Empty ;
366365 public string semanticName { get ; set ; } = string . Empty ;
@@ -371,5 +370,14 @@ internal class CDmePolygonMeshDataStream<T> : DMElement
371370 /// <summary>
372371 /// An int, vector2, vector3, or vector4 array.
373372 /// </summary>
374- public required Datamodel . Array < T > data { get ; set ; }
373+ public System . Collections . IList ? data { get ; set ; }
374+ }
375+
376+ /// <remarks>
377+ /// Note: The deserializer does not support generic types, but the serializer does.
378+ /// </remarks>
379+ /// <typeparam name="T">Int, Vector2, Vector3, or Vector4</typeparam>
380+ internal class CDmePolygonMeshDataStream < T > : CDmePolygonMeshDataStream
381+ {
382+ public new required Datamodel . Array < T > data { get ; set ; }
375383}
You can’t perform that action at this time.
0 commit comments