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)
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)
26214
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
26218
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
26222
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
26227
Assert.Equal("System.Int32 B.M()", context.
ContainingSymbol
.ToTestDisplayString());
26231
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26235
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26242
Assert.Same(literal.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
26253
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
26257
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
26261
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26268
Assert.Same(equalsValue.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
26279
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26286
Assert.Same(initializer.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
26292
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26302
switch (context.
ContainingSymbol
.ToTestDisplayString())
26317
Assert.Same(baseType.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
26324
switch (context.
ContainingSymbol
.ToTestDisplayString())
26340
Assert.Same(record.SyntaxTree, context.
ContainingSymbol
!.DeclaringSyntaxReferences.Single().SyntaxTree);
26354
Assert.Equal("B", context.
ContainingSymbol
.ToTestDisplayString());
26359
Assert.Equal("C", context.
ContainingSymbol
.ToTestDisplayString());
26368
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
26372
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
26376
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26388
switch (context.
ContainingSymbol
.ToTestDisplayString())
26405
switch (context.
ContainingSymbol
.ToTestDisplayString())
26433
Assert.Equal("A..ctor([System.Int32 X = 0])", context.
ContainingSymbol
.ToTestDisplayString());
26437
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
26441
Assert.Equal("C..ctor([System.Int32 Z = 4])", context.
ContainingSymbol
.ToTestDisplayString());
26459
Assert.Equal("B..ctor([System.Int32 Y = 1])", context.
ContainingSymbol
.ToTestDisplayString());
26463
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)