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)
73
var methodSymbol = (IMethodSymbol)analysisContext.
ContainingSymbol
!;
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (79)
Diagnostics\DiagnosticAnalyzerTests.cs (2)
1653
if (nodeContext.
ContainingSymbol
.Name.StartsWith("Funky") && nodeContext.Compilation.Language == "C#")
4135
var diagnostic = CodeAnalysis.Diagnostic.Create(Rule, context.Node.GetLocation(), context.Node.Kind(), context.
ContainingSymbol
.Name);
Diagnostics\GetDiagnosticsTests.cs (1)
966
context => analyzeNode(context.Node, context.
ContainingSymbol
, context.ReportDiagnostic),
Semantics\PrimaryConstructorTests.cs (46)
3774
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
3778
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
3782
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
3787
Assert.Equal("System.Int32 B.M()", context.
ContainingSymbol
.ToTestDisplayString());
3791
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
3795
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
3802
Assert.Same(literal.SyntaxTree, context.
ContainingSymbol
.DeclaringSyntaxReferences.Single().SyntaxTree);
3813
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
3817
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
3821
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
3828
Assert.Same(equalsValue.SyntaxTree, context.
ContainingSymbol
.DeclaringSyntaxReferences.Single().SyntaxTree);
3839
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
3846
Assert.Same(initializer.SyntaxTree, context.
ContainingSymbol
.DeclaringSyntaxReferences.Single().SyntaxTree);
3852
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
3862
switch (context.
ContainingSymbol
.ToTestDisplayString())
3877
Assert.Same(baseType.SyntaxTree, context.
ContainingSymbol
.DeclaringSyntaxReferences.Single().SyntaxTree);
3884
switch (context.
ContainingSymbol
.ToTestDisplayString())
3904
Assert.Same(@class.SyntaxTree, context.
ContainingSymbol
.DeclaringSyntaxReferences.Single().SyntaxTree);
3918
Assert.Equal("B", context.
ContainingSymbol
.ToTestDisplayString());
3923
Assert.Equal("C", context.
ContainingSymbol
.ToTestDisplayString());
3932
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
3936
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
3940
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
3952
switch (context.
ContainingSymbol
.ToTestDisplayString())
3969
switch (context.
ContainingSymbol
.ToTestDisplayString())
3997
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
4001
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
4005
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
4023
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
4027
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
5276
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
5280
Assert.Equal("System.Int32 A.M()", context.
ContainingSymbol
.ToTestDisplayString());
5284
Assert.Equal("A..ctor(System.String S)", context.
ContainingSymbol
.ToTestDisplayString());
5291
Assert.Same(literal.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
5302
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
5309
Assert.Same(equalsValue.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
5320
Assert.Equal("A..ctor(System.String S)", context.
ContainingSymbol
.ToTestDisplayString());
5327
Assert.Same(initializer.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
5333
Assert.Equal("A..ctor(System.String S)", context.
ContainingSymbol
.ToTestDisplayString());
5346
switch (context.
ContainingSymbol
.ToTestDisplayString())
5356
Assert.Same(record.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
5367
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
5379
switch (context.
ContainingSymbol
.ToTestDisplayString())
5407
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
5411
Assert.Equal("A..ctor(System.String S)", context.
ContainingSymbol
.ToTestDisplayString());
5429
Assert.Equal("A..ctor(System.String S)", context.
ContainingSymbol
.ToTestDisplayString());
Semantics\RecordTests.cs (30)
26259
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
26263
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
26267
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
26272
Assert.Equal("System.Int32 B.M()", context.
ContainingSymbol
.ToTestDisplayString());
26276
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26280
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26287
Assert.Same(literal.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
26298
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
26302
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
26306
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26313
Assert.Same(equalsValue.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
26324
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26331
Assert.Same(initializer.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
26337
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26347
switch (context.
ContainingSymbol
.ToTestDisplayString())
26362
Assert.Same(baseType.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
26369
switch (context.
ContainingSymbol
.ToTestDisplayString())
26385
Assert.Same(record.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
26399
Assert.Equal("B", context.
ContainingSymbol
.ToTestDisplayString());
26404
Assert.Equal("C", context.
ContainingSymbol
.ToTestDisplayString());
26413
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
26417
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
26421
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26433
switch (context.
ContainingSymbol
.ToTestDisplayString())
26450
switch (context.
ContainingSymbol
.ToTestDisplayString())
26478
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
26482
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
26486
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26504
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
26508
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (27)
Semantics\RecordStructTests.cs (16)
5975
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
5979
Assert.Equal("System.Int32 A.M()", context.
ContainingSymbol
.ToTestDisplayString());
5983
Assert.Equal("A..ctor(System.String S)", context.
ContainingSymbol
.ToTestDisplayString());
5990
Assert.Same(literal.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
6001
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
6008
Assert.Same(equalsValue.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
6019
Assert.Equal("A..ctor(System.String S)", context.
ContainingSymbol
.ToTestDisplayString());
6026
Assert.Same(initializer.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
6032
Assert.Equal("A..ctor(System.String S)", context.
ContainingSymbol
.ToTestDisplayString());
6045
switch (context.
ContainingSymbol
.ToTestDisplayString())
6055
Assert.Same(record.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
6066
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
6078
switch (context.
ContainingSymbol
.ToTestDisplayString())
6106
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
6110
Assert.Equal("A..ctor(System.String S)", context.
ContainingSymbol
.ToTestDisplayString());
6128
Assert.Equal("A..ctor(System.String S)", context.
ContainingSymbol
.ToTestDisplayString());
Semantics\TopLevelStatementsTests.cs (11)
6454
Assert.Equal("<top-level-statements-entry-point>", context.
ContainingSymbol
.ToTestDisplayString());
6455
Assert.Same(globalStatement.SyntaxTree, context.
ContainingSymbol
.DeclaringSyntaxReferences.Single().SyntaxTree);
6484
switch (context.
ContainingSymbol
.ToTestDisplayString())
7073
Assert.Equal("<top-level-statements-entry-point>", context.
ContainingSymbol
.ToTestDisplayString());
7078
Assert.Equal("void Test.M()", context.
ContainingSymbol
.ToTestDisplayString());
7086
var decl = (CSharpSyntaxNode)context.
ContainingSymbol
.DeclaringSyntaxReferences.Single().GetSyntax();
7103
switch (context.
ContainingSymbol
.ToTestDisplayString())
7187
Assert.Equal("<global namespace>", context.
ContainingSymbol
.ToTestDisplayString());
7192
Assert.Equal("Test", context.
ContainingSymbol
.ToTestDisplayString());
7197
Assert.Equal("void Test.M()", context.
ContainingSymbol
.ToTestDisplayString());
7208
switch (context.
ContainingSymbol
.ToTestDisplayString())
Microsoft.CodeAnalysis.Test.Utilities (4)
Diagnostics\CommonDiagnosticAnalyzers.cs (4)
1561
sortedCallbackSyntaxNodeNames.Add($"{context.
ContainingSymbol
.Name}(IsGeneratedCode:{context.IsGeneratedCode})"),
2762
ReportDiagnostics($"RegisterSyntaxNodeAction({syntaxNodeContext.Node}) in RegisterSymbolStartAction", syntaxNodeContext.Node.SyntaxTree, syntaxNodeContext.
ContainingSymbol
, syntaxNodeContext.ReportDiagnostic),
2795
ReportDiagnostics($"RegisterSyntaxNodeAction({syntaxNodeContext.Node})", syntaxNodeContext.Node.SyntaxTree, syntaxNodeContext.
ContainingSymbol
, syntaxNodeContext.ReportDiagnostic),
2808
ReportDiagnostics($"RegisterSyntaxNodeAction({syntaxNodeContext.Node}) in RegisterCodeBlockStartAction", syntaxNodeContext.Node.SyntaxTree, syntaxNodeContext.
ContainingSymbol
, syntaxNodeContext.ReportDiagnostic),
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (2)
Diagnostics\DiagnosticAnalyzerTests.vb (1)
961
If nodeContext.
ContainingSymbol
.Name.StartsWith("Funky") AndAlso nodeContext.Compilation.Language = "Visual Basic" Then
Diagnostics\GetDiagnosticsTests.vb (1)
628
AnalyzeNode(context.Node, context.
ContainingSymbol
, AddressOf context.ReportDiagnostic)