11using System . Collections . Generic ;
2+ using System . Linq . Dynamic . Core . Validation ;
23using System . Reflection ;
34
45namespace System . Linq . Dynamic . Core . Parser ;
@@ -12,45 +13,47 @@ internal class PredefinedMethodsHelper
1213 internal static readonly MethodInfo ObjectStaticEquals = typeof ( object ) . GetMethod ( nameof ( Equals ) , BindingFlags . Static | BindingFlags . Public , null , [ typeof ( object ) , typeof ( object ) ] , null ) ! ;
1314 internal static readonly MethodInfo ObjectStaticReferenceEquals = typeof ( object ) . GetMethod ( nameof ( ReferenceEquals ) , BindingFlags . Static | BindingFlags . Public , null , [ typeof ( object ) , typeof ( object ) ] , null ) ! ;
1415
15- private readonly Dictionary < Type , HashSet < MethodInfo > > _supported = new ( )
16+ private readonly Dictionary < Type , HashSet < MemberInfo > > _supported = new ( )
1617 {
17- { typeof ( bool ) , new HashSet < MethodInfo > ( ) } ,
18- { typeof ( char ) , new HashSet < MethodInfo > ( ) } ,
19- { typeof ( string ) , new HashSet < MethodInfo > ( ) } ,
20- { typeof ( sbyte ) , new HashSet < MethodInfo > ( ) } ,
21- { typeof ( byte ) , new HashSet < MethodInfo > ( ) } ,
22- { typeof ( short ) , new HashSet < MethodInfo > ( ) } ,
23- { typeof ( ushort ) , new HashSet < MethodInfo > ( ) } ,
24- { typeof ( int ) , new HashSet < MethodInfo > ( ) } ,
25- { typeof ( uint ) , new HashSet < MethodInfo > ( ) } ,
26- { typeof ( long ) , new HashSet < MethodInfo > ( ) } ,
27- { typeof ( ulong ) , new HashSet < MethodInfo > ( ) } ,
28- { typeof ( float ) , new HashSet < MethodInfo > ( ) } ,
29- { typeof ( double ) , new HashSet < MethodInfo > ( ) } ,
30- { typeof ( decimal ) , new HashSet < MethodInfo > ( ) } ,
31- // { typeof(DateTime), new HashSet<MethodInfo >() },
32- // { typeof(DateTimeOffset), new HashSet<MethodInfo >() },
33- // { typeof(TimeSpan), new HashSet<MethodInfo >() },
34- // { typeof(Guid), new HashSet<MethodInfo >() },
35- // { typeof(Uri), new HashSet<MethodInfo >() },
36- // { typeof(Enum), new HashSet<MethodInfo >() },
18+ { typeof ( bool ) , new HashSet < MemberInfo > ( ) } ,
19+ { typeof ( char ) , new HashSet < MemberInfo > ( ) } ,
20+ { typeof ( string ) , new HashSet < MemberInfo > ( ) } ,
21+ { typeof ( sbyte ) , new HashSet < MemberInfo > ( ) } ,
22+ { typeof ( byte ) , new HashSet < MemberInfo > ( ) } ,
23+ { typeof ( short ) , new HashSet < MemberInfo > ( ) } ,
24+ { typeof ( ushort ) , new HashSet < MemberInfo > ( ) } ,
25+ { typeof ( int ) , new HashSet < MemberInfo > ( ) } ,
26+ { typeof ( uint ) , new HashSet < MemberInfo > ( ) } ,
27+ { typeof ( long ) , new HashSet < MemberInfo > ( ) } ,
28+ { typeof ( ulong ) , new HashSet < MemberInfo > ( ) } ,
29+ { typeof ( float ) , new HashSet < MemberInfo > ( ) } ,
30+ { typeof ( double ) , new HashSet < MemberInfo > ( ) } ,
31+ { typeof ( decimal ) , new HashSet < MemberInfo > ( ) } ,
32+ // { typeof(DateTime), new HashSet<MemberInfo >() },
33+ // { typeof(DateTimeOffset), new HashSet<MemberInfo >() },
34+ // { typeof(TimeSpan), new HashSet<MemberInfo >() },
35+ // { typeof(Guid), new HashSet<MemberInfo >() },
36+ // { typeof(Uri), new HashSet<MemberInfo >() },
37+ // { typeof(Enum), new HashSet<MemberInfo >() },
3738#if NET6_0_OR_GREATER
38- // { typeof(DateOnly), new HashSet<MethodInfo >() },
39- // { typeof(TimeOnly), new HashSet<MethodInfo >() },
39+ // { typeof(DateOnly), new HashSet<MemberInfo >() },
40+ // { typeof(TimeOnly), new HashSet<MemberInfo >() },
4041#endif
4142 } ;
4243
4344 public PredefinedMethodsHelper ( ParsingConfig config )
4445 {
4546 foreach ( var kvp in _supported )
4647 {
47- Add ( kvp . Key . GetMethod ( nameof ( Equals ) , _bindingFlags , null , [ kvp . Key ] , null ) ) ;
48- Add ( kvp . Key . GetMethod ( nameof ( Equals ) , _bindingFlags , null , [ typeof ( object ) ] , null ) ) ;
48+ Add ( kvp . Key , ObjectInstanceEquals ) ;
49+ Add ( kvp . Key , kvp . Key . GetMethod ( nameof ( Equals ) , _bindingFlags , null , [ kvp . Key ] , null ) ) ;
50+ Add ( kvp . Key , kvp . Key . GetMethod ( nameof ( Equals ) , _bindingFlags , null , [ typeof ( object ) ] , null ) ) ;
4951
50- Add ( kvp . Key . GetMethod ( nameof ( ToString ) , _bindingFlags , null , Type . EmptyTypes , null ) ) ;
51- Add ( kvp . Key . GetMethod ( nameof ( ToString ) , _bindingFlags , null , [ typeof ( string ) ] , null ) ) ;
52- Add ( kvp . Key . GetMethod ( nameof ( ToString ) , _bindingFlags , null , [ typeof ( IFormatProvider ) ] , null ) ) ;
53- Add ( kvp . Key . GetMethod ( nameof ( ToString ) , _bindingFlags , null , [ typeof ( string ) , typeof ( IFormatProvider ) ] , null ) ) ;
52+ Add ( kvp . Key , ObjectInstanceToString ) ;
53+ Add ( kvp . Key , kvp . Key . GetMethod ( nameof ( ToString ) , _bindingFlags , null , Type . EmptyTypes , null ) ) ;
54+ Add ( kvp . Key , kvp . Key . GetMethod ( nameof ( ToString ) , _bindingFlags , null , [ typeof ( string ) ] , null ) ) ;
55+ Add ( kvp . Key , kvp . Key . GetMethod ( nameof ( ToString ) , _bindingFlags , null , [ typeof ( IFormatProvider ) ] , null ) ) ;
56+ Add ( kvp . Key , kvp . Key . GetMethod ( nameof ( ToString ) , _bindingFlags , null , [ typeof ( string ) , typeof ( IFormatProvider ) ] , null ) ) ;
5457 }
5558
5659 if ( config . AllowEqualsAndToStringMethodsOnObject )
0 commit comments