271 references to Constructor
ConfigurationSchemaGenerator (1)
RuntimeSource\Configuration.Binder\Parser\ConfigurationBinder.cs (1)
111IMethodReferenceOperation m when m.Method.MethodKind == MethodKind.Constructor => m.Method.ContainingType,
GenerateDocumentationAndConfigFiles (5)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\IParameterSymbolExtensions.cs (2)
33MethodKind: MethodKind.Constructor, 65MethodKind: MethodKind.Constructor,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ISymbolExtensions.cs (1)
287=> symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationConstructorSymbol.cs (1)
27public override MethodKind MethodKind => MethodKind.Constructor;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationNamedTypeSymbol.cs (1)
168return [.. this.GetMembers().OfType<IMethodSymbol>().Where(m => m.MethodKind == MethodKind.Constructor && !m.IsStatic)];
ILLink.RoslynAnalyzer (2)
ISymbolExtensions.cs (1)
213=> (symbol as IMethodSymbol)?.MethodKind is MethodKind.Constructor or MethodKind.StaticConstructor;
TrimAnalysis\MethodReturnValue.cs (1)
23Debug.Assert(!isNewObj || methodSymbol.MethodKind == MethodKind.Constructor, "isNewObj can only be true for constructors");
Microsoft.AspNetCore.OpenApi.SourceGenerators (2)
XmlCommentGenerator.Parser.cs (1)
100if (method.MethodKind == MethodKind.Constructor)
XmlComments\XmlComment.InheritDoc.cs (1)
282if (methodSymbol.MethodKind is MethodKind.Constructor or MethodKind.StaticConstructor)
Microsoft.CodeAnalysis (1)
Operations\CommonConversion.cs (1)
87{ MethodKind: MethodKind.Constructor, ContainingType.IsUnion: true } or
Microsoft.CodeAnalysis.Analyzers (5)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\IParameterSymbolExtensions.cs (2)
33MethodKind: MethodKind.Constructor, 65MethodKind: MethodKind.Constructor,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ISymbolExtensions.cs (1)
287=> symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationConstructorSymbol.cs (1)
27public override MethodKind MethodKind => MethodKind.Constructor;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationNamedTypeSymbol.cs (1)
168return [.. this.GetMembers().OfType<IMethodSymbol>().Where(m => m.MethodKind == MethodKind.Constructor && !m.IsStatic)];
Microsoft.CodeAnalysis.AnalyzerUtilities (7)
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\DisposeAnalysis\DisposeAnalysisHelper.cs (1)
155containingMethod.MethodKind == MethodKind.Constructor &&
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\TaintedDataAnalysis.TaintedDataOperationVisitor.cs (2)
638if (method.MethodKind == MethodKind.Constructor 695if (method.MethodKind == MethodKind.Constructor
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\DataFlowOperationVisitor.cs (1)
2482else if (invokedMethod.MethodKind == MethodKind.Constructor)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\IParameterSymbolExtensions.cs (2)
33MethodKind: MethodKind.Constructor, 65MethodKind: MethodKind.Constructor,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ISymbolExtensions.cs (1)
287=> symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
Microsoft.CodeAnalysis.CodeStyle (6)
src\roslyn\src\Analyzers\Core\Analyzers\Helpers\DeserializationConstructorCheck.cs (1)
17methodSymbol.MethodKind == MethodKind.Constructor &&
src\roslyn\src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
951case MethodKind.Constructor:
src\roslyn\src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (1)
298if (method.MethodKind != MethodKind.Constructor)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\IParameterSymbolExtensions.cs (2)
33MethodKind: MethodKind.Constructor, 65MethodKind: MethodKind.Constructor,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ISymbolExtensions.cs (1)
287=> symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
Microsoft.CodeAnalysis.CodeStyle.Fixes (5)
src\roslyn\src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (1)
139var isConstructorInitializer = candidates.All(m => m.MethodKind == MethodKind.Constructor);
src\roslyn\src\Analyzers\Core\CodeFixes\AddParameter\AddParameterService.cs (2)
167if (method.MethodKind != MethodKind.Constructor) 193if (parameter.ContainingSymbol is not IMethodSymbol { MethodKind: MethodKind.Constructor, DeclaringSyntaxReferences: [var reference] } constructor)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationConstructorSymbol.cs (1)
27public override MethodKind MethodKind => MethodKind.Constructor;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationNamedTypeSymbol.cs (1)
168return [.. this.GetMembers().OfType<IMethodSymbol>().Where(m => m.MethodKind == MethodKind.Constructor && !m.IsStatic)];
Microsoft.CodeAnalysis.CSharp (108)
Binder\Binder.ValueChecks.cs (3)
1732MethodKind desiredMethodKind = fieldIsStatic ? MethodKind.StaticConstructor : MethodKind.Constructor; 2204if (method.MethodKind == MethodKind.Constructor || method.IsInitOnly) 2878if (method.MethodKind == MethodKind.Constructor)
Binder\Binder_Conversions.cs (5)
2747Debug.Assert(analysis.Operator is { ParameterCount: 1 } and ({ MethodKind: MethodKind.Constructor } or { MethodKind: MethodKind.Ordinary, IsStatic: true, ContainingType.IsInterface: true })); 2749Debug.Assert(TypeSymbol.Equals(destination.StrippedType(), analysis.Operator.MethodKind == MethodKind.Constructor ? analysis.Operator.ContainingType : analysis.Operator.ReturnType, TypeCompareKind.AllIgnoreOptions)); 2766if (analysis.Operator.MethodKind == MethodKind.Constructor) 3372Debug.Assert(memberSymbol is not MethodSymbol { MethodKind: not MethodKind.Constructor } || 3377if (receiverOpt != null || memberSymbol is not MethodSymbol { MethodKind: MethodKind.Constructor })
Binder\Binder_Crefs.cs (1)
981int signatureMemberArity = candidateMethodKind == MethodKind.Constructor
Binder\Binder_Expressions.cs (3)
2087(this.ContainingMember() is MethodSymbol { MethodKind: MethodKind.Constructor } containingMember && (object)containingMember != primaryCtor)) && // We are in a non-primary instance constructor 4912Debug.Assert(constructor.MethodKind == MethodKind.Constructor || 6780Debug.Assert(constructor.MethodKind == MethodKind.Constructor || constructor.MethodKind == MethodKind.StaticConstructor);
Binder\Binder_Statements.cs (2)
1841MethodKind.Constructor) || 3886if (constructor.MethodKind != MethodKind.Constructor || constructor.IsExtern)
Binder\Semantics\OverloadResolution\OverloadResolutionResult.cs (1)
535Debug.Assert(firstSupported.Member is MethodSymbol { MethodKind: MethodKind.Constructor });
BoundTree\BoundNodeExtensions.cs (1)
62return method.MethodKind == MethodKind.Constructor &&
CodeGen\CodeGenerator_HasHome.cs (1)
256return (containingSymbol is MethodSymbol { MethodKind: MethodKind.Constructor } or FieldSymbol { IsStatic: false } or MethodSymbol { IsInitOnly: true }) &&
CodeGen\EmitExpression.cs (1)
2218if (method.IsEffectivelyReadOnly && method.MethodKind != MethodKind.Constructor)
Compilation\CSharpCompilation.cs (1)
3188if (symbol.Kind == SymbolKind.Method && symbol.IsImplicitlyDeclared && ((MethodSymbol)symbol).MethodKind == MethodKind.Constructor)
Compilation\MethodBodySemanticModel.cs (1)
240if (MemberSymbol is MethodSymbol methodSymbol && methodSymbol.MethodKind == MethodKind.Constructor &&
Compiler\MethodCompiler.cs (3)
548(method.MethodKind == MethodKind.Constructor || method.IsScriptInitializer) ? processedInstanceInitializers : 1123if ((methodSymbol.MethodKind == MethodKind.Constructor || methodSymbol.MethodKind == MethodKind.StaticConstructor) && 2489if (method.MethodKind == MethodKind.Constructor && !method.IsExtern)
Emitter\Model\MethodSymbolAdapter.cs (2)
408return AdaptedMethodSymbol.MethodKind == MethodKind.Constructor; 657return this.MethodKind == MethodKind.Constructor
Emitter\Model\NamedTypeSymbolAdapter.cs (1)
634if ((alwaysIncludeConstructors && method.MethodKind == MethodKind.Constructor) || method.GetCciAdapter().ShouldInclude(context))
Emitter\NoPia\EmbeddedMethod.cs (1)
70return UnderlyingMethod.AdaptedMethodSymbol.MethodKind == MethodKind.Constructor;
FlowAnalysis\AbstractFlowPass.cs (1)
1470if (method is null || method.MethodKind != MethodKind.Constructor)
FlowAnalysis\DefiniteAssignment.cs (3)
103&& CurrentSymbol is MethodSymbol { MethodKind: MethodKind.Constructor, ContainingType.TypeKind: TypeKind.Struct }; 1211Debug.Assert(CurrentSymbol is MethodSymbol { MethodKind: MethodKind.Constructor, ContainingType.TypeKind: TypeKind.Struct }); 1264if (CurrentSymbol is not MethodSymbol { MethodKind: MethodKind.Constructor, ContainingType.TypeKind: TypeKind.Struct })
FlowAnalysis\FlowAnalysisPass.cs (1)
116Debug.Assert(method.MethodKind == MethodKind.Constructor);
FlowAnalysis\NullableWalker.cs (5)
516Debug.Assert(baseOrThisInitializer is null or { MethodKind: MethodKind.Constructor }); 1591return constructorBody is BoundConstructorMethodBody { Initializer: BoundExpressionStatement { Expression: BoundCall { Method: { MethodKind: MethodKind.Constructor } initializerMethod } } } 10603Debug.Assert(analysis.Operator is { ParameterCount: 1 } and ({ MethodKind: MethodKind.Constructor } or { MethodKind: MethodKind.Ordinary, IsStatic: true, ContainingType.IsInterface: true })); 10605Debug.Assert(TypeSymbol.Equals(targetTypeWithNullability.Type.StrippedType(), analysis.Operator.MethodKind == MethodKind.Constructor ? analysis.Operator.ContainingType : analysis.Operator.ReturnType, TypeCompareKind.AllIgnoreOptions)); 10680Debug.Assert(factory.MethodKind == MethodKind.Constructor);
Lowering\ClosureConversion\ClosureConversion.cs (2)
194_seenBaseCall = method.MethodKind != MethodKind.Constructor; // only used for ctors 804if (_currentMethod.MethodKind == MethodKind.Constructor &&
Lowering\InitializerRewriter.cs (1)
22Debug.Assert((method.MethodKind == MethodKind.Constructor) || (method.MethodKind == MethodKind.StaticConstructor));
Lowering\Instrumentation\ModuleCancellationInstrumenter.cs (2)
50if (method.MethodKind is not (MethodKind.Constructor or MethodKind.StaticConstructor) && 156if (method.MethodKind is not (MethodKind.Ordinary or MethodKind.Constructor))
Lowering\Instrumentation\StackOverflowProbingInstrumenter.cs (1)
40if (method.MethodKind is not (MethodKind.Constructor or MethodKind.StaticConstructor) &&
Lowering\LocalRewriter\LocalRewriter_Call.cs (1)
677var requiresInstanceReceiver = methodOrIndexer.RequiresInstanceReceiver() && methodOrIndexer is not MethodSymbol { MethodKind: MethodKind.Constructor } and not FunctionPointerMethodSymbol;
Lowering\LocalRewriter\LocalRewriter_CollectionExpression.cs (1)
1054if (asSpanMethod is MethodSymbol { MethodKind: MethodKind.Constructor } constructor)
Lowering\LocalRewriter\LocalRewriter_Conversion.cs (4)
962Debug.Assert(analysis.Operator is { ParameterCount: 1 } and ({ MethodKind: MethodKind.Constructor } or { MethodKind: MethodKind.Ordinary, IsStatic: true, ContainingType.IsInterface: true })); 964Debug.Assert(TypeSymbol.Equals(rewrittenType.StrippedType(), analysis.Operator.MethodKind == MethodKind.Constructor ? analysis.Operator.ContainingType : analysis.Operator.ReturnType, TypeCompareKind.AllIgnoreOptions)); 1560Debug.Assert(conversion.Method is { ParameterCount: 1 } and ({ MethodKind: MethodKind.Constructor } or { MethodKind: MethodKind.Ordinary, IsStatic: true, ContainingType.IsInterface: true })); 1567if (factory is { MethodKind: MethodKind.Constructor } constructor)
Lowering\LocalRewriter\LocalRewriter_Range.cs (1)
167case MethodKind.Constructor:
src\roslyn\src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (1)
106Debug.Assert(ctor.MethodKind == MethodKind.Constructor && typeDeclaration.ParameterList is object);
SymbolDisplay\SymbolDisplayVisitor.Members.cs (2)
325case MethodKind.Constructor: 467case MethodKind.Constructor:
Symbols\AnonymousTypes\SynthesizedSymbols\AnonymousType.ConstructorSymbol.cs (1)
45get { return MethodKind.Constructor; }
Symbols\Compilation_WellKnownMembers.cs (1)
268targetMethodKind = MethodKind.Constructor;
Symbols\ErrorMethodSymbol.cs (2)
210return MethodKind.Constructor; 287Debug.Assert(MethodKind == MethodKind.Constructor);
Symbols\MemberSymbolExtensions.cs (3)
608case MethodKind.Constructor: 621if ((object)method != null && method.MethodKind == MethodKind.Constructor) 686return method.MethodKind == MethodKind.Constructor && method.ParameterCount == 0;
Symbols\Metadata\PE\PEMethodSymbol.cs (5)
1068bool isClosedConstructor = MethodKind == MethodKind.Constructor && ContainingType.IsClosed; 1244return MethodKind.Constructor; 1581if (MethodKind == MethodKind.Constructor) 1679Debug.Assert(MethodKind == MethodKind.Constructor); 1701var result = ObsoleteAttributeHelpers.GetObsoleteDataFromMetadata(_handle, (PEModuleSymbol)ContainingModule, ignoreByRefLikeMarker: false, ignoreRequiredMemberMarker: MethodKind == MethodKind.Constructor);
Symbols\Metadata\PE\PEParameterSymbol.cs (1)
908|| ContainingSymbol is MethodSymbol { MethodKind: MethodKind.Constructor or MethodKind.DelegateInvoke }
Symbols\MethodSymbol.cs (7)
382protected bool IsValidReadOnlyTarget => !IsStatic && ContainingType.IsStructType() && MethodKind != MethodKind.Constructor && !IsInitOnly; 602internal bool HasSetsRequiredMembers => MethodKind == MethodKind.Constructor && HasSetsRequiredMembersImpl; 618case MethodKind.Constructor: 668return MethodKind == MethodKind.Constructor && ContainingType.IsScriptClass; 684return ((MethodKind == MethodKind.Constructor || MethodKind == MethodKind.StaticConstructor) && IsImplicitlyDeclared); 695return MethodKind == MethodKind.Constructor && IsImplicitlyDeclared; 1218or MethodKind.Constructor
Symbols\MethodSymbolExtensions.cs (1)
130case MethodKind.Constructor:
Symbols\NamedTypeSymbol.cs (2)
294Debug.Assert(method.MethodKind == MethodKind.Constructor); 2001Debug.Assert(ctor.MethodKind is MethodKind.Constructor);
Symbols\NativeIntegerTypeSymbol.cs (1)
119case MethodKind.Constructor:
Symbols\PublicModel\MethodSymbol.cs (2)
42case MethodKind.Constructor: 43return MethodKind.Constructor;
Symbols\Source\SourceComplexParameterSymbol.cs (1)
1389|| ContainingSymbol is MethodSymbol { MethodKind: MethodKind.Constructor or MethodKind.DelegateInvoke or MethodKind.LambdaMethod }
Symbols\Source\SourceConstructorSymbol.cs (4)
26var methodKind = syntax.Modifiers.Any(SyntaxKind.StaticKeyword) ? MethodKind.StaticConstructor : MethodKind.Constructor; 66if (methodKind == MethodKind.Constructor && syntax.Initializer != null) 154if (methodKind == MethodKind.Constructor) 199else if (ContainingType.IsStatic && methodKind == MethodKind.Constructor)
Symbols\Source\SourceDelegateMethodSymbol.cs (1)
221: base(delegateType, voidType, syntax, MethodKind.Constructor, RefKind.None, DeclarationModifiers.Public)
Symbols\Source\SourceMemberContainerSymbol.cs (10)
2349if (method1.OriginalDefinition is SourceMemberMethodSymbol { MethodKind: MethodKind.Constructor } constructor && 2381var methodKind = method1.MethodKind == MethodKind.Constructor ? MessageID.IDS_SK_CONSTRUCTOR : MessageID.IDS_SK_METHOD; 4015if (member is MethodSymbol { IsImplicitlyDeclared: false, MethodKind: not (MethodKind.Constructor or MethodKind.StaticConstructor or MethodKind.Destructor or MethodKind.ExplicitInterfaceImplementation) } method && 4749case MethodKind.Constructor: 4811case MethodKind.Constructor: 4858if (m.MethodKind == MethodKind.Constructor && m.ParameterCount == 0) 4900if (hasInitializers && !builder.NonTypeMembersWithPartialImplementations.Any(member => member is MethodSymbol { MethodKind: MethodKind.Constructor })) 5045case MethodSymbol { MethodKind: not (MethodKind.Ordinary or MethodKind.Constructor) }: 5187MethodKind.Constructor, 5659case MethodKind.Constructor:
Symbols\Source\SourceMethodSymbolWithAttributes.cs (5)
155case MethodKind.Constructor: 1491case MethodKind.Constructor: 1519var errorCode = (this.MethodKind == MethodKind.Constructor || this.MethodKind == MethodKind.StaticConstructor) ? 1675case MethodKind.Constructor: 1757if (this.ContainingType.IsComImport && this.MethodKind == MethodKind.Constructor)
Symbols\Source\SourceNamedTypeSymbol.cs (1)
1941&& !GetMembers().All(m => m is not MethodSymbol { MethodKind: MethodKind.Constructor, ObsoleteKind: ObsoleteAttributeKind.None } method
Symbols\Source\ThisParameterSymbol.cs (1)
162if (_containingMethod?.MethodKind == MethodKind.Constructor)
Symbols\Symbol_Attributes.cs (1)
58case MethodKind.Constructor:
Symbols\SymbolExtensions.cs (1)
816=> method is { MethodKind: MethodKind.Constructor, HasSetsRequiredMembers: false };
Symbols\Synthesized\Records\SynthesizedPrimaryConstructor.cs (1)
43MethodKind.Constructor,
Symbols\Synthesized\Records\SynthesizedRecordCopyCtor.cs (1)
135if (member is MethodSymbol { ContainingType.IsRecord: true, MethodKind: MethodKind.Constructor } method)
Symbols\Synthesized\SynthesizedInstanceConstructor.cs (1)
190get { return MethodKind.Constructor; }
Symbols\TypeMap.cs (1)
189stopAt?.MethodKind == MethodKind.Constructor);
Microsoft.CodeAnalysis.CSharp.CodeStyle (4)
src\roslyn\src\Analyzers\CSharp\Analyzers\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs (1)
87if (context.OwningSymbol is IMethodSymbol { MethodKind: MethodKind.Constructor })
src\roslyn\src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForNewDiagnosticAnalyzer.cs (1)
55if (symbol is not IMethodSymbol { MethodKind: MethodKind.Constructor, Parameters: [var constructorParameter] } ||
src\roslyn\src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUseCollectionInitializerAnalyzer.cs (2)
100MethodKind: MethodKind.Constructor, 132MethodKind: MethodKind.Constructor,
Microsoft.CodeAnalysis.CSharp.Features (8)
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (1)
936if (symbol is not IMethodSymbol { MethodKind: MethodKind.Constructor or MethodKind.StaticConstructor } method)
InitializeParameter\CSharpInitializeMemberFromPrimaryConstructorParameterCodeRefactoringProvider.cs (1)
55if (parameter.ContainingSymbol is not IMethodSymbol { MethodKind: MethodKind.Constructor } constructor)
SignatureHelp\WithElementSignatureHelpProvider.cs (1)
87var items = creationMethods.SelectAsArray(c => c.MethodKind == MethodKind.Constructor
src\roslyn\src\Analyzers\CSharp\Analyzers\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs (1)
87if (context.OwningSymbol is IMethodSymbol { MethodKind: MethodKind.Constructor })
src\roslyn\src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForNewDiagnosticAnalyzer.cs (1)
55if (symbol is not IMethodSymbol { MethodKind: MethodKind.Constructor, Parameters: [var constructorParameter] } ||
src\roslyn\src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUseCollectionInitializerAnalyzer.cs (2)
100MethodKind: MethodKind.Constructor, 132MethodKind: MethodKind.Constructor,
src\roslyn\src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (1)
106Debug.Assert(ctor.MethodKind == MethodKind.Constructor && typeDeclaration.ParameterList is object);
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
Classification\SyntaxClassification\NameSyntaxClassifier.cs (1)
255if (methodSymbol.MethodKind == MethodKind.Constructor)
Microsoft.CodeAnalysis.Extensions.Package (3)
Symbols\IParameterSymbolExtensions.cs (2)
33MethodKind: MethodKind.Constructor, 65MethodKind: MethodKind.Constructor,
Symbols\ISymbolExtensions.cs (1)
287=> symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
Microsoft.CodeAnalysis.Features (18)
AddImport\AbstractAddImportCodeRefactoringProvider.cs (1)
144if (parentSymbol is IMethodSymbol { MethodKind: MethodKind.Constructor } constructor &&
CodeLens\CodeLensFindReferenceProgress.cs (1)
122(definition as IMethodSymbol)?.MethodKind == MethodKind.Constructor;
DocumentHighlighting\AbstractDocumentHighlightsService.cs (1)
171if (symbol is IMethodSymbol { MethodKind: MethodKind.Constructor } constructor)
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (4)
346MethodKind.Constructor => FeaturesResources.constructor, 3860MethodKind.Constructor or 5643Contract.ThrowIfFalse(oldCtor is { MethodKind: MethodKind.Constructor or MethodKind.StaticConstructor }); 7051=> symbol is IMethodSymbol { IsStatic: false, MethodKind: MethodKind.Constructor, DeclaringSyntaxReferences: [_] } && IsPrimaryConstructorDeclaration(GetSymbolDeclarationSyntax(symbol, cancellationToken));
GoToBase\AbstractGoToBaseService.cs (1)
45if (bases.Length == 0 && symbol is IMethodSymbol { MethodKind: MethodKind.Constructor } constructor)
InitializeParameter\AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs (1)
67if (method.MethodKind != MethodKind.Constructor)
IntroduceParameter\AbstractIntroduceParameterCodeRefactoringProvider.cs (2)
89if (methodKind is not (MethodKind.Ordinary or MethodKind.LocalFunction or MethodKind.Constructor)) 174if (methodSymbol.MethodKind is not MethodKind.Constructor)
RQName\RQNodeBuilder.cs (1)
212if (symbol.MethodKind == MethodKind.Constructor)
src\roslyn\src\Analyzers\Core\Analyzers\Helpers\DeserializationConstructorCheck.cs (1)
17methodSymbol.MethodKind == MethodKind.Constructor &&
src\roslyn\src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
951case MethodKind.Constructor:
src\roslyn\src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (1)
298if (method.MethodKind != MethodKind.Constructor)
src\roslyn\src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (1)
139var isConstructorInitializer = candidates.All(m => m.MethodKind == MethodKind.Constructor);
src\roslyn\src\Analyzers\Core\CodeFixes\AddParameter\AddParameterService.cs (2)
167if (method.MethodKind != MethodKind.Constructor) 193if (parameter.ContainingSymbol is not IMethodSymbol { MethodKind: MethodKind.Constructor, DeclaringSyntaxReferences: [var reference] } constructor)
Microsoft.CodeAnalysis.ResxSourceGenerator (3)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\IParameterSymbolExtensions.cs (2)
33MethodKind: MethodKind.Constructor, 65MethodKind: MethodKind.Constructor,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ISymbolExtensions.cs (1)
287=> symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
Microsoft.CodeAnalysis.VisualBasic (61)
Analysis\FlowAnalysis\AbstractFlowPass.vb (2)
1226Debug.Assert(method.Kind <> MethodKind.Constructor) 1297Debug.Assert(method.Kind <> MethodKind.Constructor)
Analysis\InitializerRewriter.vb (1)
273If methodSymbol.MethodKind = MethodKind.Constructor Then
Binding\Binder_Expressions.vb (2)
1874If containingMethodKind = MethodKind.Constructor Then 1916Return MethodKind.Constructor
Binding\Binder_Invocation.vb (2)
58If Me.ContainingMember.Kind = SymbolKind.Method AndAlso DirectCast(Me.ContainingMember, MethodSymbol).MethodKind = MethodKind.Constructor Then 716Return methodGroup.Methods(0).MethodKind = MethodKind.Constructor
Binding\Binder_Lambda.vb (1)
730Case MethodKind.SharedConstructor, MethodKind.Constructor
Binding\Binder_Lookup.vb (1)
1963containingMethod.MethodKind = MethodKind.Constructor AndAlso
Binding\Binder_Statements.vb (2)
347If methodSymbol.MethodKind = MethodKind.Constructor Then 416If Not methodSymbol.IsImplicitlyDeclared AndAlso methodSymbol.MethodKind = MethodKind.Constructor Then
Binding\Binder_Utils.vb (1)
1645MethodKindConstructor = CUInt(MethodKind.Constructor) << MethodKindShift
CodeGen\EmitAddress.vb (1)
281Return Me._method.MethodKind = MethodKind.Constructor AndAlso
Compilation\MethodCompiler.vb (7)
137DirectCast(symbol, MethodSymbol).MethodKind = MethodKind.Constructor Then 697ElseIf method.MethodKind = MethodKind.Constructor OrElse method.IsScriptInitializer Then 771sourceMethod.MethodKind = MethodKind.Constructor AndAlso 1481If method.MethodKind = MethodKind.Constructor OrElse method.MethodKind = MethodKind.SharedConstructor Then 1819If method.MethodKind = MethodKind.Constructor Then 1855If referencedMethod IsNot Nothing AndAlso referencedMethod.MethodKind = MethodKind.Constructor Then 1916Debug.Assert(constructor.MethodKind = MethodKind.Constructor)
Compilation\SemanticModel.vb (1)
1862(result.Kind = SymbolKind.Method AndAlso DirectCast(result, MethodSymbol).MethodKind = MethodKind.Constructor) Then
Emit\MethodSymbolAdapter.vb (2)
307Return AdaptedMethodSymbol.MethodKind = MethodKind.Constructor 547Dim result = Me.MethodKind = MethodKind.Constructor OrElse
Emit\NoPia\EmbeddedMethod.vb (1)
55Return UnderlyingMethod.AdaptedMethodSymbol.MethodKind = MethodKind.Constructor
Lowering\LambdaRewriter\LambdaFrameConstructor.vb (1)
25Return MethodKind.Constructor
Lowering\LambdaRewriter\LambdaRewriter.vb (2)
563If _innermostFramePointer.Kind = SymbolKind.Parameter AndAlso _topLevelMethod.MethodKind = MethodKind.Constructor AndAlso 1419If node.Method.MethodKind = MethodKind.Constructor AndAlso receiver IsNot Nothing AndAlso receiver.IsInstanceReference Then
Lowering\LocalRewriter\LocalRewriter_Conversion.vb (2)
978If memberSymbol.MethodKind = MethodKind.Constructor Then 1117If memberSymbol.MethodKind = MethodKind.Constructor Then
Semantics\OverloadResolution.vb (2)
971possiblyConstructor.MethodKind = MethodKind.Constructor AndAlso 3756DirectCast(candidate.Candidate.UnderlyingSymbol, MethodSymbol).MethodKind = MethodKind.Constructor AndAlso
SymbolDisplay\SymbolDisplayVisitor.Members.vb (3)
197Case MethodKind.Constructor, MethodKind.StaticConstructor 338Case MethodKind.Constructor, MethodKind.StaticConstructor 436Case MethodKind.Constructor,
Symbols\EmbeddedSymbols\EmbeddedSymbolManager.SymbolsCollection.vb (3)
240MethodKind.Constructor, 289MethodKind.Constructor 372Debug.Assert(kind = MethodKind.Constructor OrElse
Symbols\Metadata\PE\PEMethodSymbol.vb (6)
399Return MethodKind.Constructor 430Return _packedFlags.MethodKind = MethodKind.Constructor AndAlso ParameterCount = 0 445_packedFlags.MethodKind = MethodKind.Constructor 644Dim checkForRequiredMembers = MethodKind = MethodKind.Constructor AndAlso 1291MethodKind = MethodKind.Constructor AndAlso 1391If MethodKind <> MethodKind.Constructor Then
Symbols\MethodSymbol.vb (3)
32Return Me.ParameterCount = 0 AndAlso Me.MethodKind = MethodKind.Constructor 458MethodKind.Constructor, 496Return Me.MethodKind = MethodKind.Constructor AndAlso Me.ContainingType.IsScriptClass
Symbols\NamedTypeSymbol.vb (1)
423Debug.Assert(method.MethodKind = MethodKind.Constructor)
Symbols\PropertySymbol.vb (1)
172If If(TryCast(containingMember, MethodSymbol)?.MethodKind <> MethodKind.Constructor, True) Then
Symbols\Source\OverrideHidingHelper.vb (1)
497Case MethodKind.LambdaMethod, MethodKind.Constructor, MethodKind.SharedConstructor
Symbols\Source\SourceDelegateMethodSymbol.vb (1)
199Return Me.MethodKind = MethodKind.Constructor
Symbols\Source\SourceMemberContainerTypeSymbol.vb (2)
2779(DirectCast(sym, MethodSymbol).MethodKind = MethodKind.Constructor OrElse 2784If method.MethodKind = MethodKind.Constructor AndAlso method.ParameterCount = 0 Then
Symbols\Source\SourceMethodSymbol.vb (2)
1992Case MethodKind.Constructor, 2287Case MethodKind.Constructor,
Symbols\Source\SourceNamedTypeSymbol.vb (2)
2766If method.MethodKind = MethodKind.Constructor AndAlso method.ParameterCount = 0 Then 2775If method.MethodKind = MethodKind.Constructor AndAlso method.CanBeCalledWithNoParameters() Then
Symbols\Symbol_Attributes.vb (1)
75Case MethodKind.Constructor,
Symbols\SymbolExtensions.vb (1)
263Return kind = MethodKind.Constructor OrElse kind = MethodKind.SharedConstructor
Symbols\SynthesizedSymbols\SynthesizedConstructorBase.vb (1)
192Return If(m_isShared, MethodKind.SharedConstructor, MethodKind.Constructor)
Symbols\SynthesizedSymbols\SynthesizedDelegateMethodSymbol.vb (1)
419Return Me.MethodKind = MethodKind.Constructor
Symbols\WellKnownMembers.vb (1)
435targetMethodKind = MethodKind.Constructor
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (1)
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\GenerateConstructor\VisualBasicGenerateConstructorService.vb (1)
183Return If(methodSymbol IsNot Nothing AndAlso methodSymbol.MethodKind = MethodKind.Constructor, methodSymbol, Nothing)
Microsoft.CodeAnalysis.VisualBasic.Features (2)
EditAndContinue\VisualBasicEditAndContinueAnalyzer.vb (1)
619If method Is Nothing OrElse (method.MethodKind <> MethodKind.Constructor AndAlso method.MethodKind <> MethodKind.SharedConstructor) Then
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\GenerateConstructor\VisualBasicGenerateConstructorService.vb (1)
183Return If(methodSymbol IsNot Nothing AndAlso methodSymbol.MethodKind = MethodKind.Constructor, methodSymbol, Nothing)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (3)
CaseCorrection\VisualBasicCaseCorrectionService.Rewriter.vb (1)
169(symbol.IsKind(SymbolKind.Method) AndAlso DirectCast(symbol, IMethodSymbol).MethodKind = MethodKind.Constructor)
Classification\SyntaxClassification\NameSyntaxClassifier.vb (1)
212Case MethodKind.Constructor
Recommendations\VisualBasicRecommendationServiceRunner.vb (1)
382If method IsNot Nothing AndAlso method.MethodKind = MethodKind.Constructor Then
Microsoft.CodeAnalysis.Workspaces (15)
Editing\SyntaxGenerator.cs (2)
745case MethodKind.Constructor: 883case MethodKind.Constructor:
FindSymbols\FindReferences\Finders\ConstructorSymbolReferenceFinder.cs (3)
26=> symbol.MethodKind is MethodKind.Constructor or MethodKind.StaticConstructor; 30if (symbol.MethodKind is MethodKind.Constructor) 84if (symbol.MethodKind == MethodKind.Constructor)
FindSymbols\FindReferences\Finders\ExplicitOrImplicitConstructorInitializerSymbolReferenceFinder.cs (1)
18=> symbol.MethodKind == MethodKind.Constructor;
Rename\RenameUtilities.cs (1)
395if (symbol is IMethodSymbol { MethodKind: MethodKind.Constructor or MethodKind.StaticConstructor or MethodKind.Destructor })
Rename\SymbolicRenameLocations.ReferenceProcessing.cs (2)
211MethodKind: MethodKind.Constructor or MethodKind.StaticConstructor or MethodKind.Destructor, 297var referencedSymbolName = referencedSymbol is IMethodSymbol { MethodKind: MethodKind.Constructor } constructorSymbol
Shared\Extensions\ISymbolExtensions.cs (1)
474if (methodSymbol.MethodKind is MethodKind.Constructor or MethodKind.StaticConstructor)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\IParameterSymbolExtensions.cs (2)
33MethodKind: MethodKind.Constructor, 65MethodKind: MethodKind.Constructor,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ISymbolExtensions.cs (1)
287=> symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationConstructorSymbol.cs (1)
27public override MethodKind MethodKind => MethodKind.Constructor;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationNamedTypeSymbol.cs (1)
168return [.. this.GetMembers().OfType<IMethodSymbol>().Where(m => m.MethodKind == MethodKind.Constructor && !m.IsStatic)];
Microsoft.DotNet.ApiCompatibility (1)
Rules\MembersMustExist.cs (1)
113if (method.MethodKind == MethodKind.Constructor)
Microsoft.DotNet.ApiSymbolExtensions (1)
SymbolExtensions.cs (1)
155method.MethodKind == MethodKind.Constructor &&
Microsoft.Gen.Logging (1)
Parsing\Parser.Records.cs (1)
72if (m is not IMethodSymbol { MethodKind: MethodKind.Constructor } ctorMethod)
Roslyn.Diagnostics.Analyzers (6)
DoNotMixAttributesFromDifferentVersionsOfMEF.cs (1)
103if (member is IMethodSymbol methodSymbol && methodSymbol.MethodKind == MethodKind.Constructor)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\IParameterSymbolExtensions.cs (2)
33MethodKind: MethodKind.Constructor, 65MethodKind: MethodKind.Constructor,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ISymbolExtensions.cs (1)
287=> symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationConstructorSymbol.cs (1)
27public override MethodKind MethodKind => MethodKind.Constructor;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationNamedTypeSymbol.cs (1)
168return [.. this.GetMembers().OfType<IMethodSymbol>().Where(m => m.MethodKind == MethodKind.Constructor && !m.IsStatic)];
Roslyn.Diagnostics.CSharp.Analyzers (1)
CSharpDoNotCapturePrimaryContructorParameters.cs (1)
41if (operation.Parameter.ContainingSymbol == context.ContainingSymbol || operation.Parameter.ContainingSymbol is not IMethodSymbol { MethodKind: MethodKind.Constructor })