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)
78if (semanticModel.GetEnclosingSymbol(node.SpanStart, cancellationToken) is IMethodSymbol methodWithDiagnostic)
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.State.cs (1)
399var 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)
21152Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 21381Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 21394Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 21446Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21492Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21552Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21610Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 21621Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21699Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 21710Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21895Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21932Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 21970Assert.Equal("C..ctor(System.Int32 X)", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 22007Assert.Same("<global namespace>", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 22086Assert.Same(symbol.ContainingSymbol, model.GetEnclosingSymbol(x.SpanStart)); 24650Assert.Equal("System.Int32 C.Z", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 24685Assert.Equal("System.Int32 C.Z", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 24719Assert.Equal("System.Int32 C.Z", model.GetEnclosingSymbol(x.SpanStart).ToTestDisplayString()); 24754Assert.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)
399var 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);