11 implementations of IMethodSymbol
GenerateDocumentationAndConfigFiles (1)
Microsoft.CodeAnalysis.Analyzers (1)
Microsoft.CodeAnalysis.BannedApiAnalyzers (1)
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
Microsoft.CodeAnalysis.CSharp (1)
Microsoft.CodeAnalysis.Features (1)
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (1)
Microsoft.CodeAnalysis.VisualBasic (1)
Microsoft.CodeAnalysis.Workspaces (1)
Roslyn.Diagnostics.Analyzers (1)
Text.Analyzers (1)
10084 references to IMethodSymbol
Analyzer.Utilities.UnitTests (4)
Aspire.Hosting.Analyzers (2)
ConfigurationSchemaGenerator (18)
GenerateDocumentationAndConfigFiles (420)
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)
172public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
182public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
199private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
208private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
215private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
231private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
244private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
256public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
271this IMethodSymbol method,
321public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
327public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
334public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
339public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
341var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
344foreach (var member in methods)
374public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
395public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
404public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
416public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
430private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
436public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
442IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
475public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
484public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
493public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
503public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
515public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
529public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
537public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
546public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
557public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
559ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
576.OfType<IMethodSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
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\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\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
105protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
117if (impl is IMethodSymbol implMethod)
135.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
136SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
151.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
164(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
167return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
215public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
218public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
221public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
248public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
260public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor)
ILLink.RoslynAnalyzer (140)
DataFlow\DynamicallyAccessedMembersBinder.cs (13)
36foreach (var c in typeDefinition.ApplyIncludeInherited(t => t.GetConstructorsOnType(filter: null, bindingFlags: BindingFlags.NonPublic), withInherited))
43foreach (var c in typeDefinition.ApplyIncludeInherited(t => t.GetConstructorsOnType(filter: null, bindingFlags: BindingFlags.Public), withInherited))
49foreach (var c in typeDefinition.GetConstructorsOnType(filter: m => (m.DeclaredAccessibility == Accessibility.Public) && m.Parameters.Length == 0))
56foreach (var m in typeDefinition.ApplyIncludeInherited(t => t.GetMethodsOnTypeHierarchy(filter: null, bindingFlags: BindingFlags.NonPublic | declaredOnlyFlags), withInherited))
62foreach (var m in typeDefinition.GetMethodsOnTypeHierarchy(filter: null, bindingFlags: BindingFlags.Public | declaredOnlyFlags))
137public static IEnumerable<IMethodSymbol> GetConstructorsOnType(this ITypeSymbol type, Func<IMethodSymbol, bool>? filter, BindingFlags? bindingFlags = null)
139foreach (var method in type.GetMembers().OfType<IMethodSymbol>())
164public static IEnumerable<IMethodSymbol> GetMethodsOnTypeHierarchy(this ITypeSymbol thisType, Func<IMethodSymbol, bool>? filter, BindingFlags? bindingFlags = null)
170foreach (var method in type.GetMembers().OfType<IMethodSymbol>())
DynamicallyAccessedMembersAnalyzer.cs (18)
144VerifyDamOnPropertyAndAccessorMatch(context, (IMethodSymbol)context.Symbol);
145VerifyDamOnDerivedAndBaseMethodsMatch(context, (IMethodSymbol)context.Symbol);
167else if (member is IMethodSymbol method)
185private static void VerifyDamOnDerivedAndBaseMethodsMatch(SymbolAnalysisContext context, IMethodSymbol methodSymbol)
187if (methodSymbol.TryGetOverriddenMember(out var overriddenSymbol) && overriddenSymbol is IMethodSymbol overriddenMethod
188&& context.Symbol is IMethodSymbol method)
194private static void VerifyDamOnMethodsMatch(SymbolAnalysisContext context, IMethodSymbol overrideMethod, IMethodSymbol baseMethod, ISymbol? origin = null)
201(IMethodSymbol attributableMethod, DynamicallyAccessedMemberTypes missingAttribute) = GetTargetAndRequirements(overrideMethod,
225(IMethodSymbol attributableMethod, DynamicallyAccessedMemberTypes missingAttribute) = GetTargetAndRequirements(overrideMethod,
251(IMethodSymbol attributableMethod, DynamicallyAccessedMemberTypes missingAttribute) = GetTargetAndRequirements(overrideMethod, baseMethod, methodTypeParameterAnnotation, overriddenMethodTypeParameterAnnotation);
290if (implementationMember is IMethodSymbol implementationMethod && interfaceMember is IMethodSymbol interfaceMethod)
305private static void VerifyDamOnPropertyAndAccessorMatch(SymbolAnalysisContext context, IMethodSymbol methodSymbol)
330private static (IMethodSymbol Method, DynamicallyAccessedMemberTypes Requirements) GetTargetAndRequirements(IMethodSymbol method, IMethodSymbol overriddenMethod, DynamicallyAccessedMemberTypes methodAnnotation, DynamicallyAccessedMemberTypes overriddenMethodAnnotation)
333IMethodSymbol paramNeedsAttributes;
Metrics (273)
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)
172public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
182public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
199private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
208private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
215private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
231private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
244private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
256public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
271this IMethodSymbol method,
321public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
327public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
334public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
339public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
341var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
344foreach (var member in methods)
374public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
395public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
404public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
416public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
430private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
436public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
442IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
475public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
484public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
493public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
503public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
515public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
529public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
537public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
546public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
557public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
559ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
576.OfType<IMethodSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
Metrics.Legacy (272)
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)
172public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
182public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
199private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
208private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
215private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
231private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
244private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
256public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
271this IMethodSymbol method,
321public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
327public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
334public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
339public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
341var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
344foreach (var member in methods)
374public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
395public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
404public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
416public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
430private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
436public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
442IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
475public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
484public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
493public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
503public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
515public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
529public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
537public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
546public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
557public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
559ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
576.OfType<IMethodSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
Microsoft.Analyzers.Extra (56)
Microsoft.Analyzers.Local (18)
Microsoft.AspNetCore.Analyzers (30)
Microsoft.AspNetCore.Analyzers.Test (16)
Microsoft.AspNetCore.App.Analyzers (77)
RouteEmbeddedLanguage\Infrastructure\RouteUsageDetector.cs (13)
35IMethodSymbol? MethodSymbol,
51IMethodSymbol Method,
92var mapMethodSymbol = GetMethodInfo(semanticModel, mapMethodParts.Value.DelegateExpression, cancellationToken);
115var methodSymbol = semanticModel.GetDeclaredSymbol(methodDeclarationSyntax, cancellationToken);
117var actionMethodSymbol = FindMvcMethod(wellKnownTypes, methodSymbol);
154private static ImmutableArray<string> CalculateHttpMethods(WellKnownTypes wellKnownTypes, IMethodSymbol mapMethodSymbol)
212private static IMethodSymbol? FindMvcMethod(WellKnownTypes wellKnownTypes, IMethodSymbol? methodSymbol)
247if (symbol is IMethodSymbol methodSymbol)
260private static MapMethodParts? FindValidMapMethodParts(SemanticModel semanticModel, WellKnownTypes wellKnownTypes, BaseArgumentListSyntax argumentList, IMethodSymbol method)
308private static ArgumentSyntax? GetArgumentSyntax(BaseArgumentListSyntax argumentList, IMethodSymbol methodSymbol, IParameterSymbol parameterSymbol)
333private static IMethodSymbol? GetMethodInfo(SemanticModel semanticModel, SyntaxNode syntaxNode, CancellationToken cancellationToken)
342return delegateSymbol as IMethodSymbol;
src\Shared\RoslynUtils\ParsabilityHelper.cs (10)
20private static readonly BoundedCacheWithFactory<ITypeSymbol, (BindabilityMethod?, IMethodSymbol?)> BindabilityCache = new();
76.OfType<IMethodSymbol>();
94private static bool IsTryParse(IMethodSymbol methodSymbol)
104private static bool IsTryParseWithFormat(IMethodSymbol methodSymbol, WellKnownTypes wellKnownTypes)
134private static bool IsBindAsync(IMethodSymbol methodSymbol, ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
145private static bool IsBindAsyncWithParameter(IMethodSymbol methodSymbol, ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
162internal static Bindability GetBindability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, out BindabilityMethod? bindabilityMethod, out IMethodSymbol? bindMethodSymbol)
166IMethodSymbol? bindAsyncMethod = null;
171IMethodSymbol? bindMethodSymbol = null;
185if (methodSymbolCandidate is IMethodSymbol methodSymbol)
Microsoft.AspNetCore.App.CodeFixes (2)
Microsoft.AspNetCore.Components.Analyzers (1)
Microsoft.AspNetCore.Components.SdkAnalyzers (1)
Microsoft.AspNetCore.Http.RequestDelegateGenerator (21)
src\Shared\RoslynUtils\ParsabilityHelper.cs (10)
20private static readonly BoundedCacheWithFactory<ITypeSymbol, (BindabilityMethod?, IMethodSymbol?)> BindabilityCache = new();
76.OfType<IMethodSymbol>();
94private static bool IsTryParse(IMethodSymbol methodSymbol)
104private static bool IsTryParseWithFormat(IMethodSymbol methodSymbol, WellKnownTypes wellKnownTypes)
134private static bool IsBindAsync(IMethodSymbol methodSymbol, ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
145private static bool IsBindAsyncWithParameter(IMethodSymbol methodSymbol, ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
162internal static Bindability GetBindability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, out BindabilityMethod? bindabilityMethod, out IMethodSymbol? bindMethodSymbol)
166IMethodSymbol? bindAsyncMethod = null;
171IMethodSymbol? bindMethodSymbol = null;
185if (methodSymbolCandidate is IMethodSymbol methodSymbol)
Microsoft.AspNetCore.Mvc.Analyzers (30)
Microsoft.AspNetCore.Mvc.Api.Analyzers (40)
Microsoft.AspNetCore.OpenApi.SourceGenerators (16)
Microsoft.AspNetCore.SignalR.Client.SourceGenerator (15)
Microsoft.CodeAnalysis (197)
Compilation\Compilation.cs (18)
961public IMethodSymbol? GetEntryPoint(CancellationToken cancellationToken)
966protected abstract IMethodSymbol? CommonGetEntryPoint(CancellationToken cancellationToken);
1539/// Creates an <see cref="IMethodSymbol"/> whose <see cref="IMethodSymbol.MethodKind"/> is <see
1548public IMethodSymbol CreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol leftType, ITypeSymbol rightType)
1564protected abstract IMethodSymbol CommonCreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol leftType, ITypeSymbol rightType);
1567/// Creates an <see cref="IMethodSymbol"/> whose <see cref="IMethodSymbol.MethodKind"/> is <see
1575public IMethodSymbol CreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol operandType)
1588protected abstract IMethodSymbol CommonCreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol operandType);
2473IMethodSymbol? debugEntryPoint,
2706IMethodSymbol debugEntryPoint,
2730IMethodSymbol? debugEntryPoint,
2791IMethodSymbol? debugEntryPoint = null,
2819IMethodSymbol? debugEntryPoint,
2937IMethodSymbol? debugEntryPoint,
3171IMethodSymbol? debugEntryPoint,
3221internal abstract void ValidateDebugEntryPoint(IMethodSymbol debugEntryPoint, DiagnosticBag diagnostics);
Generated\Operations.Generated.cs (40)
577IMethodSymbol Symbol { get; }
713IMethodSymbol? OperatorMethod { get; }
776IMethodSymbol TargetMethod { get; }
969IMethodSymbol Method { get; }
1076IMethodSymbol? OperatorMethod { get; }
1134IMethodSymbol? OperatorMethod { get; }
1250IMethodSymbol Symbol { get; }
1279IMethodSymbol? Constructor { get; }
1528IMethodSymbol? OperatorMethod { get; }
1780IMethodSymbol AddMethod { get; }
2198IMethodSymbol? OperatorMethod { get; }
3147IMethodSymbol? Method { get; }
3621IMethodSymbol? CloneMethod { get; }
3952IMethodSymbol? ConstructMethod { get; }
4918internal LocalFunctionOperation(IMethodSymbol symbol, IBlockOperation? body, IBlockOperation? ignoredBody, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
4925public IMethodSymbol Symbol { get; }
5154internal InvocationOperation(IMethodSymbol targetMethod, ITypeSymbol? constrainedToType, IOperation? instance, bool isVirtual, ImmutableArray<IArgumentOperation> arguments, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5164public IMethodSymbol TargetMethod { get; }
5400internal MethodReferenceOperation(IMethodSymbol method, ITypeSymbol? constrainedToType, bool isVirtual, IOperation? instance, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5408public IMethodSymbol Method { get; }
5579internal UnaryOperation(UnaryOperatorKind operatorKind, IOperation operand, bool isLifted, bool isChecked, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5595public IMethodSymbol? OperatorMethod { get; }
5642internal BinaryOperation(BinaryOperatorKind operatorKind, IOperation leftOperand, IOperation rightOperand, bool isLifted, bool isChecked, bool isCompareText, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, IMethodSymbol? unaryOperatorMethod, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5663public IMethodSymbol? OperatorMethod { get; }
5665public IMethodSymbol? UnaryOperatorMethod { get; }
5864internal AnonymousFunctionOperation(IMethodSymbol symbol, IBlockOperation body, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
5870public IMethodSymbol Symbol { get; }
5917internal ObjectCreationOperation(IMethodSymbol? constructor, IObjectOrCollectionInitializerOperation? initializer, ImmutableArray<IArgumentOperation> arguments, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5926public IMethodSymbol? Constructor { get; }
6306internal CompoundAssignmentOperation(IConvertibleConversion inConversion, IConvertibleConversion outConversion, BinaryOperatorKind operatorKind, bool isLifted, bool isChecked, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, IOperation target, IOperation value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6325public IMethodSymbol? OperatorMethod { get; }
7256internal IncrementOrDecrementOperation(bool isPostfix, bool isLifted, bool isChecked, IOperation target, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, OperationKind kind, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7272public IMethodSymbol? OperatorMethod { get; }
9037internal RangeOperation(IOperation? leftOperand, IOperation? rightOperand, bool isLifted, IMethodSymbol? method, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9049public IMethodSymbol? Method { get; }
10024internal WithOperation(IOperation operand, IMethodSymbol? cloneMethod, IObjectOrCollectionInitializerOperation initializer, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10033public IMethodSymbol? CloneMethod { get; }
10671internal CollectionExpressionOperation(IMethodSymbol? constructMethod, ImmutableArray<IOperation> elements, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10678public IMethodSymbol? ConstructMethod { get; }
Operations\ControlFlowGraph.cs (7)
27private readonly ImmutableDictionary<IMethodSymbol, (ControlFlowRegion region, ILocalFunctionOperation operation, int ordinal)> _localFunctionsMap;
36ImmutableArray<IMethodSymbol> localFunctions,
37ImmutableDictionary<IMethodSymbol, (ControlFlowRegion region, ILocalFunctionOperation operation, int ordinal)> localFunctionsMap,
55foreach (IMethodSymbol method in localFunctions)
222public ImmutableArray<IMethodSymbol> LocalFunctions { get; }
227public ControlFlowGraph GetLocalFunctionControlFlowGraph(IMethodSymbol localFunction, CancellationToken cancellationToken = default)
244internal bool TryGetLocalFunctionControlFlowGraph(IMethodSymbol localFunction, [NotNullWhen(true)] out ControlFlowGraph? controlFlowGraph)
Operations\ControlFlowGraphBuilder.cs (23)
149var localFunctions = ArrayBuilder<IMethodSymbol>.GetInstance();
150var localFunctionsMap = ImmutableDictionary.CreateBuilder<IMethodSymbol, (ControlFlowRegion, ILocalFunctionOperation, int)>();
2472IMethodSymbol? unaryOperatorMethod = ((BinaryOperation)binOp).UnaryOperatorMethod;
2574IMethodSymbol? unaryOperatorMethod = ((BinaryOperation)binOp).UnaryOperatorMethod;
3334var method = (IMethodSymbol?)_compilation.CommonGetSpecialTypeMember(nullableMember)?.GetISymbol();
3342method = (IMethodSymbol)candidate;
3955private void HandleUsingOperationParts(IOperation resources, IOperation body, IMethodSymbol? disposeMethod, ImmutableArray<IArgumentOperation> disposeArguments, ImmutableArray<ILocalSymbol> locals, bool isAsynchronous,
4112private void AddDisposingFinally(IOperation resource, bool requiresRuntimeConversion, ITypeSymbol iDisposable, IMethodSymbol? disposeMethod, ImmutableArray<IArgumentOperation> disposeArguments, bool isAsynchronous)
4171var method = disposeMethod ?? (isAsynchronous
4172? (IMethodSymbol?)_compilation.CommonGetWellKnownTypeMember(WellKnownMember.System_IAsyncDisposable__DisposeAsync)?.GetISymbol()
4173: (IMethodSymbol?)_compilation.CommonGetSpecialTypeMember(SpecialMember.System_IDisposable__Dispose)?.GetISymbol());
4327var enterMethod = (IMethodSymbol?)_compilation.CommonGetWellKnownTypeMember(WellKnownMember.System_Threading_Monitor__Enter2)?.GetISymbol();
4333enterMethod = (IMethodSymbol?)_compilation.CommonGetWellKnownTypeMember(WellKnownMember.System_Threading_Monitor__Enter)?.GetISymbol();
4416var exitMethod = (IMethodSymbol?)_compilation.CommonGetWellKnownTypeMember(WellKnownMember.System_Threading_Monitor__Exit)?.GetISymbol();
4695InvocationOperation makeInvocationDroppingInstanceForStaticMethods(IMethodSymbol method, IOperation instance, ImmutableArray<IArgumentOperation> arguments)
4700InvocationOperation makeInvocation(SyntaxNode syntax, IMethodSymbol method, IOperation? instanceOpt, ImmutableArray<IArgumentOperation> arguments)
4788var method = (IMethodSymbol?)_compilation.CommonGetWellKnownTypeMember(helper)?.GetISymbol();
7791var matchFailureCtor =
7792(IMethodSymbol?)(_compilation.CommonGetWellKnownTypeMember(WellKnownMember.System_Runtime_CompilerServices_SwitchExpressionException__ctor) ??
Operations\ControlFlowGraphBuilder.RegionBuilder.cs (11)
24public ArrayBuilder<(IMethodSymbol, ILocalFunctionOperation)>? LocalFunctions = null;
94public void Add(IMethodSymbol symbol, ILocalFunctionOperation operation)
102LocalFunctions = ArrayBuilder<(IMethodSymbol, ILocalFunctionOperation)>.GetInstance();
108public void AddRange(ArrayBuilder<(IMethodSymbol, ILocalFunctionOperation)>? others)
117Debug.Assert(others.All(((IMethodSymbol m, ILocalFunctionOperation _) tuple) => tuple.m.MethodKind == MethodKind.LocalFunction));
121LocalFunctions = ArrayBuilder<(IMethodSymbol, ILocalFunctionOperation)>.GetInstance();
297ArrayBuilder<IMethodSymbol> localFunctions,
298ImmutableDictionary<IMethodSymbol, (ControlFlowRegion region, ILocalFunctionOperation operation, int ordinal)>.Builder localFunctionsMap,
311foreach ((IMethodSymbol method, IOperation _) in LocalFunctions)
339LocalFunctions?.SelectAsArray(((IMethodSymbol, ILocalFunctionOperation) tuple) => tuple.Item1) ?? default,
346foreach ((IMethodSymbol method, ILocalFunctionOperation operation) in LocalFunctions)
Microsoft.CodeAnalysis.Analyzers (467)
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)
172public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
182public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
199private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
208private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
215private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
231private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
244private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
256public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
271this IMethodSymbol method,
321public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
327public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
334public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
339public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
341var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
344foreach (var member in methods)
374public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
395public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
404public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
416public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
430private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
436public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
442IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
475public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
484public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
493public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
503public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
515public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
529public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
537public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
546public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
557public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
559ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
576.OfType<IMethodSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
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\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\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
105protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
117if (impl is IMethodSymbol implMethod)
135.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
136SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
151.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
164(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
167return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
215public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
218public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
221public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
248public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
260public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor)
Microsoft.CodeAnalysis.AnalyzerUtilities (409)
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)
172public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
182public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
199private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
208private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
215private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
231private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
244private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
256public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
271this IMethodSymbol method,
321public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
327public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
334public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
339public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
341var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
344foreach (var member in methods)
374public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
395public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
404public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
416public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
430private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
436public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
442IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
475public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
484public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
493public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
503public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
515public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
529public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
537public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
546public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
557public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
559ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
576.OfType<IMethodSymbol>()
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\CopyAnalysis\CopyAnalysis.CopyDataFlowOperationVisitor.cs (1)
573IMethodSymbol invokedMethod,
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\GlobalFlowStateAnalysis\GlobalFlowStateAnalysisContext.cs (1)
75IMethodSymbol invokedMethod,
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\GlobalFlowStateAnalysis\GlobalFlowStateDataFlowOperationVisitor.cs (1)
146IMethodSymbol invokedMethod,
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\GlobalFlowStateAnalysis\GlobalFlowStateValueSetFlowOperationVisitor.cs (1)
109IMethodSymbol method,
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\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PropertySetAnalysis\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\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\ValueContentAnalysis\ValueContentAnalysis.ValueContentDataFlowOperationVisitor.cs (1)
271IMethodSymbol method,
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\ValueContentAnalysis\ValueContentAnalysisContext.cs (1)
75IMethodSymbol invokedMethod,
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
Microsoft.CodeAnalysis.BannedApiAnalyzers (430)
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)
172public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
182public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
199private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
208private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
215private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
231private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
244private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
256public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
271this IMethodSymbol method,
321public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
327public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
334public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
339public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
341var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
344foreach (var member in methods)
374public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
395public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
404public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
416public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
430private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
436public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
442IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
475public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
484public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
493public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
503public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
515public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
529public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
537public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
546public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
557public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
559ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
576.OfType<IMethodSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
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\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\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
105protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
117if (impl is IMethodSymbol implMethod)
135.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
136SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
151.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
164(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
167return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
215public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
218public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
221public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
248public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
260public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor)
Microsoft.CodeAnalysis.CodeStyle (283)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
Microsoft.CodeAnalysis.CodeStyle.Fixes (307)
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\Analyzers\Core\CodeFixes\ImplementAbstractClass\ImplementAbstractClassData.cs (7)
162IMethodSymbol method => GenerateMethod(compilation, method, throughMember, modifiers, accessibility),
170Compilation compilation, IMethodSymbol method, ISymbol? throughMember,
205var getMethod = ShouldGenerateAccessor(property.GetMethod)
214var setMethod = ShouldGenerateAccessor(property.SetMethod)
241private IMethodSymbol? GetEventAddOrRemoveMethod(
242IEventSymbol @event, IMethodSymbol? accessor, ISymbol? throughMember,
260private bool ShouldGenerateAccessor([NotNullWhen(true)] IMethodSymbol? method)
src\Analyzers\Core\CodeFixes\ImplementInterface\ImplementInterfaceGenerator.cs (8)
260if (member is not IMethodSymbol method)
299IMethodSymbol method => [GenerateMethod(compilation, method, conflictingMember as IMethodSymbol, accessibility, modifiers, generateAbstractly, useExplicitInterfaceSymbol, memberName)],
308var accessor = CodeGenerationSymbolFactory.CreateAccessorSymbol(
323private IMethodSymbol? GetAddOrRemoveMethod(
324IEventSymbol @event, bool generateInvisibly, IMethodSymbol accessor, string memberName,
360if (member is IMethodSymbol method1 && baseMember is IMethodSymbol method2)
src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (9)
31IMethodSymbol methodSymbol,
62var methodSymbol = GetMethodSymbol(semanticModel, node, cancellationToken);
91private static IMethodSymbol? GetMethodSymbol(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
95return symbol as IMethodSymbol;
120var methodSymbol = GetMethodSymbol(semanticModel, node, cancellationToken);
162IMethodSymbol methodSymbol,
181var newMethod = (IMethodSymbol)semanticModel.GetRequiredDeclaredSymbol(newNode, cancellationToken);
191IMethodSymbol methodSymbol,
src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (8)
25protected abstract SyntaxNode RemoveAsyncTokenAndFixReturnType(IMethodSymbol methodSymbol, SyntaxNode node, KnownTaskTypes knownTypes);
58var methodSymbol = (IMethodSymbol?)(semanticModel.GetDeclaredSymbol(node, cancellationToken) ?? semanticModel.GetSymbolInfo(node, cancellationToken).GetAnySymbol());
73private async Task<Solution> RenameThenRemoveAsyncTokenAsync(Document document, SyntaxNode node, IMethodSymbol methodSymbol, CancellationToken cancellationToken)
89var newMethod = (IMethodSymbol)semanticModel.GetRequiredDeclaredSymbol(newNode, cancellationToken);
97Document document, IMethodSymbol methodSymbol, SyntaxNode node, CancellationToken cancellationToken)
128if (semanticModel.GetDeclaredSymbol(methodDeclaration, cancellationToken) is IMethodSymbol methodSymbol)
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\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\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
105protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
117if (impl is IMethodSymbol implMethod)
135.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
136SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
151.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
164(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
167return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
215public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
218public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
221public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
248public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
260public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor)
Microsoft.CodeAnalysis.CSharp (159)
CSharpExtensions.cs (5)
1351public static IMethodSymbol? GetDeclaredSymbol(this SemanticModel? semanticModel, CompilationUnitSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
1409public static IMethodSymbol? GetDeclaredSymbol(this SemanticModel? semanticModel, BaseMethodDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
1490public static IMethodSymbol? GetDeclaredSymbol(this SemanticModel? semanticModel, AccessorDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
1627public static IMethodSymbol? GetDeclaredSymbol(this SemanticModel? semanticModel, LocalFunctionStatementSyntax node, CancellationToken cancellationToken = default(CancellationToken))
1637public static IMethodSymbol? GetInterceptorMethod(this SemanticModel? semanticModel, InvocationExpressionSyntax node, CancellationToken cancellationToken = default)
Microsoft.CodeAnalysis.CSharp.Analyzers (5)
Microsoft.CodeAnalysis.CSharp.CodeStyle (122)
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (130)
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)
236IMethodSymbol method)
243private static SyntaxList<TypeParameterConstraintClauseSyntax> GenerateDefaultConstraints(IMethodSymbol method)
317IMethodSymbol method, CSharpCodeGenerationContextInfo info)
323IMethodSymbol method,
Microsoft.CodeAnalysis.CSharp.EditorFeatures (5)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (22)
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (60)
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (13)
Emit\EditAndContinue\EditAndContinueClosureTests.cs (3)
71Edit(SemanticEditKind.Update, c => c.GetMembers<IMethodSymbol>("C.F").Single(m => m.Parameters is []), preserveLocalVariables: true),
72Edit(SemanticEditKind.Update, c => c.GetMembers<IMethodSymbol>("C.F").Single(m => m.Parameters is [_]), preserveLocalVariables: true),
73Edit(SemanticEditKind.Update, c => c.GetMembers<IMethodSymbol>("C.F").Single(m => m.Parameters is [_, _]), preserveLocalVariables: true),
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (53)
Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Features (298)
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)
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (65)
EditAndContinue\ActiveStatementTests.Methods.cs (3)
533[SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")],
572semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
575semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C", syntaxMap: syntaxMapB)]),
EditAndContinue\StatementEditingTests.cs (5)
5620SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
5621SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")
5894SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, preserveLocalVariables: true, partialType: "C"));
5939SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, preserveLocalVariables: true, partialType: "C"));
9342SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, preserveLocalVariables: true, partialType: "C"));
EditAndContinue\TopLevelEditingTests.cs (56)
6905SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.M")),
7098semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMembers<IMethodSymbol>("C.F").Single(m => m.Parameters is [{ Type.SpecialType: SpecialType.System_Char }]))]),
7101semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMembers<IMethodSymbol>("C.F").Single(m => m.Parameters is [{ Type.SpecialType: SpecialType.System_Byte }]))]),
7335SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>("F")));
7350SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>("F")));
7399SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("S").GetMember<IMethodSymbol>("M")));
8611SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.M").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
8612SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.M").PartialImplementationPart, partialType: "C")
10296semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10307semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10316semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10318semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10331SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.F"), deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C")
10353semanticEdits: [SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C")]),
10364semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10366semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")])
10376semanticEdits: [SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart)]),
10411semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10433semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10453semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10455semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10479SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")
10500SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
10501SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")
10506SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
10507SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")
11465SemanticEdit(SemanticEditKind.Update, c => c.GetMembers<IMethodSymbol>("C.Deconstruct").Single(m => m.Parameters is [_])),
11830SemanticEdit(SemanticEditKind.Update, c => c.GetMembers<IMethodSymbol>("C.Deconstruct").Single(m => m.Parameters is [_, _])),
12899SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>("C").PartialImplementationPart, partialType: "C"));
14354SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>("F")),
14367SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>("F")),
19622semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C")]),
19633semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C")]),
19642semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C")]),
19656SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C")
19668semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C")]),
19670semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C")])
19743SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C")
19768SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C"),
19794SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C"),
19816SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
19818SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C"),
19824SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
19826SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C"),
20432SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_Item").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
20433SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.set_Item").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
20435SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.get_Item").PartialImplementationPart, partialType: "C"),
20436SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.set_Item").PartialImplementationPart, partialType: "C"),
20442SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_Item").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
20443SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.set_Item").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
20445SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.get_Item").PartialImplementationPart, partialType: "C"),
20446SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.set_Item").PartialImplementationPart, partialType: "C"),
20550SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_Item").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
20551SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.set_Item").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
20553SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.get_Item").PartialImplementationPart, partialType: "C"),
20554SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.set_Item").PartialImplementationPart, partialType: "C"),
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (7)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (343)
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (410)
Compilation\CompilationAPITests.cs (21)
2742var op = compilation.CreateBuiltinOperator(name, intType, intType, intType);
2760var op = compilation.CreateBuiltinOperator(name, boolType, intType, intType);
2779var op = compilation.CreateBuiltinOperator(WellKnownMemberNames.AdditionOperatorName, intType, intType, intType);
2846var addBuiltIn = compilation.CreateBuiltinOperator(WellKnownMemberNames.AdditionOperatorName, intType, intType, intType);
2847var addBuiltInChecked = compilation.CreateBuiltinOperator(WellKnownMemberNames.CheckedAdditionOperatorName, intType, intType, intType);
2848var subtractBuiltIn = compilation.CreateBuiltinOperator(WellKnownMemberNames.SubtractionOperatorName, intType, intType, intType);
2849var subtractBuiltInChecked = compilation.CreateBuiltinOperator(WellKnownMemberNames.CheckedSubtractionOperatorName, intType, intType, intType);
2881var addBuiltIn = compilation.CreateBuiltinOperator(WellKnownMemberNames.AdditionOperatorName, intType, intType, intType);
2882var addBuiltInChecked = compilation.CreateBuiltinOperator(WellKnownMemberNames.CheckedAdditionOperatorName, intType, intType, intType);
2883var subtractBuiltIn = compilation.CreateBuiltinOperator(WellKnownMemberNames.SubtractionOperatorName, intType, intType, intType);
2884var subtractBuiltInChecked = compilation.CreateBuiltinOperator(WellKnownMemberNames.CheckedSubtractionOperatorName, intType, intType, intType);
2913var addBuiltIn = compilation.CreateBuiltinOperator(WellKnownMemberNames.AdditionOperatorName, intType, intType, intType);
2914var addBuiltInChecked = compilation.CreateBuiltinOperator(WellKnownMemberNames.CheckedAdditionOperatorName, intType, intType, intType);
2915var subtractBuiltIn = compilation.CreateBuiltinOperator(WellKnownMemberNames.SubtractionOperatorName, intType, intType, intType);
2916var subtractBuiltInChecked = compilation.CreateBuiltinOperator(WellKnownMemberNames.CheckedSubtractionOperatorName, intType, intType, intType);
2938var op = compilation.CreateBuiltinOperator(name, intType, intType);
2950var op = compilation.CreateBuiltinOperator(name, boolType, boolType);
2969var op = compilation.CreateBuiltinOperator(WellKnownMemberNames.UnaryPlusOperatorName, intType, intType);
3065var genericMethod = (IMethodSymbol)comp.GetMember("Program.M");
3071var type = genericMethod.Construct(typeArguments, default);
Compilation\GetSemanticInfoTests.cs (47)
1026IMethodSymbol methodSymbol = (IMethodSymbol)bindInfo.Symbol;
1074Assert.Equal(MethodKind.Constructor, ((IMethodSymbol)baseConstructor).MethodKind);
1093Assert.Equal(MethodKind.Constructor, ((IMethodSymbol)baseConstructor).MethodKind);
1115var invokedConstructor = (IMethodSymbol)bindInfo.Symbol;
1172Assert.Equal(MethodKind.EventAdd, ((IMethodSymbol)parameterSymbol.ContainingSymbol).MethodKind);
1201Assert.Equal(MethodKind.EventRemove, ((IMethodSymbol)parameterSymbol.ContainingSymbol).MethodKind);
1816var candidate = (IMethodSymbol)bindInfo.CandidateSymbols.Single();
1819Assert.Equal(TypeKind.TypeParameter, ((IMethodSymbol)candidate.OriginalDefinition).Parameters.Last().Type.TypeKind);
1848var method = (IMethodSymbol)bindInfo.Symbol;
2360Assert.Equal(MethodKind.AnonymousFunction, ((IMethodSymbol)parameterSymbol.ContainingSymbol).MethodKind);
2542Assert.Equal(MethodKind.Conversion, ((IMethodSymbol)symbol.ContainingSymbol).MethodKind);
2791var operatorSymbol = comp.GlobalNamespace.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>(operatorName);
2799var method = (IMethodSymbol)symbolInfo.Symbol;
3243var operators = comp.GlobalNamespace.GetMember<INamedTypeSymbol>("C").GetMembers(WellKnownMemberNames.AdditionOperatorName).Cast<IMethodSymbol>();
3244var operatorSymbol = operators.Where(method => method.Parameters[0].Type.Equals(method.Parameters[1].Type, SymbolEqualityComparer.ConsiderEverything)).Single();
3328var mngMethod = (IMethodSymbol)comp.GlobalNamespace.GetMember<INamedTypeSymbol>("Z").GetMembers("MNG").First();
3394var mngMethod = (IMethodSymbol)comp.GlobalNamespace.GetMember<INamedTypeSymbol>("Z").GetMembers("MNG").First();
3790Assert.Equal(compilation.GlobalNamespace.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>("M"), info.CandidateSymbols.Single());
3850Assert.Equal(compilation.GlobalNamespace.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>("M"), info.CandidateSymbols.Single());
4042var method1 = info1.Symbol as IMethodSymbol;
4057Where((m) => (object)m != (object)method1.ReducedFrom).Cast<IMethodSymbol>().Single().TypeParameters[0]));
4070var method2 = info2.Symbol as IMethodSymbol;
4678var methodGoo = classA.GetMember<IMethodSymbol>("Goo");
4680var methodBar = classC.GetMember<IMethodSymbol>("Bar");
4723var methodGoo = classA.GetMember<IMethodSymbol>("Goo");
4725var methodBar = classC.GetMember<IMethodSymbol>("Bar");
4788var lambda = (IMethodSymbol)symbolInfo.Symbol;
4831var methodSymbol = (IMethodSymbol)symbolInfo.Symbol;
6083var constructedMethodSymbol = (IMethodSymbol)model.GetSymbolInfo(memberAccess).Symbol;
6097var constructedReducedFrom = constructedMethodSymbol.GetConstructedReducedFrom();
Symbols\Source\NullablePublicAPITests.cs (66)
288return c.GetMembers().OfType<IMethodSymbol>().Where(m => m.Name.StartsWith("M")).ToArray();
377return c.GetMembers("M1").OfType<IMethodSymbol>().Single().Parameters.ToArray();
480var members = c.GetMembers().OfType<IMethodSymbol>().Where(m => m.Name.StartsWith("M")).ToArray();
488members = e.GetMembers().OfType<IMethodSymbol>().Where(m => m.Name.StartsWith("M")).Select(m => m.ReduceExtensionMethod(m.Parameters[0].Type)).ToArray();
499static void assertNullability(IMethodSymbol[] methods, params PublicNullableAnnotation[] expectedAnnotations)
570return syntaxTree.GetRoot().DescendantNodes().OfType<CSharp.Syntax.LocalFunctionStatementSyntax>().Select(func => semanticModel.GetDeclaredSymbol(func)).Cast<IMethodSymbol>().ToArray();
693comp => ((INamedTypeSymbol)((Compilation)comp).GetMember("I")).GetMembers().OfType<IMethodSymbol>().Where(m => m.Name.StartsWith("F")).ToArray(),
757comp => ((INamedTypeSymbol)((Compilation)comp).GetMember("I")).GetMembers().OfType<IMethodSymbol>().Where(m => m.Name.StartsWith("F")).ToArray(),
822comp => ((INamedTypeSymbol)((Compilation)comp).GetMember("I")).GetMembers().OfType<IMethodSymbol>().Where(m => m.Name.StartsWith("F")).ToArray(),
889comp => ((INamedTypeSymbol)((Compilation)comp).GetMember("IB")).GetMembers().OfType<IMethodSymbol>().Where(m => m.Name.StartsWith("F")).ToArray(),
948var method = (IMethodSymbol)model.GetSymbolInfo(inv).Symbol;
1854verifySymbolInfo((IMethodSymbol)symbolInfo.Symbol, PublicNullableAnnotation.Annotated);
1856verifySymbolInfo((IMethodSymbol)symbolInfo.Symbol, PublicNullableAnnotation.NotAnnotated);
1858static void verifySymbolInfo(IMethodSymbol methodSymbol, PublicNullableAnnotation expectedAnnotation)
1897verifySymbolInfo((IMethodSymbol)symbolInfo.Symbol, PublicNullableAnnotation.Annotated);
1899verifySymbolInfo((IMethodSymbol)symbolInfo.Symbol, PublicNullableAnnotation.NotAnnotated);
1901static void verifySymbolInfo(IMethodSymbol methodSymbol, PublicNullableAnnotation expectedAnnotation)
2967Assert.Equal(expectedAnnotation, ((IMethodSymbol)symbolInfo.Symbol).TypeArgumentNullableAnnotations[0]);
2968Assert.Equal(expectedAnnotation, ((IMethodSymbol)symbolInfo.Symbol).TypeArguments[0].NullableAnnotation);
3009Assert.Equal(expectedAnnotation, ((IMethodSymbol)symbolInfo.Symbol).TypeArgumentNullableAnnotations[0]);
3010Assert.Equal(expectedAnnotation, ((IMethodSymbol)symbolInfo.Symbol).TypeArguments[0].NullableAnnotation);
3051Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((IMethodSymbol)symbolInfo.Symbol).TypeArgumentNullableAnnotations[0]);
3052Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((IMethodSymbol)symbolInfo.Symbol).TypeArguments[0].NullableAnnotation);
3053Assert.Equal(expectedAnnotation, ((IMethodSymbol)symbolInfo.Symbol).TypeArgumentNullableAnnotations[1]);
3054Assert.Equal(expectedAnnotation, ((IMethodSymbol)symbolInfo.Symbol).TypeArguments[1].NullableAnnotation);
3114Assert.Equal(PublicNullableAnnotation.None, ((IMethodSymbol)symbol).TypeArgumentNullableAnnotations[0]);
3115Assert.Equal(PublicNullableAnnotation.None, ((IMethodSymbol)symbol).TypeArguments[0].NullableAnnotation);
3157var methodSymbol = ((IMethodSymbol)symbolInfo.Symbol);
3202var methodSymbol = ((IMethodSymbol)symbolInfo.Symbol);
3365var propertySymbol = (IMethodSymbol)model.GetSymbolInfo(indexer).Symbol;
3411var method = (IMethodSymbol)model.GetSymbolInfo(syntax).Symbol;
3456var method = (IMethodSymbol)model.GetSymbolInfo(syntax).Symbol;
3489var lambdaSymbol = (IMethodSymbol)model.GetSymbolInfo(lambda).Symbol;
3508var mSymbol = model.GetDeclaredSymbol(mDeclaration);
3542var innerLambdaSymbol = (IMethodSymbol)model.GetSymbolInfo(innerLambda).Symbol;
3603var innerLambdaSymbol = (IMethodSymbol)model.GetSymbolInfo(innerLambda).Symbol;
3662var lambdaSymbol = (IMethodSymbol)model.GetSymbolInfo(lambda).Symbol;
3665var localFunctionSymbol = (IMethodSymbol)model.GetDeclaredSymbol(localFunction);
3809var lambdaSymbol = (IMethodSymbol)model.GetSymbolInfo(lambda).Symbol;
3877var localFunctionSymbol = model.GetDeclaredSymbol(localFunction);
3979var innerLambdaSymbol1 = (IMethodSymbol)model.GetSymbolInfo(innerLambda1).Symbol;
3989var innerLambdaSymbol2 = (IMethodSymbol)model.GetSymbolInfo(innerLambda2).Symbol;
4115var localFunctionSymbol = model.GetDeclaredSymbol(localFunction);
4131var localFunctionResult = lookupResults.OfType<IMethodSymbol>().First(m => m.MethodKind == MethodKind.LocalFunction);
4177var localFunctionSymbol = (IMethodSymbol)model.GetDeclaredSymbol(localFunction);
4178var nestedLocalFunction = (IMethodSymbol)model.GetDeclaredSymbol(lambda.DescendantNodes().OfType<LocalFunctionStatementSyntax>().ElementAt(1));
4699var symbol2 = (IMethodSymbol)model.GetSpeculativeSymbolInfo(initializer.Position, expression, SpeculativeBindingOption.BindAsExpression).Symbol;
4778var actualAnnotations = invocations.Select(inv => (((IMethodSymbol)model.GetSymbolInfo(inv).Symbol)).TypeArguments[0].NullableAnnotation).ToArray();
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (2)
Microsoft.CodeAnalysis.CSharp.Test.Utilities (23)
Microsoft.CodeAnalysis.CSharp.Workspaces (138)
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)
236IMethodSymbol method)
243private static SyntaxList<TypeParameterConstraintClauseSyntax> GenerateDefaultConstraints(IMethodSymbol method)
317IMethodSymbol method, CSharpCodeGenerationContextInfo info)
323IMethodSymbol method,
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (10)
Microsoft.CodeAnalysis.EditorFeatures (2)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (21)
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (2)
Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler (4)
Microsoft.CodeAnalysis.Extensions.Package (93)
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
Microsoft.CodeAnalysis.Features (692)
Completion\Providers\ImportCompletionProvider\ExtensionMethodImportCompletionHelper.cs (5)
127Compilation compilation, ImmutableArray<IMethodSymbol> extentsionMethodSymbols, ImmutableArray<ITypeSymbol> targetTypeSymbols, CancellationToken cancellationToken)
131using var _2 = PooledDictionary<(string containingNamespace, string methodName, bool isGeneric), (IMethodSymbol bestSymbol, int overloadCount, bool includeInTargetTypedCompletion)>
135foreach (var symbol in extentsionMethodSymbols)
139IMethodSymbol bestSymbol;
196Compilation compilation, IMethodSymbol methodSymbol, ImmutableArray<ITypeSymbol> targetTypeSymbols,
Completion\Providers\ImportCompletionProvider\ExtensionMethodImportCompletionHelper.SymbolComputer.cs (23)
81public async Task<ImmutableArray<IMethodSymbol>> GetExtensionMethodSymbolsAsync(bool forceCacheCreation, bool hideAdvancedMembers, CancellationToken cancellationToken)
86var peReferenceMethodSymbolsTask = ProducerConsumer<IMethodSymbol?>.RunParallelAsync(
93var projectMethodSymbolsTask = ProducerConsumer<IMethodSymbol?>.RunParallelAsync(
102using var _ = ArrayBuilder<IMethodSymbol>.GetInstance(results[0].Length + results[1].Length, out var symbols);
105foreach (var method in methodArray)
137Action<IMethodSymbol?> callback,
182Action<IMethodSymbol?> callback,
224MultiDictionary<ITypeSymbol, IMethodSymbol> matchingMethodSymbols,
225Action<IMethodSymbol?> callback,
257foreach (var methodInOriginatingCompilation in methodSymbols.Select(s => SymbolFinder.FindSimilarSymbols(s, _originatingSemanticModel.Compilation).FirstOrDefault()).WhereNotNull())
271var reducedMethodSymbol = methodInOriginatingCompilation.ReduceExtensionMethod(_receiverTypeSymbol);
291MultiDictionary<ITypeSymbol, IMethodSymbol> matchingMethodSymbols,
292Action<IMethodSymbol?> callback,
309var reducedMethodSymbol = TryReduceExtensionMethod(methodSymbols.First(), _receiverTypeSymbol);
318foreach (var methodSymbol in methodSymbols)
327private static IMethodSymbol? TryReduceExtensionMethod(IMethodSymbol methodSymbol, ITypeSymbol receiverTypeSymbol)
330var reduced = methodSymbol.ReduceExtensionMethod(receiverTypeSymbol);
346private MultiDictionary<ITypeSymbol, IMethodSymbol> GetPotentialMatchingSymbolsFromAssembly(
352var builder = new MultiDictionary<ITypeSymbol, IMethodSymbol>();
383var methodSymbols = containerSymbol.GetMembers(methodName).OfType<IMethodSymbol>();
385foreach (var methodSymbol in methodSymbols)
398static bool MatchExtensionMethod(IMethodSymbol method, string filterReceiverTypeName, bool internalsVisible, out ITypeSymbol? receiverType)
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (86)
255protected abstract bool AreHandledEventsEqual(IMethodSymbol oldMethod, IMethodSymbol newMethod);
313SymbolKind.Method => GetDisplayName((IMethodSymbol)symbol),
343internal virtual string GetDisplayName(IMethodSymbol symbol)
445internal abstract IMethodSymbol GetLambdaExpressionSymbol(SemanticModel model, SyntaxNode lambdaExpression, CancellationToken cancellationToken);
2554protected static bool ReturnTypesEquivalent(IMethodSymbol oldMethod, IMethodSymbol newMethod, bool exact)
2629var oldMethod = (IMethodSymbol)oldMember;
2630var newMethod = (IMethodSymbol)newMember;
2636var newInvokeMethod = ((INamedTypeSymbol)newMember).DelegateInvokeMethod;
2991var oldPrimaryConstructor = (IMethodSymbol)oldSymbol;
3303if (oldSymbol is IMethodSymbol)
3703Debug.Assert(member is IPropertySymbol or IMethodSymbol);
3712var primaryConstructor = (IMethodSymbol)member;
3748IMethodSymbol? constructor,
3749IMethodSymbol? otherConstructor,
3759void AddEdits(IMethodSymbol? constructor, Compilation otherCompilation, bool isDelete)
3805if (symbol is IMethodSymbol
3837case IMethodSymbol or IFieldSymbol:
3874case IMethodSymbol or IFieldSymbol:
3926if (oldSymbol.Name != newSymbol.Name || oldSymbol is IMethodSymbol or IFieldSymbol)
4076if (oldMember is IMethodSymbol oldMethod)
4239else if (oldSymbol is IMethodSymbol oldMethod && newSymbol is IMethodSymbol newMethod)
4321if (oldSymbol is not IMethodSymbol { AssociatedSymbol: not null })
4355else if (oldSymbol is IMethodSymbol oldMethod && newSymbol is IMethodSymbol newMethod)
4513if (oldSymbol is not IMethodSymbol { AssociatedSymbol: not null })
4589oldMember is not IMethodSymbol { AssociatedSymbol.Kind: SymbolKind.Property or SymbolKind.Event })
4613=> parameter is { Ordinal: 0, ContainingSymbol: IMethodSymbol { IsExtensionMethod: true } };
4684var oldPrimaryConstructor = (IMethodSymbol)oldContainingMember;
4685var newPrimaryConstructor = (IMethodSymbol)newContainingMember;
4691var oldSynthesizedDeconstructor = oldPrimaryConstructor.GetMatchingDeconstructor();
4692var newSynthesizedDeconstructor = newPrimaryConstructor.GetMatchingDeconstructor();
4729if (oldSymbol is IMethodSymbol oldMethod &&
4730newSymbol is IMethodSymbol newMethod)
4935if (newSymbol is IMethodSymbol or IEventSymbol or IPropertySymbol)
5001.FirstOrDefault(static (m, compilation) => m is IMethodSymbol { IsImplicitlyDeclared: true } method && HasPrintMembersSignature(method, compilation), compilation);
5008.FirstOrDefault(static m => m is IMethodSymbol { IsImplicitlyDeclared: true } method && HasIEquatableEqualsSignature(method));
5015.FirstOrDefault(static m => m is IMethodSymbol { IsImplicitlyDeclared: true } method && HasGetHashCodeSignature(method));
5482foreach (var newCtor in isStatic ? newType.StaticConstructors : newType.InstanceConstructors)
5501IMethodSymbol? oldCtor;
5524oldCtor = (IMethodSymbol)GetRequiredDeclaredSymbol(oldModel.RequiredModel, oldDeclaration, cancellationToken);
5541oldCtor = (IMethodSymbol?)resolution.Symbol;
5674private static IMethodSymbol? TryGetParameterlessConstructor(INamedTypeSymbol type, bool isStatic)
5752var oldLambdaSymbol = isNestedFunction ? GetLambdaExpressionSymbol(oldModel.RequiredModel, oldLambda, cancellationToken) : null;
5753var newLambdaSymbol = isNestedFunction ? GetLambdaExpressionSymbol(newModel.RequiredModel, newLambda, cancellationToken) : null;
5856var oldPrimaryConstructor = oldDeclaration != null && IsPrimaryConstructorDeclaration(oldDeclaration)
5857? (IMethodSymbol)oldMember
5860var newPrimaryConstructor = newDeclaration != null && IsPrimaryConstructorDeclaration(newDeclaration)
5861? (IMethodSymbol)newMember
5870var oldLiftingPrimaryConstructor = oldMember != oldPrimaryConstructor && oldDeclaration != null && !IsDeclarationWithInitializer(oldDeclaration) ? oldPrimaryConstructor : null;
5871var newLiftingPrimaryConstructor = newMember != newPrimaryConstructor && newDeclaration != null && !IsDeclarationWithInitializer(newDeclaration) ? newPrimaryConstructor : null;
6105public static VariableCaptureKey Create(ISymbol variable, IMethodSymbol? liftingPrimaryConstructor)
6109private static VariableCaptureKind GetCaptureKind(ISymbol variable, IMethodSymbol? liftingPrimaryConstructor)
6116IMethodSymbol? liftingPrimaryConstructor,
6193IMethodSymbol? oldLiftingPrimaryConstructor,
6195IMethodSymbol? newLiftingPrimaryConstructor,
6247IMethodSymbol? liftingPrimaryConstructor)
6283IMethodSymbol method => method.AssociatedSymbol,
6335var lambda = parameter.ContainingSymbol is IMethodSymbol { MethodKind: MethodKind.LambdaMethod or MethodKind.LocalFunction } containingLambda ?
6340if (parameter is { IsImplicitlyDeclared: true, ContainingSymbol: IMethodSymbol { AssociatedSymbol: { } associatedSymbol } })
6393IMethodSymbol? oldPrimaryConstructor,
6396IMethodSymbol? newPrimaryConstructor,
6571var oldLambdaSymbol = (IMethodSymbol)diagnosticContext.RequiredOldSymbol;
6572var newLambdaSymbol = (IMethodSymbol)diagnosticContext.RequiredNewSymbol;
6875=> symbol is IMethodSymbol { Name: WellKnownMemberNames.TopLevelStatementsEntryPointMethodName };
6883if (current is IMethodSymbol { Arity: > 0 })
6924public IMethodSymbol? GetPrimaryConstructor(INamedTypeSymbol typeSymbol, CancellationToken cancellationToken)
6929=> symbol is IMethodSymbol { IsStatic: false, MethodKind: MethodKind.Constructor, DeclaringSyntaxReferences: [_] } && IsPrimaryConstructorDeclaration(GetSymbolDeclarationSyntax(symbol, cancellationToken));
6945public IMethodSymbol? GetEncompassingPrimaryConstructor(SyntaxNode declaration, ISymbol symbol, CancellationToken cancellationToken)
6946=> IsPrimaryConstructorDeclaration(declaration) ? (IMethodSymbol)symbol :
6982if (newSymbol is IMethodSymbol { IsStatic: false, ContainingType.IsRecord: true, ReturnsVoid: true, Name: WellKnownMemberNames.DeconstructMethodName } method &&
7023if (newSymbol is IMethodSymbol { AssociatedSymbol: IPropertySymbol { } newProperty })
7025var oldProperty = ((IMethodSymbol)oldSymbol).AssociatedSymbol;
7035private static bool HasPrintMembersSignature(IMethodSymbol method, Compilation compilation)
7038private static bool HasIEquatableEqualsSignature(IMethodSymbol method)
7041private 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)
145TExpressionSyntax expression, IMethodSymbol methodSymbol, SyntaxNode containingMethod,
242IMethodSymbol methodSymbol, SyntaxNode containingMethod, Dictionary<Document, List<TExpressionSyntax>> methodCallSites, bool allOccurrences, IntroduceParameterCodeActionKind selectedCodeAction,
275Document 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\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\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\Analyzers\Core\CodeFixes\ImplementAbstractClass\ImplementAbstractClassData.cs (7)
162IMethodSymbol method => GenerateMethod(compilation, method, throughMember, modifiers, accessibility),
170Compilation compilation, IMethodSymbol method, ISymbol? throughMember,
205var getMethod = ShouldGenerateAccessor(property.GetMethod)
214var setMethod = ShouldGenerateAccessor(property.SetMethod)
241private IMethodSymbol? GetEventAddOrRemoveMethod(
242IEventSymbol @event, IMethodSymbol? accessor, ISymbol? throughMember,
260private bool ShouldGenerateAccessor([NotNullWhen(true)] IMethodSymbol? method)
src\Analyzers\Core\CodeFixes\ImplementInterface\ImplementInterfaceGenerator.cs (8)
260if (member is not IMethodSymbol method)
299IMethodSymbol method => [GenerateMethod(compilation, method, conflictingMember as IMethodSymbol, accessibility, modifiers, generateAbstractly, useExplicitInterfaceSymbol, memberName)],
308var accessor = CodeGenerationSymbolFactory.CreateAccessorSymbol(
323private IMethodSymbol? GetAddOrRemoveMethod(
324IEventSymbol @event, bool generateInvisibly, IMethodSymbol accessor, string memberName,
360if (member is IMethodSymbol method1 && baseMember is IMethodSymbol method2)
src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (9)
31IMethodSymbol methodSymbol,
62var methodSymbol = GetMethodSymbol(semanticModel, node, cancellationToken);
91private static IMethodSymbol? GetMethodSymbol(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
95return symbol as IMethodSymbol;
120var methodSymbol = GetMethodSymbol(semanticModel, node, cancellationToken);
162IMethodSymbol methodSymbol,
181var newMethod = (IMethodSymbol)semanticModel.GetRequiredDeclaredSymbol(newNode, cancellationToken);
191IMethodSymbol methodSymbol,
src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (8)
25protected abstract SyntaxNode RemoveAsyncTokenAndFixReturnType(IMethodSymbol methodSymbol, SyntaxNode node, KnownTaskTypes knownTypes);
58var methodSymbol = (IMethodSymbol?)(semanticModel.GetDeclaredSymbol(node, cancellationToken) ?? semanticModel.GetSymbolInfo(node, cancellationToken).GetAnySymbol());
73private async Task<Solution> RenameThenRemoveAsyncTokenAsync(Document document, SyntaxNode node, IMethodSymbol methodSymbol, CancellationToken cancellationToken)
89var newMethod = (IMethodSymbol)semanticModel.GetRequiredDeclaredSymbol(newNode, cancellationToken);
97Document document, IMethodSymbol methodSymbol, SyntaxNode node, CancellationToken cancellationToken)
128if (semanticModel.GetDeclaredSymbol(methodDeclaration, cancellationToken) is IMethodSymbol methodSymbol)
StackTraceExplorer\StackTraceExplorerUtilities.cs (5)
64var method = await TryGetBestMatchAsync(project, fullyQualifiedTypeName, methodNode, methodArguments, methodTypeArguments, cancellationToken).ConfigureAwait(false);
82var method = await TryGetBestMatchAsync(project, fullyQualifiedTypeName, methodNode, methodArguments, methodTypeArguments, cancellationToken).ConfigureAwait(false);
95DefinitionItem GetDefinition(IMethodSymbol method)
110private static async Task<IMethodSymbol?> TryGetBestMatchAsync(Project project, string fullyQualifiedTypeName, StackFrameSimpleNameNode methodNode, StackFrameParameterList methodArguments, StackFrameTypeArgumentList? methodTypeArguments, CancellationToken cancellationToken)
123var matchingMethod = await resolver.TryGetBestMatchAsync(project, type, methodNode, methodArguments, methodTypeArguments, cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.Features.Test.Utilities (1)
Microsoft.CodeAnalysis.Features.UnitTests (2)
Microsoft.CodeAnalysis.LanguageServer (1)
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (430)
Microsoft.CodeAnalysis.PublicApiAnalyzers (284)
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)
172public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
182public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
199private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
208private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
215private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
231private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
244private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
256public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
271this IMethodSymbol method,
321public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
327public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
334public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
339public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
341var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
344foreach (var member in methods)
374public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
395public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
404public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
416public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
430private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
436public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
442IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
475public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
484public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
493public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
503public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
515public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
529public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
537public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
546public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
557public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
559ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
576.OfType<IMethodSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
Microsoft.CodeAnalysis.Rebuild (3)
Microsoft.CodeAnalysis.ResxSourceGenerator (273)
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)
172public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
182public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
199private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
208private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
215private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
231private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
244private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
256public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
271this IMethodSymbol method,
321public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
327public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
334public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
339public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
341var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
344foreach (var member in methods)
374public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
395public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
404public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
416public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
430private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
436public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
442IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
475public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
484public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
493public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
503public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
515public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
529public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
537public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
546public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
557public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
559ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
576.OfType<IMethodSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
Microsoft.CodeAnalysis.Scripting (2)
Microsoft.CodeAnalysis.Test.Utilities (31)
Microsoft.CodeAnalysis.UnitTests (1)
Microsoft.CodeAnalysis.VisualBasic (126)
VisualBasicExtensions.vb (8)
553Public Function IsOverloads(methodSymbol As IMethodSymbol) As Boolean
571Public Function HandledEvents(methodSymbol As IMethodSymbol) As ImmutableArray(Of HandledEvent)
1084Public Function GetDeclaredSymbol(semanticModel As SemanticModel, declarationSyntax As SubNewStatementSyntax, Optional cancellationToken As CancellationToken = Nothing) As IMethodSymbol
1097Public Function GetDeclaredSymbol(semanticModel As SemanticModel, declarationSyntax As MethodStatementSyntax, Optional cancellationToken As CancellationToken = Nothing) As IMethodSymbol
1110Public Function GetDeclaredSymbol(semanticModel As SemanticModel, declarationSyntax As DeclareStatementSyntax, Optional cancellationToken As CancellationToken = Nothing) As IMethodSymbol
1123Public Function GetDeclaredSymbol(semanticModel As SemanticModel, declarationSyntax As OperatorStatementSyntax, Optional cancellationToken As CancellationToken = Nothing) As IMethodSymbol
1136Public Function GetDeclaredSymbol(semanticModel As SemanticModel, declarationSyntax As MethodBlockBaseSyntax, Optional cancellationToken As CancellationToken = Nothing) As IMethodSymbol
1214Public Function GetDeclaredSymbol(semanticModel As SemanticModel, declarationSyntax As AccessorStatementSyntax, Optional cancellationToken As CancellationToken = Nothing) As IMethodSymbol
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (21)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (57)
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
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures (5)
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (13)
CodeGen\CodeGenTuples.vb (12)
17248Dim cMabImplementations = DirectCast(DirectCast(c, TypeSymbol).GetMember("M_1"), IMethodSymbol).ExplicitInterfaceImplementations
17251Dim cMcdImplementations = DirectCast(DirectCast(c, TypeSymbol).GetMember("M_2"), IMethodSymbol).ExplicitInterfaceImplementations
17315Dim m2 = DirectCast(DirectCast(c2, TypeSymbol).GetMember("M"), IMethodSymbol)
17388Dim m2 = DirectCast(DirectCast(c2, TypeSymbol).GetMember("M"), IMethodSymbol)
17531Dim cMabImplementations = DirectCast(DirectCast(c, TypeSymbol).GetMember("M_1"), IMethodSymbol).ExplicitInterfaceImplementations
17534Dim cMcdImplementations = DirectCast(DirectCast(c, TypeSymbol).GetMember("M_2"), IMethodSymbol).ExplicitInterfaceImplementations
17578Dim cMabImplementations = DirectCast(DirectCast(c3, TypeSymbol).GetMember("M_1"), IMethodSymbol).ExplicitInterfaceImplementations
17581Dim cMcdImplementations = DirectCast(DirectCast(c3, TypeSymbol).GetMember("M_2"), IMethodSymbol).ExplicitInterfaceImplementations
17628Dim mImplementations = DirectCast(DirectCast(c3, TypeSymbol).GetMember("M"), IMethodSymbol).ExplicitInterfaceImplementations
21357Dim mImplementations = DirectCast(m, IMethodSymbol).ExplicitInterfaceImplementations
21493Dim mImplementations = DirectCast(m, IMethodSymbol).ExplicitInterfaceImplementations
22441Dim actSymbol = DirectCast(model.GetSymbolInfo(actSyntax).Symbol, IMethodSymbol)
Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler (1)
Microsoft.CodeAnalysis.VisualBasic.Features (101)
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
Microsoft.CodeAnalysis.VisualBasic.Features.UnitTests (1)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (31)
Semantics\IteratorTests.vb (10)
35Assert.True(DirectCast(i, IMethodSymbol).IsIterator)
60Assert.False(DirectCast(i, IMethodSymbol).IsIterator)
82Assert.False(DirectCast(i, IMethodSymbol).IsIterator)
1070Assert.True(DirectCast([property].GetMethod, IMethodSymbol).IsIterator)
1111Assert.True(DirectCast([property].GetMethod, IMethodSymbol).IsIterator)
1113Assert.False(DirectCast([property].SetMethod, IMethodSymbol).IsIterator)
1116Assert.True(DirectCast([property].GetMethod, IMethodSymbol).IsIterator)
1118Assert.False(DirectCast([property].SetMethod, IMethodSymbol).IsIterator)
1144Assert.False(DirectCast([property].GetMethod, IMethodSymbol).IsIterator)
1166Assert.False(DirectCast([property].GetMethod, IMethodSymbol).IsIterator)
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (19)
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (1)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (83)
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (4)
Microsoft.CodeAnalysis.Workspaces (502)
FindSymbols\FindReferences\Finders\ConstructorSymbolReferenceFinder.cs (14)
17internal sealed class ConstructorSymbolReferenceFinder : AbstractReferenceFinder<IMethodSymbol>
25protected override bool CanFind(IMethodSymbol symbol)
28protected override ValueTask<ImmutableArray<ISymbol>> DetermineCascadedSymbolsAsync(IMethodSymbol symbol, Solution solution, FindReferencesSearchOptions options, CancellationToken cancellationToken)
38private static ImmutableArray<ISymbol> GetOtherPartsOfPartial(IMethodSymbol symbol)
49protected override Task<ImmutableArray<string>> DetermineGlobalAliasesAsync(IMethodSymbol symbol, Project project, CancellationToken cancellationToken)
56IMethodSymbol symbol,
115IMethodSymbol methodSymbol,
151IMethodSymbol methodSymbol, FindReferencesDocumentState state, Action<FinderLocation, TData> processResult, TData processResultData, string name, string alias, CancellationToken cancellationToken)
168IMethodSymbol symbol,
182IMethodSymbol symbol,
194IMethodSymbol symbol,
214IMethodSymbol symbol,
226IMethodSymbol symbol,
287IMethodSymbol symbol,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
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\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\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
105protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
117if (impl is IMethodSymbol implMethod)
135.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
136SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
151.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
164(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
167return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
215public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
218public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
221public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
248public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
260public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor)
Microsoft.CodeAnalysis.Workspaces.UnitTests (48)
UtilityTest\DocumentationCommentIdTests.cs (23)
155CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.#cctor", compilation, s => s.MethodKind == MethodKind.StaticConstructor);
156CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.#ctor", compilation, s => s.MethodKind == MethodKind.Constructor && s.Parameters.Length == 0);
157CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.#ctor(System.String)", compilation, s => s.MethodKind == MethodKind.Constructor && s.Parameters.Length == 1);
174CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.Finalize", compilation, s => s.MethodKind == MethodKind.Destructor);
216CheckDeclarationId<IMethodSymbol>("M:Acme.ValueType.M(System.Int32)", compilation, s => s.Name == "M" && s.Parameters is [{ Type.Name: "Int32" }]);
217CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.NestedClass.M(System.Int32)", compilation, s => s.Name == "M" && s.Parameters is [{ Type.Name: "Int32" }]);
218CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.M0", compilation, s => s.Name == "M0" && s.Parameters.Length == 0);
219CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.M1(System.Char,System.Single@,Acme.ValueType@)", compilation, s => s.Name == "M1");
220CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.M2(System.Int16[],System.Int32[0:,0:],System.Int64[][])", compilation, s => s.Name == "M2");
221CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.M3(System.Int64[][],Acme.Widget[0:,0:,0:][])", compilation, s => s.Name == "M3");
222CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.M4(System.Char*,Color**)", compilation, s => s.Name == "M4");
223CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.M5(System.Void*,System.Double*[0:,0:][])", compilation, s => s.Name == "M5");
224CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.M6(System.Int32,System.Object[])", compilation, s => s.Name == "M6");
225CheckDeclarationId<IMethodSymbol>("M:Acme.MyList`1.Test(`0)", compilation, s => s.Name == "Test");
226CheckDeclarationId<IMethodSymbol>("M:Acme.UseList.Process(Acme.MyList{System.Int32})", compilation, s => s.Name == "Process");
227CheckDeclarationId<IMethodSymbol>("M:Acme.UseList.GetValues``1(``0)", compilation, s => s.Name == "GetValues");
228CheckDeclarationId<IMethodSymbol>("M:Acme.UseList.Process2``1(Acme.MyList{``0})", compilation, s => s.Name == "Process2");
281CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.op_UnaryPlus(Acme.Widget)", compilation, m => m.MethodKind == MethodKind.UserDefinedOperator && m.Parameters.Length == 1);
297CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.op_Addition(Acme.Widget,Acme.Widget)", compilation, m => m.MethodKind == MethodKind.UserDefinedOperator && m.Parameters.Length == 2);
314CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.op_Explicit(Acme.Widget)~System.Int32", compilation, m => m.MethodKind == MethodKind.Conversion && m.Parameters.Length == 1 && m.ReturnType.Name == "Int32");
315CheckDeclarationId<IMethodSymbol>("M:Acme.Widget.op_Implicit(Acme.Widget)~System.Int64", compilation, m => m.MethodKind == MethodKind.Conversion && m.Parameters.Length == 1 && m.ReturnType.Name == "Int64");
337var method = outerType.GetMembers("M").First() as IMethodSymbol;
Microsoft.DotNet.CodeAnalysis (6)
Microsoft.Extensions.Logging.Generators (6)
Microsoft.Extensions.Options.SourceGeneration (2)
Microsoft.Extensions.Validation.ValidationsGenerator (17)
src\Shared\RoslynUtils\ParsabilityHelper.cs (10)
20private static readonly BoundedCacheWithFactory<ITypeSymbol, (BindabilityMethod?, IMethodSymbol?)> BindabilityCache = new();
76.OfType<IMethodSymbol>();
94private static bool IsTryParse(IMethodSymbol methodSymbol)
104private static bool IsTryParseWithFormat(IMethodSymbol methodSymbol, WellKnownTypes wellKnownTypes)
134private static bool IsBindAsync(IMethodSymbol methodSymbol, ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
145private static bool IsBindAsyncWithParameter(IMethodSymbol methodSymbol, ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
162internal static Bindability GetBindability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, out BindabilityMethod? bindabilityMethod, out IMethodSymbol? bindMethodSymbol)
166IMethodSymbol? bindAsyncMethod = null;
171IMethodSymbol? bindMethodSymbol = null;
185if (methodSymbolCandidate is IMethodSymbol methodSymbol)
Microsoft.Gen.ComplianceReports (4)
Microsoft.Gen.ContextualOptions (2)
Microsoft.Gen.Logging (18)
Microsoft.Gen.Logging.Unit.Tests (12)
Microsoft.Gen.MetadataExtractor (7)
Microsoft.Gen.Metrics (5)
Microsoft.Gen.MetricsReports (5)
Microsoft.Interop.ComInterfaceGenerator (30)
ComMethodInfo.cs (14)
40public static SequenceEqualImmutableArray<DiagnosticOr<(ComMethodInfo ComMethod, IMethodSymbol Symbol)>> GetMethodsFromInterface((ComInterfaceInfo ifaceContext, INamedTypeSymbol ifaceSymbol) data, CancellationToken ct)
42var methods = ImmutableArray.CreateBuilder<DiagnosticOr<(ComMethodInfo, IMethodSymbol)>>();
53methods.Add(DiagnosticOr<(ComMethodInfo, IMethodSymbol)>.From(member.CreateDiagnosticInfo(GeneratorDiagnostics.InstancePropertyDeclaredInInterface, member.Name, data.ifaceSymbol.ToDisplayString())));
56methods.Add(DiagnosticOr<(ComMethodInfo, IMethodSymbol)>.From(member.CreateDiagnosticInfo(GeneratorDiagnostics.InstanceEventDeclaredInInterface, member.Name, data.ifaceSymbol.ToDisplayString())));
58case IMethodSymbol { MethodKind: MethodKind.Ordinary }:
59methods.Add(CalculateMethodInfo(data.ifaceContext, (IMethodSymbol)member, ct));
66private static DiagnosticInfo? GetDiagnosticIfInvalidMethodForGeneration(MethodDeclarationSyntax comMethodDeclaringSyntax, IMethodSymbol method)
86private static DiagnosticOr<(ComMethodInfo, IMethodSymbol)> CalculateMethodInfo(ComInterfaceInfo ifaceContext, IMethodSymbol method, CancellationToken ct)
96return DiagnosticOr<(ComMethodInfo, IMethodSymbol)>.From((
119return DiagnosticOr<(ComMethodInfo, IMethodSymbol)>.From(DiagnosticInfo.Create(GeneratorDiagnostics.MethodNotDeclaredInAttributedInterface, method.Locations.FirstOrDefault(), method.ToDisplayString()));
135return DiagnosticOr<(ComMethodInfo, IMethodSymbol)>.From(DiagnosticInfo.Create(GeneratorDiagnostics.CannotAnalyzeMethodPattern, method.Locations.FirstOrDefault(), method.ToDisplayString()));
141return DiagnosticOr<(ComMethodInfo, IMethodSymbol)>.From(diag);
153return DiagnosticOr<(ComMethodInfo, IMethodSymbol)>.From((comMethodInfo, method));
Microsoft.Interop.JavaScript.JSImportGenerator (8)
Microsoft.Interop.LibraryImportGenerator (24)
Microsoft.Interop.LibraryImportGenerator.Downlevel (6)
Microsoft.Interop.SourceGeneration (122)
MarshallerShape.cs (113)
99public IMethodSymbol? ToUnmanaged { get; init; }
100public IMethodSymbol? ToUnmanagedWithBuffer { get; init; }
101public IMethodSymbol? ToManaged { get; init; }
102public IMethodSymbol? ToManagedFinally { get; init; }
105public IMethodSymbol? ManagedValuesSource { get; init; }
106public IMethodSymbol? UnmanagedValuesDestination { get; init; }
107public IMethodSymbol? ManagedValuesDestination { get; init; }
108public IMethodSymbol? UnmanagedValuesSource { get; init; }
121IMethodSymbol? allocateUnmanaged = LinearCollection.AllocateContainerForUnmanagedElements(marshallerType, managedType);
122IMethodSymbol? allocateUnmanagedWithBuffer = LinearCollection.AllocateContainerForUnmanagedElementsWithCallerAllocatedBuffer(marshallerType, managedType, spanOfT);
123IMethodSymbol? managedSource = LinearCollection.GetManagedValuesSource(marshallerType, managedType, readOnlySpanOfT);
124IMethodSymbol? unmanagedDestination = LinearCollection.GetUnmanagedValuesDestination(marshallerType, spanOfT);
145IMethodSymbol? allocateManaged = LinearCollection.AllocateContainerForManagedElements(marshallerType, managedType);
146IMethodSymbol? allocateManagedGuaranteed = LinearCollection.AllocateContainerForManagedElementsFinally(marshallerType, managedType);
147IMethodSymbol? managedDestination = LinearCollection.GetManagedValuesDestination(marshallerType, managedType, spanOfT);
148IMethodSymbol? unmanagedSource = LinearCollection.GetUnmanagedValuesSource(marshallerType, readOnlySpanOfT);
170IMethodSymbol? toUnmanaged = Value.ConvertToUnmanaged(marshallerType, managedType);
174IMethodSymbol? toUnmanagedWithBuffer = Value.ConvertToUnmanagedWithCallerAllocatedBuffer(marshallerType, managedType, spanOfT);
178IMethodSymbol? toManaged = Value.ConvertToManaged(marshallerType, managedType);
182IMethodSymbol? toManagedFinally = Value.ConvertToManagedFinally(marshallerType, managedType);
204private static IMethodSymbol? GetStatelessFree(ITypeSymbol type)
208.OfType<IMethodSymbol>()
212private static IMethodSymbol? GetStatelessGetPinnableReference(ITypeSymbol type, ITypeSymbol managedType)
218.OfType<IMethodSymbol>()
257internal static IMethodSymbol? ConvertToUnmanaged(ITypeSymbol type, ITypeSymbol managedType)
261.OfType<IMethodSymbol>()
266internal static IMethodSymbol? ConvertToUnmanagedWithCallerAllocatedBuffer(
272IEnumerable<IMethodSymbol> methods = type.GetMembers(ShapeMemberNames.Value.Stateless.ConvertToUnmanaged)
273.OfType<IMethodSymbol>()
277foreach (IMethodSymbol method in methods)
288internal static IMethodSymbol? ConvertToManaged(ITypeSymbol type, ITypeSymbol managedType)
292.OfType<IMethodSymbol>()
297internal static IMethodSymbol? ConvertToManagedFinally(ITypeSymbol type, ITypeSymbol managedType)
301.OfType<IMethodSymbol>()
309internal static IMethodSymbol? AllocateContainerForUnmanagedElements(ITypeSymbol type, ITypeSymbol managedType)
313.OfType<IMethodSymbol>()
320internal static IMethodSymbol? AllocateContainerForUnmanagedElementsWithCallerAllocatedBuffer(ITypeSymbol type, ITypeSymbol managedType, ITypeSymbol spanOfT)
323IEnumerable<IMethodSymbol> methods = type.GetMembers(ShapeMemberNames.LinearCollection.Stateless.AllocateContainerForUnmanagedElements)
324.OfType<IMethodSymbol>()
330foreach (IMethodSymbol method in methods)
341internal static IMethodSymbol? GetManagedValuesSource(ITypeSymbol type, ITypeSymbol managedType, ITypeSymbol readOnlySpanOfT)
345.OfType<IMethodSymbol>()
351internal static IMethodSymbol? GetUnmanagedValuesDestination(ITypeSymbol type, ITypeSymbol spanOfT)
355.OfType<IMethodSymbol>()
361internal static IMethodSymbol? AllocateContainerForManagedElements(ITypeSymbol type, ITypeSymbol managedType)
365.OfType<IMethodSymbol>()
371internal static IMethodSymbol? AllocateContainerForManagedElementsFinally(ITypeSymbol type, ITypeSymbol managedType)
375.OfType<IMethodSymbol>()
381internal static IMethodSymbol? GetManagedValuesDestination(ITypeSymbol type, ITypeSymbol managedType, ITypeSymbol spanOfT)
385.OfType<IMethodSymbol>()
391internal static IMethodSymbol? GetUnmanagedValuesSource(ITypeSymbol type, ITypeSymbol readOnlySpanOfT)
395.OfType<IMethodSymbol>()
410public IMethodSymbol? FromManaged { get; init; }
411public IMethodSymbol? FromManagedWithBuffer { get; init; }
412public IMethodSymbol? ToManaged { get; init; }
413public IMethodSymbol? ToManagedGuaranteed { get; init; }
414public IMethodSymbol? FromUnmanaged { get; init; }
415public IMethodSymbol? ToUnmanaged { get; init; }
416public IMethodSymbol? Free { get; init; }
417public IMethodSymbol? OnInvoked { get; init; }
418public IMethodSymbol? StatelessGetPinnableReference { get; init; }
419public IMethodSymbol? StatefulGetPinnableReference { get; init; }
422public IMethodSymbol? ManagedValuesSource { get; init; }
423public IMethodSymbol? UnmanagedValuesDestination { get; init; }
424public IMethodSymbol? ManagedValuesDestination { get; init; }
425public IMethodSymbol? UnmanagedValuesSource { get; init; }
427public bool IsShapeMethod(IMethodSymbol method)
453IMethodSymbol? fromManaged = GetFromManagedMethod(marshallerType, managedType);
455IMethodSymbol? fromManagedWithCallerAllocatedBuffer = GetFromManagedWithCallerAllocatedBufferMethod(marshallerType, managedType, spanOfT);
457IMethodSymbol? toUnmanaged = GetToUnmanagedMethod(marshallerType);
460IMethodSymbol? managedSource = null;
461IMethodSymbol? unmanagedDestination = null;
494IMethodSymbol toManaged = GetToManagedMethod(marshallerType, managedType);
495IMethodSymbol toManagedFinally = GetToManagedFinallyMethod(marshallerType, managedType);
496IMethodSymbol fromUnmanaged = GetFromUnmanagedMethod(marshallerType, unmanagedType);
497IMethodSymbol? managedDestination = null;
498IMethodSymbol? unmanagedSource = null;
527IMethodSymbol free = GetStatefulFreeMethod(marshallerType);
533IMethodSymbol OnInvoked = GetOnInvokedMethod(marshallerType);
539IMethodSymbol statelessGetPinnableReference = GetStatelessGetPinnableReference(marshallerType, managedType);
545IMethodSymbol statefulGetPinnableReference = GetStatefulGetPinnableReference(marshallerType);
561private static IMethodSymbol? GetFromManagedMethod(ITypeSymbol type, ITypeSymbol managedType)
564.OfType<IMethodSymbol>()
569private static IMethodSymbol? GetFromManagedWithCallerAllocatedBufferMethod(
574IEnumerable<IMethodSymbol> methods = type.GetMembers(ShapeMemberNames.Value.Stateful.FromManaged)
575.OfType<IMethodSymbol>()
579foreach (IMethodSymbol method in methods)
590private static IMethodSymbol? GetToManagedMethod(ITypeSymbol type, ITypeSymbol managedType)
593.OfType<IMethodSymbol>()
598private static IMethodSymbol? GetToManagedFinallyMethod(ITypeSymbol type, ITypeSymbol managedType)
601.OfType<IMethodSymbol>()
606private static IMethodSymbol? GetToUnmanagedMethod(ITypeSymbol type)
609.OfType<IMethodSymbol>()
613public static ImmutableArray<IMethodSymbol> GetFromUnmanagedMethodCandidates(ITypeSymbol type)
616.OfType<IMethodSymbol>()
621private static IMethodSymbol? GetFromUnmanagedMethod(ITypeSymbol type, ITypeSymbol? unmanagedType)
623ImmutableArray<IMethodSymbol> candidates = GetFromUnmanagedMethodCandidates(type);
652private static IMethodSymbol? GetStatefulFreeMethod(ITypeSymbol type)
655.OfType<IMethodSymbol>()
659private static IMethodSymbol? GetOnInvokedMethod(ITypeSymbol type)
662.OfType<IMethodSymbol>()
666private static IMethodSymbol? GetStatelessGetPinnableReference(ITypeSymbol type, ITypeSymbol managedType)
669.OfType<IMethodSymbol>()
675private static IMethodSymbol? GetStatefulGetPinnableReference(ITypeSymbol type)
678.OfType<IMethodSymbol>()
685internal static IMethodSymbol? GetManagedValuesSource(ITypeSymbol type, ITypeSymbol readOnlySpanOfT)
689.OfType<IMethodSymbol>()
694internal static IMethodSymbol? GetUnmanagedValuesDestination(ITypeSymbol type, ITypeSymbol spanOfT)
698.OfType<IMethodSymbol>()
703internal static IMethodSymbol? GetManagedValuesDestination(ITypeSymbol type, ITypeSymbol spanOfT)
707.OfType<IMethodSymbol>()
713internal static IMethodSymbol? GetUnmanagedValuesSource(ITypeSymbol type, ITypeSymbol readOnlySpanOfT)
717.OfType<IMethodSymbol>()
Microsoft.Maui.Controls.BindingSourceGen (3)
Microsoft.ML.CodeAnalyzer.Tests (2)
Microsoft.ML.InternalCodeAnalyzer (4)
Microsoft.VisualStudio.LanguageServices (19)
Microsoft.VisualStudio.LanguageServices.CSharp (17)
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (1)
Microsoft.VisualStudio.LanguageServices.UnitTests (4)
Microsoft.VisualStudio.LanguageServices.VisualBasic (15)
Mvc.Analyzers.Test (38)
Mvc.Api.Analyzers.Test (87)
DeclaredApiResponseMetadataTest.cs (8)
48var declaredMetadata = DeclaredApiResponseMetadata.ForProducesResponseType(200, AttributeData, Mock.Of<IMethodSymbol>());
66var declaredMetadata = DeclaredApiResponseMetadata.ForProducesResponseType(201, AttributeData, Mock.Of<IMethodSymbol>());
84var declaredMetadata = DeclaredApiResponseMetadata.ForProducesResponseType(201, AttributeData, Mock.Of<IMethodSymbol>());
98var declaredMetadata = DeclaredApiResponseMetadata.ForProducesResponseType(302, AttributeData, Mock.Of<IMethodSymbol>());
115var declaredMetadata = DeclaredApiResponseMetadata.ForProducesDefaultResponse(AttributeData, Mock.Of<IMethodSymbol>());
129var declaredMetadata = DeclaredApiResponseMetadata.ForProducesDefaultResponse(AttributeData, Mock.Of<IMethodSymbol>());
143var declaredMetadata = DeclaredApiResponseMetadata.ForProducesDefaultResponse(AttributeData, Mock.Of<IMethodSymbol>());
157protected override IMethodSymbol CommonAttributeConstructor => throw new System.NotImplementedException();
Roslyn.Diagnostics.Analyzers (457)
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)
172public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
182public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
199private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
208private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
215private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
231private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
244private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
256public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
271this IMethodSymbol method,
321public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
327public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
334public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
339public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
341var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
344foreach (var member in methods)
374public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
395public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
404public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
416public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
430private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
436public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
442IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
475public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
484public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
493public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
503public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
515public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
529public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
537public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
546public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
557public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
559ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
576.OfType<IMethodSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
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\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\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
105protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
117if (impl is IMethodSymbol implMethod)
135.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
136SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
151.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
164(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
167return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
215public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
218public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
221public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
248public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
260public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor)
Roslyn.Diagnostics.Analyzers.UnitTests (2)
Roslyn.Diagnostics.CSharp.Analyzers (112)
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)
236IMethodSymbol method)
243private static SyntaxList<TypeParameterConstraintClauseSyntax> GenerateDefaultConstraints(IMethodSymbol method)
317IMethodSymbol method, CSharpCodeGenerationContextInfo info)
323IMethodSymbol method,
Roslyn.Diagnostics.VisualBasic.Analyzers (34)
Roslyn.Test.PdbUtilities (11)
Reader\PdbValidation.cs (11)
35IMethodSymbol debugEntryPoint = null,
49IMethodSymbol debugEntryPoint = null,
65IMethodSymbol debugEntryPoint = null,
81IMethodSymbol debugEntryPoint = null,
154IMethodSymbol debugEntryPoint = null,
169IMethodSymbol debugEntryPoint = null,
193IMethodSymbol debugEntryPoint = null,
207IMethodSymbol debugEntryPoint = null,
229IMethodSymbol debugEntryPoint,
511IMethodSymbol debugEntryPoint = null,
525private static void EmitWithPdb(MemoryStream peStream, MemoryStream pdbStream, Compilation compilation, IMethodSymbol debugEntryPoint, IEnumerable<EmbeddedText> embeddedTexts, bool portable)
SemanticSearch.BuildTask (6)
System.Private.CoreLib.Generators (3)
System.Text.Json.SourceGeneration (12)
System.Text.RegularExpressions.Generator (9)
System.Windows.Forms.Analyzers.CSharp (6)
System.Windows.Forms.Analyzers.VisualBasic (5)
Test.Utilities (264)
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)
172public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
182public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
199private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
208private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
215private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
231private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
244private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
256public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
271this IMethodSymbol method,
321public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
327public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
334public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
339public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
341var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
344foreach (var member in methods)
374public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
395public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
404public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
416public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
430private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
436public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
442IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
475public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
484public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
493public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
503public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
515public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
529public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
537public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
546public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
557public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
559ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
576.OfType<IMethodSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
Text.Analyzers (433)
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)
172public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
182public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
199private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
208private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
215private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
231private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
244private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
256public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
271this IMethodSymbol method,
321public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
327public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
334public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
339public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
341var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
344foreach (var member in methods)
374public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
395public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
404public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
416public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
430private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
436public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
442IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
475public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
484public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
493public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
503public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
515public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
529public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
537public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
546public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
557public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
559ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
576.OfType<IMethodSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\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)
132lambdaOrLocalFunctionsBeingAnalyzed: PooledHashSet<IMethodSymbol>.GetInstance(),
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
141IMethodSymbol lambdaOrLocalFunction,
320ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
485protected override BasicBlockAnalysisData AnalyzeLocalFunctionInvocationCore(IMethodSymbol localFunction, CancellationToken cancellationToken)
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (12)
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)
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
808private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
877=> symbol is IMethodSymbol { MethodKind: MethodKind.DelegateInvoke };
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)
179var rx = x.ReducedFrom;
180var ry = y.ReducedFrom;
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
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\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\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
105protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
117if (impl is IMethodSymbol implMethod)
135.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
136SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
151.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
164(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
167return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
215public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
218public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
221public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
248public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
260public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor)