src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (12)
36private readonly Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> _analyzeLocalFunctionOrLambdaInvocation;
55private readonly PooledDictionary<IMethodSymbol, ControlFlowGraph> _localFunctionTargetsToAccessingCfgMap;
79PooledHashSet<IMethodSymbol> lambdaOrLocalFunctionsBeingAnalyzed,
80Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation,
82PooledDictionary<IMethodSymbol, ControlFlowGraph> localFunctionTargetsToAccessingCfgMap,
112protected override PooledHashSet<IMethodSymbol> LambdaOrLocalFunctionsBeingAnalyzed { get; }
119Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation)
133lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
136localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
157IMethodSymbol lambdaOrLocalFunction,
336ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
501protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (48)
26public static bool IsObjectEqualsOverride(this IMethodSymbol method)
40public static bool IsObjectEquals(this IMethodSymbol method)
54public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
69private static bool IsObjectMethodOverride(IMethodSymbol method)
71IMethodSymbol overriddenMethod = method.OverriddenMethod;
89public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
93return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
100public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
109public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
119public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
141public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
163private static bool HasDisposeMethodSignature(this IMethodSymbol method)
171public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
181public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
192private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
200private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
207private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
223private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
236private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
248public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
263this IMethodSymbol method,
311public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
317public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
324public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
329public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
331var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
334foreach (var member in methods)
364public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
385public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
394public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
406public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
420private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
426public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
432IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
465public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
474public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
483public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
493public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
505public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
519public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
527public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
536public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
547public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
549ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
566.OfType<IMethodSymbol>()
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.MethodSymbolKey.cs (22)
11private sealed class ReducedExtensionMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
15public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
24SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
41using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
42foreach (var reducedFrom in reducedFromResolution.OfType<IMethodSymbol>())
55private sealed class ConstructedMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
59public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
66SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
70using var typeArguments = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
101using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
102foreach (var method in constructedFrom.OfType<IMethodSymbol>())
123private sealed class MethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
127public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
160SymbolKeyReader reader, IMethodSymbol? contextualSymbol, out string? failureReason)
179using var methods = GetMembersOfNamedType<IMethodSymbol>(containingType, metadataName: null);
180IMethodSymbol? method = null;
181foreach (var candidate in methods)
223_ = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
243private static IMethodSymbol? Resolve(
244SymbolKeyReader reader, bool isPartialImplementationPart, IMethodSymbol method)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (14)
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
379symbol = ((IMethodSymbol)symbol).GetConstructedReducedFrom()!;
384newSymbol = ((IMethodSymbol)newSymbol).GetConstructedReducedFrom()!;
404if (symbol is IMethodSymbol methodSymbol && newSymbol is IMethodSymbol newMethodSymbol)
478if (symbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } methodSymbol &&
479newSymbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } newMethodSymbol)
757return symbol is IMethodSymbol { ContainingType.SpecialType: SpecialType.System_Object }
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
806private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
875=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
1048return receiverSymbol is IMethodSymbol or IPropertySymbol;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\SymbolEquivalenceComparer.EquivalenceVisitor.cs (8)
124SymbolKind.Method => MethodsAreEquivalent((IMethodSymbol)x, (IMethodSymbol)y, equivalentTypesWithDifferingAssemblies),
170private bool MethodsAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies, bool considerReturnRefKinds = false)
186var rx = x.ReducedFrom;
187var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (7)
53public TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
82public SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
125protected abstract TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
147public abstract SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
348IMethodSymbol method => CreateMethodDeclaration(method, codeGenerationDestination, info, cancellationToken),
366IMethodSymbol method => AddMethod(currentDestination, method, info, availableIndices, cancellationToken),
446public Task<Document> AddMethodAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IMethodSymbol method, CancellationToken cancellationToken)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (28)
33IMethodSymbol? addMethod = null,
34IMethodSymbol? removeMethod = null,
35IMethodSymbol? raiseMethod = null)
52IMethodSymbol? getMethod,
53IMethodSymbol? setMethod,
80ImmutableArray<IParameterSymbol> parameters, IMethodSymbol? getMethod, IMethodSymbol? setMethod,
119public static IMethodSymbol CreateConstructorSymbol(
138public static IMethodSymbol CreateDestructorSymbol(
147internal static IMethodSymbol CreateMethodSymbol(
154ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
172public static IMethodSymbol CreateMethodSymbol(
176ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
191public static IMethodSymbol CreateOperatorSymbol(
219public static IMethodSymbol CreateConversionSymbol(
244public static IMethodSymbol CreateConversionSymbol(
356internal static IMethodSymbol CreateAccessorSymbol(
357IMethodSymbol accessor,
360ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
382public static IMethodSymbol CreateAccessorSymbol(
470var invokeMethod = CreateMethodSymbol(
510internal static IMethodSymbol CreateMethodSymbol(
511IMethodSymbol method,
515ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
549IMethodSymbol? getMethod = null,
550IMethodSymbol? setMethod = null,
575IMethodSymbol? addMethod = null,
576IMethodSymbol? removeMethod = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
106protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
118if (impl is IMethodSymbol implMethod)
136.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
137SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
152.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
165(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
168return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
216public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
219public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
222public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
249public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
261public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (12)
36private readonly Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> _analyzeLocalFunctionOrLambdaInvocation;
55private readonly PooledDictionary<IMethodSymbol, ControlFlowGraph> _localFunctionTargetsToAccessingCfgMap;
79PooledHashSet<IMethodSymbol> lambdaOrLocalFunctionsBeingAnalyzed,
80Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation,
82PooledDictionary<IMethodSymbol, ControlFlowGraph> localFunctionTargetsToAccessingCfgMap,
112protected override PooledHashSet<IMethodSymbol> LambdaOrLocalFunctionsBeingAnalyzed { get; }
119Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation)
133lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
136localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
157IMethodSymbol lambdaOrLocalFunction,
336ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
501protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (48)
26public static bool IsObjectEqualsOverride(this IMethodSymbol method)
40public static bool IsObjectEquals(this IMethodSymbol method)
54public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
69private static bool IsObjectMethodOverride(IMethodSymbol method)
71IMethodSymbol overriddenMethod = method.OverriddenMethod;
89public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
93return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
100public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
109public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
119public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
141public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
163private static bool HasDisposeMethodSignature(this IMethodSymbol method)
171public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
181public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
192private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
200private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
207private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
223private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
236private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
248public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
263this IMethodSymbol method,
311public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
317public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
324public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
329public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
331var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
334foreach (var member in methods)
364public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
385public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
394public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
406public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
420private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
426public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
432IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
465public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
474public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
483public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
493public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
505public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
519public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
527public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
536public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
547public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
549ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
566.OfType<IMethodSymbol>()
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.MethodSymbolKey.cs (22)
11private sealed class ReducedExtensionMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
15public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
24SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
41using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
42foreach (var reducedFrom in reducedFromResolution.OfType<IMethodSymbol>())
55private sealed class ConstructedMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
59public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
66SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
70using var typeArguments = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
101using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
102foreach (var method in constructedFrom.OfType<IMethodSymbol>())
123private sealed class MethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
127public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
160SymbolKeyReader reader, IMethodSymbol? contextualSymbol, out string? failureReason)
179using var methods = GetMembersOfNamedType<IMethodSymbol>(containingType, metadataName: null);
180IMethodSymbol? method = null;
181foreach (var candidate in methods)
223_ = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
243private static IMethodSymbol? Resolve(
244SymbolKeyReader reader, bool isPartialImplementationPart, IMethodSymbol method)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (14)
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
379symbol = ((IMethodSymbol)symbol).GetConstructedReducedFrom()!;
384newSymbol = ((IMethodSymbol)newSymbol).GetConstructedReducedFrom()!;
404if (symbol is IMethodSymbol methodSymbol && newSymbol is IMethodSymbol newMethodSymbol)
478if (symbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } methodSymbol &&
479newSymbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } newMethodSymbol)
757return symbol is IMethodSymbol { ContainingType.SpecialType: SpecialType.System_Object }
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
806private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
875=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
1048return receiverSymbol is IMethodSymbol or IPropertySymbol;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\SymbolEquivalenceComparer.EquivalenceVisitor.cs (8)
124SymbolKind.Method => MethodsAreEquivalent((IMethodSymbol)x, (IMethodSymbol)y, equivalentTypesWithDifferingAssemblies),
170private bool MethodsAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies, bool considerReturnRefKinds = false)
186var rx = x.ReducedFrom;
187var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (7)
53public TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
82public SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
125protected abstract TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
147public abstract SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
348IMethodSymbol method => CreateMethodDeclaration(method, codeGenerationDestination, info, cancellationToken),
366IMethodSymbol method => AddMethod(currentDestination, method, info, availableIndices, cancellationToken),
446public Task<Document> AddMethodAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IMethodSymbol method, CancellationToken cancellationToken)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (28)
33IMethodSymbol? addMethod = null,
34IMethodSymbol? removeMethod = null,
35IMethodSymbol? raiseMethod = null)
52IMethodSymbol? getMethod,
53IMethodSymbol? setMethod,
80ImmutableArray<IParameterSymbol> parameters, IMethodSymbol? getMethod, IMethodSymbol? setMethod,
119public static IMethodSymbol CreateConstructorSymbol(
138public static IMethodSymbol CreateDestructorSymbol(
147internal static IMethodSymbol CreateMethodSymbol(
154ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
172public static IMethodSymbol CreateMethodSymbol(
176ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
191public static IMethodSymbol CreateOperatorSymbol(
219public static IMethodSymbol CreateConversionSymbol(
244public static IMethodSymbol CreateConversionSymbol(
356internal static IMethodSymbol CreateAccessorSymbol(
357IMethodSymbol accessor,
360ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
382public static IMethodSymbol CreateAccessorSymbol(
470var invokeMethod = CreateMethodSymbol(
510internal static IMethodSymbol CreateMethodSymbol(
511IMethodSymbol method,
515ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
549IMethodSymbol? getMethod = null,
550IMethodSymbol? setMethod = null,
575IMethodSymbol? addMethod = null,
576IMethodSymbol? removeMethod = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
106protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
118if (impl is IMethodSymbol implMethod)
136.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
137SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
152.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
165(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
168return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
216public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
219public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
222public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
249public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
261public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor)
src\a03b2aad21e28a8a\PropertySetAnalysis.PropertySetDataFlowOperationVisitor.cs (14)
38private readonly ImmutableDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>.Builder _hazardousUsageBuilder;
40private readonly ImmutableHashSet<IMethodSymbol>.Builder _visitedLocalFunctions;
62this._hazardousUsageBuilder = ImmutableDictionary.CreateBuilder<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>();
64this._visitedLocalFunctions = ImmutableHashSet.CreateBuilder<IMethodSymbol>();
86public ImmutableDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult> HazardousUsages => this._hazardousUsageBuilder.ToImmutable();
88public ImmutableHashSet<IMethodSymbol> VisitedLocalFunctions => this._visitedLocalFunctions.ToImmutable();
456public override PropertySetAbstractValue VisitInvocation_NonLambdaOrDelegateOrLocalFunction(IMethodSymbol method, IOperation? visitedInstance, ImmutableArray<IArgumentOperation> visitedArguments, bool invokedAsDelegate, IOperation originalOperation, PropertySetAbstractValue defaultValue)
513IMethodSymbol method,
596IMethodSymbol? methodSymbol,
618IMethodSymbol? methodSymbol,
623(Location, IMethodSymbol?) key = (operationSyntax.GetLocation(), methodSymbol);
635public override PropertySetAbstractValue VisitInvocation_LocalFunction(IMethodSymbol localFunction, ImmutableArray<IArgumentOperation> visitedArguments, IOperation originalOperation, PropertySetAbstractValue defaultValue)
675foreach (KeyValuePair<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult> kvp in subResult.HazardousUsages)
687foreach (IMethodSymbol localFunctionSymbol in subResult.VisitedLocalFunctions)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (12)
36private readonly Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> _analyzeLocalFunctionOrLambdaInvocation;
55private readonly PooledDictionary<IMethodSymbol, ControlFlowGraph> _localFunctionTargetsToAccessingCfgMap;
79PooledHashSet<IMethodSymbol> lambdaOrLocalFunctionsBeingAnalyzed,
80Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation,
82PooledDictionary<IMethodSymbol, ControlFlowGraph> localFunctionTargetsToAccessingCfgMap,
112protected override PooledHashSet<IMethodSymbol> LambdaOrLocalFunctionsBeingAnalyzed { get; }
119Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation)
133lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
136localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
157IMethodSymbol lambdaOrLocalFunction,
336ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
501protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (48)
26public static bool IsObjectEqualsOverride(this IMethodSymbol method)
40public static bool IsObjectEquals(this IMethodSymbol method)
54public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
69private static bool IsObjectMethodOverride(IMethodSymbol method)
71IMethodSymbol overriddenMethod = method.OverriddenMethod;
89public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
93return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
100public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
109public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
119public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
141public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
163private static bool HasDisposeMethodSignature(this IMethodSymbol method)
171public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
181public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
192private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
200private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
207private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
223private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
236private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
248public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
263this IMethodSymbol method,
311public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
317public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
324public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
329public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
331var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
334foreach (var member in methods)
364public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
385public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
394public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
406public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
420private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
426public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
432IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
465public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
474public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
483public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
493public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
505public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
519public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
527public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
536public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
547public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
549ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
566.OfType<IMethodSymbol>()
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\CopyAnalysis\CopyAnalysis.CopyDataFlowOperationVisitor.cs (1)
573IMethodSymbol invokedMethod,
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\DisposeAnalysis\DisposeAnalysisContext.cs (1)
92IMethodSymbol invokedMethod,
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\GlobalFlowStateAnalysis\GlobalFlowStateAnalysisContext.cs (1)
75IMethodSymbol invokedMethod,
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PointsToAnalysis\PointsToAnalysisContext.cs (1)
69IMethodSymbol invokedMethod,
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PropertySetAnalysis\PropertySetAnalysis.cs (8)
150/// <returns>Dictionary of <see cref="Location"/> and <see cref="IMethodSymbol"/> pairs mapping to the kind of hazardous usage (Flagged or MaybeFlagged). The method in the key is null for return/initialization statements.</returns>
152public static PooledDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>? BatchGetOrComputeHazardousUsages(
186/// <returns>Dictionary of <see cref="Location"/> and <see cref="IMethodSymbol"/> pairs mapping to the kind of hazardous usage (Flagged or MaybeFlagged). The method in the key is null for return/initialization statements.</returns>
188public static PooledDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>? BatchGetOrComputeHazardousUsages(
199PooledDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>? allResults = null;
219foreach (IMethodSymbol localFunctionSymbol in enclosingControlFlowGraph.LocalFunctions)
264allResults ??= PooledDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>.GetInstance();
266foreach (KeyValuePair<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult> kvp
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PropertySetAnalysis\PropertySetAnalysisContext.cs (1)
108IMethodSymbol invokedMethod,
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\TaintedDataAnalysisContext.cs (1)
103IMethodSymbol invokedMethod,
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\ValueContentAnalysis\ValueContentAnalysisContext.cs (1)
75IMethodSymbol invokedMethod,
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\AnalysisEntityDataFlowOperationVisitor.cs (1)
465IMethodSymbol invokedMethod,
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\DataFlowOperationVisitor.cs (48)
55private ImmutableHashSet<IMethodSymbol>? _lazyContractCheckMethods;
65private readonly ImmutableHashSet<IMethodSymbol>.Builder _escapedLocalFunctions;
70private readonly ImmutableHashSet<IMethodSymbol>.Builder _analyzedLocalFunctions;
123private readonly ImmutableDictionary<IMethodSymbol, IDataFlowAnalysisResult<TAbstractAnalysisValue>>.Builder _standaloneLocalFunctionAnalysisResultsBuilder;
128private readonly Dictionary<IMethodSymbol, ControlFlowGraph?>? _interproceduralMethodToCfgMap;
153public ImmutableDictionary<IMethodSymbol, IDataFlowAnalysisResult<TAbstractAnalysisValue>> StandaloneLocalFunctionAnalysisResultsMap => _standaloneLocalFunctionAnalysisResultsBuilder.ToImmutable();
272.OfType<IMethodSymbol>().FirstOrDefault(HasDebugAssertSignature);
281_returnValueOperations = OwningSymbol is IMethodSymbol method && !method.ReturnsVoid ? new HashSet<IOperation>() : null;
283_standaloneLocalFunctionAnalysisResultsBuilder = ImmutableDictionary.CreateBuilder<IMethodSymbol, IDataFlowAnalysisResult<TAbstractAnalysisValue>>();
284_escapedLocalFunctions = ImmutableHashSet.CreateBuilder<IMethodSymbol>();
285_analyzedLocalFunctions = ImmutableHashSet.CreateBuilder<IMethodSymbol>();
345static bool HasDebugAssertSignature(IMethodSymbol method)
365if (OwningSymbol is IMethodSymbol method &&
554OwningSymbol is IMethodSymbol method &&
614foreach (var localFunction in DataFlowAnalysisContext.ControlFlowGraph.LocalFunctions)
632private bool IsStandaloneAnalysisRequiredForLocalFunction(IMethodSymbol localFunction)
837if (OwningSymbol is IMethodSymbol method &&
982private bool IsContractCheckMethod(IMethodSymbol method)
993var validationMethods = requiresMethods.Concat(assumeMethods).Concat(assertMethods).OfType<IMethodSymbol>().Where(m => m.IsStatic && m.ReturnsVoid && !m.Parameters.IsEmpty && (m.Parameters[0].Type.SpecialType == SpecialType.System_Boolean));
1008private bool IsAnyDebugAssertMethod(IMethodSymbol method) =>
1014protected bool IsAnyAssertMethod(IMethodSymbol method)
1766bool IsOverrideOrImplementationOfEquatableEquals(IMethodSymbol methodSymbol)
1777var equalsMember = interfaceType.GetMembers("Equals").OfType<IMethodSymbol>().FirstOrDefault();
2127IMethodSymbol invokedMethod,
2203IMethodSymbol invokedMethod,
2241int currentMethodCallCount = currentMethodsBeingAnalyzed.Count(m => !(m.OwningSymbol is IMethodSymbol ms && ms.IsLambdaOrLocalFunctionOrDelegate()));
2552if (argumentOperation.Parameter!.ContainingSymbol is IMethodSymbol method &&
2596IMethodSymbol invokedMethod,
2633private void PerformStandaloneLocalFunctionInterproceduralAnalysis(IMethodSymbol localFunction)
2734IMethodSymbol invokedMethod)
3162var method = operation.Constructor!;
3181foreach ((IMethodSymbol method, _) in resolvedMethodTargetsOpt)
3227void PostVisitInvocation(IMethodSymbol targetMethod, ImmutableArray<IArgumentOperation> arguments)
3252void ProcessInterlockedOperation(IMethodSymbol targetMethod, ImmutableArray<IArgumentOperation> arguments, INamedTypeSymbol interlockedType)
3287using var _1 = PooledHashSet<(IMethodSymbol method, IOperation? instance)>.GetInstance(out var methodTargetsOptBuilder);
3312PooledHashSet<(IMethodSymbol method, IOperation? instance)> methodTargetsOptBuilder,
3318PooledHashSet<(IMethodSymbol method, IOperation? instance)> methodTargetsOptBuilder,
3325PooledHashSet<(IMethodSymbol method, IOperation? instance)> methodTargetsOptBuilder,
3336var targetMethod = invocation.TargetMethod;
3379void AddMethodTarget(IMethodSymbol method, IOperation? instance)
3438out ImmutableHashSet<(IMethodSymbol method, IOperation? instance)>? resolvedMethodTargets)
3442using var _1 = PooledHashSet<(IMethodSymbol method, IOperation? instance)>.GetInstance(out var methodTargetsOptBuilder);
3534IMethodSymbol method,
3547private ControlFlowGraph? GetInterproceduralControlFlowGraph(IMethodSymbol method)
3577IMethodSymbol localFunction,
4196private IMethodSymbol? DebugAssertMethod { get; }
4225private protected DisposeMethodKind GetDisposeMethodKind(IMethodSymbol method)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.MethodSymbolKey.cs (22)
11private sealed class ReducedExtensionMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
15public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
24SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
41using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
42foreach (var reducedFrom in reducedFromResolution.OfType<IMethodSymbol>())
55private sealed class ConstructedMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
59public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
66SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
70using var typeArguments = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
101using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
102foreach (var method in constructedFrom.OfType<IMethodSymbol>())
123private sealed class MethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
127public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
160SymbolKeyReader reader, IMethodSymbol? contextualSymbol, out string? failureReason)
179using var methods = GetMembersOfNamedType<IMethodSymbol>(containingType, metadataName: null);
180IMethodSymbol? method = null;
181foreach (var candidate in methods)
223_ = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
243private static IMethodSymbol? Resolve(
244SymbolKeyReader reader, bool isPartialImplementationPart, IMethodSymbol method)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (14)
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
379symbol = ((IMethodSymbol)symbol).GetConstructedReducedFrom()!;
384newSymbol = ((IMethodSymbol)newSymbol).GetConstructedReducedFrom()!;
404if (symbol is IMethodSymbol methodSymbol && newSymbol is IMethodSymbol newMethodSymbol)
478if (symbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } methodSymbol &&
479newSymbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } newMethodSymbol)
757return symbol is IMethodSymbol { ContainingType.SpecialType: SpecialType.System_Object }
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
806private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
875=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
1048return receiverSymbol is IMethodSymbol or IPropertySymbol;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\SymbolEquivalenceComparer.EquivalenceVisitor.cs (8)
124SymbolKind.Method => MethodsAreEquivalent((IMethodSymbol)x, (IMethodSymbol)y, equivalentTypesWithDifferingAssemblies),
170private bool MethodsAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies, bool considerReturnRefKinds = false)
186var rx = x.ReducedFrom;
187var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (12)
36private readonly Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> _analyzeLocalFunctionOrLambdaInvocation;
55private readonly PooledDictionary<IMethodSymbol, ControlFlowGraph> _localFunctionTargetsToAccessingCfgMap;
79PooledHashSet<IMethodSymbol> lambdaOrLocalFunctionsBeingAnalyzed,
80Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation,
82PooledDictionary<IMethodSymbol, ControlFlowGraph> localFunctionTargetsToAccessingCfgMap,
112protected override PooledHashSet<IMethodSymbol> LambdaOrLocalFunctionsBeingAnalyzed { get; }
119Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation)
133lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
136localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
157IMethodSymbol lambdaOrLocalFunction,
336ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
501protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
src\roslyn\src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (5)
87protected abstract TExpression? GetGetterExpression(IMethodSymbol getMethod, CancellationToken cancellationToken);
88protected abstract TExpression? GetSetterExpression(SemanticModel semanticModel, IMethodSymbol setMethod, CancellationToken cancellationToken);
91SemanticModel semanticModel, IMethodSymbol accessor, HashSet<string> fieldNames, HashSet<IFieldSymbol> result, CancellationToken cancellationToken);
257IMethodSymbol getMethod,
275SemanticModel semanticModel, IMethodSymbol setMethod, HashSet<string> fieldNames, CancellationToken cancellationToken)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.MethodSymbolKey.cs (22)
11private sealed class ReducedExtensionMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
15public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
24SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
41using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
42foreach (var reducedFrom in reducedFromResolution.OfType<IMethodSymbol>())
55private sealed class ConstructedMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
59public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
66SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
70using var typeArguments = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
101using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
102foreach (var method in constructedFrom.OfType<IMethodSymbol>())
123private sealed class MethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
127public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
160SymbolKeyReader reader, IMethodSymbol? contextualSymbol, out string? failureReason)
179using var methods = GetMembersOfNamedType<IMethodSymbol>(containingType, metadataName: null);
180IMethodSymbol? method = null;
181foreach (var candidate in methods)
223_ = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
243private static IMethodSymbol? Resolve(
244SymbolKeyReader reader, bool isPartialImplementationPart, IMethodSymbol method)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (14)
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
379symbol = ((IMethodSymbol)symbol).GetConstructedReducedFrom()!;
384newSymbol = ((IMethodSymbol)newSymbol).GetConstructedReducedFrom()!;
404if (symbol is IMethodSymbol methodSymbol && newSymbol is IMethodSymbol newMethodSymbol)
478if (symbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } methodSymbol &&
479newSymbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } newMethodSymbol)
757return symbol is IMethodSymbol { ContainingType.SpecialType: SpecialType.System_Object }
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
806private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
875=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
1048return receiverSymbol is IMethodSymbol or IPropertySymbol;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\SymbolEquivalenceComparer.EquivalenceVisitor.cs (8)
124SymbolKind.Method => MethodsAreEquivalent((IMethodSymbol)x, (IMethodSymbol)y, equivalentTypesWithDifferingAssemblies),
170private bool MethodsAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies, bool considerReturnRefKinds = false)
186var rx = x.ReducedFrom;
187var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
src\roslyn\src\Analyzers\Core\CodeFixes\GenerateParameterizedMember\AbstractGenerateConversionService.cs (2)
24protected abstract bool TryInitializeImplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, [NotNullWhen(true)] out IMethodSymbol? methodSymbol, [NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn);
25protected abstract bool TryInitializeExplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, [NotNullWhen(true)] out IMethodSymbol? methodSymbol, [NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn);
src\roslyn\src\Analyzers\Core\CodeFixes\ImplementAbstractClass\ImplementAbstractClassData.cs (7)
167IMethodSymbol method => GenerateMethod(compilation, method, throughMember, modifiers, accessibility),
175Compilation compilation, IMethodSymbol method, ISymbol? throughMember,
210var getMethod = ShouldGenerateAccessor(property.GetMethod)
219var setMethod = ShouldGenerateAccessor(property.SetMethod)
246private IMethodSymbol? GetEventAddOrRemoveMethod(
247IEventSymbol @event, IMethodSymbol? accessor, ISymbol? throughMember,
265private bool ShouldGenerateAccessor([NotNullWhen(true)] IMethodSymbol? method)
src\roslyn\src\Analyzers\Core\CodeFixes\ImplementInterface\ImplementInterfaceGenerator.cs (8)
261if (member is not IMethodSymbol method)
300IMethodSymbol method => [GenerateMethod(compilation, method, conflictingMember as IMethodSymbol, accessibility, modifiers, generateAbstractly, useExplicitInterfaceSymbol, memberName)],
309var accessor = CodeGenerationSymbolFactory.CreateAccessorSymbol(
324private IMethodSymbol? GetAddOrRemoveMethod(
325IEventSymbol @event, bool generateInvisibly, IMethodSymbol accessor, string memberName,
361if (member is IMethodSymbol method1 && baseMember is IMethodSymbol method2)
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (12)
36IMethodSymbol methodSymbol,
67var methodSymbol = GetMethodSymbol(semanticModel, node, cancellationToken);
105IMethodSymbol methodSymbol,
122if (referencedSymbol.Definition is not IMethodSymbol definition)
150IMethodSymbol methodSymbol,
182private static IMethodSymbol? GetMethodSymbol(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
186return symbol as IMethodSymbol;
211var methodSymbol = GetMethodSymbol(semanticModel, node, cancellationToken);
261IMethodSymbol methodSymbol,
280var newMethod = (IMethodSymbol)semanticModel.GetRequiredDeclaredSymbol(newNode, cancellationToken);
291IMethodSymbol methodSymbol,
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (8)
25protected abstract SyntaxNode RemoveAsyncTokenAndFixReturnType(IMethodSymbol methodSymbol, SyntaxNode node, KnownTaskTypes knownTypes);
56var methodSymbol = (IMethodSymbol?)(semanticModel.GetDeclaredSymbol(node, cancellationToken) ?? semanticModel.GetSymbolInfo(node, cancellationToken).GetAnySymbol());
71private async Task<Solution> RenameThenRemoveAsyncTokenAsync(Document document, SyntaxNode node, IMethodSymbol methodSymbol, CancellationToken cancellationToken)
87var newMethod = (IMethodSymbol)semanticModel.GetRequiredDeclaredSymbol(newNode, cancellationToken);
95Document document, IMethodSymbol methodSymbol, SyntaxNode node, CancellationToken cancellationToken)
126if (semanticModel.GetDeclaredSymbol(methodDeclaration, cancellationToken) is IMethodSymbol methodSymbol)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (7)
53public TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
82public SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
125protected abstract TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
147public abstract SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
348IMethodSymbol method => CreateMethodDeclaration(method, codeGenerationDestination, info, cancellationToken),
366IMethodSymbol method => AddMethod(currentDestination, method, info, availableIndices, cancellationToken),
446public Task<Document> AddMethodAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IMethodSymbol method, CancellationToken cancellationToken)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (28)
33IMethodSymbol? addMethod = null,
34IMethodSymbol? removeMethod = null,
35IMethodSymbol? raiseMethod = null)
52IMethodSymbol? getMethod,
53IMethodSymbol? setMethod,
80ImmutableArray<IParameterSymbol> parameters, IMethodSymbol? getMethod, IMethodSymbol? setMethod,
119public static IMethodSymbol CreateConstructorSymbol(
138public static IMethodSymbol CreateDestructorSymbol(
147internal static IMethodSymbol CreateMethodSymbol(
154ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
172public static IMethodSymbol CreateMethodSymbol(
176ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
191public static IMethodSymbol CreateOperatorSymbol(
219public static IMethodSymbol CreateConversionSymbol(
244public static IMethodSymbol CreateConversionSymbol(
356internal static IMethodSymbol CreateAccessorSymbol(
357IMethodSymbol accessor,
360ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
382public static IMethodSymbol CreateAccessorSymbol(
470var invokeMethod = CreateMethodSymbol(
510internal static IMethodSymbol CreateMethodSymbol(
511IMethodSymbol method,
515ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
549IMethodSymbol? getMethod = null,
550IMethodSymbol? setMethod = null,
575IMethodSymbol? addMethod = null,
576IMethodSymbol? removeMethod = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
106protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
118if (impl is IMethodSymbol implMethod)
136.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
137SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
152.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
165(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
168return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
216public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
219public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
222public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
249public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
261public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (12)
32IMethodSymbol method,
45IMethodSymbol method,
60IMethodSymbol method,
75IMethodSymbol method, CodeGenerationDestination destination,
93IMethodSymbol method,
112IMethodSymbol method, CodeGenerationDestination destination,
165IMethodSymbol method, CodeGenerationDestination destination,
220IMethodSymbol method, bool isExplicit, CSharpCodeGenerationContextInfo info)
231IMethodSymbol method)
238private static SyntaxList<TypeParameterConstraintClauseSyntax> GenerateDefaultConstraints(IMethodSymbol method)
312IMethodSymbol method, CSharpCodeGenerationContextInfo info)
318IMethodSymbol method,
SignatureHelp\InvocationExpressionSignatureHelpProviderBase_DelegateAndFunctionPointerInvoke.cs (5)
18private static IMethodSymbol? GetDelegateInvokeMethod(
22var invokeMethod = delegateType.DelegateInvokeMethod;
39private static IList<SignatureHelpItem> GetDelegateOrFunctionPointerInvokeItems(InvocationExpressionSyntax invocationExpression, IMethodSymbol invokeMethod, SemanticModel semanticModel, IStructuralTypeDisplayService structuralTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, out int? selectedItem, CancellationToken cancellationToken)
58private static IList<SymbolDisplayPart> GetDelegateOrFunctionPointerInvokePreambleParts(IMethodSymbol invokeMethod, SemanticModel semanticModel, int position)
80IMethodSymbol invokeMethod, SemanticModel semanticModel, int position, IDocumentationCommentFormattingService formattingService, CancellationToken cancellationToken)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (12)
32IMethodSymbol method,
45IMethodSymbol method,
60IMethodSymbol method,
75IMethodSymbol method, CodeGenerationDestination destination,
93IMethodSymbol method,
112IMethodSymbol method, CodeGenerationDestination destination,
165IMethodSymbol method, CodeGenerationDestination destination,
220IMethodSymbol method, bool isExplicit, CSharpCodeGenerationContextInfo info)
231IMethodSymbol method)
238private static SyntaxList<TypeParameterConstraintClauseSyntax> GenerateDefaultConstraints(IMethodSymbol method)
312IMethodSymbol method, CSharpCodeGenerationContextInfo info)
318IMethodSymbol method,
AddConstructorParametersFromMembers\AddConstructorParametersFromMembersCodeRefactoringProvider.ConstructorCandidate.cs (1)
12IMethodSymbol Constructor,
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (86)
260protected abstract bool AreHandledEventsEqual(IMethodSymbol oldMethod, IMethodSymbol newMethod);
318SymbolKind.Method => GetDisplayName((IMethodSymbol)symbol),
348internal virtual string GetDisplayName(IMethodSymbol symbol)
450internal abstract IMethodSymbol GetLambdaExpressionSymbol(SemanticModel model, SyntaxNode lambdaExpression, CancellationToken cancellationToken);
2565protected static bool ReturnTypesEquivalent(IMethodSymbol oldMethod, IMethodSymbol newMethod, bool exact)
2654var oldMethod = (IMethodSymbol)oldMember;
2655var newMethod = (IMethodSymbol)newMember;
2661var newInvokeMethod = ((INamedTypeSymbol)newMember).DelegateInvokeMethod;
3038var oldPrimaryConstructor = (IMethodSymbol)oldSymbol;
3362if (oldSymbol is IMethodSymbol)
3759Debug.Assert(member is IPropertySymbol or IMethodSymbol);
3768var primaryConstructor = (IMethodSymbol)member;
3804IMethodSymbol? constructor,
3805IMethodSymbol? otherConstructor,
3815void AddEdits(IMethodSymbol? constructor, Compilation otherCompilation, bool isDelete)
3861if (symbol is IMethodSymbol
3893case IMethodSymbol or IFieldSymbol:
3930case IMethodSymbol or IFieldSymbol:
3982if (oldSymbol.Name != newSymbol.Name || oldSymbol is IMethodSymbol or IFieldSymbol)
4132if (oldMember is IMethodSymbol oldMethod)
4346else if (oldSymbol is IMethodSymbol oldMethod && newSymbol is IMethodSymbol newMethod)
4428if (oldSymbol is not IMethodSymbol { AssociatedSymbol: not null })
4462else if (oldSymbol is IMethodSymbol oldMethod && newSymbol is IMethodSymbol newMethod)
4619if (oldSymbol is not IMethodSymbol { AssociatedSymbol: not null })
4712oldMember is not IMethodSymbol { AssociatedSymbol.Kind: SymbolKind.Property or SymbolKind.Event })
4736=> parameter is { Ordinal: 0, ContainingSymbol: IMethodSymbol { IsExtensionMethod: true } };
4807var oldPrimaryConstructor = (IMethodSymbol)oldContainingMember;
4808var newPrimaryConstructor = (IMethodSymbol)newContainingMember;
4814var oldSynthesizedDeconstructor = oldPrimaryConstructor.GetMatchingDeconstructor();
4815var newSynthesizedDeconstructor = newPrimaryConstructor.GetMatchingDeconstructor();
4852if (oldSymbol is IMethodSymbol oldMethod &&
4853newSymbol is IMethodSymbol newMethod)
5058if (newSymbol is IMethodSymbol or IEventSymbol or IPropertySymbol)
5124.FirstOrDefault(static (m, compilation) => m is IMethodSymbol { IsImplicitlyDeclared: true } method && HasPrintMembersSignature(method, compilation), compilation);
5131.FirstOrDefault(static m => m is IMethodSymbol { IsImplicitlyDeclared: true } method && HasIEquatableEqualsSignature(method));
5138.FirstOrDefault(static m => m is IMethodSymbol { IsImplicitlyDeclared: true } method && HasGetHashCodeSignature(method));
5605foreach (var newCtor in isStatic ? newType.StaticConstructors : newType.InstanceConstructors)
5624IMethodSymbol? oldCtor;
5647oldCtor = (IMethodSymbol)GetRequiredDeclaredSymbol(oldModel.RequiredModel, oldDeclaration, cancellationToken);
5664oldCtor = (IMethodSymbol?)resolution.Symbol;
5797private static IMethodSymbol? TryGetParameterlessConstructor(INamedTypeSymbol type, bool isStatic)
5875var oldLambdaSymbol = isNestedFunction ? GetLambdaExpressionSymbol(oldModel.RequiredModel, oldLambda, cancellationToken) : null;
5876var newLambdaSymbol = isNestedFunction ? GetLambdaExpressionSymbol(newModel.RequiredModel, newLambda, cancellationToken) : null;
5979var oldPrimaryConstructor = oldDeclaration != null && IsPrimaryConstructorDeclaration(oldDeclaration)
5980? (IMethodSymbol)oldMember
5983var newPrimaryConstructor = newDeclaration != null && IsPrimaryConstructorDeclaration(newDeclaration)
5984? (IMethodSymbol)newMember
5993var oldLiftingPrimaryConstructor = oldMember != oldPrimaryConstructor && oldDeclaration != null && !IsDeclarationWithInitializer(oldDeclaration) ? oldPrimaryConstructor : null;
5994var newLiftingPrimaryConstructor = newMember != newPrimaryConstructor && newDeclaration != null && !IsDeclarationWithInitializer(newDeclaration) ? newPrimaryConstructor : null;
6228public static VariableCaptureKey Create(ISymbol variable, IMethodSymbol? liftingPrimaryConstructor)
6232private static VariableCaptureKind GetCaptureKind(ISymbol variable, IMethodSymbol? liftingPrimaryConstructor)
6239IMethodSymbol? liftingPrimaryConstructor,
6316IMethodSymbol? oldLiftingPrimaryConstructor,
6318IMethodSymbol? newLiftingPrimaryConstructor,
6370IMethodSymbol? liftingPrimaryConstructor)
6406IMethodSymbol method => method.AssociatedSymbol,
6458var lambda = parameter.ContainingSymbol is IMethodSymbol { MethodKind: MethodKind.LambdaMethod or MethodKind.LocalFunction } containingLambda ?
6463if (parameter is { IsImplicitlyDeclared: true, ContainingSymbol: IMethodSymbol { AssociatedSymbol: { } associatedSymbol } })
6516IMethodSymbol? oldPrimaryConstructor,
6519IMethodSymbol? newPrimaryConstructor,
6694var oldLambdaSymbol = (IMethodSymbol)diagnosticContext.RequiredOldSymbol;
6695var newLambdaSymbol = (IMethodSymbol)diagnosticContext.RequiredNewSymbol;
7002=> symbol is IMethodSymbol { Name: WellKnownMemberNames.TopLevelStatementsEntryPointMethodName };
7010if (current is IMethodSymbol { Arity: > 0 })
7051public IMethodSymbol? GetPrimaryConstructor(INamedTypeSymbol typeSymbol, CancellationToken cancellationToken)
7056=> symbol is IMethodSymbol { IsStatic: false, MethodKind: MethodKind.Constructor, DeclaringSyntaxReferences: [_] } && IsPrimaryConstructorDeclaration(GetSymbolDeclarationSyntax(symbol, cancellationToken));
7072public IMethodSymbol? GetEncompassingPrimaryConstructor(SyntaxNode declaration, ISymbol symbol, CancellationToken cancellationToken)
7073=> IsPrimaryConstructorDeclaration(declaration) ? (IMethodSymbol)symbol :
7109if (newSymbol is IMethodSymbol { IsStatic: false, ContainingType.IsRecord: true, ReturnsVoid: true, Name: WellKnownMemberNames.DeconstructMethodName } method &&
7150if (newSymbol is IMethodSymbol { AssociatedSymbol: IPropertySymbol { } newProperty })
7152var oldProperty = ((IMethodSymbol)oldSymbol).AssociatedSymbol;
7162private static bool HasPrintMembersSignature(IMethodSymbol method, Compilation compilation)
7165private static bool HasIEquatableEqualsSignature(IMethodSymbol method)
7168private static bool HasGetHashCodeSignature(IMethodSymbol method)
GenerateEqualsAndGetHashCodeFromMembers\IGenerateEqualsAndGetHashCodeService.cs (4)
29Task<IMethodSymbol> GenerateEqualsMethodAsync(Document document, INamedTypeSymbol namedType, ImmutableArray<ISymbol> members, string? localNameOpt, CancellationToken cancellationToken);
35Task<IMethodSymbol> GenerateEqualsMethodThroughIEquatableEqualsAsync(Document document, INamedTypeSymbol namedType, CancellationToken cancellationToken);
41Task<IMethodSymbol> GenerateIEquatableEqualsMethodAsync(Document document, INamedTypeSymbol namedType, ImmutableArray<ISymbol> members, INamedTypeSymbol constructedEquatableType, CancellationToken cancellationToken);
50Task<IMethodSymbol> GenerateGetHashCodeMethodAsync(Document document, INamedTypeSymbol namedType, ImmutableArray<ISymbol> members, CancellationToken cancellationToken);
InitializeParameter\AbstractAddParameterCheckCodeRefactoringProvider.cs (27)
71IMethodSymbol methodSymbol,
104IMethodSymbol methodSymbol,
211document = await AddStringCheckAsync(document, parameter, functionDeclaration, (IMethodSymbol)parameter.ContainingSymbol, blockStatement, NullOrEmptySuffix, lazySimplifierOptions, cancellationToken).ConfigureAwait(false);
217(IMethodSymbol)parameter.ContainingSymbol, blockStatement, lazySimplifierOptions, cancellationToken).ConfigureAwait(false);
420private static (IMethodSymbol? GenericOverload, IMethodSymbol? NonGenericOverload) GetEnumIsDefinedMethods(Compilation compilation)
424var enumIsDefinedGenericMethod = (IMethodSymbol?)enumIsDefinedMembers.FirstOrDefault(m => m is IMethodSymbol { IsStatic: true, Arity: 1, Parameters.Length: 1 });
425var enumIsDefinedNonGenericMethod = (IMethodSymbol?)enumIsDefinedMembers.FirstOrDefault(m => m is IMethodSymbol { IsStatic: true, Arity: 0, Parameters.Length: 2 });
463private static bool IsEnumIsDefinedCheck(IOperation statement, IParameterSymbol parameter, IMethodSymbol? enumIsDefinedGenericMethod, IMethodSymbol? enumIsDefinedNonGenericMethod)
473var method = invocation.TargetMethod;
530var targetMethod = invocation.TargetMethod;
545IMethodSymbol method,
568IMethodSymbol method,
584IMethodSymbol method,
600IMethodSymbol method,
634IMethodSymbol method,
643var enumIsDefinedGenericMethod = enumType.GetMembers(nameof(Enum.IsDefined)).FirstOrDefault(m => m is IMethodSymbol { IsStatic: true, Arity: 1, Parameters.Length: 1 });
698.FirstOrDefault(s => s is IMethodSymbol { Parameters: [{ Type.SpecialType: SpecialType.System_Object }, ..] });
723.FirstOrDefault(s => s is IMethodSymbol { IsStatic: true, Arity: 1, Parameters.Length: 2 });
765.FirstOrDefault(s => s is IMethodSymbol { Parameters: [{ Type.SpecialType: SpecialType.System_String }, ..] });
800var methodSymbol = (IMethodSymbol)parameter.ContainingSymbol;
IntroduceParameter\AbstractIntroduceParameterCodeRefactoringProvider.cs (5)
46protected abstract bool IsDestructor(IMethodSymbol methodSymbol);
74if (containingSymbol is not IMethodSymbol methodSymbol)
155TExpressionSyntax expression, IMethodSymbol methodSymbol, SyntaxNode containingMethod,
252IMethodSymbol methodSymbol, SyntaxNode containingMethod, Dictionary<Document, List<TExpressionSyntax>> methodCallSites, bool allOccurrences, IntroduceParameterCodeActionKind selectedCodeAction,
285Document document, IMethodSymbol methodSymbol, CancellationToken cancellationToken)
ReplaceMethodWithProperty\ReplaceMethodWithPropertyCodeRefactoringProvider.cs (27)
54if (semanticModel.GetDeclaredSymbol(methodDeclaration) is not IMethodSymbol methodSymbol ||
79var setMethod = FindSetMethod(methodSymbol);
96private static IMethodSymbol? FindSetMethod(IMethodSymbol getMethod)
100var setMethod = containingType.GetMembers()
101.OfType<IMethodSymbol>()
109private static bool IsValidGetMethod(IMethodSymbol getMethod)
121private static bool OverridesMethodFromSystemObject(IMethodSymbol method)
123for (var current = method; current != null; current = current.OverriddenMethod)
134private static bool IsValidSetMethod(IMethodSymbol setMethod, IMethodSymbol getMethod)
142private static bool IsValidSetMethod(IMethodSymbol setMethod)
155IMethodSymbol getMethod,
156IMethodSymbol? setMethod,
344MultiDictionary<DocumentId, IMethodSymbol>.ValueSet originalGetDefinitions,
345MultiDictionary<DocumentId, IMethodSymbol>.ValueSet originalSetDefinitions,
380foreach (var originalSetMethod in originalSetDefinitions)
384var setMethod = GetSymbolInCurrentCompilation(compilation, originalSetMethod, cancellationToken);
401MultiDictionary<DocumentId, IMethodSymbol>.ValueSet originalDefinitions,
406foreach (var originalDefinition in originalDefinitions)
410var getMethod = GetSymbolInCurrentCompilation(compilation, originalDefinition, cancellationToken);
413var setMethod = updateSetMethod ? FindSetMethod(getMethod) : null;
433private static async Task<SyntaxNode?> GetMethodDeclarationAsync(IMethodSymbol? method, CancellationToken cancellationToken)
445private static async Task<MultiDictionary<DocumentId, IMethodSymbol>> GetDefinitionsByDocumentIdAsync(
450var result = new MultiDictionary<DocumentId, IMethodSymbol>();
455var definition = referencedSymbol.Definition as IMethodSymbol;
src\roslyn\src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (5)
87protected abstract TExpression? GetGetterExpression(IMethodSymbol getMethod, CancellationToken cancellationToken);
88protected abstract TExpression? GetSetterExpression(SemanticModel semanticModel, IMethodSymbol setMethod, CancellationToken cancellationToken);
91SemanticModel semanticModel, IMethodSymbol accessor, HashSet<string> fieldNames, HashSet<IFieldSymbol> result, CancellationToken cancellationToken);
257IMethodSymbol getMethod,
275SemanticModel semanticModel, IMethodSymbol setMethod, HashSet<string> fieldNames, CancellationToken cancellationToken)
src\roslyn\src\Analyzers\Core\CodeFixes\GenerateParameterizedMember\AbstractGenerateConversionService.cs (2)
24protected abstract bool TryInitializeImplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, [NotNullWhen(true)] out IMethodSymbol? methodSymbol, [NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn);
25protected abstract bool TryInitializeExplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, [NotNullWhen(true)] out IMethodSymbol? methodSymbol, [NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn);
src\roslyn\src\Analyzers\Core\CodeFixes\ImplementAbstractClass\ImplementAbstractClassData.cs (7)
167IMethodSymbol method => GenerateMethod(compilation, method, throughMember, modifiers, accessibility),
175Compilation compilation, IMethodSymbol method, ISymbol? throughMember,
210var getMethod = ShouldGenerateAccessor(property.GetMethod)
219var setMethod = ShouldGenerateAccessor(property.SetMethod)
246private IMethodSymbol? GetEventAddOrRemoveMethod(
247IEventSymbol @event, IMethodSymbol? accessor, ISymbol? throughMember,
265private bool ShouldGenerateAccessor([NotNullWhen(true)] IMethodSymbol? method)
src\roslyn\src\Analyzers\Core\CodeFixes\ImplementInterface\ImplementInterfaceGenerator.cs (8)
261if (member is not IMethodSymbol method)
300IMethodSymbol method => [GenerateMethod(compilation, method, conflictingMember as IMethodSymbol, accessibility, modifiers, generateAbstractly, useExplicitInterfaceSymbol, memberName)],
309var accessor = CodeGenerationSymbolFactory.CreateAccessorSymbol(
324private IMethodSymbol? GetAddOrRemoveMethod(
325IEventSymbol @event, bool generateInvisibly, IMethodSymbol accessor, string memberName,
361if (member is IMethodSymbol method1 && baseMember is IMethodSymbol method2)
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (12)
36IMethodSymbol methodSymbol,
67var methodSymbol = GetMethodSymbol(semanticModel, node, cancellationToken);
105IMethodSymbol methodSymbol,
122if (referencedSymbol.Definition is not IMethodSymbol definition)
150IMethodSymbol methodSymbol,
182private static IMethodSymbol? GetMethodSymbol(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
186return symbol as IMethodSymbol;
211var methodSymbol = GetMethodSymbol(semanticModel, node, cancellationToken);
261IMethodSymbol methodSymbol,
280var newMethod = (IMethodSymbol)semanticModel.GetRequiredDeclaredSymbol(newNode, cancellationToken);
291IMethodSymbol methodSymbol,
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (8)
25protected abstract SyntaxNode RemoveAsyncTokenAndFixReturnType(IMethodSymbol methodSymbol, SyntaxNode node, KnownTaskTypes knownTypes);
56var methodSymbol = (IMethodSymbol?)(semanticModel.GetDeclaredSymbol(node, cancellationToken) ?? semanticModel.GetSymbolInfo(node, cancellationToken).GetAnySymbol());
71private async Task<Solution> RenameThenRemoveAsyncTokenAsync(Document document, SyntaxNode node, IMethodSymbol methodSymbol, CancellationToken cancellationToken)
87var newMethod = (IMethodSymbol)semanticModel.GetRequiredDeclaredSymbol(newNode, cancellationToken);
95Document document, IMethodSymbol methodSymbol, SyntaxNode node, CancellationToken cancellationToken)
126if (semanticModel.GetDeclaredSymbol(methodDeclaration, cancellationToken) is IMethodSymbol methodSymbol)
StackTraceExplorer\StackTraceExplorerUtilities.cs (5)
64var method = await TryGetBestMatchAsync(project, fullyQualifiedTypeName, methodNode, methodArguments, methodTypeArguments, cancellationToken).ConfigureAwait(false);
80var method = await TryGetBestMatchAsync(project, fullyQualifiedTypeName, methodNode, methodArguments, methodTypeArguments, cancellationToken).ConfigureAwait(false);
91Task<DefinitionItem> GetDefinitionAsync(IMethodSymbol method)
107private static async Task<IMethodSymbol?> TryGetBestMatchAsync(Project project, string fullyQualifiedTypeName, StackFrameSimpleNameNode methodNode, StackFrameParameterList methodArguments, StackFrameTypeArgumentList? methodTypeArguments, CancellationToken cancellationToken)
120var matchingMethod = await resolver.TryGetBestMatchAsync(project, type, methodNode, methodArguments, methodTypeArguments, cancellationToken).ConfigureAwait(false);
Microsoft.CodeQuality.Analyzers\ApiDesignGuidelines\DoNotRaiseExceptionsInUnexpectedLocations.cs (16)
82if (operationBlockContext.OwningSymbol is not IMethodSymbol methodSymbol)
130private readonly Func<IMethodSymbol, Compilation, bool> _matchFunction;
148public MethodCategory(Func<IMethodSymbol, Compilation, bool> matchFunction, bool analyzeOnlyPublicMethods, DiagnosticDescriptor rule, params ITypeSymbol?[] allowedExceptionTypes)
159public bool IsMatch(IMethodSymbol method, Compilation compilation)
225private static bool IsPropertyGetter(IMethodSymbol method, Compilation compilation)
230private static bool IsIndexerGetter(IMethodSymbol method, Compilation compilation)
235private static bool IsEventAccessor(IMethodSymbol method, Compilation compilation)
240private static bool IsEqualsOverrideOrInterfaceImplementation(IMethodSymbol method, Compilation compilation)
248private static bool IsEqualsInterfaceImplementation(IMethodSymbol method, Compilation compilation)
286private static bool IsGetHashCodeInterfaceImplementation(IMethodSymbol method, Compilation compilation)
314private static bool IsGetHashCodeOverride(IMethodSymbol method, Compilation compilation)
319private static bool IsToString(IMethodSymbol method, Compilation compilation)
324private static bool IsStaticConstructor(IMethodSymbol method, Compilation compilation)
329private static bool IsFinalizer(IMethodSymbol method, Compilation compilation)
334private static bool IsComparisonOperator(IMethodSymbol method, Compilation compilation)
351private static bool IsImplicitCastOperator(IMethodSymbol method, Compilation compilation)
Microsoft.CodeQuality.Analyzers\ApiDesignGuidelines\ImplementIDisposableCorrectly.cs (28)
141if (disposableType.GetMembers(DisposeMethodName).FirstOrDefault() is not IMethodSymbol disposeInterfaceMethod)
152if (garbageCollectorType.GetMembers(SuppressFinalizeMethodName).FirstOrDefault() is not IMethodSymbol suppressFinalizeMethod)
168private readonly IMethodSymbol _disposeInterfaceMethod;
169private readonly IMethodSymbol _suppressFinalizeMethod;
171public PerCompilationAnalyzer(INamedTypeSymbol disposableType, IMethodSymbol disposeInterfaceMethod, IMethodSymbol suppressFinalizeMethod)
203IMethodSymbol? disposeMethod = FindDisposeMethod(type);
211IMethodSymbol disposeBoolMethod = FindDisposeBoolMethod(type);
226foreach (IMethodSymbol method in type.GetMembers().OfType<IMethodSymbol>())
238if (context.OwningSymbol is not IMethodSymbol method)
255IMethodSymbol? disposeMethod = FindDisposeMethod(type);
293private static void CheckDisposeSignatureRule(IMethodSymbol method, INamedTypeSymbol type, SymbolAnalysisContext context)
305private static void CheckRenameDisposeRule(IMethodSymbol method, INamedTypeSymbol type, SymbolAnalysisContext context)
316private void CheckDisposeOverrideRule(IMethodSymbol method, INamedTypeSymbol type, SymbolAnalysisContext context)
321for (IMethodSymbol? m = method.OverriddenMethod; m != null; m = m.OverriddenMethod)
364private static void CheckDisposeBoolSignatureRule(IMethodSymbol method, INamedTypeSymbol type, SymbolAnalysisContext context)
376private void CheckDisposeImplementationRule(IMethodSymbol method, INamedTypeSymbol type, ImmutableArray<IOperation> operationBlocks, OperationBlockAnalysisContext context)
388private static void CheckFinalizeImplementationRule(IMethodSymbol method, INamedTypeSymbol type, ImmutableArray<IOperation> operationBlocks, OperationBlockAnalysisContext context)
427private IMethodSymbol? FindDisposeMethod(INamedTypeSymbol type)
429if (type.FindImplementationForInterfaceMember(_disposeInterfaceMethod) is IMethodSymbol disposeMethod && Equals(disposeMethod.ContainingType, type))
440private static IMethodSymbol FindDisposeBoolMethod(INamedTypeSymbol type)
442return type.GetMembers(DisposeMethodName).OfType<IMethodSymbol>().FirstOrDefault(m => m.HasDisposeBoolMethodSignature());
448private IMethodSymbol? FindInheritedDisposeBoolMethod(INamedTypeSymbol? type)
450IMethodSymbol? method = null;
507private readonly IMethodSymbol _suppressFinalizeMethod;
512public DisposeImplementationValidator(IMethodSymbol suppressFinalizeMethod, INamedTypeSymbol type)
709IMethodSymbol methodSymbol = invocation.TargetMethod;
Microsoft.CodeQuality.Analyzers\Maintainability\UseCrossPlatformIntrinsicsAnalyzer.cs (16)
140Dictionary<IMethodSymbol, RuleKind> methodSymbols = new Dictionary<IMethodSymbol, RuleKind>(SymbolEqualityComparer.Default);
303static void AddBinaryOperatorMethods(Dictionary<IMethodSymbol, RuleKind> methodSymbols, string name, INamedTypeSymbol typeSymbol, RuleKind ruleKind, params SpecialType[] supportedTypes)
308IEnumerable<IMethodSymbol> members =
310.OfType<IMethodSymbol>()
318methodSymbols.AddRange(members.Select((m) => new KeyValuePair<IMethodSymbol, RuleKind>(m, ruleKind)));
321static void AddShiftOperatorMethods(Dictionary<IMethodSymbol, RuleKind> methodSymbols, string name, INamedTypeSymbol typeSymbol, RuleKind ruleKind, params SpecialType[] supportedTypes)
327IEnumerable<IMethodSymbol> members =
329.OfType<IMethodSymbol>()
337methodSymbols.AddRange(members.Select((m) => new KeyValuePair<IMethodSymbol, RuleKind>(m, ruleKind)));
340static void AddUnaryOperatorMethods(Dictionary<IMethodSymbol, RuleKind> methodSymbols, string name, INamedTypeSymbol typeSymbol, RuleKind ruleKind, params SpecialType[] supportedTypes)
345IEnumerable<IMethodSymbol> members =
347.OfType<IMethodSymbol>()
354methodSymbols.AddRange(members.Select((m) => new KeyValuePair<IMethodSymbol, RuleKind>(m, ruleKind)));
358private void AnalyzeInvocation(OperationAnalysisContext context, Dictionary<IMethodSymbol, RuleKind> methodSymbols)
365IMethodSymbol targetMethod = invocation.TargetMethod;
Microsoft.CodeQuality.Analyzers\QualityGuidelines\AvoidMultipleEnumerations\FlowAnalysis\GlobalFlowStateDictionaryAnalysisContext.cs (1)
46IMethodSymbol invokedMethod,
Microsoft.NetCore.Analyzers\InteropServices\PlatformCompatibilityAnalyzer.cs (18)
183var runtimeIsOSPlatformMethod = runtimeInformationType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m =>
192var osPlatformCreateMethod = osPlatformType?.GetMembers("Create").OfType<IMethodSymbol>().FirstOrDefault(m =>
205static List<IMethodSymbol> GetOperatingSystemGuardMethods(IMethodSymbol? runtimeIsOSPlatformMethod,
220static IEnumerable<IMethodSymbol> FilterPlatformCheckMethods(INamedTypeSymbol symbol,
223return symbol.GetMembers().OfType<IMethodSymbol>().Where(m =>
237static void CheckDependentPlatforms(IMethodSymbol method, SmallDictionary<string, (string relatedPlatform, bool isSubset)> relatedPlatforms)
256static bool NameAndParametersValid(IMethodSymbol method) => method.Name.StartsWith(IsPrefix, StringComparison.Ordinal) &&
308ImmutableArray<IMethodSymbol> guardMethods,
309IMethodSymbol? runtimeIsOSPlatformMethod,
310IMethodSymbol? osPlatformCreateMethod,
369var symbol = platformSpecificOperation.Value is IMethodSymbol method && method.IsConstructor() ?
442private static bool ComputeNeedsValueContentAnalysis(IOperation operationBlock, ImmutableArray<IMethodSymbol> guardMethods, IMethodSymbol? runtimeIsOSPlatformMethod, INamedTypeSymbol? osPlatformType)
1373else if (symbol is IMethodSymbol method && method.IsGenericMethod)
1413if (containingSymbol is IMethodSymbol method && method.IsAccessorMethod())
Microsoft.NetCore.Analyzers\Performance\PreferConvertToHexStringOverBitConverter.cs (38)
71out var convertToHexStringReplacementMethod))
95ImmutableArray<IMethodSymbol> stringReplaceMethods,
96ImmutableArray<IMethodSymbol> stringToLowerMethods,
98ImmutableDictionary<IMethodSymbol, IMethodSymbol> bitConverterReplacements,
99ImmutableDictionary<IMethodSymbol, IMethodSymbol> bitConverterReplacementsToLower)
127.OfType<IMethodSymbol>()
137.OfType<IMethodSymbol>()
144.OfType<IMethodSymbol>()
147var bitConverterToString = bitConverterToStringMethods.GetFirstOrDefaultMemberWithParameterTypes(byteArrayType);
148var bitConverterToStringStart = bitConverterToStringMethods.GetFirstOrDefaultMemberWithParameterTypes(byteArrayType, int32Type);
149var bitConverterToStringStartLength = bitConverterToStringMethods.GetFirstOrDefaultMemberWithParameterTypes(byteArrayType, int32Type, int32Type);
152.OfType<IMethodSymbol>()
155var convertToHexString = convertToHexStringMethods.GetFirstOrDefaultMemberWithParameterTypes(byteArrayType);
156var convertToHexStringRos = rosByteType is not null ? convertToHexStringMethods.GetFirstOrDefaultMemberWithParameterTypes(rosByteType) : null;
157var convertToHexStringStartLength = convertToHexStringMethods.GetFirstOrDefaultMemberWithParameterTypes(byteArrayType, int32Type, int32Type);
159var bitConverterReplacementsBuilder = ImmutableDictionary.CreateBuilder<IMethodSymbol, IMethodSymbol>();
175.OfType<IMethodSymbol>()
178var convertToHexStringLower = convertToHexStringLowerMethods.GetFirstOrDefaultMemberWithParameterTypes(byteArrayType);
179var convertToHexStringLowerRos = rosByteType is not null ? convertToHexStringLowerMethods.GetFirstOrDefaultMemberWithParameterTypes(rosByteType) : null;
180var convertToHexStringLowerStartLength = convertToHexStringLowerMethods.GetFirstOrDefaultMemberWithParameterTypes(byteArrayType, int32Type, int32Type);
183var bitConverterReplacementsToLowerBuilder = ImmutableDictionary.CreateBuilder<IMethodSymbol, IMethodSymbol>();
197bool FilterStringReplaceMethods(IMethodSymbol stringReplaceMethod)
229[NotNullWhen(true)] out IMethodSymbol? replacementMethod)
286_bitConverterReplacementsToLower.TryGetValue(bitConverterInvocation.TargetMethod, out var replacementToLower))
294else if (_bitConverterReplacements.TryGetValue(bitConverterInvocation.TargetMethod, out var replacement))
312private bool IsAnyBitConverterMethod(IMethodSymbol method)
317private bool IsAnyStringReplaceMethod(IMethodSymbol? method)
322private bool IsAnyStringToLowerMethod(IMethodSymbol? method)
351private readonly ImmutableArray<IMethodSymbol> _stringReplaceMethods;
352private readonly ImmutableArray<IMethodSymbol> _stringToLowerMethods;
354private readonly ImmutableDictionary<IMethodSymbol, IMethodSymbol> _bitConverterReplacements;
355private readonly ImmutableDictionary<IMethodSymbol, IMethodSymbol> _bitConverterReplacementsToLower;
Microsoft.NetCore.Analyzers\Performance\PreferDictionaryTryMethodsOverContainsKeyGuardAnalyzer.cs (14)
53public DictionaryUsageContext(IOperation dictionaryReference, IOperation containsKeyArgumentReference, IMethodSymbol addSymbol)
100public IMethodSymbol AddSymbol { get; }
128if (!TryGetDictionaryTypeAndMembers(context.Compilation, out var iDictionaryType, out var containsKeySymbol, out var addSymbol))
136private static void OnInvocationOperation(INamedTypeSymbol iDictionaryType, IMethodSymbol containsKeySymbol, IMethodSymbol addSymbol, OperationAnalysisContext context)
230[NotNullWhen(true)] out IMethodSymbol? containsKeySymbol,
231[NotNullWhen(true)] out IMethodSymbol? addSymbol)
242containsKeySymbol = iDictionaryType.GetMembers(ContainsKey).OfType<IMethodSymbol>().FirstOrDefault();
243addSymbol = iDictionaryType.GetMembers(Add).OfType<IMethodSymbol>().FirstOrDefault();
248private static bool IsContainsKeyMethod(IMethodSymbol suspectedContainsKeyMethod, IMethodSymbol containsKeyMethod)
264private static bool DoesSignatureMatch(IMethodSymbol suspected, IMethodSymbol comparator)
Microsoft.NetCore.Analyzers\Performance\PreferHashDataOverComputeHash.cs (29)
173methodHelper.TryGetHashDataMethod(declarationTuple.OriginalType, type, out var hashDataMethodSymbol))
229if (!methodHelper.TryGetHashDataMethod(originalHashType, computeType, out var staticHashMethod))
346private readonly IMethodSymbol _computeHashMethodSymbol;
347private readonly IMethodSymbol _disposeMethodSymbol;
348private readonly IMethodSymbol? _computeHashSectionMethodSymbol;
349private readonly IMethodSymbol? _tryComputeHashMethodSymbol;
370IMethodSymbol computeHashMethodSymbol,
371IMethodSymbol disposeMethodSymbol,
372IMethodSymbol? computeHashSectionMethodSymbol,
373IMethodSymbol? tryComputeHashMethodSymbol,
397IMethodSymbol methodSymbol = invocationOperation.TargetMethod;
435public bool TryGetHashDataMethod(ITypeSymbol? originalHashType, ComputeType computeType, [NotNullWhen(true)] out IMethodSymbol? staticHashMethod)
447public bool TryGetHashDataMethodByteArg(ITypeSymbol? originalHashType, [NotNullWhen(true)] out IMethodSymbol? staticHashMethod) => TryGetHashDataMethodOneArg(originalHashType, _byteArrayParameter, out staticHashMethod);
449public bool TryGetHashDataMethodSpanArg(ITypeSymbol? originalHashType, [NotNullWhen(true)] out IMethodSymbol? staticHashMethod) => TryGetHashDataMethodOneArg(originalHashType, _rosByteParameter, out staticHashMethod);
451public bool TryGetTryHashDataMethod(ITypeSymbol? originalHashType, [NotNullWhen(true)] out IMethodSymbol? staticHashMethod) => TryGetTryHashDataMethod(originalHashType, _rosByteParameter, _spanByteParameter, _intParameter, out staticHashMethod);
453private static bool TryGetHashDataMethodOneArg(ITypeSymbol? originalHashType, ParameterInfo argOne, [NotNullWhen(true)] out IMethodSymbol? staticHashMethod)
466staticHashMethod = originalHashType.GetMembers(HashDataMethodName).OfType<IMethodSymbol>()
477[NotNullWhen(true)] out IMethodSymbol? staticHashMethod)
490staticHashMethod = originalHashType.GetMembers(TryHashDataMethodName).OfType<IMethodSymbol>()
540var hashDataMethodType = sha256Type.GetMembers(HashDataMethodName).OfType<IMethodSymbol>().GetFirstOrDefaultMemberWithParameterInfos(byteArrayParameter);
546var disposeHashMethodBaseType = hashAlgoBaseType.GetMembers(DisposeMethodName).OfType<IMethodSymbol>().GetFirstOrDefaultMemberWithParameterInfos();
552var computeHashMethodBaseType = hashAlgoBaseType.GetMembers(ComputeHashMethodName).OfType<IMethodSymbol>().GetFirstOrDefaultMemberWithParameterInfos(byteArrayParameter);
558var computeHashSectionMethodBaseType = hashAlgoBaseType.GetMembers(ComputeHashMethodName).OfType<IMethodSymbol>().GetFirstOrDefaultMemberWithParameterInfos(byteArrayParameter, intParameter, intParameter);
559var tryComputeHashMethodBaseType = hashAlgoBaseType.GetMembers(TryComputeHashMethodName).OfType<IMethodSymbol>().GetFirstOrDefaultMemberWithParameterInfos(rosByteParameter, spanByteParameter, intParameter);
Microsoft.NetCore.Analyzers\Performance\UseConcreteTypeAnalyzer.Collector.cs (25)
22public ConcurrentDictionary<IFieldSymbol, PooledConcurrentSet<IMethodSymbol>> VirtualDispatchFields { get; } = new(SymbolEqualityComparer.Default);
23public ConcurrentDictionary<IPropertySymbol, PooledConcurrentSet<IMethodSymbol>> VirtualDispatchProperties { get; } = new(SymbolEqualityComparer.Default);
24public ConcurrentDictionary<ILocalSymbol, PooledConcurrentSet<IMethodSymbol>> VirtualDispatchLocals { get; } = new(SymbolEqualityComparer.Default);
25public ConcurrentDictionary<IParameterSymbol, PooledConcurrentSet<IMethodSymbol>> VirtualDispatchParameters { get; } = new(SymbolEqualityComparer.Default);
32public ConcurrentDictionary<IMethodSymbol, PooledConcurrentSet<ITypeSymbol>> MethodReturns { get; } = new(SymbolEqualityComparer.Default);
34public ConcurrentDictionary<IMethodSymbol, bool> MethodsAssignedToDelegate { get; } = new(SymbolEqualityComparer.Default);
97var targetMethod = op.Property.GetMethod ?? op.Property.SetMethod!;
399if (c is IMethodSymbol methodSym)
611foreach (var method in value)
624foreach (var method in value)
634if (parameter.ContainingSymbol is IMethodSymbol method)
639foreach (var m in value)
676if (parameter.ContainingSymbol is IMethodSymbol method)
691var method = pair.Key;
712private bool CanUpgrade(IMethodSymbol methodSym)
731var m = setter ? propSym.SetMethod! : propSym.GetMethod!;
740private void RecordVirtualDispatch(IFieldSymbol field, IMethodSymbol target) => VirtualDispatchFields.GetOrAdd(field, _ => PooledConcurrentSet<IMethodSymbol>.GetInstance(SymbolEqualityComparer.Default)).Add(target);
741private void RecordVirtualDispatch(IPropertySymbol property, IMethodSymbol target) => VirtualDispatchProperties.GetOrAdd(property, _ => PooledConcurrentSet<IMethodSymbol>.GetInstance(SymbolEqualityComparer.Default)).Add(target);
742private void RecordVirtualDispatch(ILocalSymbol local, IMethodSymbol target) => VirtualDispatchLocals.GetOrAdd(local, _ => PooledConcurrentSet<IMethodSymbol>.GetInstance(SymbolEqualityComparer.Default)).Add(target);
743private void RecordVirtualDispatch(IParameterSymbol parameter, IMethodSymbol target) => VirtualDispatchParameters.GetOrAdd(parameter, _ => PooledConcurrentSet<IMethodSymbol>.GetInstance(SymbolEqualityComparer.Default)).Add(target);
750private void RecordReturn(IMethodSymbol method, ITypeSymbol valueType) => MethodReturns.GetOrAdd(method, _ => PooledConcurrentSet<ITypeSymbol>.GetInstance(SymbolEqualityComparer.Default)).Add(valueType);
Microsoft.NetCore.Analyzers\Runtime\PreferAsSpanOverSubstring.cs (28)
95internal static ImmutableArray<IMethodSymbol> GetBestSpanBasedOverloads(in RequiredSymbols symbols, IInvocationOperation invocation, CancellationToken cancellationToken)
97var method = invocation.TargetMethod;
113return ImmutableArray<IMethodSymbol>.Empty;
117var bestCandidates = ImmutableArray.CreateBuilder<IMethodSymbol>();
120foreach (var candidate in candidates)
146static int EvaluateCandidateQuality(in RequiredSymbols symbols, ReadOnlySpan<bool> isSubstringLookup, IInvocationOperation invocation, IMethodSymbol candidate)
148var method = invocation.TargetMethod;
173private static IEnumerable<IMethodSymbol> GetAllAccessibleOverloadsAtInvocationCallSite(IInvocationOperation invocation, CancellationToken cancellationToken)
175var method = invocation.TargetMethod;
180IEnumerable<IMethodSymbol> allOverloads;
183allOverloads = model.LookupStaticMembers(location, method.ContainingType, method.Name).OfType<IMethodSymbol>();
189allOverloads = model.LookupSymbols(location, instance.Type, method.Name).OfType<IMethodSymbol>();
192allOverloads = allOverloads.Union(model.LookupBaseMembers(location, method.Name).OfType<IMethodSymbol>());
198return Enumerable.Empty<IMethodSymbol>();
221IMethodSymbol substring1, IMethodSymbol substring2,
222IMethodSymbol asSpan1, IMethodSymbol asSpan2)
257var substringMembers = stringType.GetMembers(nameof(string.Substring)).OfType<IMethodSymbol>();
258var substringStart = substringMembers.GetFirstOrDefaultMemberWithParameterInfos(int32ParamInfo);
259var substringStartLength = substringMembers.GetFirstOrDefaultMemberWithParameterInfos(int32ParamInfo, int32ParamInfo);
261var asSpanMembers = memoryExtensionsType.GetMembers(nameof(MemoryExtensions.AsSpan)).OfType<IMethodSymbol>();
262var asSpanStart = asSpanMembers.GetFirstOrDefaultMemberWithParameterInfos(stringParamInfo, int32ParamInfo);
263var asSpanStartLength = asSpanMembers.GetFirstOrDefaultMemberWithParameterInfos(stringParamInfo, int32ParamInfo, int32ParamInfo);
282public IMethodSymbol SubstringStart { get; }
283public IMethodSymbol SubstringStartLength { get; }
284public IMethodSymbol AsSpanStart { get; }
285public IMethodSymbol AsSpanStartLength { get; }
Microsoft.NetCore.Analyzers\Runtime\ProvideStreamMemoryBasedAsyncOverrides.cs (26)
73IMethodSymbol? readAsyncArrayOverride = GetOverridingMethodSymbols(type, symbols.ReadAsyncArrayMethod).FirstOrDefault();
74IMethodSymbol? readAsyncMemoryOverride = GetOverridingMethodSymbols(type, symbols.ReadAsyncMemoryMethod).FirstOrDefault();
75IMethodSymbol? writeAsyncArrayOverride = GetOverridingMethodSymbols(type, symbols.WriteAsyncArrayMethod).FirstOrDefault();
76IMethodSymbol? writeAsyncMemoryOverride = GetOverridingMethodSymbols(type, symbols.WriteAsyncMemoryMethod).FirstOrDefault();
94static Diagnostic CreateDiagnostic(INamedTypeSymbol violatingType, IMethodSymbol arrayBasedOverride, IMethodSymbol memoryBasedMethod)
135var readAsyncArrayMethod = GetOverloads(streamType, ReadAsyncName, byteArrayType, int32Type, int32Type, cancellationTokenType).FirstOrDefault();
136var readAsyncMemoryMethod = GetOverloads(streamType, ReadAsyncName, memoryOfByteType, cancellationTokenType).FirstOrDefault();
137var writeAsyncArrayMethod = GetOverloads(streamType, WriteAsyncName, byteArrayType, int32Type, int32Type, cancellationTokenType).FirstOrDefault();
138var writeAsyncMemoryMethod = GetOverloads(streamType, WriteAsyncName, readOnlyMemoryOfByteType, cancellationTokenType).FirstOrDefault();
154private static ImmutableArray<IMethodSymbol> GetOverloads(ITypeSymbol containingType, string methodName, params ITypeSymbol[] argumentTypes)
157.OfType<IMethodSymbol>()
160static bool IsMatch(IMethodSymbol method, ITypeSymbol[] argumentTypes)
176/// If <paramref name="derivedType"/> overrides <paramref name="overriddenMethod"/> on its immediate base class, returns the <see cref="IMethodSymbol"/>
181/// <returns>The <see cref="IMethodSymbol"/> for the method that overrides <paramref name="overriddenMethod"/>, or null if
183private static ImmutableArray<IMethodSymbol> GetOverridingMethodSymbols(ITypeSymbol derivedType, IMethodSymbol overriddenMethod)
188.OfType<IMethodSymbol>()
201IMethodSymbol readAsyncArrayMethod, IMethodSymbol readAsyncMemoryMethod,
202IMethodSymbol writeAsyncArrayMethod, IMethodSymbol writeAsyncMemoryMethod)
216public IMethodSymbol ReadAsyncArrayMethod { get; }
217public IMethodSymbol ReadAsyncMemoryMethod { get; }
218public IMethodSymbol WriteAsyncArrayMethod { get; }
219public IMethodSymbol WriteAsyncMemoryMethod { get; }
Microsoft.NetCore.Analyzers\Runtime\UseStringEqualsOverStringCompare.cs (25)
80IMethodSymbol? compareStringString,
81IMethodSymbol? compareStringStringBool,
82IMethodSymbol? compareStringStringStringComparison,
83IMethodSymbol? compareOrdinalStringString,
84IMethodSymbol? equalsStringString,
85IMethodSymbol? equalsStringStringStringComparison,
86IMethodSymbol intEquals)
115.OfType<IMethodSymbol>()
117var compareStringString = compareMethods.GetFirstOrDefaultMemberWithParameterTypes(stringType, stringType);
118var compareStringStringBool = compareMethods.GetFirstOrDefaultMemberWithParameterTypes(stringType, stringType, boolType);
119var compareStringStringStringComparison = compareMethods.GetFirstOrDefaultMemberWithParameterTypes(stringType, stringType, stringComparisonType);
122.OfType<IMethodSymbol>()
124var compareOrdinalStringString = compareOrdinalMethods.GetFirstOrDefaultMemberWithParameterTypes(stringType, stringType);
127.OfType<IMethodSymbol>()
129var equalsStringString = equalsMethods.GetFirstOrDefaultMemberWithParameterTypes(stringType, stringType);
130var equalsStringStringStringComparison = equalsMethods.GetFirstOrDefaultMemberWithParameterTypes(stringType, stringType, stringComparisonType);
134.OfType<IMethodSymbol>()
160public IMethodSymbol? CompareStringString { get; }
161public IMethodSymbol? CompareStringStringBool { get; }
162public IMethodSymbol? CompareStringStringStringComparison { get; }
163public IMethodSymbol? CompareOrdinalStringString { get; }
164public IMethodSymbol? EqualsStringString { get; }
165public IMethodSymbol? EqualsStringStringStringComparison { get; }
166public IMethodSymbol IntEquals { get; }
201internal static IInvocationOperation? GetInvocationFromEqualsCheckWithLiteralZero(IInvocationOperation? invocation, IMethodSymbol int32Equals)
Microsoft.NetFramework.Analyzers\Helpers\SecurityDiagnosticHelpers.cs (12)
16public static bool IsXslCompiledTransformLoad([NotNullWhen(returnValue: true)] this IMethodSymbol? method, CompilationSecurityTypes xmlTypes)
21public static bool IsXmlDocumentCtorDerived([NotNullWhen(returnValue: true)] this IMethodSymbol? method, CompilationSecurityTypes xmlTypes)
33public static bool IsXmlTextReaderCtorDerived([NotNullWhen(returnValue: true)] this IMethodSymbol? method, CompilationSecurityTypes xmlTypes)
60public static bool IsXmlReaderSettingsCtor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, CompilationSecurityTypes xmlTypes)
82public static bool IsXsltSettingsCtor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, CompilationSecurityTypes xmlTypes)
119public static int GetXmlResolverParameterIndex(this IMethodSymbol? method, CompilationSecurityTypes xmlTypes)
122public static int GetXsltSettingsParameterIndex(this IMethodSymbol? method, CompilationSecurityTypes xmlTypes)
125public static int GetXmlReaderSettingsParameterIndex(this IMethodSymbol? method, CompilationSecurityTypes xmlTypes)
136public static int HasXmlReaderParameter(IMethodSymbol? method, CompilationSecurityTypes xmlTypes)
182private static int GetSpecifiedParameterIndex(IMethodSymbol? method, CompilationSecurityTypes xmlTypes, Func<ITypeSymbol, CompilationSecurityTypes, bool> func)
238case IMethodSymbol method:
260case IMethodSymbol method:
src\11b41c7305441175\PropertySetAnalysis.PropertySetDataFlowOperationVisitor.cs (14)
35private readonly ImmutableDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>.Builder _hazardousUsageBuilder;
37private readonly ImmutableHashSet<IMethodSymbol>.Builder _visitedLocalFunctions;
59this._hazardousUsageBuilder = ImmutableDictionary.CreateBuilder<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>();
61this._visitedLocalFunctions = ImmutableHashSet.CreateBuilder<IMethodSymbol>();
83public ImmutableDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult> HazardousUsages => this._hazardousUsageBuilder.ToImmutable();
85public ImmutableHashSet<IMethodSymbol> VisitedLocalFunctions => this._visitedLocalFunctions.ToImmutable();
453public override PropertySetAbstractValue VisitInvocation_NonLambdaOrDelegateOrLocalFunction(IMethodSymbol method, IOperation? visitedInstance, ImmutableArray<IArgumentOperation> visitedArguments, bool invokedAsDelegate, IOperation originalOperation, PropertySetAbstractValue defaultValue)
510IMethodSymbol method,
593IMethodSymbol? methodSymbol,
615IMethodSymbol? methodSymbol,
620(Location, IMethodSymbol?) key = (operationSyntax.GetLocation(), methodSymbol);
632public override PropertySetAbstractValue VisitInvocation_LocalFunction(IMethodSymbol localFunction, ImmutableArray<IArgumentOperation> visitedArguments, IOperation originalOperation, PropertySetAbstractValue defaultValue)
672foreach (KeyValuePair<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult> kvp in subResult.HazardousUsages)
684foreach (IMethodSymbol localFunctionSymbol in subResult.VisitedLocalFunctions)
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\Compiler\Extensions\IEnumerableOfIMethodSymbolExtensions.cs (25)
15/// <param name="methods">List of <see cref="IMethodSymbol"/> to filter.</param>
18public static IEnumerable<IMethodSymbol> WhereMethodDoesNotContainAttribute(
19this IEnumerable<IMethodSymbol> methods,
35/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
36/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
39public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtLeadingOrTrailing(
40this IEnumerable<IMethodSymbol> methods,
41IMethodSymbol selectedOverload,
92/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
93/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
95public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtTrailing(
96this IEnumerable<IMethodSymbol> methods,
97IMethodSymbol selectedOverload,
104/// Gets the <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>.
106/// <param name="members">The sequence of <see cref="IMethodSymbol"/>s to search.</param>
109/// The first <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>, or <langword>null</langword> if
112public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, params ITypeSymbol[] expectedParameterTypesInOrder)
138public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterInfos(this IEnumerable<IMethodSymbol>? members, params ParameterInfo[] expectedParameterTypesInOrder)
180/// Given an <see cref="IEnumerable{IMethodSymbol}"/>, returns the <see cref="IMethodSymbol"/> whose parameter list
189public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, IReadOnlyList<ITypeSymbol> expectedParameterTypesInOrder)
194foreach (var member in members)
202bool Predicate(IMethodSymbol member)
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (66)
27public static bool IsObjectEqualsOverride(this IMethodSymbol method)
41public static bool IsObjectEquals(this IMethodSymbol method)
55public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
70public static bool IsGetHashCodeOverride(this IMethodSymbol method)
83public static bool IsToStringOverride(this IMethodSymbol method)
96private static bool IsObjectMethodOverride(IMethodSymbol method)
98IMethodSymbol overriddenMethod = method.OverriddenMethod;
115public static bool IsFinalizer(this IMethodSymbol method)
127IMethodSymbol overridden = method.OverriddenMethod;
140for (IMethodSymbol o = overridden.OverriddenMethod; o != null; o = o.OverriddenMethod)
152public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
156return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
163public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
172public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
182public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
204public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
226private static bool HasDisposeMethodSignature(this IMethodSymbol method)
235public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
245public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
262private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
271private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
278private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
294private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
307private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
319public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
334this IMethodSymbol method,
387public static bool IsOnDeserializationImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDeserializationCallback)
407public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
413public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
423public static bool IsPropertyGetter(this IMethodSymbol method)
432public static bool IsIndexerGetter(this IMethodSymbol method)
441public static bool IsPropertyAccessor(this IMethodSymbol method)
450public static bool IsEventAccessor(this IMethodSymbol method)
457public static bool IsOperator(this IMethodSymbol methodSymbol)
462public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
467public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
469var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
472foreach (var member in methods)
502public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
523public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
532public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
544public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
559private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
565public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
571IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
605public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
614public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
623public static int GetParameterIndex(this IMethodSymbol methodSymbol, IParameterSymbol parameterSymbol)
642public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType)
652public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
662public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
674public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
688public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
697public static bool IsOverrideOrVirtualMethodOf([NotNullWhen(returnValue: true)] this IMethodSymbol? methodSymbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? typeSymbol)
721public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
730public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
744public static bool IsAutoPropertyAccessor(this IMethodSymbol methodSymbol)
752public static bool IsTopLevelStatementsEntryPointMethod([NotNullWhen(true)] this IMethodSymbol? methodSymbol)
760public static bool IsGetAwaiterFromAwaitablePattern([NotNullWhen(true)] this IMethodSymbol? method,
782[NotNullWhen(true)] this IMethodSymbol? method,
803public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
805ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
822.OfType<IMethodSymbol>()
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\Compiler\Extensions\ISymbolExtensions.cs (28)
26return symbol is IMethodSymbol accessorSymbol &&
30public static IEnumerable<IMethodSymbol> GetAccessors(this ISymbol symbol)
98return symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
103return (symbol as IMethodSymbol)?.IsFinalizer() ?? false;
157return symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator };
162return symbol is IMethodSymbol { MethodKind: MethodKind.Conversion };
174IMethodSymbol m => m.Parameters,
238public static bool MatchMethodDerivedByName([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol type, string name)
320public static bool HasOverloadWithParameterOfType(this IEnumerable<IMethodSymbol> overloads, IMethodSymbol self, INamedTypeSymbol type, CancellationToken cancellationToken)
322foreach (var overload in overloads)
343public static IEnumerable<int> GetParameterIndices(this IMethodSymbol method, IEnumerable<IParameterSymbol> parameters, CancellationToken cancellationToken)
360public static bool ParametersAreSame(this IMethodSymbol method1, IMethodSymbol method2)
381public static bool ParameterTypesAreSame(this IMethodSymbol method1, IMethodSymbol method2, IEnumerable<int> parameterIndices, CancellationToken cancellationToken)
416public static bool ReturnTypeAndParametersAreSame(this IMethodSymbol method, IMethodSymbol otherMethod)
432public static IMethodSymbol? GetMatchingOverload(this IMethodSymbol method, IEnumerable<IMethodSymbol> overloads, int parameterIndex, INamedTypeSymbol type, CancellationToken cancellationToken)
434foreach (IMethodSymbol overload in overloads)
557IMethodSymbol methodSymbol => methodSymbol.OverriddenMethod,
572if (symbol is IMethodSymbol methodSymbol && !methodSymbol.ExplicitInterfaceImplementations.IsEmpty)
610IMethodSymbol methodSymbol => methodSymbol.ReturnType,
778public static bool HasDerivedMethodAttribute(this IMethodSymbol symbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? attribute)
836=> (symbol as IMethodSymbol)?.IsLambdaOrLocalFunction() == true;
865IMethodSymbol method => method.IsReadOnly,
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\FlowAnalysis\Analysis\CopyAnalysis\CopyAnalysisContext.cs (1)
60IMethodSymbol invokedMethod,
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\FlowAnalysis\Analysis\DisposeAnalysis\DisposeAnalysisContext.cs (1)
91IMethodSymbol invokedMethod,
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PointsToAnalysis\PointsToAnalysisContext.cs (1)
68IMethodSymbol invokedMethod,
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PropertySetAnalysis\PropertySetAnalysis.cs (8)
149/// <returns>Dictionary of <see cref="Location"/> and <see cref="IMethodSymbol"/> pairs mapping to the kind of hazardous usage (Flagged or MaybeFlagged). The method in the key is null for return/initialization statements.</returns>
151public static PooledDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>? BatchGetOrComputeHazardousUsages(
185/// <returns>Dictionary of <see cref="Location"/> and <see cref="IMethodSymbol"/> pairs mapping to the kind of hazardous usage (Flagged or MaybeFlagged). The method in the key is null for return/initialization statements.</returns>
187public static PooledDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>? BatchGetOrComputeHazardousUsages(
198PooledDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>? allResults = null;
218foreach (IMethodSymbol localFunctionSymbol in enclosingControlFlowGraph.LocalFunctions)
263allResults ??= PooledDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>.GetInstance();
265foreach (KeyValuePair<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult> kvp
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\DataFlowOperationVisitor.cs (49)
52private ImmutableHashSet<IMethodSymbol>? _lazyContractCheckMethods;
62private readonly ImmutableHashSet<IMethodSymbol>.Builder _escapedLocalFunctions;
67private readonly ImmutableHashSet<IMethodSymbol>.Builder _analyzedLocalFunctions;
120private readonly ImmutableDictionary<IMethodSymbol, IDataFlowAnalysisResult<TAbstractAnalysisValue>>.Builder _standaloneLocalFunctionAnalysisResultsBuilder;
125private readonly Dictionary<IMethodSymbol, ControlFlowGraph?>? _interproceduralMethodToCfgMap;
150public ImmutableDictionary<IMethodSymbol, IDataFlowAnalysisResult<TAbstractAnalysisValue>> StandaloneLocalFunctionAnalysisResultsMap => _standaloneLocalFunctionAnalysisResultsBuilder.ToImmutable();
269.OfType<IMethodSymbol>().FirstOrDefault(HasDebugAssertSignature);
278_returnValueOperations = OwningSymbol is IMethodSymbol method && !method.ReturnsVoid ? new HashSet<IOperation>() : null;
280_standaloneLocalFunctionAnalysisResultsBuilder = ImmutableDictionary.CreateBuilder<IMethodSymbol, IDataFlowAnalysisResult<TAbstractAnalysisValue>>();
281_escapedLocalFunctions = ImmutableHashSet.CreateBuilder<IMethodSymbol>();
282_analyzedLocalFunctions = ImmutableHashSet.CreateBuilder<IMethodSymbol>();
304_interproceduralMethodToCfgMap = new Dictionary<IMethodSymbol, ControlFlowGraph?>();
342static bool HasDebugAssertSignature(IMethodSymbol method)
362if (OwningSymbol is IMethodSymbol method &&
551OwningSymbol is IMethodSymbol method &&
611foreach (var localFunction in DataFlowAnalysisContext.ControlFlowGraph.LocalFunctions)
629private bool IsStandaloneAnalysisRequiredForLocalFunction(IMethodSymbol localFunction)
834if (OwningSymbol is IMethodSymbol method &&
979private bool IsContractCheckMethod(IMethodSymbol method)
990var validationMethods = requiresMethods.Concat(assumeMethods).Concat(assertMethods).OfType<IMethodSymbol>().Where(m => m.IsStatic && m.ReturnsVoid && !m.Parameters.IsEmpty && (m.Parameters[0].Type.SpecialType == SpecialType.System_Boolean));
1005private bool IsAnyDebugAssertMethod(IMethodSymbol method) =>
1011protected bool IsAnyAssertMethod(IMethodSymbol method)
1763bool IsOverrideOrImplementationOfEquatableEquals(IMethodSymbol methodSymbol)
1774var equalsMember = interfaceType.GetMembers("Equals").OfType<IMethodSymbol>().FirstOrDefault();
2124IMethodSymbol invokedMethod,
2200IMethodSymbol invokedMethod,
2238int currentMethodCallCount = currentMethodsBeingAnalyzed.Count(m => !(m.OwningSymbol is IMethodSymbol ms && ms.IsLambdaOrLocalFunctionOrDelegate()));
2549if (argumentOperation.Parameter!.ContainingSymbol is IMethodSymbol method &&
2593IMethodSymbol invokedMethod,
2630private void PerformStandaloneLocalFunctionInterproceduralAnalysis(IMethodSymbol localFunction)
2731IMethodSymbol invokedMethod)
3159var method = operation.Constructor!;
3178foreach ((IMethodSymbol method, _) in resolvedMethodTargetsOpt)
3224void PostVisitInvocation(IMethodSymbol targetMethod, ImmutableArray<IArgumentOperation> arguments)
3249void ProcessInterlockedOperation(IMethodSymbol targetMethod, ImmutableArray<IArgumentOperation> arguments, INamedTypeSymbol interlockedType)
3284using var methodTargetsOptBuilder = PooledHashSet<(IMethodSymbol method, IOperation? instance)>.GetInstance();
3309PooledHashSet<(IMethodSymbol method, IOperation? instance)> methodTargetsOptBuilder,
3315PooledHashSet<(IMethodSymbol method, IOperation? instance)> methodTargetsOptBuilder,
3322PooledHashSet<(IMethodSymbol method, IOperation? instance)> methodTargetsOptBuilder,
3333var targetMethod = invocation.TargetMethod;
3376void AddMethodTarget(IMethodSymbol method, IOperation? instance)
3435out ImmutableHashSet<(IMethodSymbol method, IOperation? instance)>? resolvedMethodTargets)
3439using var methodTargetsOptBuilder = PooledHashSet<(IMethodSymbol method, IOperation? instance)>.GetInstance();
3531IMethodSymbol method,
3544private ControlFlowGraph? GetInterproceduralControlFlowGraph(IMethodSymbol method)
3574IMethodSymbol localFunction,
4193private IMethodSymbol? DebugAssertMethod { get; }
4222private protected DisposeMethodKind GetDisposeMethodKind(IMethodSymbol method)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (12)
36private readonly Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> _analyzeLocalFunctionOrLambdaInvocation;
55private readonly PooledDictionary<IMethodSymbol, ControlFlowGraph> _localFunctionTargetsToAccessingCfgMap;
79PooledHashSet<IMethodSymbol> lambdaOrLocalFunctionsBeingAnalyzed,
80Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation,
82PooledDictionary<IMethodSymbol, ControlFlowGraph> localFunctionTargetsToAccessingCfgMap,
112protected override PooledHashSet<IMethodSymbol> LambdaOrLocalFunctionsBeingAnalyzed { get; }
119Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation)
133lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
136localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
157IMethodSymbol lambdaOrLocalFunction,
336ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
501protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (48)
26public static bool IsObjectEqualsOverride(this IMethodSymbol method)
40public static bool IsObjectEquals(this IMethodSymbol method)
54public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
69private static bool IsObjectMethodOverride(IMethodSymbol method)
71IMethodSymbol overriddenMethod = method.OverriddenMethod;
89public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
93return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
100public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
109public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
119public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
141public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
163private static bool HasDisposeMethodSignature(this IMethodSymbol method)
171public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
181public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
192private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
200private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
207private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
223private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
236private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
248public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
263this IMethodSymbol method,
311public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
317public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
324public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
329public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
331var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
334foreach (var member in methods)
364public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
385public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
394public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
406public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
420private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
426public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
432IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
465public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
474public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
483public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
493public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
505public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
519public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
527public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
536public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
547public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
549ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
566.OfType<IMethodSymbol>()
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.MethodSymbolKey.cs (22)
11private sealed class ReducedExtensionMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
15public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
24SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
41using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
42foreach (var reducedFrom in reducedFromResolution.OfType<IMethodSymbol>())
55private sealed class ConstructedMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
59public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
66SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
70using var typeArguments = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
101using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
102foreach (var method in constructedFrom.OfType<IMethodSymbol>())
123private sealed class MethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
127public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
160SymbolKeyReader reader, IMethodSymbol? contextualSymbol, out string? failureReason)
179using var methods = GetMembersOfNamedType<IMethodSymbol>(containingType, metadataName: null);
180IMethodSymbol? method = null;
181foreach (var candidate in methods)
223_ = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
243private static IMethodSymbol? Resolve(
244SymbolKeyReader reader, bool isPartialImplementationPart, IMethodSymbol method)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (14)
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
379symbol = ((IMethodSymbol)symbol).GetConstructedReducedFrom()!;
384newSymbol = ((IMethodSymbol)newSymbol).GetConstructedReducedFrom()!;
404if (symbol is IMethodSymbol methodSymbol && newSymbol is IMethodSymbol newMethodSymbol)
478if (symbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } methodSymbol &&
479newSymbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } newMethodSymbol)
757return symbol is IMethodSymbol { ContainingType.SpecialType: SpecialType.System_Object }
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
806private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
875=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
1048return receiverSymbol is IMethodSymbol or IPropertySymbol;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\SymbolEquivalenceComparer.EquivalenceVisitor.cs (8)
124SymbolKind.Method => MethodsAreEquivalent((IMethodSymbol)x, (IMethodSymbol)y, equivalentTypesWithDifferingAssemblies),
170private bool MethodsAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies, bool considerReturnRefKinds = false)
186var rx = x.ReducedFrom;
187var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\VisualBasicGenerateConversionService.vb (6)
55Protected Overrides Function TryInitializeExplicitConversionState(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef identifierToken As SyntaxToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
69Protected Overrides Function TryInitializeImplicitConversionState(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef identifierToken As SyntaxToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
83Private Shared Function TryGetConversionMethodAndTypeToGenerateIn(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
113Private Shared Function TryGetExplicitConversionMethodAndTypeToGenerateIn(document As SemanticDocument, castExpression As CastExpressionSyntax, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
129Private Shared Function TryGetImplicitConversionMethodAndTypeToGenerateIn(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
145Private Shared Function GenerateMethodSymbol(typeToGenerateIn As INamedTypeSymbol, parameterSymbol As INamedTypeSymbol) As IMethodSymbol
FindSymbols\FindReferences\Finders\ConstructorSymbolReferenceFinder.cs (16)
17internal sealed class ConstructorSymbolReferenceFinder : AbstractReferenceFinder<IMethodSymbol>
25protected override bool CanFind(IMethodSymbol symbol)
28protected override async ValueTask<ImmutableArray<ISymbol>> DetermineCascadedSymbolsAsync(IMethodSymbol symbol, Solution solution, FindReferencesSearchOptions options, CancellationToken cancellationToken)
36private static ImmutableArray<ISymbol> GetOtherPartsOfPartial(IMethodSymbol symbol)
47protected override Task<ImmutableArray<string>> DetermineGlobalAliasesAsync(IMethodSymbol symbol, Project project, CancellationToken cancellationToken)
54IMethodSymbol symbol,
94private bool IsCollectionConstructor(IMethodSymbol symbol)
98symbol.ContainingType.GetBaseTypesAndThis().Any(t => t.GetMembers(nameof(IList<>.Add)).Any(m => m is IMethodSymbol { IsStatic: false, Parameters.Length: 1 }));
123IMethodSymbol methodSymbol,
162IMethodSymbol methodSymbol, FindReferencesDocumentState state, Action<FinderLocation, TData> processResult, TData processResultData, string name, string alias, CancellationToken cancellationToken)
179IMethodSymbol symbol,
193IMethodSymbol symbol,
205IMethodSymbol symbol,
225IMethodSymbol symbol,
237IMethodSymbol symbol,
298IMethodSymbol symbol,
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (12)
36private readonly Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> _analyzeLocalFunctionOrLambdaInvocation;
55private readonly PooledDictionary<IMethodSymbol, ControlFlowGraph> _localFunctionTargetsToAccessingCfgMap;
79PooledHashSet<IMethodSymbol> lambdaOrLocalFunctionsBeingAnalyzed,
80Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation,
82PooledDictionary<IMethodSymbol, ControlFlowGraph> localFunctionTargetsToAccessingCfgMap,
112protected override PooledHashSet<IMethodSymbol> LambdaOrLocalFunctionsBeingAnalyzed { get; }
119Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation)
133lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
136localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
157IMethodSymbol lambdaOrLocalFunction,
336ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
501protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.MethodSymbolKey.cs (22)
11private sealed class ReducedExtensionMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
15public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
24SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
41using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
42foreach (var reducedFrom in reducedFromResolution.OfType<IMethodSymbol>())
55private sealed class ConstructedMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
59public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
66SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
70using var typeArguments = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
101using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
102foreach (var method in constructedFrom.OfType<IMethodSymbol>())
123private sealed class MethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
127public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
160SymbolKeyReader reader, IMethodSymbol? contextualSymbol, out string? failureReason)
179using var methods = GetMembersOfNamedType<IMethodSymbol>(containingType, metadataName: null);
180IMethodSymbol? method = null;
181foreach (var candidate in methods)
223_ = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
243private static IMethodSymbol? Resolve(
244SymbolKeyReader reader, bool isPartialImplementationPart, IMethodSymbol method)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (14)
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
379symbol = ((IMethodSymbol)symbol).GetConstructedReducedFrom()!;
384newSymbol = ((IMethodSymbol)newSymbol).GetConstructedReducedFrom()!;
404if (symbol is IMethodSymbol methodSymbol && newSymbol is IMethodSymbol newMethodSymbol)
478if (symbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } methodSymbol &&
479newSymbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } newMethodSymbol)
757return symbol is IMethodSymbol { ContainingType.SpecialType: SpecialType.System_Object }
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
806private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
875=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
1048return receiverSymbol is IMethodSymbol or IPropertySymbol;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\SymbolEquivalenceComparer.EquivalenceVisitor.cs (8)
124SymbolKind.Method => MethodsAreEquivalent((IMethodSymbol)x, (IMethodSymbol)y, equivalentTypesWithDifferingAssemblies),
170private bool MethodsAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies, bool considerReturnRefKinds = false)
186var rx = x.ReducedFrom;
187var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (7)
53public TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
82public SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
125protected abstract TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
147public abstract SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
348IMethodSymbol method => CreateMethodDeclaration(method, codeGenerationDestination, info, cancellationToken),
366IMethodSymbol method => AddMethod(currentDestination, method, info, availableIndices, cancellationToken),
446public Task<Document> AddMethodAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IMethodSymbol method, CancellationToken cancellationToken)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (28)
33IMethodSymbol? addMethod = null,
34IMethodSymbol? removeMethod = null,
35IMethodSymbol? raiseMethod = null)
52IMethodSymbol? getMethod,
53IMethodSymbol? setMethod,
80ImmutableArray<IParameterSymbol> parameters, IMethodSymbol? getMethod, IMethodSymbol? setMethod,
119public static IMethodSymbol CreateConstructorSymbol(
138public static IMethodSymbol CreateDestructorSymbol(
147internal static IMethodSymbol CreateMethodSymbol(
154ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
172public static IMethodSymbol CreateMethodSymbol(
176ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
191public static IMethodSymbol CreateOperatorSymbol(
219public static IMethodSymbol CreateConversionSymbol(
244public static IMethodSymbol CreateConversionSymbol(
356internal static IMethodSymbol CreateAccessorSymbol(
357IMethodSymbol accessor,
360ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
382public static IMethodSymbol CreateAccessorSymbol(
470var invokeMethod = CreateMethodSymbol(
510internal static IMethodSymbol CreateMethodSymbol(
511IMethodSymbol method,
515ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
549IMethodSymbol? getMethod = null,
550IMethodSymbol? setMethod = null,
575IMethodSymbol? addMethod = null,
576IMethodSymbol? removeMethod = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
106protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
118if (impl is IMethodSymbol implMethod)
136.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
137SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
152.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
165(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
168return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
216public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
219public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
222public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
249public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
261public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (12)
36private readonly Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> _analyzeLocalFunctionOrLambdaInvocation;
55private readonly PooledDictionary<IMethodSymbol, ControlFlowGraph> _localFunctionTargetsToAccessingCfgMap;
79PooledHashSet<IMethodSymbol> lambdaOrLocalFunctionsBeingAnalyzed,
80Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation,
82PooledDictionary<IMethodSymbol, ControlFlowGraph> localFunctionTargetsToAccessingCfgMap,
112protected override PooledHashSet<IMethodSymbol> LambdaOrLocalFunctionsBeingAnalyzed { get; }
119Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation)
133lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
136localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
157IMethodSymbol lambdaOrLocalFunction,
336ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
501protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (48)
26public static bool IsObjectEqualsOverride(this IMethodSymbol method)
40public static bool IsObjectEquals(this IMethodSymbol method)
54public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
69private static bool IsObjectMethodOverride(IMethodSymbol method)
71IMethodSymbol overriddenMethod = method.OverriddenMethod;
89public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
93return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
100public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
109public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
119public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
141public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
163private static bool HasDisposeMethodSignature(this IMethodSymbol method)
171public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
181public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
192private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
200private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
207private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
223private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
236private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
248public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
263this IMethodSymbol method,
311public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
317public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
324public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
329public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
331var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
334foreach (var member in methods)
364public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
385public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
394public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
406public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
420private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
426public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
432IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
465public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
474public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
483public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
493public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
505public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
519public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
527public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
536public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
547public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
549ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
566.OfType<IMethodSymbol>()
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.MethodSymbolKey.cs (22)
11private sealed class ReducedExtensionMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
15public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
24SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
41using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
42foreach (var reducedFrom in reducedFromResolution.OfType<IMethodSymbol>())
55private sealed class ConstructedMethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
59public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
66SymbolKeyReader reader, IMethodSymbol? contextualMethod, out string? failureReason)
70using var typeArguments = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
101using var result = PooledArrayBuilder<IMethodSymbol>.GetInstance();
102foreach (var method in constructedFrom.OfType<IMethodSymbol>())
123private sealed class MethodSymbolKey : AbstractSymbolKey<IMethodSymbol>
127public sealed override void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
160SymbolKeyReader reader, IMethodSymbol? contextualSymbol, out string? failureReason)
179using var methods = GetMembersOfNamedType<IMethodSymbol>(containingType, metadataName: null);
180IMethodSymbol? method = null;
181foreach (var candidate in methods)
223_ = reader.ReadSymbolKeyArray<IMethodSymbol, ITypeSymbol>(
243private static IMethodSymbol? Resolve(
244SymbolKeyReader reader, bool isPartialImplementationPart, IMethodSymbol method)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (14)
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
379symbol = ((IMethodSymbol)symbol).GetConstructedReducedFrom()!;
384newSymbol = ((IMethodSymbol)newSymbol).GetConstructedReducedFrom()!;
404if (symbol is IMethodSymbol methodSymbol && newSymbol is IMethodSymbol newMethodSymbol)
478if (symbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } methodSymbol &&
479newSymbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } newMethodSymbol)
757return symbol is IMethodSymbol { ContainingType.SpecialType: SpecialType.System_Object }
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
806private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
875=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
1048return receiverSymbol is IMethodSymbol or IPropertySymbol;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\SymbolEquivalenceComparer.EquivalenceVisitor.cs (8)
124SymbolKind.Method => MethodsAreEquivalent((IMethodSymbol)x, (IMethodSymbol)y, equivalentTypesWithDifferingAssemblies),
170private bool MethodsAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies, bool considerReturnRefKinds = false)
186var rx = x.ReducedFrom;
187var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (7)
53public TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
82public SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
125protected abstract TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
147public abstract SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
348IMethodSymbol method => CreateMethodDeclaration(method, codeGenerationDestination, info, cancellationToken),
366IMethodSymbol method => AddMethod(currentDestination, method, info, availableIndices, cancellationToken),
446public Task<Document> AddMethodAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IMethodSymbol method, CancellationToken cancellationToken)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (28)
33IMethodSymbol? addMethod = null,
34IMethodSymbol? removeMethod = null,
35IMethodSymbol? raiseMethod = null)
52IMethodSymbol? getMethod,
53IMethodSymbol? setMethod,
80ImmutableArray<IParameterSymbol> parameters, IMethodSymbol? getMethod, IMethodSymbol? setMethod,
119public static IMethodSymbol CreateConstructorSymbol(
138public static IMethodSymbol CreateDestructorSymbol(
147internal static IMethodSymbol CreateMethodSymbol(
154ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
172public static IMethodSymbol CreateMethodSymbol(
176ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
191public static IMethodSymbol CreateOperatorSymbol(
219public static IMethodSymbol CreateConversionSymbol(
244public static IMethodSymbol CreateConversionSymbol(
356internal static IMethodSymbol CreateAccessorSymbol(
357IMethodSymbol accessor,
360ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
382public static IMethodSymbol CreateAccessorSymbol(
470var invokeMethod = CreateMethodSymbol(
510internal static IMethodSymbol CreateMethodSymbol(
511IMethodSymbol method,
515ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
549IMethodSymbol? getMethod = null,
550IMethodSymbol? setMethod = null,
575IMethodSymbol? addMethod = null,
576IMethodSymbol? removeMethod = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
106protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
118if (impl is IMethodSymbol implMethod)
136.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
137SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
152.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
165(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
168return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
216public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
219public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
222public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
249public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
261public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (12)
32IMethodSymbol method,
45IMethodSymbol method,
60IMethodSymbol method,
75IMethodSymbol method, CodeGenerationDestination destination,
93IMethodSymbol method,
112IMethodSymbol method, CodeGenerationDestination destination,
165IMethodSymbol method, CodeGenerationDestination destination,
220IMethodSymbol method, bool isExplicit, CSharpCodeGenerationContextInfo info)
231IMethodSymbol method)
238private static SyntaxList<TypeParameterConstraintClauseSyntax> GenerateDefaultConstraints(IMethodSymbol method)
312IMethodSymbol method, CSharpCodeGenerationContextInfo info)
318IMethodSymbol method,