@@ -1314,10 +1314,22 @@ Expression ParseNew()
13141314 if ( _textParser . CurrentToken . Id == TokenId . Identifier )
13151315 {
13161316 var newTypeName = _textParser . CurrentToken . Text ;
1317+ _textParser . NextToken ( ) ;
1318+
1319+ while ( _textParser . CurrentToken . Id == TokenId . Dot || _textParser . CurrentToken . Id == TokenId . Plus )
1320+ {
1321+ var sep = _textParser . CurrentToken . Text ;
1322+ _textParser . NextToken ( ) ;
1323+ if ( _textParser . CurrentToken . Id != TokenId . Identifier )
1324+ throw ParseError ( Res . IdentifierExpected ) ;
1325+ newTypeName += sep + _textParser . CurrentToken . Text ;
1326+ _textParser . NextToken ( ) ;
1327+ }
1328+
13171329 newType = FindType ( newTypeName ) ;
13181330 if ( newType == null )
13191331 throw ParseError ( _textParser . CurrentToken . Pos , Res . TypeNotFound , newTypeName ) ;
1320- _textParser . NextToken ( ) ;
1332+
13211333 if ( _textParser . CurrentToken . Id != TokenId . OpenParen &&
13221334 _textParser . CurrentToken . Id != TokenId . OpenBracket &&
13231335 _textParser . CurrentToken . Id != TokenId . OpenCurlyParen )
@@ -1414,9 +1426,13 @@ private Expression CreateNewExpression(List<DynamicProperty> properties, List<Ex
14141426#endif
14151427 type = typeof ( DynamicClass ) ;
14161428 Type typeForKeyValuePair = typeof ( KeyValuePair < string , object > ) ;
1429+ #if NET35 || NET40
1430+ ConstructorInfo constructorForKeyValuePair =
1431+ typeForKeyValuePair . GetConstructors ( ) . First ( ) ;
1432+ #else
14171433 ConstructorInfo constructorForKeyValuePair =
14181434 typeForKeyValuePair . GetTypeInfo ( ) . DeclaredConstructors . First ( ) ;
1419-
1435+ #endif
14201436 var arrayIndexParams = new List < Expression > ( ) ;
14211437 for ( int i = 0 ; i < expressions . Count ; i ++ )
14221438 {
@@ -1433,7 +1449,11 @@ private Expression CreateNewExpression(List<DynamicProperty> properties, List<Ex
14331449 Expression . NewArrayInit ( typeof ( KeyValuePair < string , object > ) , arrayIndexParams ) ;
14341450
14351451 // Get the "public DynamicClass(KeyValuePair<string, object>[] propertylist)" constructor
1452+ #if NET35 || NET40
1453+ ConstructorInfo constructor = type . GetConstructors ( ) . First ( ) ;
1454+ #else
14361455 ConstructorInfo constructor = type . GetTypeInfo ( ) . DeclaredConstructors . First ( ) ;
1456+ #endif
14371457 return Expression . New ( constructor , newArrayExpression ) ;
14381458#if ! UAP10_0
14391459 }
@@ -1446,7 +1466,7 @@ private Expression CreateNewExpression(List<DynamicProperty> properties, List<Ex
14461466
14471467 Type [ ] propertyTypes = type . GetProperties ( ) . Select ( p => p . PropertyType ) . ToArray ( ) ;
14481468 ConstructorInfo ctor = type . GetConstructor ( propertyTypes ) ;
1449- if ( ctor ! = null )
1469+ if ( ctor ! = null && ctor . GetParameters ( ) . Length == expressions . Count )
14501470 return Expression . New ( ctor , expressions ) ;
14511471
14521472 MemberBinding [ ] bindings = new MemberBinding [ properties . Count ] ;
0 commit comments