114 references to ContainingSymbol
ILLink.RoslynAnalyzer (1)
RequiresAnalyzerBase.cs (1)
74 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)
26259Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 26263Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 26267Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 26272Assert.Equal("System.Int32 B.M()", context.ContainingSymbol.ToTestDisplayString()); 26276Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26280Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26287Assert.Same(literal.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26298Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 26302Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 26306Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26313Assert.Same(equalsValue.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26324Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26331Assert.Same(initializer.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26337Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26347switch (context.ContainingSymbol.ToTestDisplayString()) 26362Assert.Same(baseType.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26369switch (context.ContainingSymbol.ToTestDisplayString()) 26385Assert.Same(record.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26399Assert.Equal("B", context.ContainingSymbol.ToTestDisplayString()); 26404Assert.Equal("C", context.ContainingSymbol.ToTestDisplayString()); 26413Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 26417Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 26421Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26433switch (context.ContainingSymbol.ToTestDisplayString()) 26450switch (context.ContainingSymbol.ToTestDisplayString()) 26478Assert.Equal("A..ctor([System.Int32 X = 0])", context.ContainingSymbol.ToTestDisplayString()); 26482Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 26486Assert.Equal("C..ctor([System.Int32 Z = 4])", context.ContainingSymbol.ToTestDisplayString()); 26504Assert.Equal("B..ctor([System.Int32 Y = 1])", context.ContainingSymbol.ToTestDisplayString()); 26508Assert.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)