@@ -19,19 +19,14 @@ public static object MakeObject(
1919 [ DynamicallyAccessedMembers ( Trimming . Properties ) ] Type objectType , KVObject keyValueObject , IObjectReflector reflector )
2020 => InvokeGeneric ( nameof ( MakeObject ) , objectType , new object [ ] { keyValueObject , reflector } ) ;
2121
22- [ UnconditionalSuppressMessage ( "ReflectionAnalysis" , "IL2062" , Justification = "If the lookup value type exists at runtime then it should have enough for us to introspect." ) ]
2322 public static TObject MakeObject < [ DynamicallyAccessedMembers ( Trimming . Constructors | Trimming . Properties ) ] TObject > ( KVObject keyValueObject , IObjectReflector reflector )
2423 {
2524 ArgumentNullException . ThrowIfNull ( keyValueObject ) ;
2625 ArgumentNullException . ThrowIfNull ( reflector ) ;
2726
2827 if ( keyValueObject . ValueType == KVValueType . Collection )
2928 {
30- if ( IsLookupWithStringKey ( typeof ( TObject ) , out var lookupValueType ) )
31- {
32- return ( TObject ) MakeLookup ( lookupValueType , keyValueObject , reflector ) ;
33- }
34- else if ( IsDictionary ( typeof ( TObject ) ) )
29+ if ( IsDictionary ( typeof ( TObject ) ) )
3530 {
3631 return ( TObject ) MakeDictionary ( typeof ( TObject ) , keyValueObject , reflector ) ;
3732 }
@@ -182,47 +177,6 @@ static bool IsArray(KVObject obj, out object[] values)
182177 return true ;
183178 }
184179
185- static bool IsLookupWithStringKey ( Type type , out Type valueType )
186- {
187- valueType = null ;
188-
189- if ( ! type . IsConstructedGenericType )
190- {
191- return false ;
192- }
193-
194- var genericType = type . GetGenericTypeDefinition ( ) ;
195- if ( genericType != typeof ( ILookup < , > ) )
196- {
197- return false ;
198- }
199-
200- var genericArguments = type . GetGenericArguments ( ) ;
201- if ( genericArguments . Length != 2 )
202- {
203- return false ;
204- }
205-
206- if ( genericArguments [ 0 ] != typeof ( string ) )
207- {
208- return false ;
209- }
210-
211- valueType = genericArguments [ 1 ] ;
212- return true ;
213- }
214-
215- static object MakeLookup (
216- [ DynamicallyAccessedMembers ( Trimming . Constructors | Trimming . Properties ) ] Type valueType ,
217- KVObject obj ,
218- IObjectReflector reflector )
219- => InvokeGeneric ( nameof ( MakeLookupCore ) , valueType , new object [ ] { obj , reflector } ) ;
220-
221- static ILookup < string , TValue > MakeLookupCore < [ DynamicallyAccessedMembers ( Trimming . Constructors | Trimming . Properties ) ] TValue > ( KVObject obj , IObjectReflector reflector )
222- {
223- return obj . ToLookup ( kvp => kvp . Key , kvp => ConvertValue < TValue > ( kvp . Value , reflector ) ) ;
224- }
225-
226180 static readonly Dictionary < Type , Func < Type , object [ ] , IObjectReflector , object > > EnumerableBuilders = new ( )
227181 {
228182 [ typeof ( List < > ) ] = ( type , values , reflector ) => InvokeGeneric ( nameof ( MakeList ) , type . GetGenericArguments ( ) [ 0 ] , new object [ ] { values , reflector } ) ,
0 commit comments