114 references to ContainingSymbol
ILLink.RoslynAnalyzer (1)
RequiresAnalyzerBase.cs (1)
66 if (syntaxNodeAnalysisContext.ContainingSymbol is not ISymbol containingSymbol || containingSymbol.IsInRequiresScope (RequiresAttributeName, out _))
Microsoft.Analyzers.Extra (1)
AsyncMethodWithoutCancellation.cs (1)
73var methodSymbol = (IMethodSymbol)analysisContext.ContainingSymbol!;
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (79)
Diagnostics\DiagnosticAnalyzerTests.cs (2)
1653if (nodeContext.ContainingSymbol.Name.StartsWith("Funky") && nodeContext.Compilation.Language == "C#") 4135var diagnostic = CodeAnalysis.Diagnostic.Create(Rule, context.Node.GetLocation(), context.Node.Kind(), context.ContainingSymbol.Name);
Diagnostics\GetDiagnosticsTests.cs (1)
966context => analyzeNode(context.Node, context.ContainingSymbol, context.ReportDiagnostic),
Semantics\PrimaryConstructorTests.cs (46)
3774Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 3778Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 3782Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 3787Assert.Equal("System.Int32 B.M()", context.ContainingSymbol.ToTestDisplayString()); 3791Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 3795Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 3802Assert.Same(literal.SyntaxTree, context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree); 3813Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 3817Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 3821Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 3828Assert.Same(equalsValue.SyntaxTree, context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree); 3839Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 3846Assert.Same(initializer.SyntaxTree, context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree); 3852Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 3862switch (context.ContainingSymbol.ToTestDisplayString()) 3877Assert.Same(baseType.SyntaxTree, context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree); 3884switch (context.ContainingSymbol.ToTestDisplayString()) 3904Assert.Same(@class.SyntaxTree, context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree); 3918Assert.Equal("B", context.ContainingSymbol.ToTestDisplayString()); 3923Assert.Equal("C", context.ContainingSymbol.ToTestDisplayString()); 3932Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 3936Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 3940Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 3952switch (context.ContainingSymbol.ToTestDisplayString()) 3969switch (context.ContainingSymbol.ToTestDisplayString()) 3997Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 4001Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 4005Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 4023Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 4027Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 5276Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 5280Assert.Equal("System.Int32 A.M()", context.ContainingSymbol.ToTestDisplayString()); 5284Assert.Equal("A..ctor(System.String S)", context.ContainingSymbol.ToTestDisplayString()); 5291Assert.Same(literal.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 5302Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 5309Assert.Same(equalsValue.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 5320Assert.Equal("A..ctor(System.String S)", context.ContainingSymbol.ToTestDisplayString()); 5327Assert.Same(initializer.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 5333Assert.Equal("A..ctor(System.String S)", context.ContainingSymbol.ToTestDisplayString()); 5346switch (context.ContainingSymbol.ToTestDisplayString()) 5356Assert.Same(record.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 5367Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 5379switch (context.ContainingSymbol.ToTestDisplayString()) 5407Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 5411Assert.Equal("A..ctor(System.String S)", context.ContainingSymbol.ToTestDisplayString()); 5429Assert.Equal("A..ctor(System.String S)", context.ContainingSymbol.ToTestDisplayString());
Semantics\RecordTests.cs (30)
26214Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 26218Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 26222Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 26227Assert.Equal("System.Int32 B.M()", context.ContainingSymbol.ToTestDisplayString()); 26231Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26235Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26242Assert.Same(literal.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26253Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 26257Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 26261Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26268Assert.Same(equalsValue.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26279Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26286Assert.Same(initializer.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26292Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26302switch (context.ContainingSymbol.ToTestDisplayString()) 26317Assert.Same(baseType.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26324switch (context.ContainingSymbol.ToTestDisplayString()) 26340Assert.Same(record.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26354Assert.Equal("B", context.ContainingSymbol.ToTestDisplayString()); 26359Assert.Equal("C", context.ContainingSymbol.ToTestDisplayString()); 26368Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 26372Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 26376Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26388switch (context.ContainingSymbol.ToTestDisplayString()) 26405switch (context.ContainingSymbol.ToTestDisplayString()) 26433Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 26437Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 26441Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26459Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 26463Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString());
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (27)
Semantics\RecordStructTests.cs (16)
5975Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 5979Assert.Equal("System.Int32 A.M()", context.ContainingSymbol.ToTestDisplayString()); 5983Assert.Equal("A..ctor(System.String S)", context.ContainingSymbol.ToTestDisplayString()); 5990Assert.Same(literal.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 6001Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 6008Assert.Same(equalsValue.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 6019Assert.Equal("A..ctor(System.String S)", context.ContainingSymbol.ToTestDisplayString()); 6026Assert.Same(initializer.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 6032Assert.Equal("A..ctor(System.String S)", context.ContainingSymbol.ToTestDisplayString()); 6045switch (context.ContainingSymbol.ToTestDisplayString()) 6055Assert.Same(record.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 6066Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 6078switch (context.ContainingSymbol.ToTestDisplayString()) 6106Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 6110Assert.Equal("A..ctor(System.String S)", context.ContainingSymbol.ToTestDisplayString()); 6128Assert.Equal("A..ctor(System.String S)", context.ContainingSymbol.ToTestDisplayString());
Semantics\TopLevelStatementsTests.cs (11)
6454Assert.Equal("<top-level-statements-entry-point>", context.ContainingSymbol.ToTestDisplayString()); 6455Assert.Same(globalStatement.SyntaxTree, context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree); 6484switch (context.ContainingSymbol.ToTestDisplayString()) 7073Assert.Equal("<top-level-statements-entry-point>", context.ContainingSymbol.ToTestDisplayString()); 7078Assert.Equal("void Test.M()", context.ContainingSymbol.ToTestDisplayString()); 7086var decl = (CSharpSyntaxNode)context.ContainingSymbol.DeclaringSyntaxReferences.Single().GetSyntax(); 7103switch (context.ContainingSymbol.ToTestDisplayString()) 7187Assert.Equal("<global namespace>", context.ContainingSymbol.ToTestDisplayString()); 7192Assert.Equal("Test", context.ContainingSymbol.ToTestDisplayString()); 7197Assert.Equal("void Test.M()", context.ContainingSymbol.ToTestDisplayString()); 7208switch (context.ContainingSymbol.ToTestDisplayString())
Microsoft.CodeAnalysis.Test.Utilities (4)
Diagnostics\CommonDiagnosticAnalyzers.cs (4)
1561sortedCallbackSyntaxNodeNames.Add($"{context.ContainingSymbol.Name}(IsGeneratedCode:{context.IsGeneratedCode})"), 2762ReportDiagnostics($"RegisterSyntaxNodeAction({syntaxNodeContext.Node}) in RegisterSymbolStartAction", syntaxNodeContext.Node.SyntaxTree, syntaxNodeContext.ContainingSymbol, syntaxNodeContext.ReportDiagnostic), 2795ReportDiagnostics($"RegisterSyntaxNodeAction({syntaxNodeContext.Node})", syntaxNodeContext.Node.SyntaxTree, syntaxNodeContext.ContainingSymbol, syntaxNodeContext.ReportDiagnostic), 2808ReportDiagnostics($"RegisterSyntaxNodeAction({syntaxNodeContext.Node}) in RegisterCodeBlockStartAction", syntaxNodeContext.Node.SyntaxTree, syntaxNodeContext.ContainingSymbol, syntaxNodeContext.ReportDiagnostic),
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (2)
Diagnostics\DiagnosticAnalyzerTests.vb (1)
961If nodeContext.ContainingSymbol.Name.StartsWith("Funky") AndAlso nodeContext.Compilation.Language = "Visual Basic" Then
Diagnostics\GetDiagnosticsTests.vb (1)
628AnalyzeNode(context.Node, context.ContainingSymbol, AddressOf context.ReportDiagnostic)