60 references to ConstraintClauses
Microsoft.CodeAnalysis.CSharp (19)
Symbols\Source\SourceOrdinaryMethodSymbol.cs (6)
82
ReportErrorIfHasConstraints(syntax.
ConstraintClauses
, diagnostics.DiagnosticBag);
165
if (syntax.
ConstraintClauses
.Count > 0)
168
syntax.
ConstraintClauses
[0].WhereKeyword, MessageID.IDS_OverrideWithConstraints, diagnostics);
171
BindTypeParameterConstraintClauses(this, TypeParameters, syntax.TypeParameterList, syntax.
ConstraintClauses
,
1088
syntax.
ConstraintClauses
,
1115
syntax.
ConstraintClauses
);
Syntax.xml.Main.Generated.cs (1)
2059
=> node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), (TypeSyntax?)Visit(node.ReturnType) ?? throw new ArgumentNullException("returnType"), (ExplicitInterfaceSpecifierSyntax?)Visit(node.ExplicitInterfaceSpecifier), VisitToken(node.Identifier), (TypeParameterListSyntax?)Visit(node.TypeParameterList), (ParameterListSyntax?)Visit(node.ParameterList) ?? throw new ArgumentNullException("parameterList"), VisitList(node.
ConstraintClauses
), (BlockSyntax?)Visit(node.Body), (ArrowExpressionClauseSyntax?)Visit(node.ExpressionBody), VisitToken(node.SemicolonToken));
Syntax.xml.Syntax.Generated.cs (12)
12366
if (attributeLists != this.AttributeLists || modifiers != this.Modifiers || returnType != this.ReturnType || explicitInterfaceSpecifier != this.ExplicitInterfaceSpecifier || identifier != this.Identifier || typeParameterList != this.TypeParameterList || parameterList != this.ParameterList || constraintClauses != this.
ConstraintClauses
|| body != this.Body || expressionBody != this.ExpressionBody || semicolonToken != this.SemicolonToken)
12377
public new MethodDeclarationSyntax WithAttributeLists(SyntaxList<AttributeListSyntax> attributeLists) => Update(attributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.Identifier, this.TypeParameterList, this.ParameterList, this.
ConstraintClauses
, this.Body, this.ExpressionBody, this.SemicolonToken);
12379
public new MethodDeclarationSyntax WithModifiers(SyntaxTokenList modifiers) => Update(this.AttributeLists, modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.Identifier, this.TypeParameterList, this.ParameterList, this.
ConstraintClauses
, this.Body, this.ExpressionBody, this.SemicolonToken);
12380
public MethodDeclarationSyntax WithReturnType(TypeSyntax returnType) => Update(this.AttributeLists, this.Modifiers, returnType, this.ExplicitInterfaceSpecifier, this.Identifier, this.TypeParameterList, this.ParameterList, this.
ConstraintClauses
, this.Body, this.ExpressionBody, this.SemicolonToken);
12381
public MethodDeclarationSyntax WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, explicitInterfaceSpecifier, this.Identifier, this.TypeParameterList, this.ParameterList, this.
ConstraintClauses
, this.Body, this.ExpressionBody, this.SemicolonToken);
12382
public MethodDeclarationSyntax WithIdentifier(SyntaxToken identifier) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, identifier, this.TypeParameterList, this.ParameterList, this.
ConstraintClauses
, this.Body, this.ExpressionBody, this.SemicolonToken);
12383
public MethodDeclarationSyntax WithTypeParameterList(TypeParameterListSyntax? typeParameterList) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.Identifier, typeParameterList, this.ParameterList, this.
ConstraintClauses
, this.Body, this.ExpressionBody, this.SemicolonToken);
12385
public new MethodDeclarationSyntax WithParameterList(ParameterListSyntax parameterList) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.Identifier, this.TypeParameterList, parameterList, this.
ConstraintClauses
, this.Body, this.ExpressionBody, this.SemicolonToken);
12388
public new MethodDeclarationSyntax WithBody(BlockSyntax? body) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.Identifier, this.TypeParameterList, this.ParameterList, this.
ConstraintClauses
, body, this.ExpressionBody, this.SemicolonToken);
12390
public new MethodDeclarationSyntax WithExpressionBody(ArrowExpressionClauseSyntax? expressionBody) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.Identifier, this.TypeParameterList, this.ParameterList, this.
ConstraintClauses
, this.Body, expressionBody, this.SemicolonToken);
12392
public new MethodDeclarationSyntax WithSemicolonToken(SyntaxToken semicolonToken) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.Identifier, this.TypeParameterList, this.ParameterList, this.
ConstraintClauses
, this.Body, this.ExpressionBody, semicolonToken);
12405
public MethodDeclarationSyntax AddConstraintClauses(params TypeParameterConstraintClauseSyntax[] items) => WithConstraintClauses(this.
ConstraintClauses
.AddRange(items));
Microsoft.CodeAnalysis.CSharp.Features (5)
ConvertProgram\ConvertProgramTransform_TopLevelStatements.cs (1)
244
constraintClauses: otherMethod.
ConstraintClauses
,
ConvertToExtension\ConvertToExtensionCodeRefactoringProvider.cs (3)
346
if (extensionMethod.
ConstraintClauses
.Count == 0 || movedTypeParameterCount == 0)
347
return extensionMethod.
ConstraintClauses
;
350
return [.. extensionMethod.
ConstraintClauses
.Where(
Organizing\Organizers\MethodDeclarationOrganizer.cs (1)
37
constraintClauses: syntax.
ConstraintClauses
,
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (6)
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (6)
1489
symbol = LookupTypeParameterFromConstraintClause(model, methodDecl.
ConstraintClauses
[0], "T");
1497
symbol = LookupTypeParameterFromConstraintClause(model, methodDecl.
ConstraintClauses
[0], "U");
1538
symbol = LookupTypeParameterFromConstraintClause(model, methodDecl.
ConstraintClauses
[0], "U1");
1540
symbol = LookupTypeParameterFromConstraintClause(model, methodDecl.
ConstraintClauses
[0], "U2");
1550
symbol = LookupTypeParameterFromConstraintClause(model, methodDecl.
ConstraintClauses
[0], "U4");
1552
symbol = LookupTypeParameterFromConstraintClause(model, methodDecl.
ConstraintClauses
[0], "U3");
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (25)
Generated\Syntax.Test.xml.Generated.cs (2)
13432
Assert.Equal(default, node.
ConstraintClauses
);
13436
var newNode = node.WithAttributeLists(node.AttributeLists).WithModifiers(node.Modifiers).WithReturnType(node.ReturnType).WithExplicitInterfaceSpecifier(node.ExplicitInterfaceSpecifier).WithIdentifier(node.Identifier).WithTypeParameterList(node.TypeParameterList).WithParameterList(node.ParameterList).WithConstraintClauses(node.
ConstraintClauses
).WithBody(node.Body).WithExpressionBody(node.ExpressionBody).WithSemicolonToken(node.SemicolonToken);
Parsing\DeclarationParsingTests.cs (23)
2511
Assert.Equal(0, ms.
ConstraintClauses
.Count);
2556
Assert.Equal(0, ms.
ConstraintClauses
.Count);
2602
Assert.Equal(0, ms.
ConstraintClauses
.Count);
2710
Assert.Equal(0, ms.
ConstraintClauses
.Count);
2775
Assert.Equal(0, ms.
ConstraintClauses
.Count);
2822
Assert.Equal(0, ms.
ConstraintClauses
.Count);
2872
Assert.Equal(0, ms.
ConstraintClauses
.Count);
3026
Assert.Equal(0, ms.
ConstraintClauses
.Count);
3088
Assert.Equal(0, ms.
ConstraintClauses
.Count);
3143
Assert.Equal(0, ms.
ConstraintClauses
.Count);
3206
Assert.Equal(0, ms.
ConstraintClauses
.Count);
3272
Assert.Equal(0, ms.
ConstraintClauses
.Count);
3343
Assert.Equal(0, ms.
ConstraintClauses
.Count);
3389
Assert.Equal(0, ms.
ConstraintClauses
.Count);
3438
Assert.Equal(1, ms.
ConstraintClauses
.Count);
3439
Assert.NotEqual(default, ms.
ConstraintClauses
[0].WhereKeyword);
3440
Assert.NotNull(ms.
ConstraintClauses
[0].Name);
3441
Assert.Equal("b", ms.
ConstraintClauses
[0].Name.ToString());
3442
Assert.NotEqual(default, ms.
ConstraintClauses
[0].ColonToken);
3443
Assert.False(ms.
ConstraintClauses
[0].ColonToken.IsMissing);
3444
Assert.Equal(1, ms.
ConstraintClauses
[0].Constraints.Count);
3445
Assert.Equal(SyntaxKind.TypeConstraint, ms.
ConstraintClauses
[0].Constraints[0].Kind());
3446
var typeBound = (TypeConstraintSyntax)ms.
ConstraintClauses
[0].Constraints[0];
Microsoft.CodeAnalysis.CSharp.Workspaces (5)
CodeGeneration\CSharpSyntaxGenerator.cs (5)
621
if (method.
ConstraintClauses
.Count > 0)
623
return RemoveNodes(method, method.
ConstraintClauses
);
1797
if (method.
ConstraintClauses
.Count == 0)
1802
method.ParameterList.GetTrailingTrivia().Add(SyntaxFactory.ElasticMarker).AddRange(method.
ConstraintClauses
.Last().GetTrailingTrivia())));
1827
MethodDeclarationSyntax method => method.WithConstraintClauses(WithTypeConstraints(method.
ConstraintClauses
, typeParameterName, kinds, isUnmanagedType, types)),