未验证 提交 dfe87b3b 编写于 作者: N Neal Gafter 提交者: GitHub

Parsing changes for recursive pattern-matching (#22718)

上级 9a09a707
......@@ -54,6 +54,12 @@ private BoundExpression BindIsPatternExpression(IsPatternExpressionSyntax node,
return BindConstantPattern(
(ConstantPatternSyntax)node, operandType, hasErrors, diagnostics, wasSwitchCase);
case SyntaxKind.DeconstructionPattern:
case SyntaxKind.PropertyPattern:
// PROTOTYPE(patterns2): binding not yet supported for recursive pattern forms.
diagnostics.Add(ErrorCode.ERR_BindToBogus, node.Location, "recursive pattern");
return new BoundConstantPattern(node, BadExpression(node), ConstantValue.Null, hasErrors: true);
default:
throw ExceptionUtilities.UnexpectedValue(node.Kind());
}
......
......@@ -6415,6 +6415,15 @@ internal class CSharpResources {
}
}
/// <summary>
/// Looks up a localized string similar to Pattern missing.
/// </summary>
internal static string ERR_MissingPattern {
get {
return ResourceManager.GetString("ERR_MissingPattern", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Quoted file name, single-line comment or end-of-line expected.
/// </summary>
......@@ -10628,6 +10637,15 @@ internal class CSharpResources {
}
}
/// <summary>
/// Looks up a localized string similar to recursive patterns.
/// </summary>
internal static string IDS_FeatureRecursivePatterns {
get {
return ResourceManager.GetString("IDS_FeatureRecursivePatterns", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to ref extension methods.
/// </summary>
......
......@@ -5210,4 +5210,10 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_RefExtensionMustBeValueTypeOrConstrainedToOne" xml:space="preserve">
<value>The first parameter of a 'ref' extension method '{0}' must be a value type or a generic type constrained to struct.</value>
</data>
<data name="ERR_MissingPattern" xml:space="preserve">
<value>Pattern missing</value>
</data>
<data name="IDS_FeatureRecursivePatterns" xml:space="preserve">
<value>recursive patterns</value>
</data>
</root>
\ No newline at end of file
......@@ -1537,5 +1537,11 @@ internal enum ErrorCode
ERR_EscapeStackAlloc = 8353,
ERR_RefReturnThis = 8354,
#endregion diagnostics introduced for `ref readonly`, `ref ternary` and `ref-like` features in C# 7.2
#region diagnostics introduced for recursive patterns
// PROTOTYPE(patterns2): renumber these before committing
ERR_MissingPattern = 8500,
#endregion diagnostics introduced for recursive patterns
}
}
......@@ -145,6 +145,8 @@ internal enum MessageID
IDS_FeatureRefExtensionMethods = MessageBase + 12728,
IDS_StackAllocExpression = MessageBase + 12729,
IDS_FeaturePrivateProtected = MessageBase + 12730,
IDS_FeatureRecursivePatterns = MessageBase + 12731,
}
// Message IDs may refer to strings that need to be localized.
......@@ -190,6 +192,8 @@ internal static string RequiredFeature(this MessageID feature)
{
case MessageID.IDS_FeatureIOperation:
return "IOperation";
case MessageID.IDS_FeatureRecursivePatterns:
return "patterns2";
default:
return null;
}
......@@ -197,6 +201,7 @@ internal static string RequiredFeature(this MessageID feature)
internal static LanguageVersion RequiredVersion(this MessageID feature)
{
Debug.Assert(RequiredFeature(feature) == null);
// Based on CSourceParser::GetFeatureUsage from SourceParser.cpp.
// Checks are in the LanguageParser unless otherwise noted.
switch (feature)
......
......@@ -460,6 +460,30 @@ public virtual TResult VisitDeclarationPattern(DeclarationPatternSyntax node)
return this.DefaultVisit(node);
}
/// <summary>Called when the visitor visits a DeconstructionPatternSyntax node.</summary>
public virtual TResult VisitDeconstructionPattern(DeconstructionPatternSyntax node)
{
return this.DefaultVisit(node);
}
/// <summary>Called when the visitor visits a SubpatternElementSyntax node.</summary>
public virtual TResult VisitSubpatternElement(SubpatternElementSyntax node)
{
return this.DefaultVisit(node);
}
/// <summary>Called when the visitor visits a PropertyPatternSyntax node.</summary>
public virtual TResult VisitPropertyPattern(PropertyPatternSyntax node)
{
return this.DefaultVisit(node);
}
/// <summary>Called when the visitor visits a PropertySubpatternSyntax node.</summary>
public virtual TResult VisitPropertySubpattern(PropertySubpatternSyntax node)
{
return this.DefaultVisit(node);
}
/// <summary>Called when the visitor visits a ConstantPatternSyntax node.</summary>
public virtual TResult VisitConstantPattern(ConstantPatternSyntax node)
{
......@@ -1687,6 +1711,30 @@ public virtual void VisitDeclarationPattern(DeclarationPatternSyntax node)
this.DefaultVisit(node);
}
/// <summary>Called when the visitor visits a DeconstructionPatternSyntax node.</summary>
public virtual void VisitDeconstructionPattern(DeconstructionPatternSyntax node)
{
this.DefaultVisit(node);
}
/// <summary>Called when the visitor visits a SubpatternElementSyntax node.</summary>
public virtual void VisitSubpatternElement(SubpatternElementSyntax node)
{
this.DefaultVisit(node);
}
/// <summary>Called when the visitor visits a PropertyPatternSyntax node.</summary>
public virtual void VisitPropertyPattern(PropertyPatternSyntax node)
{
this.DefaultVisit(node);
}
/// <summary>Called when the visitor visits a PropertySubpatternSyntax node.</summary>
public virtual void VisitPropertySubpattern(PropertySubpatternSyntax node)
{
this.DefaultVisit(node);
}
/// <summary>Called when the visitor visits a ConstantPatternSyntax node.</summary>
public virtual void VisitConstantPattern(ConstantPatternSyntax node)
{
......@@ -3049,6 +3097,40 @@ public override SyntaxNode VisitDeclarationPattern(DeclarationPatternSyntax node
return node.Update(type, designation);
}
public override SyntaxNode VisitDeconstructionPattern(DeconstructionPatternSyntax node)
{
var type = (TypeSyntax)this.Visit(node.Type);
var openParenToken = this.VisitToken(node.OpenParenToken);
var subPatterns = this.VisitList(node.SubPatterns);
var closeParenToken = this.VisitToken(node.CloseParenToken);
var propertySubpattern = (PropertySubpatternSyntax)this.Visit(node.PropertySubpattern);
var designation = (VariableDesignationSyntax)this.Visit(node.Designation);
return node.Update(type, openParenToken, subPatterns, closeParenToken, propertySubpattern, designation);
}
public override SyntaxNode VisitSubpatternElement(SubpatternElementSyntax node)
{
var nameColon = (NameColonSyntax)this.Visit(node.NameColon);
var pattern = (PatternSyntax)this.Visit(node.Pattern);
return node.Update(nameColon, pattern);
}
public override SyntaxNode VisitPropertyPattern(PropertyPatternSyntax node)
{
var type = (TypeSyntax)this.Visit(node.Type);
var propertySubpattern = (PropertySubpatternSyntax)this.Visit(node.PropertySubpattern);
var designation = (VariableDesignationSyntax)this.Visit(node.Designation);
return node.Update(type, propertySubpattern, designation);
}
public override SyntaxNode VisitPropertySubpattern(PropertySubpatternSyntax node)
{
var openBraceToken = this.VisitToken(node.OpenBraceToken);
var subPatterns = this.VisitList(node.SubPatterns);
var closeBraceToken = this.VisitToken(node.CloseBraceToken);
return node.Update(openBraceToken, subPatterns, closeBraceToken);
}
public override SyntaxNode VisitConstantPattern(ConstantPatternSyntax node)
{
var expression = (ExpressionSyntax)this.Visit(node.Expression);
......@@ -6538,6 +6620,96 @@ public static DeclarationPatternSyntax DeclarationPattern(TypeSyntax type, Varia
}
/// <summary>Creates a new DeconstructionPatternSyntax instance.</summary>
public static DeconstructionPatternSyntax DeconstructionPattern(TypeSyntax type, SyntaxToken openParenToken, SeparatedSyntaxList<SubpatternElementSyntax> subPatterns, SyntaxToken closeParenToken, PropertySubpatternSyntax propertySubpattern, VariableDesignationSyntax designation)
{
switch (openParenToken.Kind())
{
case SyntaxKind.OpenParenToken:
break;
default:
throw new ArgumentException("openParenToken");
}
switch (closeParenToken.Kind())
{
case SyntaxKind.CloseParenToken:
break;
default:
throw new ArgumentException("closeParenToken");
}
return (DeconstructionPatternSyntax)Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.DeconstructionPattern(type == null ? null : (Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.TypeSyntax)type.Green, (Syntax.InternalSyntax.SyntaxToken)openParenToken.Node, subPatterns.Node.ToGreenSeparatedList<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SubpatternElementSyntax>(), (Syntax.InternalSyntax.SyntaxToken)closeParenToken.Node, propertySubpattern == null ? null : (Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.PropertySubpatternSyntax)propertySubpattern.Green, designation == null ? null : (Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.VariableDesignationSyntax)designation.Green).CreateRed();
}
/// <summary>Creates a new DeconstructionPatternSyntax instance.</summary>
public static DeconstructionPatternSyntax DeconstructionPattern(TypeSyntax type, SeparatedSyntaxList<SubpatternElementSyntax> subPatterns, PropertySubpatternSyntax propertySubpattern, VariableDesignationSyntax designation)
{
return SyntaxFactory.DeconstructionPattern(type, SyntaxFactory.Token(SyntaxKind.OpenParenToken), subPatterns, SyntaxFactory.Token(SyntaxKind.CloseParenToken), propertySubpattern, designation);
}
/// <summary>Creates a new DeconstructionPatternSyntax instance.</summary>
public static DeconstructionPatternSyntax DeconstructionPattern(SeparatedSyntaxList<SubpatternElementSyntax> subPatterns = default(SeparatedSyntaxList<SubpatternElementSyntax>))
{
return SyntaxFactory.DeconstructionPattern(default(TypeSyntax), SyntaxFactory.Token(SyntaxKind.OpenParenToken), subPatterns, SyntaxFactory.Token(SyntaxKind.CloseParenToken), default(PropertySubpatternSyntax), default(VariableDesignationSyntax));
}
/// <summary>Creates a new SubpatternElementSyntax instance.</summary>
public static SubpatternElementSyntax SubpatternElement(NameColonSyntax nameColon, PatternSyntax pattern)
{
if (pattern == null)
throw new ArgumentNullException(nameof(pattern));
return (SubpatternElementSyntax)Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.SubpatternElement(nameColon == null ? null : (Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.NameColonSyntax)nameColon.Green, pattern == null ? null : (Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.PatternSyntax)pattern.Green).CreateRed();
}
/// <summary>Creates a new SubpatternElementSyntax instance.</summary>
public static SubpatternElementSyntax SubpatternElement(PatternSyntax pattern)
{
return SyntaxFactory.SubpatternElement(default(NameColonSyntax), pattern);
}
/// <summary>Creates a new PropertyPatternSyntax instance.</summary>
public static PropertyPatternSyntax PropertyPattern(TypeSyntax type, PropertySubpatternSyntax propertySubpattern, VariableDesignationSyntax designation)
{
if (propertySubpattern == null)
throw new ArgumentNullException(nameof(propertySubpattern));
return (PropertyPatternSyntax)Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.PropertyPattern(type == null ? null : (Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.TypeSyntax)type.Green, propertySubpattern == null ? null : (Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.PropertySubpatternSyntax)propertySubpattern.Green, designation == null ? null : (Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.VariableDesignationSyntax)designation.Green).CreateRed();
}
/// <summary>Creates a new PropertyPatternSyntax instance.</summary>
public static PropertyPatternSyntax PropertyPattern()
{
return SyntaxFactory.PropertyPattern(default(TypeSyntax), SyntaxFactory.PropertySubpattern(), default(VariableDesignationSyntax));
}
/// <summary>Creates a new PropertySubpatternSyntax instance.</summary>
public static PropertySubpatternSyntax PropertySubpattern(SyntaxToken openBraceToken, SeparatedSyntaxList<SubpatternElementSyntax> subPatterns, SyntaxToken closeBraceToken)
{
switch (openBraceToken.Kind())
{
case SyntaxKind.OpenBraceToken:
break;
default:
throw new ArgumentException("openBraceToken");
}
switch (closeBraceToken.Kind())
{
case SyntaxKind.CloseBraceToken:
break;
default:
throw new ArgumentException("closeBraceToken");
}
return (PropertySubpatternSyntax)Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.PropertySubpattern((Syntax.InternalSyntax.SyntaxToken)openBraceToken.Node, subPatterns.Node.ToGreenSeparatedList<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SubpatternElementSyntax>(), (Syntax.InternalSyntax.SyntaxToken)closeBraceToken.Node).CreateRed();
}
/// <summary>Creates a new PropertySubpatternSyntax instance.</summary>
public static PropertySubpatternSyntax PropertySubpattern(SeparatedSyntaxList<SubpatternElementSyntax> subPatterns = default(SeparatedSyntaxList<SubpatternElementSyntax>))
{
return SyntaxFactory.PropertySubpattern(SyntaxFactory.Token(SyntaxKind.OpenBraceToken), subPatterns, SyntaxFactory.Token(SyntaxKind.CloseBraceToken));
}
/// <summary>Creates a new ConstantPatternSyntax instance.</summary>
public static ConstantPatternSyntax ConstantPattern(ExpressionSyntax expression)
{
......
......@@ -6791,6 +6791,427 @@ public DeclarationPatternSyntax WithDesignation(VariableDesignationSyntax design
}
}
public sealed partial class DeconstructionPatternSyntax : PatternSyntax
{
private TypeSyntax type;
private SyntaxNode subPatterns;
private PropertySubpatternSyntax propertySubpattern;
private VariableDesignationSyntax designation;
internal DeconstructionPatternSyntax(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode green, SyntaxNode parent, int position)
: base(green, parent, position)
{
}
public TypeSyntax Type
{
get
{
return this.GetRedAtZero(ref this.type);
}
}
public SyntaxToken OpenParenToken
{
get { return new SyntaxToken(this, ((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.DeconstructionPatternSyntax)this.Green).openParenToken, this.GetChildPosition(1), this.GetChildIndex(1)); }
}
public SeparatedSyntaxList<SubpatternElementSyntax> SubPatterns
{
get
{
var red = this.GetRed(ref this.subPatterns, 2);
if (red != null)
return new SeparatedSyntaxList<SubpatternElementSyntax>(red, this.GetChildIndex(2));
return default(SeparatedSyntaxList<SubpatternElementSyntax>);
}
}
public SyntaxToken CloseParenToken
{
get { return new SyntaxToken(this, ((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.DeconstructionPatternSyntax)this.Green).closeParenToken, this.GetChildPosition(3), this.GetChildIndex(3)); }
}
public PropertySubpatternSyntax PropertySubpattern
{
get
{
return this.GetRed(ref this.propertySubpattern, 4);
}
}
public VariableDesignationSyntax Designation
{
get
{
return this.GetRed(ref this.designation, 5);
}
}
internal override SyntaxNode GetNodeSlot(int index)
{
switch (index)
{
case 0: return this.GetRedAtZero(ref this.type);
case 2: return this.GetRed(ref this.subPatterns, 2);
case 4: return this.GetRed(ref this.propertySubpattern, 4);
case 5: return this.GetRed(ref this.designation, 5);
default: return null;
}
}
internal override SyntaxNode GetCachedSlot(int index)
{
switch (index)
{
case 0: return this.type;
case 2: return this.subPatterns;
case 4: return this.propertySubpattern;
case 5: return this.designation;
default: return null;
}
}
public override TResult Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
{
return visitor.VisitDeconstructionPattern(this);
}
public override void Accept(CSharpSyntaxVisitor visitor)
{
visitor.VisitDeconstructionPattern(this);
}
public DeconstructionPatternSyntax Update(TypeSyntax type, SyntaxToken openParenToken, SeparatedSyntaxList<SubpatternElementSyntax> subPatterns, SyntaxToken closeParenToken, PropertySubpatternSyntax propertySubpattern, VariableDesignationSyntax designation)
{
if (type != this.Type || openParenToken != this.OpenParenToken || subPatterns != this.SubPatterns || closeParenToken != this.CloseParenToken || propertySubpattern != this.PropertySubpattern || designation != this.Designation)
{
var newNode = SyntaxFactory.DeconstructionPattern(type, openParenToken, subPatterns, closeParenToken, propertySubpattern, designation);
var annotations = this.GetAnnotations();
if (annotations != null && annotations.Length > 0)
return newNode.WithAnnotations(annotations);
return newNode;
}
return this;
}
public DeconstructionPatternSyntax WithType(TypeSyntax type)
{
return this.Update(type, this.OpenParenToken, this.SubPatterns, this.CloseParenToken, this.PropertySubpattern, this.Designation);
}
public DeconstructionPatternSyntax WithOpenParenToken(SyntaxToken openParenToken)
{
return this.Update(this.Type, openParenToken, this.SubPatterns, this.CloseParenToken, this.PropertySubpattern, this.Designation);
}
public DeconstructionPatternSyntax WithSubPatterns(SeparatedSyntaxList<SubpatternElementSyntax> subPatterns)
{
return this.Update(this.Type, this.OpenParenToken, subPatterns, this.CloseParenToken, this.PropertySubpattern, this.Designation);
}
public DeconstructionPatternSyntax WithCloseParenToken(SyntaxToken closeParenToken)
{
return this.Update(this.Type, this.OpenParenToken, this.SubPatterns, closeParenToken, this.PropertySubpattern, this.Designation);
}
public DeconstructionPatternSyntax WithPropertySubpattern(PropertySubpatternSyntax propertySubpattern)
{
return this.Update(this.Type, this.OpenParenToken, this.SubPatterns, this.CloseParenToken, propertySubpattern, this.Designation);
}
public DeconstructionPatternSyntax WithDesignation(VariableDesignationSyntax designation)
{
return this.Update(this.Type, this.OpenParenToken, this.SubPatterns, this.CloseParenToken, this.PropertySubpattern, designation);
}
public DeconstructionPatternSyntax AddSubPatterns(params SubpatternElementSyntax[] items)
{
return this.WithSubPatterns(this.SubPatterns.AddRange(items));
}
public DeconstructionPatternSyntax AddPropertySubpatternSubPatterns(params SubpatternElementSyntax[] items)
{
var propertySubpattern = this.PropertySubpattern ?? SyntaxFactory.PropertySubpattern();
return this.WithPropertySubpattern(propertySubpattern.WithSubPatterns(propertySubpattern.SubPatterns.AddRange(items)));
}
}
public sealed partial class SubpatternElementSyntax : CSharpSyntaxNode
{
private NameColonSyntax nameColon;
private PatternSyntax pattern;
internal SubpatternElementSyntax(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode green, SyntaxNode parent, int position)
: base(green, parent, position)
{
}
public NameColonSyntax NameColon
{
get
{
return this.GetRedAtZero(ref this.nameColon);
}
}
public PatternSyntax Pattern
{
get
{
return this.GetRed(ref this.pattern, 1);
}
}
internal override SyntaxNode GetNodeSlot(int index)
{
switch (index)
{
case 0: return this.GetRedAtZero(ref this.nameColon);
case 1: return this.GetRed(ref this.pattern, 1);
default: return null;
}
}
internal override SyntaxNode GetCachedSlot(int index)
{
switch (index)
{
case 0: return this.nameColon;
case 1: return this.pattern;
default: return null;
}
}
public override TResult Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
{
return visitor.VisitSubpatternElement(this);
}
public override void Accept(CSharpSyntaxVisitor visitor)
{
visitor.VisitSubpatternElement(this);
}
public SubpatternElementSyntax Update(NameColonSyntax nameColon, PatternSyntax pattern)
{
if (nameColon != this.NameColon || pattern != this.Pattern)
{
var newNode = SyntaxFactory.SubpatternElement(nameColon, pattern);
var annotations = this.GetAnnotations();
if (annotations != null && annotations.Length > 0)
return newNode.WithAnnotations(annotations);
return newNode;
}
return this;
}
public SubpatternElementSyntax WithNameColon(NameColonSyntax nameColon)
{
return this.Update(nameColon, this.Pattern);
}
public SubpatternElementSyntax WithPattern(PatternSyntax pattern)
{
return this.Update(this.NameColon, pattern);
}
}
public sealed partial class PropertyPatternSyntax : PatternSyntax
{
private TypeSyntax type;
private PropertySubpatternSyntax propertySubpattern;
private VariableDesignationSyntax designation;
internal PropertyPatternSyntax(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode green, SyntaxNode parent, int position)
: base(green, parent, position)
{
}
public TypeSyntax Type
{
get
{
return this.GetRedAtZero(ref this.type);
}
}
public PropertySubpatternSyntax PropertySubpattern
{
get
{
return this.GetRed(ref this.propertySubpattern, 1);
}
}
public VariableDesignationSyntax Designation
{
get
{
return this.GetRed(ref this.designation, 2);
}
}
internal override SyntaxNode GetNodeSlot(int index)
{
switch (index)
{
case 0: return this.GetRedAtZero(ref this.type);
case 1: return this.GetRed(ref this.propertySubpattern, 1);
case 2: return this.GetRed(ref this.designation, 2);
default: return null;
}
}
internal override SyntaxNode GetCachedSlot(int index)
{
switch (index)
{
case 0: return this.type;
case 1: return this.propertySubpattern;
case 2: return this.designation;
default: return null;
}
}
public override TResult Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
{
return visitor.VisitPropertyPattern(this);
}
public override void Accept(CSharpSyntaxVisitor visitor)
{
visitor.VisitPropertyPattern(this);
}
public PropertyPatternSyntax Update(TypeSyntax type, PropertySubpatternSyntax propertySubpattern, VariableDesignationSyntax designation)
{
if (type != this.Type || propertySubpattern != this.PropertySubpattern || designation != this.Designation)
{
var newNode = SyntaxFactory.PropertyPattern(type, propertySubpattern, designation);
var annotations = this.GetAnnotations();
if (annotations != null && annotations.Length > 0)
return newNode.WithAnnotations(annotations);
return newNode;
}
return this;
}
public PropertyPatternSyntax WithType(TypeSyntax type)
{
return this.Update(type, this.PropertySubpattern, this.Designation);
}
public PropertyPatternSyntax WithPropertySubpattern(PropertySubpatternSyntax propertySubpattern)
{
return this.Update(this.Type, propertySubpattern, this.Designation);
}
public PropertyPatternSyntax WithDesignation(VariableDesignationSyntax designation)
{
return this.Update(this.Type, this.PropertySubpattern, designation);
}
public PropertyPatternSyntax AddPropertySubpatternSubPatterns(params SubpatternElementSyntax[] items)
{
return this.WithPropertySubpattern(this.PropertySubpattern.WithSubPatterns(this.PropertySubpattern.SubPatterns.AddRange(items)));
}
}
public sealed partial class PropertySubpatternSyntax : CSharpSyntaxNode
{
private SyntaxNode subPatterns;
internal PropertySubpatternSyntax(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode green, SyntaxNode parent, int position)
: base(green, parent, position)
{
}
public SyntaxToken OpenBraceToken
{
get { return new SyntaxToken(this, ((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.PropertySubpatternSyntax)this.Green).openBraceToken, this.Position, 0); }
}
public SeparatedSyntaxList<SubpatternElementSyntax> SubPatterns
{
get
{
var red = this.GetRed(ref this.subPatterns, 1);
if (red != null)
return new SeparatedSyntaxList<SubpatternElementSyntax>(red, this.GetChildIndex(1));
return default(SeparatedSyntaxList<SubpatternElementSyntax>);
}
}
public SyntaxToken CloseBraceToken
{
get { return new SyntaxToken(this, ((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.PropertySubpatternSyntax)this.Green).closeBraceToken, this.GetChildPosition(2), this.GetChildIndex(2)); }
}
internal override SyntaxNode GetNodeSlot(int index)
{
switch (index)
{
case 1: return this.GetRed(ref this.subPatterns, 1);
default: return null;
}
}
internal override SyntaxNode GetCachedSlot(int index)
{
switch (index)
{
case 1: return this.subPatterns;
default: return null;
}
}
public override TResult Accept<TResult>(CSharpSyntaxVisitor<TResult> visitor)
{
return visitor.VisitPropertySubpattern(this);
}
public override void Accept(CSharpSyntaxVisitor visitor)
{
visitor.VisitPropertySubpattern(this);
}
public PropertySubpatternSyntax Update(SyntaxToken openBraceToken, SeparatedSyntaxList<SubpatternElementSyntax> subPatterns, SyntaxToken closeBraceToken)
{
if (openBraceToken != this.OpenBraceToken || subPatterns != this.SubPatterns || closeBraceToken != this.CloseBraceToken)
{
var newNode = SyntaxFactory.PropertySubpattern(openBraceToken, subPatterns, closeBraceToken);
var annotations = this.GetAnnotations();
if (annotations != null && annotations.Length > 0)
return newNode.WithAnnotations(annotations);
return newNode;
}
return this;
}
public PropertySubpatternSyntax WithOpenBraceToken(SyntaxToken openBraceToken)
{
return this.Update(openBraceToken, this.SubPatterns, this.CloseBraceToken);
}
public PropertySubpatternSyntax WithSubPatterns(SeparatedSyntaxList<SubpatternElementSyntax> subPatterns)
{
return this.Update(this.OpenBraceToken, subPatterns, this.CloseBraceToken);
}
public PropertySubpatternSyntax WithCloseBraceToken(SyntaxToken closeBraceToken)
{
return this.Update(this.OpenBraceToken, this.SubPatterns, closeBraceToken);
}
public PropertySubpatternSyntax AddSubPatterns(params SubpatternElementSyntax[] items)
{
return this.WithSubPatterns(this.SubPatterns.AddRange(items));
}
}
public sealed partial class ConstantPatternSyntax : PatternSyntax
{
private ExpressionSyntax expression;
......
......@@ -24,4 +24,6 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("ApiDesign", "RS0027:Public API with optional parameter(s) should have the most parameters amongst its public overloads.", Justification = "<Pending>", Scope = "member", Target = "~M:Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParenthesizedVariableDesignation(Microsoft.CodeAnalysis.SeparatedSyntaxList{Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax})~Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "<Pending>", Scope = "member", Target = "~M:Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeclaredSymbol(Microsoft.CodeAnalysis.SemanticModel,Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax,System.Threading.CancellationToken)~Microsoft.CodeAnalysis.INamedTypeSymbol")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "<Pending>", Scope = "member", Target = "~M:Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeclaredSymbol(Microsoft.CodeAnalysis.SemanticModel,Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax,System.Threading.CancellationToken)~Microsoft.CodeAnalysis.ISymbol")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("ApiDesign", "RS0027:Public API with optional parameter(s) should have the most parameters amongst its public overloads.", Justification = "<Pending>", Scope = "member", Target = "~M:Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DeconstructionPattern(Microsoft.CodeAnalysis.SeparatedSyntaxList{Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax})~Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("ApiDesign", "RS0027:Public API with optional parameter(s) should have the most parameters amongst its public overloads.", Justification = "<Pending>", Scope = "member", Target = "~M:Microsoft.CodeAnalysis.CSharp.SyntaxFactory.PropertySubpattern(Microsoft.CodeAnalysis.SeparatedSyntaxList{Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax})~Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax")]
......@@ -4859,7 +4859,7 @@ private enum NameOptions
InTypeList = 1 << 1, // Allows attributes to appear within the generic type argument list. Used during ParseInstantiation.
PossiblePattern = 1 << 2, // Used to influence parser ambiguity around "<" and generics vs. expressions on the right of 'is'
AfterIs = 1 << 3,
AfterCase = 1 << 4,
DefinitePattern = 1 << 4,
AfterOut = 1 << 5,
AfterTupleComma = 1 << 6,
FirstElementOfPossibleTupleLiteral = 1 << 7,
......@@ -5154,7 +5154,7 @@ private ScanTypeArgumentListKind ScanTypeArgumentList(NameOptions options)
// subsequent element of a tuple literal (in which case the tokens are preceded by `,` and the
// identifier is followed by a `,` or `)`).
// Note that we treat query contextual keywords (which appear here as identifiers) as disambiguating tokens as well.
if ((options & (NameOptions.AfterIs | NameOptions.AfterCase | NameOptions.AfterOut)) != 0 ||
if ((options & (NameOptions.AfterIs | NameOptions.DefinitePattern | NameOptions.AfterOut)) != 0 ||
(options & NameOptions.AfterTupleComma) != 0 && (this.PeekToken(1).Kind == SyntaxKind.CommaToken || this.PeekToken(1).Kind == SyntaxKind.CloseParenToken) ||
(options & NameOptions.FirstElementOfPossibleTupleLiteral) != 0 && this.PeekToken(1).Kind == SyntaxKind.CommaToken
)
......@@ -5824,15 +5824,15 @@ private bool IsPossibleName()
return this.IsTrueIdentifier();
}
private ScanTypeFlags ScanType()
private ScanTypeFlags ScanType(bool forPattern = false)
{
SyntaxToken lastTokenOfType;
return ScanType(out lastTokenOfType);
}
private ScanTypeFlags ScanType(out SyntaxToken lastTokenOfType)
private ScanTypeFlags ScanType(out SyntaxToken lastTokenOfType, bool forPattern = false)
{
return ScanType(ParseTypeMode.Normal, out lastTokenOfType);
return ScanType(forPattern ? ParseTypeMode.DefinitePattern : ParseTypeMode.Normal, out lastTokenOfType);
}
private ScanTypeFlags ScanType(ParseTypeMode mode, out SyntaxToken lastTokenOfType)
......@@ -5950,7 +5950,7 @@ private ScanTypeFlags ScanNonArrayType(ParseTypeMode mode, out SyntaxToken lastT
lastTokenOfType = this.EatToken();
result = ScanTypeFlags.MustBeType;
}
else if (this.CurrentToken.Kind == SyntaxKind.OpenParenToken)
else if (this.CurrentToken.Kind == SyntaxKind.OpenParenToken && mode != ParseTypeMode.DefinitePattern)
{
lastTokenOfType = this.EatToken();
......@@ -5981,6 +5981,9 @@ private ScanTypeFlags ScanNonArrayType(ParseTypeMode mode, out SyntaxToken lastT
// We are parsing the type for a declaration expression in a tuple, which does
// not permit pointer types. In that context a `*` is parsed as a multiplication.
break;
case ParseTypeMode.DefinitePattern:
// pointer type syntax is not supported in patterns.
break;
default:
while (this.CurrentToken.Kind == SyntaxKind.AsteriskToken)
{
......@@ -6110,7 +6113,7 @@ private enum ParseTypeMode
Normal,
Parameter,
AfterIs,
AfterCase,
DefinitePattern,
AfterOut,
AfterTupleComma,
AsExpression,
......@@ -6152,8 +6155,8 @@ private enum ParseTypeMode
case ParseTypeMode.AfterIs:
nameOptions = NameOptions.InExpression | NameOptions.AfterIs | NameOptions.PossiblePattern;
break;
case ParseTypeMode.AfterCase:
nameOptions = NameOptions.InExpression | NameOptions.AfterCase | NameOptions.PossiblePattern;
case ParseTypeMode.DefinitePattern:
nameOptions = NameOptions.InExpression | NameOptions.DefinitePattern | NameOptions.PossiblePattern;
break;
case ParseTypeMode.AfterOut:
nameOptions = NameOptions.InExpression | NameOptions.AfterOut;
......@@ -6178,7 +6181,7 @@ private enum ParseTypeMode
if (this.CurrentToken.Kind == SyntaxKind.QuestionToken &&
// we do not permit nullable types in a declaration pattern
(mode != ParseTypeMode.AfterIs && mode != ParseTypeMode.AfterCase || !IsTrueIdentifier(this.PeekToken(1))))
(mode != ParseTypeMode.AfterIs && mode != ParseTypeMode.DefinitePattern || !IsTrueIdentifier(this.PeekToken(1))))
{
var resetPoint = this.GetResetPoint();
try
......@@ -6206,7 +6209,7 @@ private enum ParseTypeMode
switch (mode)
{
case ParseTypeMode.AfterIs:
case ParseTypeMode.AfterCase:
case ParseTypeMode.DefinitePattern:
case ParseTypeMode.AfterTupleComma:
case ParseTypeMode.FirstElementOfPossibleTupleLiteral:
// these contexts do not permit a pointer type.
......@@ -7964,7 +7967,7 @@ private SwitchSectionSyntax ParseSwitchSection()
}
else
{
var node = ParseExpressionOrPatternForCase();
var node = ParseExpressionOrPattern(forCase: true);
if (this.CurrentToken.ContextualKind == SyntaxKind.WhenKeyword && node is ExpressionSyntax)
{
// if there is a 'where' token, we treat a case expression as a constant pattern.
......@@ -9444,10 +9447,7 @@ internal ArgumentListSyntax ParseParenthesizedArgumentList()
return (ArgumentListSyntax)this.EatNode();
}
SyntaxToken openToken, closeToken;
SeparatedSyntaxList<ArgumentSyntax> arguments;
ParseArgumentList(out openToken, out arguments, out closeToken, SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken);
ParseArgumentList(out var openToken, out var arguments, out var closeToken, SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken);
return _syntaxFactory.ArgumentList(openToken, arguments, closeToken);
}
......@@ -9458,10 +9458,7 @@ internal BracketedArgumentListSyntax ParseBracketedArgumentList()
return (BracketedArgumentListSyntax)this.EatNode();
}
SyntaxToken openToken, closeToken;
SeparatedSyntaxList<ArgumentSyntax> arguments;
ParseArgumentList(out openToken, out arguments, out closeToken, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
ParseArgumentList(out var openToken, out var arguments, out var closeToken, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
return _syntaxFactory.BracketedArgumentList(openToken, arguments, closeToken);
}
......@@ -10006,7 +10003,7 @@ private TupleExpressionSyntax ParseTupleExpressionTail(SyntaxToken openParen, Ar
}
}
private bool ScanCast()
private bool ScanCast(bool forPattern = false)
{
if (this.CurrentToken.Kind != SyntaxKind.OpenParenToken)
{
......@@ -10015,7 +10012,7 @@ private bool ScanCast()
this.EatToken();
var type = this.ScanType();
var type = this.ScanType(forPattern: forPattern);
if (type == ScanTypeFlags.NotType)
{
return false;
......@@ -10142,6 +10139,7 @@ private static bool CanFollowCast(SyntaxKind kind)
case SyntaxKind.MinusGreaterThanToken:
case SyntaxKind.QuestionQuestionToken:
case SyntaxKind.EndOfFileToken:
case SyntaxKind.EqualsGreaterThanToken:
return false;
default:
return true;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Diagnostics;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax
{
......@@ -222,51 +223,242 @@ private bool ScanDesignation(bool permitTuple)
// Priority is the ExpressionSyntax. It might return ExpressionSyntax which might be a constant pattern such as 'case 3:'
// All constant expressions are converted to the constant pattern in the switch binder if it is a match statement.
// It is used for parsing patterns in the switch cases. It never returns constant pattern!
private CSharpSyntaxNode ParseExpressionOrPatternForCase()
// It is used for parsing patterns in the switch cases. It never returns constant pattern, because for a `case` we
// need to use a pre-pattern-matching syntax node for a constant case.
private CSharpSyntaxNode ParseExpressionOrPattern(bool forCase)
{
var tk = this.CurrentToken.Kind;
CSharpSyntaxNode node = null;
// If it is a nameof, skip the 'if' and parse as an expression.
if ((SyntaxFacts.IsPredefinedType(tk) || tk == SyntaxKind.IdentifierToken) &&
this.CurrentToken.ContextualKind != SyntaxKind.NameOfKeyword)
// handle common error recovery situations during typing
switch (this.CurrentToken.Kind)
{
case SyntaxKind.CommaToken:
case SyntaxKind.SemicolonToken:
case SyntaxKind.CloseBraceToken:
case SyntaxKind.CloseParenToken:
case SyntaxKind.CloseBracketToken:
case SyntaxKind.EqualsGreaterThanToken:
return this.ParseIdentifierName(ErrorCode.ERR_MissingArgument);
}
var resetPoint = this.GetResetPoint();
try
{
TypeSyntax type = this.ParseType(ParseTypeMode.AfterCase);
if (!type.IsMissing)
TypeSyntax type = null;
var tk = this.CurrentToken.Kind;
if ((SyntaxFacts.IsPredefinedType(tk) || tk == SyntaxKind.IdentifierToken) &&
// If it is a nameof, skip the 'if' and parse as an expression.
(this.CurrentToken.ContextualKind != SyntaxKind.NameOfKeyword || this.PeekToken(1).Kind != SyntaxKind.OpenParenToken))
{
// X.Y.Z id
if (this.IsTrueIdentifier() && this.CurrentToken.ContextualKind != SyntaxKind.WhenKeyword)
type = this.ParseType(ParseTypeMode.DefinitePattern);
if (type.IsMissing)
{
var designation = ParseSimpleDesignation();
node = _syntaxFactory.DeclarationPattern(type, designation);
// either it is not shaped like a type, or it is a constant expression.
this.Reset(ref resetPoint);
type = null;
}
}
PropertySubpatternSyntax propertySubpattern = null;
bool parsePropertySubpattern()
{
if (this.CurrentToken.Kind == SyntaxKind.OpenBraceToken)
{
propertySubpattern = ParsePropertySubpattern();
return true;
}
return false;
}
VariableDesignationSyntax designation = null;
bool parseDesignation()
{
if (this.IsTrueIdentifier() && (!forCase || this.CurrentToken.ContextualKind != SyntaxKind.WhenKeyword))
{
designation = ParseSimpleDesignation();
return true;
}
return false;
}
if (node == null)
bool looksLikeCast()
{
var resetPoint2 = this.GetResetPoint();
try
{
// it is an expression for typical switch case.
return this.ScanCast(forPattern: true);
}
finally
{
this.Reset(ref resetPoint2);
this.Release(ref resetPoint2);
}
}
if (this.CurrentToken.Kind == SyntaxKind.OpenParenToken && (type != null || !looksLikeCast()))
{
// It is possible this is a parenthesized (constant) expression.
// We normalize later.
ParseSubpatternList(out var openParenToken, out var subPatterns, out var closeParenToken, SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken);
if (this.CurrentToken.Kind == SyntaxKind.EqualsGreaterThanToken)
{
// Testers do the darndest things, in this case putting a lambda expression where a pattern is expected.
this.Reset(ref resetPoint);
node = this.ParseSubExpression(Precedence.Expression);
return this.ParseSubExpression(Precedence.Expression);
}
parsePropertySubpattern();
parseDesignation();
if (type == null &&
propertySubpattern == null &&
designation == null &&
subPatterns.Count == 1 &&
subPatterns[0].NameColon == null &&
subPatterns[0].Pattern is ConstantPatternSyntax cp)
{
// There is an ambiguity between a deconstruction pattern `(` pattern `)`
// and a constant expression pattern than happens to be parenthesized.
// We normalize to the parenthesized expression, and semantic analysis
// will notice the parens and treat it whichever way is semantically sensible,
// giving priority to its treatment as a constant expression.
return _syntaxFactory.ParenthesizedExpression(openParenToken, cp.Expression, closeParenToken);
}
var node = _syntaxFactory.DeconstructionPattern(type, openParenToken, subPatterns, closeParenToken, propertySubpattern, designation);
return this.CheckFeatureAvailability(node, MessageID.IDS_FeatureRecursivePatterns);
}
if (parsePropertySubpattern())
{
parseDesignation();
var node = _syntaxFactory.PropertyPattern(type, propertySubpattern, designation);
return this.CheckFeatureAvailability(node, MessageID.IDS_FeatureRecursivePatterns);
}
if (type != null && parseDesignation())
{
return _syntaxFactory.DeclarationPattern(type, designation);
}
this.Reset(ref resetPoint);
return this.ParseSubExpression(Precedence.Expression);
}
finally
{
this.Release(ref resetPoint);
}
}
else
private PatternSyntax ParsePattern()
{
// In places where a pattern is supported, we do not support tuple types
// due to both syntactic and semantic ambiguities between tuple types and positional patterns.
var node = ParseExpressionOrPattern(forCase: false);
switch (node)
{
case PatternSyntax pattern:
return pattern;
case ExpressionSyntax expression:
return _syntaxFactory.ConstantPattern(expression);
default:
throw ExceptionUtilities.UnexpectedValue(node);
}
}
// But it still might be a pattern such as (operand is 3) or (operand is nameof(x))
node = this.ParseSubExpression(Precedence.Expression);
private PropertySubpatternSyntax ParsePropertySubpattern()
{
ParseSubpatternList(out var openBraceToken, out var subPatterns, out var closeBraceToken, SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken);
return _syntaxFactory.PropertySubpattern(openBraceToken, subPatterns, closeBraceToken);
}
private void ParseSubpatternList(
out SyntaxToken openToken,
out Microsoft.CodeAnalysis.Syntax.InternalSyntax.SeparatedSyntaxList<SubpatternElementSyntax> subPatterns,
out SyntaxToken closeToken,
SyntaxKind openKind,
SyntaxKind closeKind)
{
Debug.Assert(openKind == SyntaxKind.OpenParenToken || openKind == SyntaxKind.OpenBraceToken);
Debug.Assert(closeKind == SyntaxKind.CloseParenToken || closeKind == SyntaxKind.CloseBraceToken);
Debug.Assert((openKind == SyntaxKind.OpenParenToken) == (closeKind == SyntaxKind.CloseParenToken));
openToken = this.EatToken(openKind);
var list = _pool.AllocateSeparated<SubpatternElementSyntax>();
try
{
if (this.CurrentToken.Kind != closeKind && this.CurrentToken.Kind != SyntaxKind.SemicolonToken)
{
tryAgain:
if (this.IsPossibleSubpatternElement() || this.CurrentToken.Kind == SyntaxKind.CommaToken)
{
// first pattern
list.Add(this.ParseSubpatternElement());
// additional patterns
while (true)
{
if (this.CurrentToken.Kind == SyntaxKind.CloseParenToken ||
this.CurrentToken.Kind == SyntaxKind.CloseBraceToken ||
this.CurrentToken.Kind == SyntaxKind.SemicolonToken)
{
break;
}
else if (this.CurrentToken.Kind == SyntaxKind.CommaToken || this.IsPossibleSubpatternElement())
{
list.AddSeparator(this.EatToken(SyntaxKind.CommaToken));
list.Add(this.ParseSubpatternElement());
continue;
}
else if (this.SkipBadPatternListTokens(ref openToken, list, SyntaxKind.CommaToken, closeKind) == PostSkipAction.Abort)
{
break;
}
}
}
else if (this.SkipBadPatternListTokens(ref openToken, list, SyntaxKind.IdentifierToken, closeKind) == PostSkipAction.Continue)
{
goto tryAgain;
}
}
closeToken = this.EatToken(closeKind);
subPatterns = list.ToList();
}
finally
{
_pool.Free(list);
}
}
private SubpatternElementSyntax ParseSubpatternElement()
{
NameColonSyntax nameColon = null;
if (this.CurrentToken.Kind == SyntaxKind.IdentifierToken && this.PeekToken(1).Kind == SyntaxKind.ColonToken)
{
var name = this.ParseIdentifierName();
var colon = this.EatToken(SyntaxKind.ColonToken);
nameColon = _syntaxFactory.NameColon(name, colon);
}
var pattern = ParsePattern();
return this._syntaxFactory.SubpatternElement(nameColon, pattern);
}
private bool IsPossibleSubpatternElement()
{
return this.IsPossibleExpression() || this.CurrentToken.Kind == SyntaxKind.OpenBraceToken;
}
return node;
private PostSkipAction SkipBadPatternListTokens(
ref SyntaxToken open,
Microsoft.CodeAnalysis.Syntax.InternalSyntax.SeparatedSyntaxListBuilder<SubpatternElementSyntax> list,
SyntaxKind expected,
SyntaxKind closeKind)
{
return this.SkipBadSeparatedListTokensWithExpectedKind(ref open, list,
p => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleSubpatternElement(),
p => p.CurrentToken.Kind == closeKind || p.CurrentToken.Kind == SyntaxKind.SemicolonToken || p.IsTerminator(),
expected);
}
}
}
Microsoft.CodeAnalysis.CSharp.Conversion.IsStackAlloc.get -> bool
Microsoft.CodeAnalysis.CSharp.Conversion.ToCommonConversion() -> Microsoft.CodeAnalysis.Semantics.CommonConversion
Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp7_2 = 702 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion
static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetConversion(this Microsoft.CodeAnalysis.Semantics.IConversionExpression conversionExpression) -> Microsoft.CodeAnalysis.CSharp.Conversion
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.AddPropertySubpatternSubPatterns(params Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.AddSubPatterns(params Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.CloseParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.Designation.get -> Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.OpenParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.PropertySubpattern.get -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.SubPatterns.get -> Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax>
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.Type.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax> subPatterns, Microsoft.CodeAnalysis.SyntaxToken closeParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax propertySubpattern, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.WithCloseParenToken(Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.WithDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.WithOpenParenToken(Microsoft.CodeAnalysis.SyntaxToken openParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.WithPropertySubpattern(Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax propertySubpattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.WithSubPatterns(Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax> subPatterns) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.WithType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax.AddPropertySubpatternSubPatterns(params Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax.Designation.get -> Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax.PropertySubpattern.get -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax.Type.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax propertySubpattern, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax.WithDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax.WithPropertySubpattern(Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax propertySubpattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax.WithType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax.AddSubPatterns(params Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax.CloseBraceToken.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax.OpenBraceToken.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax.SubPatterns.get -> Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax>
Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken openBraceToken, Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax> subPatterns, Microsoft.CodeAnalysis.SyntaxToken closeBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax.WithCloseBraceToken(Microsoft.CodeAnalysis.SyntaxToken closeBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax.WithOpenBraceToken(Microsoft.CodeAnalysis.SyntaxToken openBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax.WithSubPatterns(Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax> subPatterns) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.ReadOnlyKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.WithReadOnlyKeyword(Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax.NameColon.get -> Microsoft.CodeAnalysis.CSharp.Syntax.NameColonSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax.Pattern.get -> Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.NameColonSyntax nameColon, Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax.WithNameColon(Microsoft.CodeAnalysis.CSharp.Syntax.NameColonSyntax nameColon) -> Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax.WithPattern(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax
Microsoft.CodeAnalysis.CSharp.SyntaxKind.DeconstructionPattern = 9023 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind
Microsoft.CodeAnalysis.CSharp.SyntaxKind.PropertyPattern = 9020 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind
Microsoft.CodeAnalysis.CSharp.SyntaxKind.PropertySubpattern = 9021 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind
Microsoft.CodeAnalysis.CSharp.SyntaxKind.SubpatternElement = 9022 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind
override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitDeconstructionPattern(Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode
override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitPropertyPattern(Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode
override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitPropertySubpattern(Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode
override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitSubpatternElement(Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode
override Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void
override Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax.Accept<TResult>(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor<TResult> visitor) -> TResult
override Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void
override Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax.Accept<TResult>(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor<TResult> visitor) -> TResult
override Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void
override Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax.Accept<TResult>(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor<TResult> visitor) -> TResult
override Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void
override Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax.Accept<TResult>(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor<TResult> visitor) -> TResult
static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetConversion(this Microsoft.CodeAnalysis.Semantics.IConversionExpression conversionExpression) -> Microsoft.CodeAnalysis.CSharp.Conversion
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DeconstructionPattern(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax> subPatterns, Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax propertySubpattern, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DeconstructionPattern(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax> subPatterns, Microsoft.CodeAnalysis.SyntaxToken closeParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax propertySubpattern, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DeconstructionPattern(Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax> subPatterns = default(Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax>)) -> Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.PropertyPattern() -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.PropertyPattern(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax propertySubpattern, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.PropertySubpattern(Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax> subPatterns = default(Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax>)) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.PropertySubpattern(Microsoft.CodeAnalysis.SyntaxToken openBraceToken, Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax> subPatterns, Microsoft.CodeAnalysis.SyntaxToken closeBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Conversion.IsStackAlloc.get -> bool
\ No newline at end of file
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SubpatternElement(Microsoft.CodeAnalysis.CSharp.Syntax.NameColonSyntax nameColon, Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SubpatternElement(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitDeconstructionPattern(Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax node) -> void
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitPropertyPattern(Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax node) -> void
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitPropertySubpattern(Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax node) -> void
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitSubpatternElement(Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax node) -> void
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor<TResult>.VisitDeconstructionPattern(Microsoft.CodeAnalysis.CSharp.Syntax.DeconstructionPatternSyntax node) -> TResult
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor<TResult>.VisitPropertyPattern(Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternSyntax node) -> TResult
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor<TResult>.VisitPropertySubpattern(Microsoft.CodeAnalysis.CSharp.Syntax.PropertySubpatternSyntax node) -> TResult
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor<TResult>.VisitSubpatternElement(Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternElementSyntax node) -> TResult
\ No newline at end of file
......@@ -1720,12 +1720,52 @@
<AbstractNode Name="PatternSyntax" Base="CSharpSyntaxNode" />
<Node Name="DeclarationPatternSyntax" Base="PatternSyntax">
<Kind Name="DeclarationPattern" />
<Field Name="Type" Type="TypeSyntax" />
<Field Name="Type" Type="TypeSyntax"/>
<Field Name="Designation" Type="VariableDesignationSyntax">
<Kind Name="SingleVariableDesignation"/>
<Kind Name="DiscardDesignation"/>
</Field>
</Node>
<Node Name="DeconstructionPatternSyntax" Base="PatternSyntax">
<Kind Name="DeconstructionPattern" />
<Field Name="Type" Type="TypeSyntax" Optional="true" />
<Field Name="OpenParenToken" Type="SyntaxToken">
<Kind Name="OpenParenToken"/>
</Field>
<Field Name="SubPatterns" Type="SeparatedSyntaxList&lt;SubpatternElementSyntax&gt;"/>
<Field Name="CloseParenToken" Type="SyntaxToken">
<Kind Name="CloseParenToken"/>
</Field>
<Field Name="PropertySubpattern" Type="PropertySubpatternSyntax" Optional="true" />
<Field Name="Designation" Type="VariableDesignationSyntax" Optional="true">
<Kind Name="SingleVariableDesignation"/>
<Kind Name="DiscardDesignation"/>
</Field>
</Node>
<Node Name="SubpatternElementSyntax" Base="CSharpSyntaxNode">
<Kind Name="SubpatternElement"/>
<Field Name="NameColon" Type="NameColonSyntax" Optional="true" />
<Field Name="Pattern" Type="PatternSyntax" />
</Node>
<Node Name="PropertyPatternSyntax" Base="PatternSyntax">
<Kind Name="PropertyPattern" />
<Field Name="Type" Type="TypeSyntax" Optional="true" />
<Field Name="PropertySubpattern" Type="PropertySubpatternSyntax"/>
<Field Name="Designation" Type="VariableDesignationSyntax" Optional="true">
<Kind Name="SingleVariableDesignation"/>
<Kind Name="DiscardDesignation"/>
</Field>
</Node>
<Node Name="PropertySubpatternSyntax" Base="CSharpSyntaxNode">
<Kind Name="PropertySubpattern"/>
<Field Name="OpenBraceToken" Type="SyntaxToken">
<Kind Name="OpenBraceToken"/>
</Field>
<Field Name="SubPatterns" Type="SeparatedSyntaxList&lt;SubpatternElementSyntax&gt;"/>
<Field Name="CloseBraceToken" Type="SyntaxToken">
<Kind Name="CloseBraceToken"/>
</Field>
</Node>
<Node Name="ConstantPatternSyntax" Base="PatternSyntax">
<Kind Name="ConstantPattern"/>
<Field Name="Expression" Type="ExpressionSyntax">
......@@ -1851,7 +1891,6 @@
</Field>
<Field Name="Value" Type="ExpressionSyntax"/>
</Node>
<AbstractNode Name="VariableDesignationSyntax" Base="CSharpSyntaxNode">
</AbstractNode>
<Node Name="SingleVariableDesignationSyntax" Base="VariableDesignationSyntax">
......@@ -1876,7 +1915,6 @@
<Kind Name="CloseParenToken"/>
</Field>
</Node>
<Node Name="ExpressionStatementSyntax" Base="StatementSyntax">
<Kind Name="ExpressionStatement"/>
<Field Name="Expression" Type="ExpressionSyntax"/>
......
......@@ -556,6 +556,11 @@ public enum SyntaxKind : ushort
WhenClause = 9013,
DiscardDesignation = 9014,
PropertyPattern = 9020,
PropertySubpattern = 9021,
SubpatternElement = 9022,
DeconstructionPattern = 9023,
// Kinds between 9000 and 9039 are "reserved" for pattern matching.
// Please start with 9040 if you add more kinds below.
......
......@@ -14983,24 +14983,21 @@ void Match(object o)
var comp = CreateStandardCompilation(source);
comp.VerifyDiagnostics(
// (7,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case (int, int) tuple: return;
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(int, int) tuple").WithArguments("recursive patterns", "patterns2").WithLocation(7, 18),
// (7,19): error CS1525: Invalid expression term 'int'
// case (int, int) tuple: return;
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "int").WithArguments("int").WithLocation(7, 19),
// (7,24): error CS1525: Invalid expression term 'int'
// case (int, int) tuple: return;
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "int").WithArguments("int").WithLocation(7, 24),
// (7,29): error CS1003: Syntax error, ':' expected
// case (int, int) tuple: return;
Diagnostic(ErrorCode.ERR_SyntaxError, "tuple").WithArguments(":", "").WithLocation(7, 29),
// (7,18): error CS0150: A constant value is expected
// case (int, int) tuple: return;
Diagnostic(ErrorCode.ERR_ConstantExpected, "(int, int)").WithLocation(7, 18),
// (7,29): warning CS0162: Unreachable code detected
// (7,18): error CS0570: 'recursive pattern' is not supported by the language
// case (int, int) tuple: return;
Diagnostic(ErrorCode.WRN_UnreachableCode, "tuple").WithLocation(7, 29),
// (7,29): warning CS0164: This label has not been referenced
Diagnostic(ErrorCode.ERR_BindToBogus, "(int, int) tuple").WithArguments("recursive pattern").WithLocation(7, 18),
// (7,36): warning CS0162: Unreachable code detected
// case (int, int) tuple: return;
Diagnostic(ErrorCode.WRN_UnreferencedLabel, "tuple").WithLocation(7, 29)
Diagnostic(ErrorCode.WRN_UnreachableCode, "return").WithLocation(7, 36)
);
}
......@@ -15021,9 +15018,12 @@ void Match(object o)
var comp = CreateStandardCompilation(source);
comp.VerifyDiagnostics(
// (7,18): error CS0150: A constant value is expected
// (7,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case (1, 1): return;
Diagnostic(ErrorCode.ERR_ConstantExpected, "(1, 1)").WithLocation(7, 18),
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(1, 1)").WithArguments("recursive patterns", "patterns2").WithLocation(7, 18),
// (7,18): error CS0570: 'recursive pattern' is not supported by the language
// case (1, 1): return;
Diagnostic(ErrorCode.ERR_BindToBogus, "(1, 1)").WithArguments("recursive pattern").WithLocation(7, 18),
// (7,26): warning CS0162: Unreachable code detected
// case (1, 1): return;
Diagnostic(ErrorCode.WRN_UnreachableCode, "return").WithLocation(7, 26)
......@@ -15047,18 +15047,15 @@ void Match(object o)
var comp = CreateStandardCompilation(source);
comp.VerifyDiagnostics(
// (7,25): error CS1003: Syntax error, ':' expected
// case (1, 1) t: return;
Diagnostic(ErrorCode.ERR_SyntaxError, "t").WithArguments(":", "").WithLocation(7, 25),
// (7,18): error CS0150: A constant value is expected
// (7,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case (1, 1) t: return;
Diagnostic(ErrorCode.ERR_ConstantExpected, "(1, 1)").WithLocation(7, 18),
// (7,25): warning CS0162: Unreachable code detected
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(1, 1) t").WithArguments("recursive patterns", "patterns2").WithLocation(7, 18),
// (7,18): error CS0570: 'recursive pattern' is not supported by the language
// case (1, 1) t: return;
Diagnostic(ErrorCode.WRN_UnreachableCode, "t").WithLocation(7, 25),
// (7,25): warning CS0164: This label has not been referenced
Diagnostic(ErrorCode.ERR_BindToBogus, "(1, 1) t").WithArguments("recursive pattern").WithLocation(7, 18),
// (7,28): warning CS0162: Unreachable code detected
// case (1, 1) t: return;
Diagnostic(ErrorCode.WRN_UnreferencedLabel, "t").WithLocation(7, 25)
Diagnostic(ErrorCode.WRN_UnreachableCode, "return").WithLocation(7, 28)
);
}
......
......@@ -30353,7 +30353,7 @@ static void Main(string[] args)
{
switch (true)
{
case TakeOutParam(3, out var x1):
case 1+TakeOutParam(3, out var x1):
System.Console.WriteLine(x1);
break;
}
......@@ -30368,9 +30368,9 @@ static bool TakeOutParam(int y, out int x)
var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular);
// The point of this test is that it should not crash.
compilation.VerifyDiagnostics(
// (8,18): error CS0150: A constant value is expected
// case TakeOutParam(3, out var x1):
Diagnostic(ErrorCode.ERR_ConstantExpected, "TakeOutParam(3, out var x1)").WithLocation(8, 18),
// (8,18): error CS0019: Operator '+' cannot be applied to operands of type 'int' and 'bool'
// case 1+TakeOutParam(3, out var x1):
Diagnostic(ErrorCode.ERR_BadBinaryOps, "1+TakeOutParam(3, out var x1)").WithArguments("+", "int", "bool").WithLocation(8, 18),
// (9,17): warning CS0162: Unreachable code detected
// System.Console.WriteLine(x1);
Diagnostic(ErrorCode.WRN_UnreachableCode, "System").WithLocation(9, 17)
......@@ -30394,7 +30394,7 @@ static void Main(string[] args)
{
switch (true)
{
case TakeOutParam(3, out UndelcaredType x1):
case 1+TakeOutParam(3, out UndelcaredType x1):
System.Console.WriteLine(x1);
break;
}
......@@ -30404,12 +30404,12 @@ static void Main(string[] args)
var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular);
// The point of this test is that it should not crash.
compilation.VerifyDiagnostics(
// (8,38): error CS0246: The type or namespace name 'UndelcaredType' could not be found (are you missing a using directive or an assembly reference?)
// case TakeOutParam(3, out UndelcaredType x1):
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "UndelcaredType").WithArguments("UndelcaredType").WithLocation(8, 38),
// (8,18): error CS0103: The name 'TakeOutParam' does not exist in the current context
// case TakeOutParam(3, out UndelcaredType x1):
Diagnostic(ErrorCode.ERR_NameNotInContext, "TakeOutParam").WithArguments("TakeOutParam").WithLocation(8, 18),
// (8,20): error CS0103: The name 'TakeOutParam' does not exist in the current context
// case 1+TakeOutParam(3, out UndelcaredType x1):
Diagnostic(ErrorCode.ERR_NameNotInContext, "TakeOutParam").WithArguments("TakeOutParam").WithLocation(8, 20),
// (8,40): error CS0246: The type or namespace name 'UndelcaredType' could not be found (are you missing a using directive or an assembly reference?)
// case 1+TakeOutParam(3, out UndelcaredType x1):
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "UndelcaredType").WithArguments("UndelcaredType").WithLocation(8, 40),
// (9,17): warning CS0162: Unreachable code detected
// System.Console.WriteLine(x1);
Diagnostic(ErrorCode.WRN_UnreachableCode, "System").WithLocation(9, 17)
......@@ -32138,10 +32138,10 @@ public static void Main(string[] args)
{
switch ((object)args.Length)
{
case M(nameof(M(out int z1)), z1):
case 1+M(nameof(M(out int z1)), z1):
System.Console.WriteLine(z1);
break;
case M(nameof(M(out var z2)), z2):
case 1+M(nameof(M(out var z2)), z2):
System.Console.WriteLine(z2);
break;
}
......@@ -32152,18 +32152,18 @@ public static void Main(string[] args)
";
var compilation = CreateCompilationWithMscorlib45(text);
compilation.VerifyDiagnostics(
// (8,27): error CS8081: Expression does not have a name.
// case M(nameof(M(out int z1)), z1):
Diagnostic(ErrorCode.ERR_ExpressionHasNoName, "M(out int z1)").WithLocation(8, 27),
// (8,18): error CS0150: A constant value is expected
// case M(nameof(M(out int z1)), z1):
Diagnostic(ErrorCode.ERR_ConstantExpected, "M(nameof(M(out int z1)), z1)").WithLocation(8, 18),
// (11,27): error CS8081: Expression does not have a name.
// case M(nameof(M(out var z2)), z2):
Diagnostic(ErrorCode.ERR_ExpressionHasNoName, "M(out var z2)").WithLocation(11, 27),
// (11,18): error CS0150: A constant value is expected
// case M(nameof(M(out var z2)), z2):
Diagnostic(ErrorCode.ERR_ConstantExpected, "M(nameof(M(out var z2)), z2)").WithLocation(11, 18),
// (8,29): error CS8081: Expression does not have a name.
// case 1+M(nameof(M(out int z1)), z1):
Diagnostic(ErrorCode.ERR_ExpressionHasNoName, "M(out int z1)").WithLocation(8, 29),
// (8,18): error CS0019: Operator '+' cannot be applied to operands of type 'int' and 'bool'
// case 1+M(nameof(M(out int z1)), z1):
Diagnostic(ErrorCode.ERR_BadBinaryOps, "1+M(nameof(M(out int z1)), z1)").WithArguments("+", "int", "bool").WithLocation(8, 18),
// (11,29): error CS8081: Expression does not have a name.
// case 1+M(nameof(M(out var z2)), z2):
Diagnostic(ErrorCode.ERR_ExpressionHasNoName, "M(out var z2)").WithLocation(11, 29),
// (11,18): error CS0019: Operator '+' cannot be applied to operands of type 'int' and 'bool'
// case 1+M(nameof(M(out var z2)), z2):
Diagnostic(ErrorCode.ERR_BadBinaryOps, "1+M(nameof(M(out var z2)), z2)").WithArguments("+", "int", "bool").WithLocation(11, 18),
// (9,17): warning CS0162: Unreachable code detected
// System.Console.WriteLine(z1);
Diagnostic(ErrorCode.WRN_UnreachableCode, "System").WithLocation(9, 17),
......@@ -1512,69 +1512,63 @@ static void M(object o)
";
var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugDll);
compilation.VerifyDiagnostics(
// (21,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case (int, int):
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(int, int)").WithArguments("recursive patterns", "patterns2").WithLocation(21, 18),
// (21,19): error CS1525: Invalid expression term 'int'
// case (int, int):
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "int").WithArguments("int").WithLocation(21, 19),
// (21,24): error CS1525: Invalid expression term 'int'
// case (int, int):
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "int").WithArguments("int").WithLocation(21, 24),
// (22,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case (int x, int y):
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(int x, int y)").WithArguments("recursive patterns", "patterns2").WithLocation(22, 18),
// (23,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case (int, int) z:
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(int, int) z").WithArguments("recursive patterns", "patterns2").WithLocation(23, 18),
// (23,19): error CS1525: Invalid expression term 'int'
// case (int, int) z:
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "int").WithArguments("int").WithLocation(23, 19),
// (23,24): error CS1525: Invalid expression term 'int'
// case (int, int) z:
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "int").WithArguments("int").WithLocation(23, 24),
// (23,29): error CS1003: Syntax error, ':' expected
// case (int, int) z:
Diagnostic(ErrorCode.ERR_SyntaxError, "z").WithArguments(":", "").WithLocation(23, 29),
// (23,31): error CS1525: Invalid expression term 'case'
// case (int, int) z:
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "").WithArguments("case").WithLocation(23, 31),
// (23,31): error CS1002: ; expected
// case (int, int) z:
Diagnostic(ErrorCode.ERR_SemicolonExpected, "").WithLocation(23, 31),
// (24,33): error CS1003: Syntax error, ':' expected
// case (int a, int b) c:
Diagnostic(ErrorCode.ERR_SyntaxError, "c").WithArguments(":", "").WithLocation(24, 33),
// (24,35): error CS1525: Invalid expression term 'case'
// case (int a, int b) c:
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "").WithArguments("case").WithLocation(24, 35),
// (24,35): error CS1002: ; expected
// (24,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case (int a, int b) c:
Diagnostic(ErrorCode.ERR_SemicolonExpected, "").WithLocation(24, 35),
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(int a, int b) c").WithArguments("recursive patterns", "patterns2").WithLocation(24, 18),
// (25,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case (long, long) d:
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(long, long) d").WithArguments("recursive patterns", "patterns2").WithLocation(25, 18),
// (25,19): error CS1525: Invalid expression term 'long'
// case (long, long) d:
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "long").WithArguments("long").WithLocation(25, 19),
// (25,25): error CS1525: Invalid expression term 'long'
// case (long, long) d:
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "long").WithArguments("long").WithLocation(25, 25),
// (25,31): error CS1003: Syntax error, ':' expected
// case (long, long) d:
Diagnostic(ErrorCode.ERR_SyntaxError, "d").WithArguments(":", "").WithLocation(25, 31),
// (30,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case (int, int) z:
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(int, int) z").WithArguments("recursive patterns", "patterns2").WithLocation(30, 18),
// (30,19): error CS1525: Invalid expression term 'int'
// case (int, int) z:
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "int").WithArguments("int").WithLocation(30, 19),
// (30,24): error CS1525: Invalid expression term 'int'
// case (int, int) z:
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "int").WithArguments("int").WithLocation(30, 24),
// (30,29): error CS1003: Syntax error, ':' expected
// case (int, int) z:
Diagnostic(ErrorCode.ERR_SyntaxError, "z").WithArguments(":", "").WithLocation(30, 29),
// (32,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case (long, long) d:
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(long, long) d").WithArguments("recursive patterns", "patterns2").WithLocation(32, 18),
// (32,19): error CS1525: Invalid expression term 'long'
// case (long, long) d:
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "long").WithArguments("long").WithLocation(32, 19),
// (32,25): error CS1525: Invalid expression term 'long'
// case (long, long) d:
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "long").WithArguments("long").WithLocation(32, 25),
// (32,31): error CS1003: Syntax error, ':' expected
// case (long, long) d:
Diagnostic(ErrorCode.ERR_SyntaxError, "d").WithArguments(":", "").WithLocation(32, 31),
// (37,47): error CS1003: Syntax error, ':' expected
// (37,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case (System.Int32, System.Int32) z:
Diagnostic(ErrorCode.ERR_SyntaxError, "z").WithArguments(":", "").WithLocation(37, 47),
// (39,47): error CS1003: Syntax error, ':' expected
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(System.Int32, System.Int32) z").WithArguments("recursive patterns", "patterns2").WithLocation(37, 18),
// (39,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case (System.Int64, System.Int64) d:
Diagnostic(ErrorCode.ERR_SyntaxError, "d").WithArguments(":", "").WithLocation(39, 47),
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(System.Int64, System.Int64) d").WithArguments("recursive patterns", "patterns2").WithLocation(39, 18),
// (43,23): error CS1525: Invalid expression term 'int'
// if (o is (int, int)) {}
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "int").WithArguments("int").WithLocation(43, 23),
......@@ -1623,51 +1617,33 @@ static void M(object o)
// (52,56): error CS1513: } expected
// if (o is (System.Int32 a, System.Int32 b) c) {}
Diagnostic(ErrorCode.ERR_RbraceExpected, ")").WithLocation(52, 56),
// (21,18): error CS0150: A constant value is expected
// (21,18): error CS0570: 'recursive pattern' is not supported by the language
// case (int, int):
Diagnostic(ErrorCode.ERR_ConstantExpected, "(int, int)").WithLocation(21, 18),
// (22,19): error CS8185: A declaration is not allowed in this context.
// case (int x, int y):
Diagnostic(ErrorCode.ERR_DeclarationExpressionNotPermitted, "int x").WithLocation(22, 19),
// (22,26): error CS8185: A declaration is not allowed in this context.
Diagnostic(ErrorCode.ERR_BindToBogus, "(int, int)").WithArguments("recursive pattern").WithLocation(21, 18),
// (22,18): error CS0570: 'recursive pattern' is not supported by the language
// case (int x, int y):
Diagnostic(ErrorCode.ERR_DeclarationExpressionNotPermitted, "int y").WithLocation(22, 26),
// (22,18): error CS0150: A constant value is expected
// case (int x, int y):
Diagnostic(ErrorCode.ERR_ConstantExpected, "(int x, int y)").WithLocation(22, 18),
// (23,18): error CS0150: A constant value is expected
Diagnostic(ErrorCode.ERR_BindToBogus, "(int x, int y)").WithArguments("recursive pattern").WithLocation(22, 18),
// (23,18): error CS0570: 'recursive pattern' is not supported by the language
// case (int, int) z:
Diagnostic(ErrorCode.ERR_ConstantExpected, "(int, int)").WithLocation(23, 18),
// (24,19): error CS8185: A declaration is not allowed in this context.
// case (int a, int b) c:
Diagnostic(ErrorCode.ERR_DeclarationExpressionNotPermitted, "int a").WithLocation(24, 19),
// (24,26): error CS8185: A declaration is not allowed in this context.
// case (int a, int b) c:
Diagnostic(ErrorCode.ERR_DeclarationExpressionNotPermitted, "int b").WithLocation(24, 26),
// (24,18): error CS0150: A constant value is expected
Diagnostic(ErrorCode.ERR_BindToBogus, "(int, int) z").WithArguments("recursive pattern").WithLocation(23, 18),
// (24,18): error CS0570: 'recursive pattern' is not supported by the language
// case (int a, int b) c:
Diagnostic(ErrorCode.ERR_ConstantExpected, "(int a, int b)").WithLocation(24, 18),
// (25,18): error CS0150: A constant value is expected
Diagnostic(ErrorCode.ERR_BindToBogus, "(int a, int b) c").WithArguments("recursive pattern").WithLocation(24, 18),
// (25,18): error CS0570: 'recursive pattern' is not supported by the language
// case (long, long) d:
Diagnostic(ErrorCode.ERR_ConstantExpected, "(long, long)").WithLocation(25, 18),
// (30,18): error CS0150: A constant value is expected
Diagnostic(ErrorCode.ERR_BindToBogus, "(long, long) d").WithArguments("recursive pattern").WithLocation(25, 18),
// (30,18): error CS0570: 'recursive pattern' is not supported by the language
// case (int, int) z:
Diagnostic(ErrorCode.ERR_ConstantExpected, "(int, int)").WithLocation(30, 18),
// (32,18): error CS0150: A constant value is expected
Diagnostic(ErrorCode.ERR_BindToBogus, "(int, int) z").WithArguments("recursive pattern").WithLocation(30, 18),
// (32,18): error CS0570: 'recursive pattern' is not supported by the language
// case (long, long) d:
Diagnostic(ErrorCode.ERR_ConstantExpected, "(long, long)").WithLocation(32, 18),
// (37,19): error CS0119: 'int' is a type, which is not valid in the given context
Diagnostic(ErrorCode.ERR_BindToBogus, "(long, long) d").WithArguments("recursive pattern").WithLocation(32, 18),
// (37,18): error CS0570: 'recursive pattern' is not supported by the language
// case (System.Int32, System.Int32) z:
Diagnostic(ErrorCode.ERR_BadSKunknown, "System.Int32").WithArguments("int", "type").WithLocation(37, 19),
// (37,33): error CS0119: 'int' is a type, which is not valid in the given context
// case (System.Int32, System.Int32) z:
Diagnostic(ErrorCode.ERR_BadSKunknown, "System.Int32").WithArguments("int", "type").WithLocation(37, 33),
// (39,19): error CS0119: 'long' is a type, which is not valid in the given context
// case (System.Int64, System.Int64) d:
Diagnostic(ErrorCode.ERR_BadSKunknown, "System.Int64").WithArguments("long", "type").WithLocation(39, 19),
// (39,33): error CS0119: 'long' is a type, which is not valid in the given context
Diagnostic(ErrorCode.ERR_BindToBogus, "(System.Int32, System.Int32) z").WithArguments("recursive pattern").WithLocation(37, 18),
// (39,18): error CS0570: 'recursive pattern' is not supported by the language
// case (System.Int64, System.Int64) d:
Diagnostic(ErrorCode.ERR_BadSKunknown, "System.Int64").WithArguments("long", "type").WithLocation(39, 33),
Diagnostic(ErrorCode.ERR_BindToBogus, "(System.Int64, System.Int64) d").WithArguments("recursive pattern").WithLocation(39, 18),
// (43,22): error CS0150: A constant value is expected
// if (o is (int, int)) {}
Diagnostic(ErrorCode.ERR_ConstantExpected, "(int, int)").WithLocation(43, 22),
......@@ -1734,48 +1710,21 @@ static void M(object o)
// (52,55): error CS0103: The name 'c' does not exist in the current context
// if (o is (System.Int32 a, System.Int32 b) c) {}
Diagnostic(ErrorCode.ERR_NameNotInContext, "c").WithArguments("c").WithLocation(52, 55),
// (23,29): warning CS0162: Unreachable code detected
// case (int, int) z:
Diagnostic(ErrorCode.WRN_UnreachableCode, "z").WithLocation(23, 29),
// (24,33): warning CS0162: Unreachable code detected
// case (int a, int b) c:
Diagnostic(ErrorCode.WRN_UnreachableCode, "c").WithLocation(24, 33),
// (25,31): warning CS0162: Unreachable code detected
// case (long, long) d:
Diagnostic(ErrorCode.WRN_UnreachableCode, "d").WithLocation(25, 31),
// (30,29): warning CS0162: Unreachable code detected
// case (int, int) z:
Diagnostic(ErrorCode.WRN_UnreachableCode, "z").WithLocation(30, 29),
// (32,31): warning CS0162: Unreachable code detected
// case (long, long) d:
Diagnostic(ErrorCode.WRN_UnreachableCode, "d").WithLocation(32, 31),
// (37,47): warning CS0162: Unreachable code detected
// case (System.Int32, System.Int32) z:
Diagnostic(ErrorCode.WRN_UnreachableCode, "z").WithLocation(37, 47),
// (39,47): warning CS0162: Unreachable code detected
// case (System.Int64, System.Int64) d:
Diagnostic(ErrorCode.WRN_UnreachableCode, "d").WithLocation(39, 47),
// (23,29): warning CS0164: This label has not been referenced
// case (int, int) z:
Diagnostic(ErrorCode.WRN_UnreferencedLabel, "z").WithLocation(23, 29),
// (24,33): warning CS0164: This label has not been referenced
// case (int a, int b) c:
Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(24, 33),
// (25,31): warning CS0164: This label has not been referenced
// case (long, long) d:
Diagnostic(ErrorCode.WRN_UnreferencedLabel, "d").WithLocation(25, 31),
// (30,29): warning CS0164: This label has not been referenced
// case (int, int) z:
Diagnostic(ErrorCode.WRN_UnreferencedLabel, "z").WithLocation(30, 29),
// (32,31): warning CS0164: This label has not been referenced
// case (long, long) d:
Diagnostic(ErrorCode.WRN_UnreferencedLabel, "d").WithLocation(32, 31),
// (37,47): warning CS0164: This label has not been referenced
// case (System.Int32, System.Int32) z:
Diagnostic(ErrorCode.WRN_UnreferencedLabel, "z").WithLocation(37, 47),
// (39,47): warning CS0164: This label has not been referenced
// case (System.Int64, System.Int64) d:
Diagnostic(ErrorCode.WRN_UnreferencedLabel, "d").WithLocation(39, 47),
// (26,17): warning CS0162: Unreachable code detected
// break;
Diagnostic(ErrorCode.WRN_UnreachableCode, "break").WithLocation(26, 17),
// (31,17): warning CS0162: Unreachable code detected
// break;
Diagnostic(ErrorCode.WRN_UnreachableCode, "break").WithLocation(31, 17),
// (33,17): warning CS0162: Unreachable code detected
// break;
Diagnostic(ErrorCode.WRN_UnreachableCode, "break").WithLocation(33, 17),
// (38,17): warning CS0162: Unreachable code detected
// break;
Diagnostic(ErrorCode.WRN_UnreachableCode, "break").WithLocation(38, 17),
// (40,17): warning CS0162: Unreachable code detected
// break;
Diagnostic(ErrorCode.WRN_UnreachableCode, "break").WithLocation(40, 17),
// (44,23): error CS0165: Use of unassigned local variable 'x'
// if (o is (int x, int y)) {}
Diagnostic(ErrorCode.ERR_UseDefViolation, "int x").WithArguments("x").WithLocation(44, 23),
......
......@@ -1160,26 +1160,65 @@ static object F(int i)
";
CreateStandardCompilation(text, parseOptions: TestOptions.Regular6).VerifyDiagnostics(
// (8,13): error CS8059: Feature 'pattern matching' is not available in C# 6. Please use language version 7.0 or greater.
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion6, "case ((o.GetType().Name.Length)):").WithArguments("pattern matching", "7.0").WithLocation(8, 13),
// (8,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "((o.GetType().Name.Length))").WithArguments("recursive patterns", "patterns2").WithLocation(8, 18),
// (8,19): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(o.GetType().Name.Length)").WithArguments("recursive patterns", "patterns2").WithLocation(8, 19),
// (8,20): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "o.GetType()").WithArguments("recursive patterns", "patterns2").WithLocation(8, 20),
// (8,31): error CS1003: Syntax error, ',' expected
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_SyntaxError, ".").WithArguments(",", ".").WithLocation(8, 31),
// (8,32): error CS1003: Syntax error, ',' expected
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_SyntaxError, "Name").WithArguments(",", "").WithLocation(8, 32),
// (6,17): error CS0151: A switch expression or case label must be a bool, char, string, integral, enum, or corresponding nullable type in C# 6 and earlier.
// switch (o)
Diagnostic(ErrorCode.ERR_V6SwitchGoverningTypeValueExpected, "o").WithLocation(6, 17),
// (8,18): error CS0150: A constant value is expected
// (8,18): error CS0570: 'recursive pattern' is not supported by the language
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_ConstantExpected, "((o.GetType().Name.Length))").WithLocation(8, 18),
Diagnostic(ErrorCode.ERR_BindToBogus, "((o.GetType().Name.Length))").WithArguments("recursive pattern").WithLocation(8, 18),
// (9,17): error CS7036: There is no argument given that corresponds to the required formal parameter 'o' of 'C.M(object)'
// M();
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("o", "C.M(object)").WithLocation(9, 17),
// (12,13): error CS0152: The switch statement contains multiple cases with the label value '0'
// (12,13): error CS8120: The switch case has already been handled by a previous case.
// case 0:
Diagnostic(ErrorCode.ERR_DuplicateCaseLabel, "case 0:").WithArguments("0").WithLocation(12, 13)
Diagnostic(ErrorCode.ERR_PatternIsSubsumed, "case 0:").WithLocation(12, 13),
// (9,17): warning CS0162: Unreachable code detected
// M();
Diagnostic(ErrorCode.WRN_UnreachableCode, "M").WithLocation(9, 17)
);
CreateStandardCompilation(text, parseOptions: TestOptions.Regular6WithV7SwitchBinder).VerifyDiagnostics(
// (8,13): error CS8059: Feature 'pattern matching' is not available in C# 6. Please use language version 7.0 or greater.
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion6, "case ((o.GetType().Name.Length)):").WithArguments("pattern matching", "7.0").WithLocation(8, 13),
// (8,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "((o.GetType().Name.Length))").WithArguments("recursive patterns", "patterns2").WithLocation(8, 18),
// (8,19): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(o.GetType().Name.Length)").WithArguments("recursive patterns", "patterns2").WithLocation(8, 19),
// (8,20): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "o.GetType()").WithArguments("recursive patterns", "patterns2").WithLocation(8, 20),
// (8,31): error CS1003: Syntax error, ',' expected
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_SyntaxError, ".").WithArguments(",", ".").WithLocation(8, 31),
// (8,32): error CS1003: Syntax error, ',' expected
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_SyntaxError, "Name").WithArguments(",", "").WithLocation(8, 32),
// (6,17): error CS0151: A switch expression or case label must be a bool, char, string, integral, enum, or corresponding nullable type in C# 6 and earlier.
// switch (o)
Diagnostic(ErrorCode.ERR_V6SwitchGoverningTypeValueExpected, "o").WithLocation(6, 17),
// (8,18): error CS0150: A constant value is expected
// (8,18): error CS0570: 'recursive pattern' is not supported by the language
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_ConstantExpected, "((o.GetType().Name.Length))").WithLocation(8, 18),
Diagnostic(ErrorCode.ERR_BindToBogus, "((o.GetType().Name.Length))").WithArguments("recursive pattern").WithLocation(8, 18),
// (9,17): error CS7036: There is no argument given that corresponds to the required formal parameter 'o' of 'C.M(object)'
// M();
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("o", "C.M(object)").WithLocation(9, 17),
......@@ -1191,9 +1230,24 @@ static object F(int i)
Diagnostic(ErrorCode.WRN_UnreachableCode, "M").WithLocation(9, 17)
);
CreateStandardCompilation(text).VerifyDiagnostics(
// (8,18): error CS0150: A constant value is expected
// (8,18): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "((o.GetType().Name.Length))").WithArguments("recursive patterns", "patterns2").WithLocation(8, 18),
// (8,19): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "(o.GetType().Name.Length)").WithArguments("recursive patterns", "patterns2").WithLocation(8, 19),
// (8,20): error CS8058: Feature 'recursive patterns' is experimental and unsupported; use '/features:patterns2' to enable.
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "o.GetType()").WithArguments("recursive patterns", "patterns2").WithLocation(8, 20),
// (8,31): error CS1003: Syntax error, ',' expected
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_SyntaxError, ".").WithArguments(",", ".").WithLocation(8, 31),
// (8,32): error CS1003: Syntax error, ',' expected
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_SyntaxError, "Name").WithArguments(",", "").WithLocation(8, 32),
// (8,18): error CS0570: 'recursive pattern' is not supported by the language
// case ((o.GetType().Name.Length)):
Diagnostic(ErrorCode.ERR_ConstantExpected, "((o.GetType().Name.Length))").WithLocation(8, 18),
Diagnostic(ErrorCode.ERR_BindToBogus, "((o.GetType().Name.Length))").WithArguments("recursive pattern").WithLocation(8, 18),
// (9,17): error CS7036: There is no argument given that corresponds to the required formal parameter 'o' of 'C.M(object)'
// M();
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("o", "C.M(object)").WithLocation(9, 17),
......
......@@ -379,6 +379,26 @@ private static Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.DeclarationPa
return Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.DeclarationPattern(GenerateIdentifierName(), GenerateSingleVariableDesignation());
}
private static Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.DeconstructionPatternSyntax GenerateDeconstructionPattern()
{
return Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.DeconstructionPattern(null, Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.Token(SyntaxKind.OpenParenToken), new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SubpatternElementSyntax>(), Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.Token(SyntaxKind.CloseParenToken), null, null);
}
private static Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SubpatternElementSyntax GenerateSubpatternElement()
{
return Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.SubpatternElement(null, GenerateDeclarationPattern());
}
private static Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.PropertyPatternSyntax GeneratePropertyPattern()
{
return Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.PropertyPattern(null, GeneratePropertySubpattern(), null);
}
private static Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.PropertySubpatternSyntax GeneratePropertySubpattern()
{
return Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.PropertySubpattern(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.Token(SyntaxKind.OpenBraceToken), new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SubpatternElementSyntax>(), Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.Token(SyntaxKind.CloseBraceToken));
}
private static Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ConstantPatternSyntax GenerateConstantPattern()
{
return Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.ConstantPattern(GenerateIdentifierName());
......@@ -1906,6 +1926,56 @@ public void TestDeclarationPatternFactoryAndProperties()
AttachAndCheckDiagnostics(node);
}
[Fact]
public void TestDeconstructionPatternFactoryAndProperties()
{
var node = GenerateDeconstructionPattern();
Assert.Null(node.Type);
Assert.Equal(SyntaxKind.OpenParenToken, node.OpenParenToken.Kind);
Assert.NotNull(node.SubPatterns);
Assert.Equal(SyntaxKind.CloseParenToken, node.CloseParenToken.Kind);
Assert.Null(node.PropertySubpattern);
Assert.Null(node.Designation);
AttachAndCheckDiagnostics(node);
}
[Fact]
public void TestSubpatternElementFactoryAndProperties()
{
var node = GenerateSubpatternElement();
Assert.Null(node.NameColon);
Assert.NotNull(node.Pattern);
AttachAndCheckDiagnostics(node);
}
[Fact]
public void TestPropertyPatternFactoryAndProperties()
{
var node = GeneratePropertyPattern();
Assert.Null(node.Type);
Assert.NotNull(node.PropertySubpattern);
Assert.Null(node.Designation);
AttachAndCheckDiagnostics(node);
}
[Fact]
public void TestPropertySubpatternFactoryAndProperties()
{
var node = GeneratePropertySubpattern();
Assert.Equal(SyntaxKind.OpenBraceToken, node.OpenBraceToken.Kind);
Assert.NotNull(node.SubPatterns);
Assert.Equal(SyntaxKind.CloseBraceToken, node.CloseBraceToken.Kind);
AttachAndCheckDiagnostics(node);
}
[Fact]
public void TestConstantPatternFactoryAndProperties()
{
......@@ -5543,6 +5613,110 @@ public void TestDeclarationPatternIdentityRewriter()
Assert.Same(oldNode, newNode);
}
[Fact]
public void TestDeconstructionPatternTokenDeleteRewriter()
{
var oldNode = GenerateDeconstructionPattern();
var rewriter = new TokenDeleteRewriter();
var newNode = rewriter.Visit(oldNode);
if(!oldNode.IsMissing)
{
Assert.NotEqual(oldNode, newNode);
}
Assert.NotNull(newNode);
Assert.True(newNode.IsMissing, "No tokens => missing");
}
[Fact]
public void TestDeconstructionPatternIdentityRewriter()
{
var oldNode = GenerateDeconstructionPattern();
var rewriter = new IdentityRewriter();
var newNode = rewriter.Visit(oldNode);
Assert.Same(oldNode, newNode);
}
[Fact]
public void TestSubpatternElementTokenDeleteRewriter()
{
var oldNode = GenerateSubpatternElement();
var rewriter = new TokenDeleteRewriter();
var newNode = rewriter.Visit(oldNode);
if(!oldNode.IsMissing)
{
Assert.NotEqual(oldNode, newNode);
}
Assert.NotNull(newNode);
Assert.True(newNode.IsMissing, "No tokens => missing");
}
[Fact]
public void TestSubpatternElementIdentityRewriter()
{
var oldNode = GenerateSubpatternElement();
var rewriter = new IdentityRewriter();
var newNode = rewriter.Visit(oldNode);
Assert.Same(oldNode, newNode);
}
[Fact]
public void TestPropertyPatternTokenDeleteRewriter()
{
var oldNode = GeneratePropertyPattern();
var rewriter = new TokenDeleteRewriter();
var newNode = rewriter.Visit(oldNode);
if(!oldNode.IsMissing)
{
Assert.NotEqual(oldNode, newNode);
}
Assert.NotNull(newNode);
Assert.True(newNode.IsMissing, "No tokens => missing");
}
[Fact]
public void TestPropertyPatternIdentityRewriter()
{
var oldNode = GeneratePropertyPattern();
var rewriter = new IdentityRewriter();
var newNode = rewriter.Visit(oldNode);
Assert.Same(oldNode, newNode);
}
[Fact]
public void TestPropertySubpatternTokenDeleteRewriter()
{
var oldNode = GeneratePropertySubpattern();
var rewriter = new TokenDeleteRewriter();
var newNode = rewriter.Visit(oldNode);
if(!oldNode.IsMissing)
{
Assert.NotEqual(oldNode, newNode);
}
Assert.NotNull(newNode);
Assert.True(newNode.IsMissing, "No tokens => missing");
}
[Fact]
public void TestPropertySubpatternIdentityRewriter()
{
var oldNode = GeneratePropertySubpattern();
var rewriter = new IdentityRewriter();
var newNode = rewriter.Visit(oldNode);
Assert.Same(oldNode, newNode);
}
[Fact]
public void TestConstantPatternTokenDeleteRewriter()
{
......@@ -9298,6 +9472,26 @@ private static DeclarationPatternSyntax GenerateDeclarationPattern()
return SyntaxFactory.DeclarationPattern(GenerateIdentifierName(), GenerateSingleVariableDesignation());
}
private static DeconstructionPatternSyntax GenerateDeconstructionPattern()
{
return SyntaxFactory.DeconstructionPattern(default(TypeSyntax), SyntaxFactory.Token(SyntaxKind.OpenParenToken), new SeparatedSyntaxList<SubpatternElementSyntax>(), SyntaxFactory.Token(SyntaxKind.CloseParenToken), default(PropertySubpatternSyntax), default(VariableDesignationSyntax));
}
private static SubpatternElementSyntax GenerateSubpatternElement()
{
return SyntaxFactory.SubpatternElement(default(NameColonSyntax), GenerateDeclarationPattern());
}
private static PropertyPatternSyntax GeneratePropertyPattern()
{
return SyntaxFactory.PropertyPattern(default(TypeSyntax), GeneratePropertySubpattern(), default(VariableDesignationSyntax));
}
private static PropertySubpatternSyntax GeneratePropertySubpattern()
{
return SyntaxFactory.PropertySubpattern(SyntaxFactory.Token(SyntaxKind.OpenBraceToken), new SeparatedSyntaxList<SubpatternElementSyntax>(), SyntaxFactory.Token(SyntaxKind.CloseBraceToken));
}
private static ConstantPatternSyntax GenerateConstantPattern()
{
return SyntaxFactory.ConstantPattern(GenerateIdentifierName());
......@@ -10825,6 +11019,56 @@ public void TestDeclarationPatternFactoryAndProperties()
Assert.Equal(node, newNode);
}
[Fact]
public void TestDeconstructionPatternFactoryAndProperties()
{
var node = GenerateDeconstructionPattern();
Assert.Null(node.Type);
Assert.Equal(SyntaxKind.OpenParenToken, node.OpenParenToken.Kind());
Assert.NotNull(node.SubPatterns);
Assert.Equal(SyntaxKind.CloseParenToken, node.CloseParenToken.Kind());
Assert.Null(node.PropertySubpattern);
Assert.Null(node.Designation);
var newNode = node.WithType(node.Type).WithOpenParenToken(node.OpenParenToken).WithSubPatterns(node.SubPatterns).WithCloseParenToken(node.CloseParenToken).WithPropertySubpattern(node.PropertySubpattern).WithDesignation(node.Designation);
Assert.Equal(node, newNode);
}
[Fact]
public void TestSubpatternElementFactoryAndProperties()
{
var node = GenerateSubpatternElement();
Assert.Null(node.NameColon);
Assert.NotNull(node.Pattern);
var newNode = node.WithNameColon(node.NameColon).WithPattern(node.Pattern);
Assert.Equal(node, newNode);
}
[Fact]
public void TestPropertyPatternFactoryAndProperties()
{
var node = GeneratePropertyPattern();
Assert.Null(node.Type);
Assert.NotNull(node.PropertySubpattern);
Assert.Null(node.Designation);
var newNode = node.WithType(node.Type).WithPropertySubpattern(node.PropertySubpattern).WithDesignation(node.Designation);
Assert.Equal(node, newNode);
}
[Fact]
public void TestPropertySubpatternFactoryAndProperties()
{
var node = GeneratePropertySubpattern();
Assert.Equal(SyntaxKind.OpenBraceToken, node.OpenBraceToken.Kind());
Assert.NotNull(node.SubPatterns);
Assert.Equal(SyntaxKind.CloseBraceToken, node.CloseBraceToken.Kind());
var newNode = node.WithOpenBraceToken(node.OpenBraceToken).WithSubPatterns(node.SubPatterns).WithCloseBraceToken(node.CloseBraceToken);
Assert.Equal(node, newNode);
}
[Fact]
public void TestConstantPatternFactoryAndProperties()
{
......@@ -14462,6 +14706,110 @@ public void TestDeclarationPatternIdentityRewriter()
Assert.Same(oldNode, newNode);
}
[Fact]
public void TestDeconstructionPatternTokenDeleteRewriter()
{
var oldNode = GenerateDeconstructionPattern();
var rewriter = new TokenDeleteRewriter();
var newNode = rewriter.Visit(oldNode);
if(!oldNode.IsMissing)
{
Assert.NotEqual(oldNode, newNode);
}
Assert.NotNull(newNode);
Assert.True(newNode.IsMissing, "No tokens => missing");
}
[Fact]
public void TestDeconstructionPatternIdentityRewriter()
{
var oldNode = GenerateDeconstructionPattern();
var rewriter = new IdentityRewriter();
var newNode = rewriter.Visit(oldNode);
Assert.Same(oldNode, newNode);
}
[Fact]
public void TestSubpatternElementTokenDeleteRewriter()
{
var oldNode = GenerateSubpatternElement();
var rewriter = new TokenDeleteRewriter();
var newNode = rewriter.Visit(oldNode);
if(!oldNode.IsMissing)
{
Assert.NotEqual(oldNode, newNode);
}
Assert.NotNull(newNode);
Assert.True(newNode.IsMissing, "No tokens => missing");
}
[Fact]
public void TestSubpatternElementIdentityRewriter()
{
var oldNode = GenerateSubpatternElement();
var rewriter = new IdentityRewriter();
var newNode = rewriter.Visit(oldNode);
Assert.Same(oldNode, newNode);
}
[Fact]
public void TestPropertyPatternTokenDeleteRewriter()
{
var oldNode = GeneratePropertyPattern();
var rewriter = new TokenDeleteRewriter();
var newNode = rewriter.Visit(oldNode);
if(!oldNode.IsMissing)
{
Assert.NotEqual(oldNode, newNode);
}
Assert.NotNull(newNode);
Assert.True(newNode.IsMissing, "No tokens => missing");
}
[Fact]
public void TestPropertyPatternIdentityRewriter()
{
var oldNode = GeneratePropertyPattern();
var rewriter = new IdentityRewriter();
var newNode = rewriter.Visit(oldNode);
Assert.Same(oldNode, newNode);
}
[Fact]
public void TestPropertySubpatternTokenDeleteRewriter()
{
var oldNode = GeneratePropertySubpattern();
var rewriter = new TokenDeleteRewriter();
var newNode = rewriter.Visit(oldNode);
if(!oldNode.IsMissing)
{
Assert.NotEqual(oldNode, newNode);
}
Assert.NotNull(newNode);
Assert.True(newNode.IsMissing, "No tokens => missing");
}
[Fact]
public void TestPropertySubpatternIdentityRewriter()
{
var oldNode = GeneratePropertySubpattern();
var rewriter = new IdentityRewriter();
var newNode = rewriter.Visit(oldNode);
Assert.Same(oldNode, newNode);
}
[Fact]
public void TestConstantPatternTokenDeleteRewriter()
{
......
......@@ -324,6 +324,8 @@ namespace My
break;
case int i:
break;
case Type (int x, 3) { A: 5, B: 7 } identifier:
break;
default:
{
return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册