82 references to GetEnclosingSymbol
Microsoft.CodeAnalysis.CodeStyle (2)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SemanticModelExtensions.cs (2)
61return semanticModel.GetEnclosingSymbol(position, cancellationToken) 68for (var symbol = semanticModel.GetEnclosingSymbol(position, cancellationToken);
Microsoft.CodeAnalysis.CodeStyle.Fixes (2)
src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (1)
87if (semanticModel.GetEnclosingSymbol(node.SpanStart, cancellationToken) is IMethodSymbol methodWithDiagnostic)
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.State.cs (1)
393var symbol = semanticModel.GetEnclosingSymbol(position, cancellationToken);
Microsoft.CodeAnalysis.CSharp (1)
Operations\CSharpOperationFactory.cs (1)
2077legacyMode ? null : new SynthesizedLocal((_semanticModel.GetEnclosingSymbol(boundLockStatement.Syntax.SpanStart) as IMethodSymbol).GetSymbol(),
Microsoft.CodeAnalysis.CSharp.CodeStyle (1)
src\Analyzers\CSharp\Analyzers\UseLocalFunction\CSharpUseLocalFunctionDiagnosticAnalyzer.cs (1)
401var localEnclosingSymbol = semanticModel.GetEnclosingSymbol(localDeclaration.SpanStart, cancellationToken);
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (2)
src\Analyzers\CSharp\CodeFixes\Iterator\CSharpAddYieldCodeFixProvider.cs (1)
106var symbol = model.GetEnclosingSymbol(node.Span.Start, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
2015var enclosingSymbol = semanticModel.GetEnclosingSymbol(position, cancellationToken);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (38)
Semantics\PrimaryConstructorTests.cs (19)
1080Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 1307Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 1320Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 1372Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 1418Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 1478Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 1536Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 1547Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 1625Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 1636Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 1821Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 1861Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 1902Assert.Equal("C..ctor(System.Int32 X)", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 1974Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 2432Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 2648Assert.Equal("System.Int32 C.Z", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 2686Assert.Equal("System.Int32 C.Z", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 2723Assert.Equal("System.Int32 C.Z", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 2759Assert.Equal("lambda expression", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString());
Semantics\RecordTests.cs (19)
21197Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 21426Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 21439Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 21491Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21537Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21597Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21655Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 21666Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21744Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 21755Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21940Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21977Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 22015Assert.Equal("C..ctor(System.Int32 X)", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 22052Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 22131Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 24695Assert.Equal("System.Int32 C.Z", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 24730Assert.Equal("System.Int32 C.Z", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 24764Assert.Equal("System.Int32 C.Z", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 24799Assert.Equal("lambda expression", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString());
Microsoft.CodeAnalysis.CSharp.Features (6)
ConvertLinq\ConvertForEachToLinqQuery\CSharpConvertForEachToLinqQueryProvider.cs (1)
289.Where(statement => Equals(semanticModel.GetEnclosingSymbol(
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (1)
780declaredSymbol = _semanticModel.GetEnclosingSymbol(node.SpanStart, _cancellationToken);
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (2)
1412return model.GetEnclosingSymbol(node.SpanStart, cancellationToken); 1417return model.GetEnclosingSymbol(primaryCtorBase.ArgumentList.SpanStart, cancellationToken);
src\Analyzers\CSharp\Analyzers\UseLocalFunction\CSharpUseLocalFunctionDiagnosticAnalyzer.cs (1)
401var localEnclosingSymbol = semanticModel.GetEnclosingSymbol(localDeclaration.SpanStart, cancellationToken);
src\Analyzers\CSharp\CodeFixes\Iterator\CSharpAddYieldCodeFixProvider.cs (1)
106var symbol = model.GetEnclosingSymbol(node.Span.Start, cancellationToken);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (7)
Semantics\LambdaTests.cs (3)
3043var lambda = (IMethodSymbol)model.GetEnclosingSymbol(contentType.SpanStart); 3050lambda = (IMethodSymbol)model.GetEnclosingSymbol(b.SpanStart); 3055Assert.Equal("void Program.method1()", model.GetEnclosingSymbol(parameterSyntax.SpanStart).ToTestDisplayString());
Semantics\RecordStructTests.cs (4)
2601Assert.Equal("System.Int32 C.Z", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 2636Assert.Equal("System.Int32 C.Z", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 2670Assert.Equal("System.Int32 C.Z", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 2705Assert.Equal("lambda expression", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString());
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (5)
Compilation\SemanticModelAPITests.cs (4)
4031var discarded = model.GetEnclosingSymbol(match.Index); 4060var discarded = model.GetEnclosingSymbol(match.Index); 4085var discarded1 = model.GetEnclosingSymbol(source.LastIndexOf(" => x")); 4086var discarded2 = model.GetEnclosingSymbol(source.IndexOf(" => x"));
DocumentationComments\ParameterTests.cs (1)
651Assert.Equal(type, model.GetEnclosingSymbol(position));
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (4)
Syntax\LambdaUtilitiesTests.cs (4)
47var enclosingMethod = (IMethodSymbol)model.GetEnclosingSymbol(span.Value.Start); 58Assert.Equal("C", model.GetEnclosingSymbol(methodDef.SpanStart).ToTestDisplayString()); 59Assert.Equal("C", model.GetEnclosingSymbol(methodDef.ParameterList.CloseParenToken.SpanStart).ToTestDisplayString()); 60Assert.Equal("void C.M()", model.GetEnclosingSymbol(methodDef.Body.SpanStart).ToTestDisplayString());
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
2015var enclosingSymbol = semanticModel.GetEnclosingSymbol(position, cancellationToken);
Microsoft.CodeAnalysis.Features (2)
CodeLens\CodeLensReferencesService.cs (1)
219var enclosingSymbol = semanticModel.GetEnclosingSymbol(location.SourceSpan.Start, cancellationToken);
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.State.cs (1)
393var symbol = semanticModel.GetEnclosingSymbol(position, cancellationToken);
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (1)
src\Analyzers\VisualBasic\CodeFixes\Iterator\VisualBasicConvertToIteratorCodeFixProvider.vb (1)
58Dim symbol = model.GetEnclosingSymbol(node.Span.Start, cancellationToken)
Microsoft.CodeAnalysis.VisualBasic.Features (3)
EditAndContinue\VisualBasicEditAndContinueAnalyzer.vb (1)
1004Return DirectCast(model.GetEnclosingSymbol(lambdaExpressionSyntax.SubOrFunctionHeader.Span.End, cancellationToken), IMethodSymbol)
SignatureHelp\RaiseEventStatementSignatureHelpProvider.vb (1)
79Dim containingType = semanticModel.GetEnclosingSymbol(position, cancellationToken).ContainingType
src\Analyzers\VisualBasic\CodeFixes\Iterator\VisualBasicConvertToIteratorCodeFixProvider.vb (1)
58Dim symbol = model.GetEnclosingSymbol(node.Span.Start, cancellationToken)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (1)
Semantics\GetExtendedSemanticInfoTests.vb (1)
8523Dim containingType = DirectCast(model, SemanticModel).GetEnclosingSymbol(SLDeclaration.SpanStart)
Microsoft.CodeAnalysis.Workspaces (4)
FindSymbols\ReferenceLocationExtensions.cs (1)
73var enclosingSymbol = semanticModel.GetEnclosingSymbol(reference.Location.SourceSpan.Start);
Recommendations\AbstractRecommendationService.cs (1)
46var enclosingSymbol = context.SemanticModel.GetEnclosingSymbol(context.LeftToken.SpanStart, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SemanticModelExtensions.cs (2)
61return semanticModel.GetEnclosingSymbol(position, cancellationToken) 68for (var symbol = semanticModel.GetEnclosingSymbol(position, cancellationToken);
Microsoft.Interop.LibraryImportGenerator (2)
Analyzers\CustomMarshallerAttributeFixer.cs (2)
39var entryPointTypeSymbol = (INamedTypeSymbol)model.GetEnclosingSymbol(diagnostic.Location.SourceSpan.Start, fixAllContext.CancellationToken); 158var entryPointTypeSymbol = (INamedTypeSymbol)model.GetEnclosingSymbol(node.SpanStart, ct);