Browse Source

use RuntimeHelpers.IsReferenceOrContainsReferences<T>

Bert Temme 2 years ago
parent
commit
6dfc9a257e
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/SharpGLTF.Cesium/BinaryTable.cs

+ 5 - 1
src/SharpGLTF.Cesium/BinaryTable.cs

@@ -197,7 +197,11 @@ namespace SharpGLTF
 
 
         public static int GetSize<T>()
         public static int GetSize<T>()
         {
         {
-            var isValueType = typeof(T).IsValueType;
+            #if NETSTANDARD2_1_OR_GREATER
+                var isValueType = !System.Runtime.CompilerServices.RuntimeHelpers.IsReferenceOrContainsReferences<T>();
+            #else
+                var isValueType = typeof(T).IsValueType;
+            #endif
             Guard.IsTrue(isValueType, nameof(T), "T must be a value type");
             Guard.IsTrue(isValueType, nameof(T), "T must be a value type");
 
 
             var type = typeof(T);
             var type = typeof(T);