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