@@ -7,7 +7,7 @@ namespace Microsoft.OData.Edm;
7
7
#else
8
8
using Microsoft . OData . ModelBuilder ;
9
9
#endif
10
- using static System . StringComparison ;
10
+ using System . Runtime . CompilerServices ;
11
11
12
12
internal static class EdmExtensions
13
13
{
@@ -41,11 +41,24 @@ internal static class EdmExtensions
41
41
{
42
42
"Edm.String" or "Edm.Byte" or "Edm.SByte" or "Edm.Int16" or "Edm.Int32" or "Edm.Int64" or
43
43
"Edm.Double" or "Edm.Single" or "Edm.Boolean" or "Edm.Decimal" or "Edm.DateTime" or "Edm.DateTimeOffset" or
44
- "Edm.Guid" => Type . GetType ( edmFullName . Replace ( "Edm" , "System" , Ordinal ) , ThrowOnError ) ,
44
+ "Edm.Guid" => Type . GetType ( Requalify ( edmFullName , "System" ) , ThrowOnError ) ,
45
45
"Edm.Duration" => typeof ( TimeSpan ) ,
46
46
"Edm.Binary" => typeof ( byte [ ] ) ,
47
- "Edm.Geography" or "Edm.Geometry" => Type . GetType ( edmFullName . Replace ( "Edm" , "Microsoft.Spatial" , Ordinal ) , ThrowOnError ) ,
48
- "Edm.Date" or "Edm.TimeOfDay" => Type . GetType ( edmFullName . Replace ( "Edm" , "Microsoft.OData.Edm" , Ordinal ) , ThrowOnError ) ,
47
+ "Edm.Geography" or "Edm.Geometry" => GetTypeFromAssembly ( edmFullName , "Microsoft.Spatial" ) ,
48
+ "Edm.Date" or "Edm.TimeOfDay" => GetTypeFromAssembly ( edmFullName , "Microsoft.OData.Edm" ) ,
49
49
_ => null ,
50
50
} ;
51
+
52
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
53
+ #if NETFRAMEWORK
54
+ private static string Requalify ( string edmFullName , string @namespace ) => @namespace + edmFullName . Substring ( 3 ) ;
55
+ #else
56
+ private static string Requalify ( string edmFullName , string @namespace ) => string . Concat ( @namespace . AsSpan ( ) , edmFullName . AsSpan ( ) . Slice ( 3 ) ) ;
57
+ #endif
58
+
59
+ private static Type ? GetTypeFromAssembly ( string edmFullName , string assemblyName )
60
+ {
61
+ var typeName = Requalify ( edmFullName , assemblyName ) + "," + assemblyName ;
62
+ return Type . GetType ( typeName , ThrowOnError ) ;
63
+ }
51
64
}
0 commit comments