345 references to ConstructorDeclarationSyntax
Microsoft.CodeAnalysis.CSharp (47)
Binder\Binder.CapturedParametersFinder.cs (1)
119
case
ConstructorDeclarationSyntax
s:
Binder\Binder_Statements.cs (5)
3549
ConstructorDeclarationSyntax
or DestructorDeclarationSyntax => MessageID.IDS_FeatureExpressionBodiedDeOrConstructor,
3629
return BindConstructorBody((
ConstructorDeclarationSyntax
)method, diagnostics);
3712
private BoundNode BindConstructorBody(
ConstructorDeclarationSyntax
constructor, BindingDiagnosticBag diagnostics)
3818
|| ((
ConstructorDeclarationSyntax
?)sourceConstructor?.SyntaxNode)?.Initializer == null);
3888
case
ConstructorDeclarationSyntax
ctorDecl:
Binder\BinderFactory.BinderFactoryVisitor.cs (1)
196
public override Binder VisitConstructorDeclaration(
ConstructorDeclarationSyntax
parent)
Binder\ExpressionVariableFinder.cs (1)
457
public override void VisitConstructorDeclaration(
ConstructorDeclarationSyntax
node)
Binder\LocalBinderFactory.cs (1)
154
public override void VisitConstructorDeclaration(
ConstructorDeclarationSyntax
node)
Compilation\SyntaxTreeSemanticModel.cs (6)
175
case
ConstructorDeclarationSyntax
constructor:
797
var
constructorDecl = (
ConstructorDeclarationSyntax
)memberDecl;
864
ConstructorDeclarationSyntax
constructorDecl = (
ConstructorDeclarationSyntax
)memberDecl;
1671
if (((
ConstructorDeclarationSyntax
)declaration).Modifiers.Any(SyntaxKind.StaticKeyword))
Compiler\MethodCompiler.cs (2)
1761
syntaxNode is
ConstructorDeclarationSyntax
constructorSyntax &&
2001
case
ConstructorDeclarationSyntax
s:
FlowAnalysis\FlowAnalysisPass.cs (1)
59
Debug.Assert(method is not SourceMemberMethodSymbol { SyntaxNode:
ConstructorDeclarationSyntax
{ Initializer: not null } } || block.HasErrors);
FlowAnalysis\NullableWalker.cs (1)
872
if (method is SourceMemberMethodSymbol { SyntaxNode:
ConstructorDeclarationSyntax
{ Initializer: { RawKind: var initializerKind } } })
Lowering\Instrumentation\CodeCoverageInstrumenter.cs (2)
612
ConstructorDeclarationSyntax
constructorSyntax = (
ConstructorDeclarationSyntax
)syntax;
Lowering\Instrumentation\DebugInfoInjector.cs (1)
63
case
ConstructorDeclarationSyntax
ctorDecl:
Parser\LanguageParser.cs (2)
3284
private
ConstructorDeclarationSyntax
ParseConstructorDeclaration(
5081
return ((CSharp.Syntax.
ConstructorDeclarationSyntax
)decl).Modifiers;
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (2)
282
if (t is
ConstructorDeclarationSyntax
ctorDecl && ctorDecl.Initializer != null)
404
arrowExpr = ((
ConstructorDeclarationSyntax
)node).ExpressionBody;
Symbols\MemberSymbolExtensions.cs (2)
380
ConstructorDeclarationSyntax
constructorSyntax = sourceMethod.SyntaxNode as
ConstructorDeclarationSyntax
;
Symbols\Source\SourceConstructorSymbol.cs (8)
17
ConstructorDeclarationSyntax
syntax,
28
ConstructorDeclarationSyntax
syntax,
82
ConstructorDeclarationSyntax
syntax,
101
internal
ConstructorDeclarationSyntax
GetSyntax()
104
return (
ConstructorDeclarationSyntax
)syntaxReferenceOpt.GetSyntax();
123
NamedTypeSymbol containingType,
ConstructorDeclarationSyntax
syntax, MethodKind methodKind, bool hasBody, Location location, BindingDiagnosticBag diagnostics,
183
return OneOrMany.Create(((
ConstructorDeclarationSyntax
)this.SyntaxNode).AttributeLists);
201
ConstructorDeclarationSyntax
ctorSyntax = GetSyntax();
Symbols\Source\SourceConstructorSymbolBase.cs (1)
65
ContainingType.Name == ((
ConstructorDeclarationSyntax
)this.SyntaxNode).Identifier.ValueText)
Symbols\Source\SourceMemberContainerSymbol.cs (3)
2145
((
ConstructorDeclarationSyntax
)method1.SyntaxRef.GetSyntax()).Identifier.ValueText != this.Name)
4978
var
constructorSyntax = (
ConstructorDeclarationSyntax
)m;
Symbols\Source\SourceMethodSymbolWithAttributes.cs (1)
47
case
ConstructorDeclarationSyntax
constructor:
Syntax\ConstructorDeclarationSyntax.cs (5)
13
public
ConstructorDeclarationSyntax
Update(
37
public static
ConstructorDeclarationSyntax
ConstructorDeclaration(
54
public static
ConstructorDeclarationSyntax
ConstructorDeclaration(
72
public static
ConstructorDeclarationSyntax
ConstructorDeclaration(
89
public static
ConstructorDeclarationSyntax
ConstructorDeclaration(
Syntax\LookupPosition.cs (1)
177
internal static bool IsInConstructorParameterScope(int position,
ConstructorDeclarationSyntax
constructorDecl)
Microsoft.CodeAnalysis.CSharp.CodeStyle (29)
src\Analyzers\CSharp\Analyzers\UseAutoProperty\CSharpUseAutoPropertyAnalyzer.cs (1)
24
ConstructorDeclarationSyntax
,
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyForConstructorsHelper.cs (11)
15
UseExpressionBodyHelper<
ConstructorDeclarationSyntax
>
32
protected override BlockSyntax? GetBody(
ConstructorDeclarationSyntax
declaration)
35
protected override ArrowExpressionClauseSyntax? GetExpressionBody(
ConstructorDeclarationSyntax
declaration)
38
protected override SyntaxToken GetSemicolonToken(
ConstructorDeclarationSyntax
declaration)
41
protected override
ConstructorDeclarationSyntax
WithSemicolonToken(
ConstructorDeclarationSyntax
declaration, SyntaxToken token)
44
protected override
ConstructorDeclarationSyntax
WithExpressionBody(
ConstructorDeclarationSyntax
declaration, ArrowExpressionClauseSyntax? expressionBody)
47
protected override
ConstructorDeclarationSyntax
WithBody(
ConstructorDeclarationSyntax
declaration, BlockSyntax? body)
50
protected override bool CreateReturnStatementForExpression(SemanticModel semanticModel,
ConstructorDeclarationSyntax
declaration) => false;
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyHelper`1.cs (1)
203
if (declaration is AccessorDeclarationSyntax or
ConstructorDeclarationSyntax
)
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (6)
143
ConstructorDeclarationSyntax
primaryConstructorDeclaration,
151
private readonly
ConstructorDeclarationSyntax
_primaryConstructorDeclaration = primaryConstructorDeclaration;
288
if (!TryFindPrimaryConstructorCandidate(namedType, out var primaryConstructor, out
var
primaryConstructorDeclaration))
342
[NotNullWhen(true)] out
ConstructorDeclarationSyntax
? primaryConstructorDeclaration)
360
if (constructorReference.GetSyntax(cancellationToken) is not
ConstructorDeclarationSyntax
constructorDeclaration)
386
ConstructorDeclarationSyntax
primaryConstructorDeclaration,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberDeclarationSyntaxExtensions.cs (2)
54
return ((
ConstructorDeclarationSyntax
)member).Identifier;
125
return ((
ConstructorDeclarationSyntax
)member).WithParameterList((ParameterListSyntax)parameterList);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
462
public static IMethodSymbol GetRequiredDeclaredSymbol(this SemanticModel semanticModel,
ConstructorDeclarationSyntax
syntax, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (2)
133
var
constructorDeclarationNode = constructorInitializerNode.Parent as
ConstructorDeclarationSyntax
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (1)
55
return ignoreDeclarationModifiers || !((
ConstructorDeclarationSyntax
)declaration).Modifiers.Any(SyntaxKind.StaticKeyword);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (3)
615
=> node.GetAncestor<
ConstructorDeclarationSyntax
>() != null;
977
case
ConstructorDeclarationSyntax
constructor:
1087
case
ConstructorDeclarationSyntax
constructor:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
126
ConstructorDeclarationSyntax
or
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (26)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (5)
140
foreach (
var
constructor in typeDeclaration.Members.OfType<
ConstructorDeclarationSyntax
>())
188
var
modifiedConstructor = constructor
333
(
ConstructorDeclarationSyntax
? constructor, ImmutableArray<IPropertySymbol> propertiesToAssign) TryFindPrimaryConstructor()
340
if (member is not
ConstructorDeclarationSyntax
constructor)
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\CSharpGenerateConstructorService.cs (2)
186
=> token.GetAncestor<
ConstructorDeclarationSyntax
>() is { } constructor ? semanticModel.GetDeclaredSymbol(constructor, cancellationToken) : null;
190
if (constructor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) is
ConstructorDeclarationSyntax
constructorDeclarationSyntax &&
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (4)
56
if (diagnostic.Location.FindNode(cancellationToken) is not
ConstructorDeclarationSyntax
constructorDeclaration)
90
ConstructorDeclarationSyntax
constructorDeclaration,
106
ConstructorDeclarationSyntax
constructorDeclaration,
299
ConstructorDeclarationSyntax
constructorDeclaration,
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider_DocComments.cs (2)
66
ConstructorDeclarationSyntax
constructorDeclaration,
101
ConstructorDeclarationSyntax
constructorDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ConstructorGenerator.cs (7)
33
var
constructorDeclaration = GenerateConstructorDeclaration(constructor, info, cancellationToken);
43
internal static
ConstructorDeclarationSyntax
GenerateConstructorDeclaration(
48
var
reusableSyntax = GetReuseableSyntaxNodeForSymbol<
ConstructorDeclarationSyntax
>(constructor, info);
56
var
declaration = ConstructorDeclaration(
71
private static
ConstructorDeclarationSyntax
UseExpressionBodyIfDesired(
72
CSharpCodeGenerationContextInfo info,
ConstructorDeclarationSyntax
declaration, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
161
=> members.LastOrDefault(m => m is
ConstructorDeclarationSyntax
);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpDeclarationComparer.cs (4)
111
return Compare((
ConstructorDeclarationSyntax
)x, (
ConstructorDeclarationSyntax
)y);
188
private static int Compare(
ConstructorDeclarationSyntax
x,
ConstructorDeclarationSyntax
y)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
1130
MethodDeclarationSyntax or LocalFunctionStatementSyntax or
ConstructorDeclarationSyntax
or DelegateDeclarationSyntax or TypeDeclarationSyntax => true,
Microsoft.CodeAnalysis.CSharp.EditorFeatures (1)
GoToBase\CSharpGoToBaseService.cs (1)
29
if (constructor.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax(cancellationToken) is not
ConstructorDeclarationSyntax
constructorDeclaration)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (3)
Structure\ConstructorDeclarationStructureTests.cs (1)
16
public class ConstructorDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<
ConstructorDeclarationSyntax
>
Structure\MetadataAsSource\ConstructorDeclarationStructureTests.cs (1)
14
public class ConstructorDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<
ConstructorDeclarationSyntax
>
SymbolKey\SymbolKeyTestBase.cs (1)
321
if (node is
ConstructorDeclarationSyntax
ctor && ctor.Initializer != null)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (15)
Diagnostics\GetDiagnosticsTests.cs (1)
1030
ConstructorDeclarationSyntax
constructorDecl => constructorDecl.Identifier.GetLocation(),
OverloadResolutionPriorityTests.cs (2)
978
var
secondCtor = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Skip(ctorToForce).First();
Semantics\OutVarTests.cs (4)
18814
var
constructorDeclaration = (
ConstructorDeclarationSyntax
)context.Node.Parent;
36001
var
declarationSyntax = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().First();
Semantics\PrimaryConstructorTests.cs (5)
4851
case
ConstructorDeclarationSyntax
{ Identifier: { ValueText: "C" } }:
4996
case
ConstructorDeclarationSyntax
{ Identifier: { ValueText: "C" } }:
5064
case
ConstructorDeclarationSyntax
{ Identifier: { ValueText: "C" } }:
5962
case
ConstructorDeclarationSyntax
{ Identifier: { ValueText: "A" } }:
6020
case
ConstructorDeclarationSyntax
{ Identifier: { ValueText: "A" } }:
Semantics\RecordTests.cs (3)
27314
case
ConstructorDeclarationSyntax
{ Identifier: { ValueText: "C" } }:
27459
case
ConstructorDeclarationSyntax
{ Identifier: { ValueText: "C" } }:
27527
case
ConstructorDeclarationSyntax
{ Identifier: { ValueText: "C" } }:
Microsoft.CodeAnalysis.CSharp.Features (84)
ChangeSignature\CSharpChangeSignatureService.cs (1)
336
if (updatedNode is
ConstructorDeclarationSyntax
constructor)
CodeLens\CSharpCodeLensMemberFinder.cs (1)
77
public override void VisitConstructorDeclaration(
ConstructorDeclarationSyntax
node)
Completion\CompletionProviders\DeclarationName\DeclarationNameRecommender.cs (1)
322
ConstructorDeclarationSyntax
constructor => namedType.GetMembers(WellKnownMemberNames.InstanceConstructorName).OfType<IMethodSymbol>().ToImmutableArray(),
Completion\KeywordRecommenders\BaseKeywordRecommender.cs (1)
56
var constructor = token.GetRequiredAncestor<
ConstructorDeclarationSyntax
>();
Completion\KeywordRecommenders\ThisKeywordRecommender.cs (1)
49
var constructor = token.GetRequiredAncestor<
ConstructorDeclarationSyntax
>();
ConvertPrimaryToRegularConstructor\ConvertPrimaryToRegularConstructorCodeRefactoringProvider.cs (7)
314
var
constructorDeclaration = CreateConstructorDeclaration().WithAdditionalAnnotations(constructorAnnotation);
317
var firstConstructorIndex = currentTypeDeclaration.Members.IndexOf(m => m is
ConstructorDeclarationSyntax
c && !c.Modifiers.Any(SyntaxKind.StaticKeyword));
386
var
constructor = (
ConstructorDeclarationSyntax
)formattedRoot.GetAnnotatedNodes(constructorAnnotation).Single();
392
var
rewrittenConstructor = constructor
402
ConstructorDeclarationSyntax
constructorDeclaration,
438
ConstructorDeclarationSyntax
CreateConstructorDeclaration()
ConvertPrimaryToRegularConstructor\ConvertPrimaryToRegularConstructorCodeRefactoringProvider_DocumentationComments.cs (2)
109
private static
ConstructorDeclarationSyntax
WithTypeDeclarationParamDocComments(TypeDeclarationSyntax typeDeclaration,
ConstructorDeclarationSyntax
constructor)
EditAndContinue\BreakpointSpans.cs (4)
181
return CreateSpanForConstructorDeclaration((
ConstructorDeclarationSyntax
)node, position);
439
internal static TextSpan? CreateSpanForConstructorDeclaration(
ConstructorDeclarationSyntax
constructorSyntax, int position)
471
internal static TextSpan CreateSpanForImplicitConstructorInitializer(
ConstructorDeclarationSyntax
constructor)
474
internal static IEnumerable<SyntaxToken> GetActiveTokensForImplicitConstructorInitializer(
ConstructorDeclarationSyntax
constructor)
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (6)
395
ConstructorDeclarationSyntax
ctor => ctor,
977
var ctorInitializer = ((
ConstructorDeclarationSyntax
)symbol.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken)).Initializer;
1694
var
constructorDeclaration = (
ConstructorDeclarationSyntax
)node;
2067
var
ctor = (
ConstructorDeclarationSyntax
)node;
EditAndContinue\DeclarationBody\OrdinaryInstanceConstructorDeclarationBody.cs (2)
10
internal abstract class OrdinaryInstanceConstructorDeclarationBody(
ConstructorDeclarationSyntax
constructor)
13
public
ConstructorDeclarationSyntax
Constructor
EditAndContinue\DeclarationBody\OrdinaryInstanceConstructorWithExplicitInitializerDeclarationBody.cs (1)
14
internal sealed class OrdinaryInstanceConstructorWithExplicitInitializerDeclarationBody(
ConstructorDeclarationSyntax
constructor)
EditAndContinue\DeclarationBody\OrdinaryInstanceConstructorWithImplicitInitializerDeclarationBody.cs (1)
14
internal sealed class OrdinaryInstanceConstructorWithImplicitInitializerDeclarationBody(
ConstructorDeclarationSyntax
constructor)
EditAndContinue\SyntaxComparer.cs (1)
1456
return ((
ConstructorDeclarationSyntax
)node).Identifier;
EditAndContinue\SyntaxUtilities.cs (2)
45
ConstructorDeclarationSyntax
constructorDeclaration when constructorDeclaration.Body != null || constructorDeclaration.ExpressionBody != null
183
if (declaration is not
ConstructorDeclarationSyntax
ctor)
EncapsulateField\CSharpEncapsulateFieldService.cs (3)
34
internal sealed class CSharpEncapsulateFieldService() : AbstractEncapsulateFieldService<
ConstructorDeclarationSyntax
>
202
protected override IEnumerable<
ConstructorDeclarationSyntax
> GetConstructorNodes(INamedTypeSymbol containingType)
204
c => c.DeclaringSyntaxReferences.Select(d => d.GetSyntax()).OfType<
ConstructorDeclarationSyntax
>());
ExtractMethod\CSharpMethodExtractor.Analyzer.cs (1)
57
var scope = SelectionResult.GetContainingScopeOf<
ConstructorDeclarationSyntax
>();
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (1)
365
public override SyntaxNode VisitConstructorDeclaration(
ConstructorDeclarationSyntax
node)
ExtractMethod\CSharpSelectionResult.cs (1)
118
container is
ConstructorDeclarationSyntax
||
LineSeparators\CSharpLineSeparatorService.cs (1)
162
if (node is
ConstructorDeclarationSyntax
constructorDecl)
Organizing\Organizers\ConstructorDeclarationOrganizer.cs (3)
17
internal class ConstructorDeclarationOrganizer : AbstractSyntaxNodeOrganizer<
ConstructorDeclarationSyntax
>
25
protected override
ConstructorDeclarationSyntax
Organize(
26
ConstructorDeclarationSyntax
syntax,
Snippets\CSharpConstructorSnippetProvider.cs (3)
28
internal sealed class CSharpConstructorSnippetProvider() : AbstractConstructorSnippetProvider<
ConstructorDeclarationSyntax
>
78
protected override int GetTargetCaretPosition(
ConstructorDeclarationSyntax
constructorDeclaration, SourceText sourceText)
84
protected override Task<Document> AddIndentationToDocumentAsync(Document document,
ConstructorDeclarationSyntax
constructorDeclaration, CancellationToken cancellationToken)
src\Analyzers\CSharp\Analyzers\UseAutoProperty\CSharpUseAutoPropertyAnalyzer.cs (1)
24
ConstructorDeclarationSyntax
,
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyForConstructorsHelper.cs (11)
15
UseExpressionBodyHelper<
ConstructorDeclarationSyntax
>
32
protected override BlockSyntax? GetBody(
ConstructorDeclarationSyntax
declaration)
35
protected override ArrowExpressionClauseSyntax? GetExpressionBody(
ConstructorDeclarationSyntax
declaration)
38
protected override SyntaxToken GetSemicolonToken(
ConstructorDeclarationSyntax
declaration)
41
protected override
ConstructorDeclarationSyntax
WithSemicolonToken(
ConstructorDeclarationSyntax
declaration, SyntaxToken token)
44
protected override
ConstructorDeclarationSyntax
WithExpressionBody(
ConstructorDeclarationSyntax
declaration, ArrowExpressionClauseSyntax? expressionBody)
47
protected override
ConstructorDeclarationSyntax
WithBody(
ConstructorDeclarationSyntax
declaration, BlockSyntax? body)
50
protected override bool CreateReturnStatementForExpression(SemanticModel semanticModel,
ConstructorDeclarationSyntax
declaration) => false;
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyHelper`1.cs (1)
203
if (declaration is AccessorDeclarationSyntax or
ConstructorDeclarationSyntax
)
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (6)
143
ConstructorDeclarationSyntax
primaryConstructorDeclaration,
151
private readonly
ConstructorDeclarationSyntax
_primaryConstructorDeclaration = primaryConstructorDeclaration;
288
if (!TryFindPrimaryConstructorCandidate(namedType, out var primaryConstructor, out
var
primaryConstructorDeclaration))
342
[NotNullWhen(true)] out
ConstructorDeclarationSyntax
? primaryConstructorDeclaration)
360
if (constructorReference.GetSyntax(cancellationToken) is not
ConstructorDeclarationSyntax
constructorDeclaration)
386
ConstructorDeclarationSyntax
primaryConstructorDeclaration,
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (5)
140
foreach (
var
constructor in typeDeclaration.Members.OfType<
ConstructorDeclarationSyntax
>())
188
var
modifiedConstructor = constructor
333
(
ConstructorDeclarationSyntax
? constructor, ImmutableArray<IPropertySymbol> propertiesToAssign) TryFindPrimaryConstructor()
340
if (member is not
ConstructorDeclarationSyntax
constructor)
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\CSharpGenerateConstructorService.cs (2)
186
=> token.GetAncestor<
ConstructorDeclarationSyntax
>() is { } constructor ? semanticModel.GetDeclaredSymbol(constructor, cancellationToken) : null;
190
if (constructor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) is
ConstructorDeclarationSyntax
constructorDeclarationSyntax &&
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (4)
56
if (diagnostic.Location.FindNode(cancellationToken) is not
ConstructorDeclarationSyntax
constructorDeclaration)
90
ConstructorDeclarationSyntax
constructorDeclaration,
106
ConstructorDeclarationSyntax
constructorDeclaration,
299
ConstructorDeclarationSyntax
constructorDeclaration,
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider_DocComments.cs (2)
66
ConstructorDeclarationSyntax
constructorDeclaration,
101
ConstructorDeclarationSyntax
constructorDeclaration)
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorFixAllProvider.cs (1)
51
if (diagnostic.Location.FindNode(cancellationToken) is not
ConstructorDeclarationSyntax
constructorDeclaration)
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (2)
282
if (t is
ConstructorDeclarationSyntax
ctorDecl && ctorDecl.Initializer != null)
404
arrowExpr = ((
ConstructorDeclarationSyntax
)node).ExpressionBody;
Structure\CSharpBlockStructureProvider.cs (1)
26
builder.Add<
ConstructorDeclarationSyntax
, ConstructorDeclarationStructureProvider>();
Structure\CSharpStructureHelpers.cs (1)
270
ConstructorDeclarationSyntax
constructorDeclaration => constructorDeclaration.Modifiers.FirstOrNull() ?? constructorDeclaration.Identifier,
Structure\Providers\ConstructorDeclarationStructureProvider.cs (2)
12
internal class ConstructorDeclarationStructureProvider : AbstractSyntaxNodeStructureProvider<
ConstructorDeclarationSyntax
>
16
ConstructorDeclarationSyntax
constructorDeclaration,
UseAutoProperty\CSharpUseAutoPropertyCodeFixProvider.cs (1)
39
ConstructorDeclarationSyntax
,
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (7)
EditAndContinue\BreakpointSpansTests.cs (7)
262
VerifyAllSpansInDeclaration<
ConstructorDeclarationSyntax
>(@"
4273
VerifyAllSpansInDeclaration<
ConstructorDeclarationSyntax
>(
4306
VerifyAllSpansInDeclaration<
ConstructorDeclarationSyntax
>(
4552
VerifyAllSpansInDeclaration<
ConstructorDeclarationSyntax
>(
4576
VerifyAllSpansInDeclaration<
ConstructorDeclarationSyntax
>(
4648
VerifyAllSpansInDeclaration<
ConstructorDeclarationSyntax
>(
4670
VerifyAllSpansInDeclaration<
ConstructorDeclarationSyntax
>(
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (38)
IOperation\IOperationTests_IConstructorBodyOperation.cs (38)
40
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
67
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
123
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
189
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
257
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
323
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
398
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
487
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
514
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
589
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
651
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().First();
721
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().First();
796
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().First();
865
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().First();
955
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().First();
1072
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
1092
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
1125
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
1163
var
node1 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Skip(1).Single();
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (12)
Semantics\ExpressionBodiedMemberTests.cs (2)
540
Assert.Contains("P1", model.LookupNames(tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single().Body.Position));
542
var node2 = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single()
Semantics\RecordStructTests.cs (2)
6688
case
ConstructorDeclarationSyntax
{ Identifier: { ValueText: "A" } }:
6746
case
ConstructorDeclarationSyntax
{ Identifier: { ValueText: "A" } }:
Semantics\RefFieldTests.cs (2)
28874
var
constructorSyntax = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
Semantics\StructConstructorTests.cs (6)
1050
var
syntax = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().First();
1145
var
syntax = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().First();
1242
var
syntax = tree.GetRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().First();
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (16)
Compilation\SemanticModelAPITests.cs (14)
1390
var
oldSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
1588
var
constructorDecl = (
ConstructorDeclarationSyntax
)typeDecl.Members[0];
2141
var
oldSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
ConstructorDeclarationSyntax
>().Single();
2170
var
ctor1 = (
ConstructorDeclarationSyntax
)typeDecl.Members[0];
2171
var
ctor2 = (
ConstructorDeclarationSyntax
)typeDecl.Members[1];
2215
var
ctor1 = (
ConstructorDeclarationSyntax
)typeDecl.Members[0];
2216
var
ctor2 = (
ConstructorDeclarationSyntax
)typeDecl.Members[1];
Symbols\Source\NullablePublicAPITests.cs (2)
4902
var
ctorDecl = tree.GetRoot()
4904
.OfType<
ConstructorDeclarationSyntax
>()
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (12)
Generated\Syntax.Test.xml.Generated.cs (5)
10787
private static
ConstructorDeclarationSyntax
GenerateConstructorDeclaration()
13321
var
node = GenerateConstructorDeclaration();
13331
var
newNode = node.WithAttributeLists(node.AttributeLists).WithModifiers(node.Modifiers).WithIdentifier(node.Identifier).WithParameterList(node.ParameterList).WithInitializer(node.Initializer).WithBody(node.Body).WithExpressionBody(node.ExpressionBody).WithSemicolonToken(node.SemicolonToken);
18935
var
oldNode = GenerateConstructorDeclaration();
18951
var
oldNode = GenerateConstructorDeclaration();
IncrementalParsing\TypeChanges.cs (3)
48
Assert.IsType<
ConstructorDeclarationSyntax
>(classType.Members[0]);
63
Assert.IsType<
ConstructorDeclarationSyntax
>(classType.Members[0]);
78
Assert.IsType<
ConstructorDeclarationSyntax
>(classType.Members[0]);
Parsing\DeclarationParsingTests.cs (4)
3505
var
cn = (
ConstructorDeclarationSyntax
)cs.Members[0];
3540
var
cn = (
ConstructorDeclarationSyntax
)cs.Members[0];
Microsoft.CodeAnalysis.CSharp.Workspaces (33)
Classification\ClassificationHelpers.cs (1)
210
else if (token.Parent is
ConstructorDeclarationSyntax
constructorDeclaration && constructorDeclaration.Identifier == token)
CodeGeneration\CSharpSyntaxGenerator.cs (4)
738
node = ((
ConstructorDeclarationSyntax
)node).WithIdentifier(className.ToIdentifierToken());
2239
return ((
ConstructorDeclarationSyntax
)declaration).WithParameterList(list);
2485
SyntaxKind.ConstructorDeclaration => ((
ConstructorDeclarationSyntax
)declaration).Body?.Statements,
2515
return ((
ConstructorDeclarationSyntax
)declaration).WithBody(somebody).WithSemicolonToken(semicolon).WithExpressionBody(null);
FindSymbols\CSharpDeclaredSymbolInfoFactoryService.cs (3)
278
var
ctorDecl = (
ConstructorDeclarationSyntax
)node;
491
private static string GetConstructorSuffix(
ConstructorDeclarationSyntax
constructor)
Simplification\Simplifiers\ExpressionSimplifier.cs (2)
393
var
constructor = memberAccess.Ancestors().OfType<
ConstructorDeclarationSyntax
>().SingleOrDefault();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberDeclarationSyntaxExtensions.cs (2)
54
return ((
ConstructorDeclarationSyntax
)member).Identifier;
125
return ((
ConstructorDeclarationSyntax
)member).WithParameterList((ParameterListSyntax)parameterList);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
462
public static IMethodSymbol GetRequiredDeclaredSymbol(this SemanticModel semanticModel,
ConstructorDeclarationSyntax
syntax, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (2)
133
var
constructorDeclarationNode = constructorInitializerNode.Parent as
ConstructorDeclarationSyntax
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (1)
55
return ignoreDeclarationModifiers || !((
ConstructorDeclarationSyntax
)declaration).Modifiers.Any(SyntaxKind.StaticKeyword);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (3)
615
=> node.GetAncestor<
ConstructorDeclarationSyntax
>() != null;
977
case
ConstructorDeclarationSyntax
constructor:
1087
case
ConstructorDeclarationSyntax
constructor:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
126
ConstructorDeclarationSyntax
or
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ConstructorGenerator.cs (7)
33
var
constructorDeclaration = GenerateConstructorDeclaration(constructor, info, cancellationToken);
43
internal static
ConstructorDeclarationSyntax
GenerateConstructorDeclaration(
48
var
reusableSyntax = GetReuseableSyntaxNodeForSymbol<
ConstructorDeclarationSyntax
>(constructor, info);
56
var
declaration = ConstructorDeclaration(
71
private static
ConstructorDeclarationSyntax
UseExpressionBodyIfDesired(
72
CSharpCodeGenerationContextInfo info,
ConstructorDeclarationSyntax
declaration, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
161
=> members.LastOrDefault(m => m is
ConstructorDeclarationSyntax
);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpDeclarationComparer.cs (4)
111
return Compare((
ConstructorDeclarationSyntax
)x, (
ConstructorDeclarationSyntax
)y);
188
private static int Compare(
ConstructorDeclarationSyntax
x,
ConstructorDeclarationSyntax
y)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
1130
MethodDeclarationSyntax or LocalFunctionStatementSyntax or
ConstructorDeclarationSyntax
or DelegateDeclarationSyntax or TypeDeclarationSyntax => true,
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (10)
CodeGeneration\SyntaxGeneratorTests.cs (10)
1007
VerifySyntax<
ConstructorDeclarationSyntax
>(
1011
VerifySyntax<
ConstructorDeclarationSyntax
>(
1015
VerifySyntax<
ConstructorDeclarationSyntax
>(
1019
VerifySyntax<
ConstructorDeclarationSyntax
>(
1023
VerifySyntax<
ConstructorDeclarationSyntax
>(
2313
VerifySyntax<
ConstructorDeclarationSyntax
>(
3101
VerifySyntax<
ConstructorDeclarationSyntax
>(ctor, @"static C()
3106
VerifySyntax<
ConstructorDeclarationSyntax
>(publicCtor, @"public C()
3115
VerifySyntax<
ConstructorDeclarationSyntax
>(ctor, @"public C()
3120
VerifySyntax<
ConstructorDeclarationSyntax
>(staticCtor, @"static C()
Microsoft.DotNet.GenFacades (1)
NotSupportedAssemblyGenerator.cs (1)
157
public override SyntaxNode VisitConstructorDeclaration(
ConstructorDeclarationSyntax
node)
Microsoft.ML.InternalCodeAnalyzer (2)
ContractsCheckAnalyzer.cs (1)
169
?? ((
ConstructorDeclarationSyntax
)node).ParameterList).Parameters;
ContractsCheckNameofFixProvider.cs (1)
115
?? ((
ConstructorDeclarationSyntax
)temp).ParameterList;
Microsoft.VisualStudio.LanguageServices.CSharp (9)
CodeModel\CSharpCodeModelService.cs (5)
814
return ((
ConstructorDeclarationSyntax
)node).Identifier.ToString();
894
return ((
ConstructorDeclarationSyntax
)node).WithIdentifier(newIdentifier);
934
var
constructor = ((
ConstructorDeclarationSyntax
)member).WithIdentifier(newIdentifier);
3399
else if (container is
ConstructorDeclarationSyntax
constructor)
CodeModel\CSharpCodeModelService.NodeLocator.cs (2)
398
startPosition = ((
ConstructorDeclarationSyntax
)node).Identifier.SpanStart;
961
endPosition = ((
ConstructorDeclarationSyntax
)node).Identifier.Span.End;
CodeModel\CSharpCodeModelService.NodeNameGenerator.cs (2)
224
var
constructorDeclaration = (
ConstructorDeclarationSyntax
)node;