@@ -104,6 +104,10 @@ private MemberPath(MemberPathKey key, ComponentType componentType, int structInd
104104
105105 private const BindingFlags Flags = BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . GetField | BindingFlags . GetProperty ;
106106
107+ #if NETSTANDARD && ! NETSTANDARD2_1_OR_GREATER
108+ private static readonly char [ ] SplitDotArray = [ '.' ] ;
109+ #endif
110+
107111 /// <summary>
108112 /// Returns a <see cref="MemberPath"/> identifying a specific field / property by its <paramref name="path"/>
109113 /// within the passed <paramref name="type"/>.
@@ -122,7 +126,11 @@ public static MemberPath Get(Type type, string path)
122126 if ( Map . TryGetValue ( key , out var componentFieldInfo ) ) {
123127 return componentFieldInfo ;
124128 }
129+ #if NETSTANDARD && ! NETSTANDARD2_1_OR_GREATER
130+ var pathItems = path . Split ( SplitDotArray , StringSplitOptions . RemoveEmptyEntries ) ;
131+ #else
125132 var pathItems = path . Split ( '.' , StringSplitOptions . RemoveEmptyEntries ) ;
133+ #endif
126134 var memberInfos = new MemberInfo [ pathItems . Length ] ;
127135 var memberType = type ;
128136 bool canWrite = true ;
@@ -188,10 +196,24 @@ public static MemberPath Get(Type type, string path)
188196
189197 // See ThrowIfTypeNeverValidGenericArgument() at:
190198 // https://github.com/dotnet/runtime/blob/4f5c6938d09e935830492c006aa8381611b65ad8/src/libraries/System.Private.CoreLib/src/System/RuntimeType.cs#L736
191- private static bool IsInvalidType ( Type type ) {
192- return type . IsPointer || type . IsByRef || type == typeof ( void ) ||
193- type . IsByRefLike ; // type is a ref struct. E.g. Span<>
199+ private static bool IsInvalidType ( Type type )
200+ {
201+ if ( type . IsPointer || type . IsByRef || type == typeof ( void ) )
202+ return true ;
203+ #if NETSTANDARD && ! NETSTANDARD2_1_OR_GREATER
204+ if ( type . IsByRef )
205+ return true ;
206+ if ( type . IsGenericType )
207+ {
208+ var genericTypeDef = type . GetGenericTypeDefinition ( ) ;
209+ if ( genericTypeDef == typeof ( Span < > ) || genericTypeDef == typeof ( ReadOnlySpan < > ) )
210+ return true ;
194211 }
212+ return false ;
213+ #else
214+ return type . IsByRefLike ; // type is a ref struct. E.g. Span<>
215+ #endif
216+ }
195217
196218 // ReSharper disable UnusedMember.Local
197219 [ UnconditionalSuppressMessage ( "ReflectionAnalysis" , "IL2026" , Justification = "Not called for NativeAOT" ) ]
0 commit comments