@@ -1580,7 +1580,7 @@ private Expression CreateNewExpression(List<DynamicProperty> properties, List<Ex
15801580 var propertyInfos = type . GetProperties ( ) ;
15811581 if ( type . GetTypeInfo ( ) . BaseType == typeof ( DynamicClass ) )
15821582 {
1583- propertyInfos = propertyInfos . Where ( x => x . Name != "Item" ) . ToArray ( ) ;
1583+ propertyInfos = propertyInfos . Where ( x => x . Name != DynamicClass . IndexerName ) . ToArray ( ) ;
15841584 }
15851585
15861586 var propertyTypes = propertyInfos . Select ( p => p . PropertyType ) . ToArray ( ) ;
@@ -1906,7 +1906,7 @@ private Expression ParseMemberAccess(Type? type, Expression? expression, string?
19061906#if UAP10_0 || NETSTANDARD1_3
19071907 if ( type == typeof ( DynamicClass ) )
19081908 {
1909- return Expression . MakeIndex ( expression , typeof ( DynamicClass ) . GetProperty ( "Item" ) , new [ ] { Expression . Constant ( id ) } ) ;
1909+ return Expression . MakeIndex ( expression ! , typeof ( DynamicClass ) . GetProperty ( DynamicClass . IndexerName ) , [ Expression . Constant ( id ) ] ) ;
19101910 }
19111911#endif
19121912 if ( TryFindPropertyOrField ( type ! , id , expression , out var propertyOrFieldExpression ) )
@@ -1920,7 +1920,8 @@ private Expression ParseMemberAccess(Type? type, Expression? expression, string?
19201920
19211921 if ( ! _parsingConfig . DisableMemberAccessToIndexAccessorFallback && extraCheck )
19221922 {
1923- var indexerMethod = expression ? . Type . GetMethod ( "get_Item" , new [ ] { typeof ( string ) } ) ;
1923+ var indexerName = TypeHelper . IsDynamicClass ( type ! ) ? DynamicClass . IndexerName : "Item" ;
1924+ var indexerMethod = expression ? . Type . GetMethod ( $ "get_{ indexerName } ", [ typeof ( string ) ] ) ;
19241925 if ( indexerMethod != null )
19251926 {
19261927 return Expression . Call ( expression , indexerMethod , Expression . Constant ( id ) ) ;
0 commit comments