Represents the label of a switch case (i.e., the literal or tuple literal to which the expression is compared).
Namespace: Metalama.Framework.Code.SyntaxBuilders
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public sealed class SwitchStatementLabelRemarks
SwitchStatementLabel represents the case label in a switch statement's case section. It supports single literals
(e.g., case 1:) and tuple literals (e.g., case (1, "a"):).
Use the static CreateLiteral(params object[]) method to create labels from intrinsic values like int, string, or enum values. For more control over types, use CreateLiteral(params TypedConstant[]) with explicitly typed constants.
Limitation: Only constant literals and tuple literals are supported. Advanced C# pattern matching syntax (such as type patterns, property patterns, relational patterns, or logical patterns) is not supported. For complex pattern matching, consider using StatementBuilder to construct the switch statement as text.
Properties
| Name | Description |
|---|---|
| Values | Gets the list of literals in the tuple. |
Methods
| Name | Description |
|---|---|
| CreateLiteral(params TypedConstant[]) | Creates a literal SwitchStatementLabel by giving the literals as TypedConstant values. |
| CreateLiteral(IReadOnlyList<TypedConstant>) | Creates a literal SwitchStatementLabel by giving the literals as TypedConstant values. |
| CreateLiteral(params object[]) | Creates a literal SwitchStatementLabel by giving the literals as intrinsic values (string, int, ...). |