@@ -7,7 +7,7 @@ namespace Microsoft.OData.Edm;
77#else
88using Microsoft . OData . ModelBuilder ;
99#endif
10- using static System . StringComparison ;
10+ using System . Runtime . CompilerServices ;
1111
1212internal static class EdmExtensions
1313{
@@ -41,11 +41,24 @@ internal static class EdmExtensions
4141 {
4242 "Edm.String" or "Edm.Byte" or "Edm.SByte" or "Edm.Int16" or "Edm.Int32" or "Edm.Int64" or
4343 "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 ) ,
4545 "Edm.Duration" => typeof ( TimeSpan ) ,
4646 "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" ) ,
4949 _ => null ,
5050 } ;
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+ }
5164}
0 commit comments