Class AnonymousTypeTupletizer
Provides expression tree rewrite functionality to substitute anonymous types with tuple types. This rewrite is useful to reduce dependencies on compiler-generated types, e.g. for serialization.
Inheritance
Namespace: System.Linq.CompilerServices
Assembly: Nuqleon.Linq.CompilerServices.dll
Syntax
public static class AnonymousTypeTupletizer : Object
Methods
Tupletize(Expression, Expression)
Substitutes occurrences of anonymous types in the specified expression by replacing those for tuple types. Types visible in the expression result type are included in the tupletization.
Declaration
public static Expression Tupletize(Expression expression, Expression unitValue)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to tupletize. |
System.Linq.Expressions.Expression | unitValue | Expression representing the unit value, used for anonymous types with no properties (e.g. new { } in C#). The type of the expression can't be a value type, but you can use a boxing conversion to work around this limitation. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Expression tree with anonymous types substituted for tuple types. |
Remarks
Assignments to Visual Basic anonymous type properties will cause the rewrite to fail. Semantics of tuples are similar to those of C# anonymous types, with every property participating in equality semantics.
Tupletize(Expression, Expression, Boolean)
Substitutes occurrences of anonymous types in the specified expression by replacing those for tuple types. Types visible in the expression result type can be excluded explicitly.
Declaration
public static Expression Tupletize(Expression expression, Expression unitValue, bool excludeVisibleTypes)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to tupletize. |
System.Linq.Expressions.Expression | unitValue | Expression representing the unit value, used for anonymous types with no properties (e.g. new { } in C#). The type of the expression can't be a value type, but you can use a boxing conversion to work around this limitation. |
System.Boolean | excludeVisibleTypes | Indicates whether to exclude visible types (i.e. occurring in the expression result type) from the tupletization rewrite. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Expression tree with anonymous types substituted for tuple types. |
Remarks
Assignments to Visual Basic anonymous type properties will cause the rewrite to fail. Semantics of tuples are similar to those of C# anonymous types, with every property participating in equality semantics.