Open bartdesmet opened 8 years ago
For context, we use a check against Members
being non-null to determine whether a NewExpression
node represents the instantiation of an anonymous type (as part of a pretty printer for expression trees as C# strings). For the corner case new { }
, it now fails.
Considering the impact of the scenario and the risk of potential regressions, moved to 2.1.
@bartdesmet
For context, we use a check against
Members
being non-null to determine whether aNewExpression
node represents the instantiation of an anonymous type (as part of a pretty printer for expression trees as C# strings). For the corner casenew { }
, it now fails.
I wanted to chime in here to warn against this; a NewExpression
with non-null Members
cannot be guaranteed to represent the construction of an anonymous type. It is a shame that there was no AnonymousTypeAttribute
or anything specified when anonymous types were introduced, but you can still more-or-less tell whether a given type is anonymous or not by checking certain features of the type itself.
Self-contained repro, comparing against C# 5 native compiler: