Browse Source

Fix #1500: anonymous type creation expression cannot have an object initializer.

pull/1505/head
Siegfried Pammer 6 years ago
parent
commit
7a976f197f
  1. 4
      ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs

4
ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs

@ -66,6 +66,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false;
if (DelegateConstruction.IsDelegateConstruction(newObjInst) || DelegateConstruction.IsPotentialClosure(context, newObjInst))
return false;
// Cannot build a collection/object initializer attached to an AnonymousTypeCreateExpression:s
// anon = new { A = 5 } { 3,4,5 } is invalid syntax.
if (newObjInst.Method.DeclaringType.ContainsAnonymousType())
return false;
instType = newObjInst.Method.DeclaringType;
break;
case DefaultValue defaultVal:

Loading…
Cancel
Save