Skip to content

Commit b07fa87

Browse files
author
Julien Couvreur
committed
Remove Validate from ParameterSyntax
1 parent 9864ab6 commit b07fa87

File tree

6 files changed

+5
-43
lines changed

6 files changed

+5
-43
lines changed

src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Syntax.Generated.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13766,7 +13766,6 @@ public sealed partial class ParameterSyntax : BaseParameterSyntax
1376613766
internal ParameterSyntax(InternalSyntax.CSharpSyntaxNode green, SyntaxNode? parent, int position)
1376713767
: base(green, parent, position)
1376813768
{
13769-
Validate();
1377013769
}
1377113770

1377213771
/// <summary>Gets the attribute declaration list.</summary>
@@ -13823,9 +13822,7 @@ public ParameterSyntax Update(SyntaxList<AttributeListSyntax> attributeLists, Sy
1382313822
{
1382413823
var newNode = SyntaxFactory.Parameter(attributeLists, modifiers, type, identifier, @default);
1382513824
var annotations = GetAnnotations();
13826-
var result = annotations?.Length > 0 ? newNode.WithAnnotations(annotations) : newNode;
13827-
result.Validate();
13828-
return result;
13825+
return annotations?.Length > 0 ? newNode.WithAnnotations(annotations) : newNode;
1382913826
}
1383013827

1383113828
return this;

src/Compilers/CSharp/Portable/Syntax/ParameterSyntax.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,5 @@ internal bool IsArgList
1313
return this.Type == null && this.Identifier.ContextualKind() == SyntaxKind.ArgListKeyword;
1414
}
1515
}
16-
17-
internal void Validate()
18-
{
19-
if (Type is null && Identifier.IsKind(SyntaxKind.None))
20-
{
21-
throw new System.NotSupportedException();
22-
}
23-
}
2416
}
2517
}

src/Compilers/CSharp/Portable/Syntax/Syntax.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4342,7 +4342,7 @@
43424342
</Field>
43434343
<Field Name="Type" Type="TypeSyntax" Optional="true"/>
43444344
</AbstractNode>
4345-
<Node Name="ParameterSyntax" Base="BaseParameterSyntax" SkipConvenienceFactories="true" HasValidate="true">
4345+
<Node Name="ParameterSyntax" Base="BaseParameterSyntax" SkipConvenienceFactories="true">
43464346
<TypeComment>
43474347
<summary>Parameter syntax.</summary>
43484348
</TypeComment>

src/Compilers/CSharp/Test/Emit3/Semantics/ExtensionTests2.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34440,9 +34440,8 @@ static class E
3444034440
var withoutIdentifer = parameter.WithIdentifier(default);
3444134441
Assert.Equal("int ", withoutIdentifer.ToFullString());
3444234442

34443-
// Type and identifier cannot both be missing
34444-
Assert.Throws<NotSupportedException>(() => SyntaxFactory.Parameter(identifier: default));
34445-
Assert.Throws<NotSupportedException>(() => withoutType.WithIdentifier(default));
34443+
Assert.Equal("", SyntaxFactory.Parameter(identifier: default).ToFullString());
34444+
Assert.Equal("", withoutType.WithIdentifier(default).ToFullString());
3444634445
}
3444734446

3444834447
[Fact]

src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/Model/TreeType.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ public class TreeType
2626
[XmlElement]
2727
public Comment FactoryComment;
2828

29-
[XmlAttribute]
30-
public string HasValidate;
31-
3229
[XmlElement(ElementName = "Field", Type = typeof(Field))]
3330
[XmlElement(ElementName = "Choice", Type = typeof(Choice))]
3431
[XmlElement(ElementName = "Sequence", Type = typeof(Sequence))]

src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/SourceWriter.cs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
using System;
88
using System.Collections.Generic;
9-
using System.Diagnostics;
109
using System.IO;
1110
using System.Linq;
1211
using System.Threading;
@@ -847,12 +846,6 @@ private void WriteRedType(TreeType node)
847846
WriteLine($"internal {node.Name}(InternalSyntax.CSharpSyntaxNode green, SyntaxNode? parent, int position)");
848847
WriteLine(" : base(green, parent, position)");
849848
OpenBlock();
850-
851-
if (HasValidate(node))
852-
{
853-
WriteLine("Validate();");
854-
}
855-
856849
CloseBlock();
857850
WriteLine();
858851

@@ -1026,11 +1019,6 @@ private void WriteRedType(TreeType node)
10261019
}
10271020
}
10281021

1029-
private bool HasValidate(TreeType node)
1030-
{
1031-
return node.HasValidate != null && string.Compare(node.HasValidate, "true", ignoreCase: true) == 0;
1032-
}
1033-
10341022
private string GetRedFieldType(Field field)
10351023
{
10361024
if (field.Type == "SyntaxList<SyntaxToken>")
@@ -1118,18 +1106,7 @@ private void WriteRedUpdateMethod(Node node)
11181106
node.Fields.Select(f => CamelCase(f.Name))));
11191107
WriteLine(");");
11201108
WriteLine("var annotations = GetAnnotations();");
1121-
1122-
if (HasValidate(node))
1123-
{
1124-
WriteLine("var result = annotations?.Length > 0 ? newNode.WithAnnotations(annotations) : newNode;");
1125-
WriteLine("result.Validate();");
1126-
WriteLine("return result;");
1127-
}
1128-
else
1129-
{
1130-
WriteLine("return annotations?.Length > 0 ? newNode.WithAnnotations(annotations) : newNode;");
1131-
}
1132-
1109+
WriteLine("return annotations?.Length > 0 ? newNode.WithAnnotations(annotations) : newNode;");
11331110
CloseBlock();
11341111
}
11351112

0 commit comments

Comments
 (0)