5 implementations of IMethodSymbol
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
Microsoft.CodeAnalysis.CSharp (1)
Microsoft.CodeAnalysis.Features (1)
Microsoft.CodeAnalysis.VisualBasic (1)
Microsoft.CodeAnalysis.Workspaces (1)
7027 references to IMethodSymbol
Analyzer.Utilities.UnitTests (18)
FlowAnalysis\Analysis\PropertySetAnalysis\PropertySetAnalysisTests.cs (18)
98ImmutableDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult> actual =
106foreach (KeyValuePair<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult> kvp in actual)
141foreach (KeyValuePair<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult> kvp in actual)
155static string MethodSymbolOrReturnString(IMethodSymbol? methodSymbol)
240(IMethodSymbol methodSymbol, PropertySetAbstractValue abstractValue) =>
256(IMethodSymbol methodSymbol, PropertySetAbstractValue abstractValue) =>
273(IMethodSymbol methodSymbol, PropertySetAbstractValue abstractValue) =>
402(IMethodSymbol method, IReadOnlyList<PointsToAbstractValue> argumentPointsToAbstractValues) =>
436(IMethodSymbol methodSymbol, PropertySetAbstractValue abstractValue) =>
535(IMethodSymbol methodSymbol, PropertySetAbstractValue abstractValue) =>
589(IMethodSymbol method, IReadOnlyList<ValueContentAbstractValue> argumentValueContentAbstractValues, IReadOnlyList<PointsToAbstractValue> argumentPointsToAbstractValues) =>
608(IMethodSymbol methodSymbol, PropertySetAbstractValue abstractValue) =>
681(IMethodSymbol methodSymbol, PropertySetAbstractValue abstractValue) =>
826(IMethodSymbol constructorMethodSymbol, IReadOnlyList<PointsToAbstractValue> argumentPointsToAbstractValues) =>
868(IMethodSymbol methodSymbol, PropertySetAbstractValue abstractValue) =>
949(IMethodSymbol constructorMethodSymbol,
972(IMethodSymbol methodSymbol, PropertySetAbstractValue abstractValue) =>
1172(IMethodSymbol methodSymbol, PropertySetAbstractValue abstractValue) =>
Aspire.Hosting.Analyzers (2)
ConfigurationSchemaGenerator (18)
ILLink.RoslynAnalyzer (139)
DataFlow\DynamicallyAccessedMembersBinder.cs (13)
34 foreach (var c in typeDefinition.ApplyIncludeInherited (t => t.GetConstructorsOnType (filter: null, bindingFlags: BindingFlags.NonPublic), withInherited))
40 foreach (var c in typeDefinition.ApplyIncludeInherited (t => t.GetConstructorsOnType (filter: null, bindingFlags: BindingFlags.Public), withInherited))
45 foreach (var c in typeDefinition.GetConstructorsOnType (filter: m => (m.DeclaredAccessibility == Accessibility.Public) && m.Parameters.Length == 0))
51 foreach (var m in typeDefinition.ApplyIncludeInherited (t => t.GetMethodsOnTypeHierarchy (filter: null, bindingFlags: BindingFlags.NonPublic | declaredOnlyFlags), withInherited))
56 foreach (var m in typeDefinition.GetMethodsOnTypeHierarchy (filter: null, bindingFlags: BindingFlags.Public | declaredOnlyFlags))
120 public static IEnumerable<IMethodSymbol> GetConstructorsOnType (this ITypeSymbol type, Func<IMethodSymbol, bool>? filter, BindingFlags? bindingFlags = null)
122 foreach (var method in type.GetMembers ().OfType<IMethodSymbol> ()) {
146 public static IEnumerable<IMethodSymbol> GetMethodsOnTypeHierarchy (this ITypeSymbol thisType, Func<IMethodSymbol, bool>? filter, BindingFlags? bindingFlags = null)
151 foreach (var method in type.GetMembers ().OfType<IMethodSymbol> ()) {
DynamicallyAccessedMembersAnalyzer.cs (18)
135 VerifyDamOnPropertyAndAccessorMatch (context, (IMethodSymbol) context.Symbol);
136 VerifyDamOnDerivedAndBaseMethodsMatch (context, (IMethodSymbol) context.Symbol);
155 else if (member is IMethodSymbol method) {
169 static void VerifyDamOnDerivedAndBaseMethodsMatch (SymbolAnalysisContext context, IMethodSymbol methodSymbol)
171 if (methodSymbol.TryGetOverriddenMember (out var overriddenSymbol) && overriddenSymbol is IMethodSymbol overriddenMethod
172 && context.Symbol is IMethodSymbol method) {
177 static void VerifyDamOnMethodsMatch (SymbolAnalysisContext context, IMethodSymbol overrideMethod, IMethodSymbol baseMethod, ISymbol? origin = null)
183 (IMethodSymbol attributableMethod, DynamicallyAccessedMemberTypes missingAttribute) = GetTargetAndRequirements (overrideMethod,
205 (IMethodSymbol attributableMethod, DynamicallyAccessedMemberTypes missingAttribute) = GetTargetAndRequirements (overrideMethod,
229 (IMethodSymbol attributableMethod, DynamicallyAccessedMemberTypes missingAttribute) = GetTargetAndRequirements (overrideMethod, baseMethod, methodTypeParameterAnnotation, overriddenMethodTypeParameterAnnotation);
265 if (implementationMember is IMethodSymbol implementationMethod && interfaceMember is IMethodSymbol interfaceMethod) {
279 static void VerifyDamOnPropertyAndAccessorMatch (SymbolAnalysisContext context, IMethodSymbol methodSymbol)
303 private static (IMethodSymbol Method, DynamicallyAccessedMemberTypes Requirements) GetTargetAndRequirements (IMethodSymbol method, IMethodSymbol overriddenMethod, DynamicallyAccessedMemberTypes methodAnnotation, DynamicallyAccessedMemberTypes overriddenMethodAnnotation)
306 IMethodSymbol paramNeedsAttributes;
Metrics (148)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IEnumerableOfIMethodSymbolExtensions.cs (25)
16/// <param name="methods">List of <see cref="IMethodSymbol"/> to filter.</param>
19public static IEnumerable<IMethodSymbol> WhereMethodDoesNotContainAttribute(
20this IEnumerable<IMethodSymbol> methods,
36/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
37/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
40public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtLeadingOrTrailing(
41this IEnumerable<IMethodSymbol> methods,
42IMethodSymbol selectedOverload,
93/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
94/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
96public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtTrailing(
97this IEnumerable<IMethodSymbol> methods,
98IMethodSymbol selectedOverload,
105/// Gets the <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>.
107/// <param name="members">The sequence of <see cref="IMethodSymbol"/>s to search.</param>
110/// The first <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>, or <langword>null</langword> if
113public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, params ITypeSymbol[] expectedParameterTypesInOrder)
139public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterInfos(this IEnumerable<IMethodSymbol>? members, params ParameterInfo[] expectedParameterTypesInOrder)
181/// Given an <see cref="IEnumerable{IMethodSymbol}"/>, returns the <see cref="IMethodSymbol"/> whose parameter list
190public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, IReadOnlyList<ITypeSymbol> expectedParameterTypesInOrder)
195foreach (var member in members)
203bool Predicate(IMethodSymbol member)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (66)
28public static bool IsObjectEqualsOverride(this IMethodSymbol method)
42public static bool IsObjectEquals(this IMethodSymbol method)
56public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
71public static bool IsGetHashCodeOverride(this IMethodSymbol method)
84public static bool IsToStringOverride(this IMethodSymbol method)
97private static bool IsObjectMethodOverride(IMethodSymbol method)
99IMethodSymbol overriddenMethod = method.OverriddenMethod;
116public static bool IsFinalizer(this IMethodSymbol method)
128IMethodSymbol overridden = method.OverriddenMethod;
141for (IMethodSymbol o = overridden.OverriddenMethod; o != null; o = o.OverriddenMethod)
153public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
157return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
164public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
173public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
183public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
205public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
227private static bool HasDisposeMethodSignature(this IMethodSymbol method)
236public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
246public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
263private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
272private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
279private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
295private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
308private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
320public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
335this IMethodSymbol method,
388public static bool IsOnDeserializationImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDeserializationCallback)
408public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
414public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
424public static bool IsPropertyGetter(this IMethodSymbol method)
433public static bool IsIndexerGetter(this IMethodSymbol method)
442public static bool IsPropertyAccessor(this IMethodSymbol method)
451public static bool IsEventAccessor(this IMethodSymbol method)
458public static bool IsOperator(this IMethodSymbol methodSymbol)
463public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
468public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
470var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
473foreach (var member in methods)
503public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
524public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
533public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
545public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
560private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
566public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
572IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
606public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
615public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
624public static int GetParameterIndex(this IMethodSymbol methodSymbol, IParameterSymbol parameterSymbol)
643public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType)
653public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
663public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
675public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
689public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
698public static bool IsOverrideOrVirtualMethodOf([NotNullWhen(returnValue: true)] this IMethodSymbol? methodSymbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? typeSymbol)
722public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
731public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
745public static bool IsAutoPropertyAccessor(this IMethodSymbol methodSymbol)
753public static bool IsTopLevelStatementsEntryPointMethod([NotNullWhen(true)] this IMethodSymbol? methodSymbol)
761public static bool IsGetAwaiterFromAwaitablePattern([NotNullWhen(true)] this IMethodSymbol? method,
783[NotNullWhen(true)] this IMethodSymbol? method,
804public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
806ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
823.OfType<IMethodSymbol>()
src\RoslynAnalyzers\Utilities\Compiler\Extensions\ISymbolExtensions.cs (28)
27return symbol is IMethodSymbol accessorSymbol &&
31public static IEnumerable<IMethodSymbol> GetAccessors(this ISymbol symbol)
99return symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
104return (symbol as IMethodSymbol)?.IsFinalizer() ?? false;
158return symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator };
163return symbol is IMethodSymbol { MethodKind: MethodKind.Conversion };
170IMethodSymbol m => m.Parameters,
234public static bool MatchMethodDerivedByName([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol type, string name)
316public static bool HasOverloadWithParameterOfType(this IEnumerable<IMethodSymbol> overloads, IMethodSymbol self, INamedTypeSymbol type, CancellationToken cancellationToken)
318foreach (var overload in overloads)
339public static IEnumerable<int> GetParameterIndices(this IMethodSymbol method, IEnumerable<IParameterSymbol> parameters, CancellationToken cancellationToken)
356public static bool ParametersAreSame(this IMethodSymbol method1, IMethodSymbol method2)
377public static bool ParameterTypesAreSame(this IMethodSymbol method1, IMethodSymbol method2, IEnumerable<int> parameterIndices, CancellationToken cancellationToken)
412public static bool ReturnTypeAndParametersAreSame(this IMethodSymbol method, IMethodSymbol otherMethod)
428public static IMethodSymbol? GetMatchingOverload(this IMethodSymbol method, IEnumerable<IMethodSymbol> overloads, int parameterIndex, INamedTypeSymbol type, CancellationToken cancellationToken)
430foreach (IMethodSymbol overload in overloads)
553IMethodSymbol methodSymbol => methodSymbol.OverriddenMethod,
568if (symbol is IMethodSymbol methodSymbol && !methodSymbol.ExplicitInterfaceImplementations.IsEmpty)
606IMethodSymbol methodSymbol => methodSymbol.ReturnType,
774public static bool HasDerivedMethodAttribute(this IMethodSymbol symbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? attribute)
832=> (symbol as IMethodSymbol)?.IsLambdaOrLocalFunction() == true;
861IMethodSymbol method => method.IsReadOnly,
Metrics.Legacy (147)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IEnumerableOfIMethodSymbolExtensions.cs (25)
16/// <param name="methods">List of <see cref="IMethodSymbol"/> to filter.</param>
19public static IEnumerable<IMethodSymbol> WhereMethodDoesNotContainAttribute(
20this IEnumerable<IMethodSymbol> methods,
36/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
37/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
40public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtLeadingOrTrailing(
41this IEnumerable<IMethodSymbol> methods,
42IMethodSymbol selectedOverload,
93/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
94/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
96public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtTrailing(
97this IEnumerable<IMethodSymbol> methods,
98IMethodSymbol selectedOverload,
105/// Gets the <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>.
107/// <param name="members">The sequence of <see cref="IMethodSymbol"/>s to search.</param>
110/// The first <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>, or <langword>null</langword> if
113public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, params ITypeSymbol[] expectedParameterTypesInOrder)
139public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterInfos(this IEnumerable<IMethodSymbol>? members, params ParameterInfo[] expectedParameterTypesInOrder)
181/// Given an <see cref="IEnumerable{IMethodSymbol}"/>, returns the <see cref="IMethodSymbol"/> whose parameter list
190public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, IReadOnlyList<ITypeSymbol> expectedParameterTypesInOrder)
195foreach (var member in members)
203bool Predicate(IMethodSymbol member)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (66)
28public static bool IsObjectEqualsOverride(this IMethodSymbol method)
42public static bool IsObjectEquals(this IMethodSymbol method)
56public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
71public static bool IsGetHashCodeOverride(this IMethodSymbol method)
84public static bool IsToStringOverride(this IMethodSymbol method)
97private static bool IsObjectMethodOverride(IMethodSymbol method)
99IMethodSymbol overriddenMethod = method.OverriddenMethod;
116public static bool IsFinalizer(this IMethodSymbol method)
128IMethodSymbol overridden = method.OverriddenMethod;
141for (IMethodSymbol o = overridden.OverriddenMethod; o != null; o = o.OverriddenMethod)
153public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
157return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
164public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
173public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
183public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
205public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
227private static bool HasDisposeMethodSignature(this IMethodSymbol method)
236public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
246public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
263private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
272private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
279private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
295private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
308private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
320public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
335this IMethodSymbol method,
388public static bool IsOnDeserializationImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDeserializationCallback)
408public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
414public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
424public static bool IsPropertyGetter(this IMethodSymbol method)
433public static bool IsIndexerGetter(this IMethodSymbol method)
442public static bool IsPropertyAccessor(this IMethodSymbol method)
451public static bool IsEventAccessor(this IMethodSymbol method)
458public static bool IsOperator(this IMethodSymbol methodSymbol)
463public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
468public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
470var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
473foreach (var member in methods)
503public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
524public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
533public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
545public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
560private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
566public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
572IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
606public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
615public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
624public static int GetParameterIndex(this IMethodSymbol methodSymbol, IParameterSymbol parameterSymbol)
643public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType)
653public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
663public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
675public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
689public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
698public static bool IsOverrideOrVirtualMethodOf([NotNullWhen(returnValue: true)] this IMethodSymbol? methodSymbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? typeSymbol)
722public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
731public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
745public static bool IsAutoPropertyAccessor(this IMethodSymbol methodSymbol)
753public static bool IsTopLevelStatementsEntryPointMethod([NotNullWhen(true)] this IMethodSymbol? methodSymbol)
761public static bool IsGetAwaiterFromAwaitablePattern([NotNullWhen(true)] this IMethodSymbol? method,
783[NotNullWhen(true)] this IMethodSymbol? method,
804public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
806ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
823.OfType<IMethodSymbol>()
src\RoslynAnalyzers\Utilities\Compiler\Extensions\ISymbolExtensions.cs (28)
27return symbol is IMethodSymbol accessorSymbol &&
31public static IEnumerable<IMethodSymbol> GetAccessors(this ISymbol symbol)
99return symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
104return (symbol as IMethodSymbol)?.IsFinalizer() ?? false;
158return symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator };
163return symbol is IMethodSymbol { MethodKind: MethodKind.Conversion };
170IMethodSymbol m => m.Parameters,
234public static bool MatchMethodDerivedByName([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol type, string name)
316public static bool HasOverloadWithParameterOfType(this IEnumerable<IMethodSymbol> overloads, IMethodSymbol self, INamedTypeSymbol type, CancellationToken cancellationToken)
318foreach (var overload in overloads)
339public static IEnumerable<int> GetParameterIndices(this IMethodSymbol method, IEnumerable<IParameterSymbol> parameters, CancellationToken cancellationToken)
356public static bool ParametersAreSame(this IMethodSymbol method1, IMethodSymbol method2)
377public static bool ParameterTypesAreSame(this IMethodSymbol method1, IMethodSymbol method2, IEnumerable<int> parameterIndices, CancellationToken cancellationToken)
412public static bool ReturnTypeAndParametersAreSame(this IMethodSymbol method, IMethodSymbol otherMethod)
428public static IMethodSymbol? GetMatchingOverload(this IMethodSymbol method, IEnumerable<IMethodSymbol> overloads, int parameterIndex, INamedTypeSymbol type, CancellationToken cancellationToken)
430foreach (IMethodSymbol overload in overloads)
553IMethodSymbol methodSymbol => methodSymbol.OverriddenMethod,
568if (symbol is IMethodSymbol methodSymbol && !methodSymbol.ExplicitInterfaceImplementations.IsEmpty)
606IMethodSymbol methodSymbol => methodSymbol.ReturnType,
774public static bool HasDerivedMethodAttribute(this IMethodSymbol symbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? attribute)
832=> (symbol as IMethodSymbol)?.IsLambdaOrLocalFunction() == true;
861IMethodSymbol method => method.IsReadOnly,
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.Http.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.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)
962public IMethodSymbol? GetEntryPoint(CancellationToken cancellationToken)
967protected abstract IMethodSymbol? CommonGetEntryPoint(CancellationToken cancellationToken);
1540/// Creates an <see cref="IMethodSymbol"/> whose <see cref="IMethodSymbol.MethodKind"/> is <see
1549public IMethodSymbol CreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol leftType, ITypeSymbol rightType)
1565protected abstract IMethodSymbol CommonCreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol leftType, ITypeSymbol rightType);
1568/// Creates an <see cref="IMethodSymbol"/> whose <see cref="IMethodSymbol.MethodKind"/> is <see
1576public IMethodSymbol CreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol operandType)
1589protected abstract IMethodSymbol CommonCreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol operandType);
2474IMethodSymbol? debugEntryPoint,
2707IMethodSymbol debugEntryPoint,
2731IMethodSymbol? debugEntryPoint,
2792IMethodSymbol? debugEntryPoint = null,
2820IMethodSymbol? debugEntryPoint,
2938IMethodSymbol? debugEntryPoint,
3172IMethodSymbol? debugEntryPoint,
3222internal 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 (186)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IEnumerableOfIMethodSymbolExtensions.cs (25)
16/// <param name="methods">List of <see cref="IMethodSymbol"/> to filter.</param>
19public static IEnumerable<IMethodSymbol> WhereMethodDoesNotContainAttribute(
20this IEnumerable<IMethodSymbol> methods,
36/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
37/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
40public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtLeadingOrTrailing(
41this IEnumerable<IMethodSymbol> methods,
42IMethodSymbol selectedOverload,
93/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
94/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
96public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtTrailing(
97this IEnumerable<IMethodSymbol> methods,
98IMethodSymbol selectedOverload,
105/// Gets the <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>.
107/// <param name="members">The sequence of <see cref="IMethodSymbol"/>s to search.</param>
110/// The first <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>, or <langword>null</langword> if
113public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, params ITypeSymbol[] expectedParameterTypesInOrder)
139public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterInfos(this IEnumerable<IMethodSymbol>? members, params ParameterInfo[] expectedParameterTypesInOrder)
181/// Given an <see cref="IEnumerable{IMethodSymbol}"/>, returns the <see cref="IMethodSymbol"/> whose parameter list
190public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, IReadOnlyList<ITypeSymbol> expectedParameterTypesInOrder)
195foreach (var member in members)
203bool Predicate(IMethodSymbol member)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (66)
28public static bool IsObjectEqualsOverride(this IMethodSymbol method)
42public static bool IsObjectEquals(this IMethodSymbol method)
56public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
71public static bool IsGetHashCodeOverride(this IMethodSymbol method)
84public static bool IsToStringOverride(this IMethodSymbol method)
97private static bool IsObjectMethodOverride(IMethodSymbol method)
99IMethodSymbol overriddenMethod = method.OverriddenMethod;
116public static bool IsFinalizer(this IMethodSymbol method)
128IMethodSymbol overridden = method.OverriddenMethod;
141for (IMethodSymbol o = overridden.OverriddenMethod; o != null; o = o.OverriddenMethod)
153public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
157return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
164public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
173public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
183public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
205public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
227private static bool HasDisposeMethodSignature(this IMethodSymbol method)
236public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
246public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
263private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
272private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
279private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
295private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
308private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
320public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
335this IMethodSymbol method,
388public static bool IsOnDeserializationImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDeserializationCallback)
408public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
414public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
424public static bool IsPropertyGetter(this IMethodSymbol method)
433public static bool IsIndexerGetter(this IMethodSymbol method)
442public static bool IsPropertyAccessor(this IMethodSymbol method)
451public static bool IsEventAccessor(this IMethodSymbol method)
458public static bool IsOperator(this IMethodSymbol methodSymbol)
463public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
468public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
470var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
473foreach (var member in methods)
503public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
524public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
533public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
545public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
560private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
566public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
572IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
606public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
615public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
624public static int GetParameterIndex(this IMethodSymbol methodSymbol, IParameterSymbol parameterSymbol)
643public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType)
653public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
663public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
675public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
689public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
698public static bool IsOverrideOrVirtualMethodOf([NotNullWhen(returnValue: true)] this IMethodSymbol? methodSymbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? typeSymbol)
722public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
731public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
745public static bool IsAutoPropertyAccessor(this IMethodSymbol methodSymbol)
753public static bool IsTopLevelStatementsEntryPointMethod([NotNullWhen(true)] this IMethodSymbol? methodSymbol)
761public static bool IsGetAwaiterFromAwaitablePattern([NotNullWhen(true)] this IMethodSymbol? method,
783[NotNullWhen(true)] this IMethodSymbol? method,
804public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
806ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
823.OfType<IMethodSymbol>()
src\RoslynAnalyzers\Utilities\Compiler\Extensions\ISymbolExtensions.cs (28)
27return symbol is IMethodSymbol accessorSymbol &&
31public static IEnumerable<IMethodSymbol> GetAccessors(this ISymbol symbol)
99return symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
104return (symbol as IMethodSymbol)?.IsFinalizer() ?? false;
158return symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator };
163return symbol is IMethodSymbol { MethodKind: MethodKind.Conversion };
170IMethodSymbol m => m.Parameters,
234public static bool MatchMethodDerivedByName([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol type, string name)
316public static bool HasOverloadWithParameterOfType(this IEnumerable<IMethodSymbol> overloads, IMethodSymbol self, INamedTypeSymbol type, CancellationToken cancellationToken)
318foreach (var overload in overloads)
339public static IEnumerable<int> GetParameterIndices(this IMethodSymbol method, IEnumerable<IParameterSymbol> parameters, CancellationToken cancellationToken)
356public static bool ParametersAreSame(this IMethodSymbol method1, IMethodSymbol method2)
377public static bool ParameterTypesAreSame(this IMethodSymbol method1, IMethodSymbol method2, IEnumerable<int> parameterIndices, CancellationToken cancellationToken)
412public static bool ReturnTypeAndParametersAreSame(this IMethodSymbol method, IMethodSymbol otherMethod)
428public static IMethodSymbol? GetMatchingOverload(this IMethodSymbol method, IEnumerable<IMethodSymbol> overloads, int parameterIndex, INamedTypeSymbol type, CancellationToken cancellationToken)
430foreach (IMethodSymbol overload in overloads)
553IMethodSymbol methodSymbol => methodSymbol.OverriddenMethod,
568if (symbol is IMethodSymbol methodSymbol && !methodSymbol.ExplicitInterfaceImplementations.IsEmpty)
606IMethodSymbol methodSymbol => methodSymbol.ReturnType,
774public static bool HasDerivedMethodAttribute(this IMethodSymbol symbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? attribute)
832=> (symbol as IMethodSymbol)?.IsLambdaOrLocalFunction() == true;
861IMethodSymbol method => method.IsReadOnly,
Microsoft.CodeAnalysis.AnalyzerUtilities (284)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IEnumerableOfIMethodSymbolExtensions.cs (25)
16/// <param name="methods">List of <see cref="IMethodSymbol"/> to filter.</param>
19public static IEnumerable<IMethodSymbol> WhereMethodDoesNotContainAttribute(
20this IEnumerable<IMethodSymbol> methods,
36/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
37/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
40public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtLeadingOrTrailing(
41this IEnumerable<IMethodSymbol> methods,
42IMethodSymbol selectedOverload,
93/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
94/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
96public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtTrailing(
97this IEnumerable<IMethodSymbol> methods,
98IMethodSymbol selectedOverload,
105/// Gets the <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>.
107/// <param name="members">The sequence of <see cref="IMethodSymbol"/>s to search.</param>
110/// The first <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>, or <langword>null</langword> if
113public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, params ITypeSymbol[] expectedParameterTypesInOrder)
139public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterInfos(this IEnumerable<IMethodSymbol>? members, params ParameterInfo[] expectedParameterTypesInOrder)
181/// Given an <see cref="IEnumerable{IMethodSymbol}"/>, returns the <see cref="IMethodSymbol"/> whose parameter list
190public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, IReadOnlyList<ITypeSymbol> expectedParameterTypesInOrder)
195foreach (var member in members)
203bool Predicate(IMethodSymbol member)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (66)
28public static bool IsObjectEqualsOverride(this IMethodSymbol method)
42public static bool IsObjectEquals(this IMethodSymbol method)
56public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
71public static bool IsGetHashCodeOverride(this IMethodSymbol method)
84public static bool IsToStringOverride(this IMethodSymbol method)
97private static bool IsObjectMethodOverride(IMethodSymbol method)
99IMethodSymbol overriddenMethod = method.OverriddenMethod;
116public static bool IsFinalizer(this IMethodSymbol method)
128IMethodSymbol overridden = method.OverriddenMethod;
141for (IMethodSymbol o = overridden.OverriddenMethod; o != null; o = o.OverriddenMethod)
153public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
157return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
164public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
173public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
183public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
205public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
227private static bool HasDisposeMethodSignature(this IMethodSymbol method)
236public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
246public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
263private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
272private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
279private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
295private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
308private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
320public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
335this IMethodSymbol method,
388public static bool IsOnDeserializationImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDeserializationCallback)
408public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
414public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
424public static bool IsPropertyGetter(this IMethodSymbol method)
433public static bool IsIndexerGetter(this IMethodSymbol method)
442public static bool IsPropertyAccessor(this IMethodSymbol method)
451public static bool IsEventAccessor(this IMethodSymbol method)
458public static bool IsOperator(this IMethodSymbol methodSymbol)
463public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
468public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
470var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
473foreach (var member in methods)
503public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
524public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
533public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
545public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
560private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
566public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
572IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
606public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
615public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
624public static int GetParameterIndex(this IMethodSymbol methodSymbol, IParameterSymbol parameterSymbol)
643public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType)
653public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
663public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
675public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
689public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
698public static bool IsOverrideOrVirtualMethodOf([NotNullWhen(returnValue: true)] this IMethodSymbol? methodSymbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? typeSymbol)
722public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
731public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
745public static bool IsAutoPropertyAccessor(this IMethodSymbol methodSymbol)
753public static bool IsTopLevelStatementsEntryPointMethod([NotNullWhen(true)] this IMethodSymbol? methodSymbol)
761public static bool IsGetAwaiterFromAwaitablePattern([NotNullWhen(true)] this IMethodSymbol? method,
783[NotNullWhen(true)] this IMethodSymbol? method,
804public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
806ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
823.OfType<IMethodSymbol>()
src\RoslynAnalyzers\Utilities\Compiler\Extensions\ISymbolExtensions.cs (28)
27return symbol is IMethodSymbol accessorSymbol &&
31public static IEnumerable<IMethodSymbol> GetAccessors(this ISymbol symbol)
99return symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
104return (symbol as IMethodSymbol)?.IsFinalizer() ?? false;
158return symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator };
163return symbol is IMethodSymbol { MethodKind: MethodKind.Conversion };
170IMethodSymbol m => m.Parameters,
234public static bool MatchMethodDerivedByName([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol type, string name)
316public static bool HasOverloadWithParameterOfType(this IEnumerable<IMethodSymbol> overloads, IMethodSymbol self, INamedTypeSymbol type, CancellationToken cancellationToken)
318foreach (var overload in overloads)
339public static IEnumerable<int> GetParameterIndices(this IMethodSymbol method, IEnumerable<IParameterSymbol> parameters, CancellationToken cancellationToken)
356public static bool ParametersAreSame(this IMethodSymbol method1, IMethodSymbol method2)
377public static bool ParameterTypesAreSame(this IMethodSymbol method1, IMethodSymbol method2, IEnumerable<int> parameterIndices, CancellationToken cancellationToken)
412public static bool ReturnTypeAndParametersAreSame(this IMethodSymbol method, IMethodSymbol otherMethod)
428public static IMethodSymbol? GetMatchingOverload(this IMethodSymbol method, IEnumerable<IMethodSymbol> overloads, int parameterIndex, INamedTypeSymbol type, CancellationToken cancellationToken)
430foreach (IMethodSymbol overload in overloads)
553IMethodSymbol methodSymbol => methodSymbol.OverriddenMethod,
568if (symbol is IMethodSymbol methodSymbol && !methodSymbol.ExplicitInterfaceImplementations.IsEmpty)
606IMethodSymbol methodSymbol => methodSymbol.ReturnType,
774public static bool HasDerivedMethodAttribute(this IMethodSymbol symbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? attribute)
832=> (symbol as IMethodSymbol)?.IsLambdaOrLocalFunction() == true;
861IMethodSymbol method => method.IsReadOnly,
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\CopyAnalysis\CopyAnalysis.CopyDataFlowOperationVisitor.cs (1)
574IMethodSymbol invokedMethod,
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\GlobalFlowStateAnalysis\GlobalFlowStateAnalysisContext.cs (1)
74IMethodSymbol 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)
36private readonly ImmutableDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>.Builder _hazardousUsageBuilder;
38private readonly ImmutableHashSet<IMethodSymbol>.Builder _visitedLocalFunctions;
60this._hazardousUsageBuilder = ImmutableDictionary.CreateBuilder<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult>();
62this._visitedLocalFunctions = ImmutableHashSet.CreateBuilder<IMethodSymbol>();
84public ImmutableDictionary<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult> HazardousUsages => this._hazardousUsageBuilder.ToImmutable();
86public ImmutableHashSet<IMethodSymbol> VisitedLocalFunctions => this._visitedLocalFunctions.ToImmutable();
454public override PropertySetAbstractValue VisitInvocation_NonLambdaOrDelegateOrLocalFunction(IMethodSymbol method, IOperation? visitedInstance, ImmutableArray<IArgumentOperation> visitedArguments, bool invokedAsDelegate, IOperation originalOperation, PropertySetAbstractValue defaultValue)
511IMethodSymbol method,
594IMethodSymbol? methodSymbol,
616IMethodSymbol? methodSymbol,
621(Location, IMethodSymbol?) key = (operationSyntax.GetLocation(), methodSymbol);
633public override PropertySetAbstractValue VisitInvocation_LocalFunction(IMethodSymbol localFunction, ImmutableArray<IArgumentOperation> visitedArguments, IOperation originalOperation, PropertySetAbstractValue defaultValue)
673foreach (KeyValuePair<(Location Location, IMethodSymbol? Method), HazardousUsageEvaluationResult> kvp in subResult.HazardousUsages)
685foreach (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)
53private ImmutableHashSet<IMethodSymbol>? _lazyContractCheckMethods;
63private readonly ImmutableHashSet<IMethodSymbol>.Builder _escapedLocalFunctions;
68private readonly ImmutableHashSet<IMethodSymbol>.Builder _analyzedLocalFunctions;
121private readonly ImmutableDictionary<IMethodSymbol, IDataFlowAnalysisResult<TAbstractAnalysisValue>>.Builder _standaloneLocalFunctionAnalysisResultsBuilder;
126private readonly Dictionary<IMethodSymbol, ControlFlowGraph?>? _interproceduralMethodToCfgMap;
151public ImmutableDictionary<IMethodSymbol, IDataFlowAnalysisResult<TAbstractAnalysisValue>> StandaloneLocalFunctionAnalysisResultsMap => _standaloneLocalFunctionAnalysisResultsBuilder.ToImmutable();
270.OfType<IMethodSymbol>().FirstOrDefault(HasDebugAssertSignature);
279_returnValueOperations = OwningSymbol is IMethodSymbol method && !method.ReturnsVoid ? new HashSet<IOperation>() : null;
281_standaloneLocalFunctionAnalysisResultsBuilder = ImmutableDictionary.CreateBuilder<IMethodSymbol, IDataFlowAnalysisResult<TAbstractAnalysisValue>>();
282_escapedLocalFunctions = ImmutableHashSet.CreateBuilder<IMethodSymbol>();
283_analyzedLocalFunctions = ImmutableHashSet.CreateBuilder<IMethodSymbol>();
343static bool HasDebugAssertSignature(IMethodSymbol method)
363if (OwningSymbol is IMethodSymbol method &&
552OwningSymbol is IMethodSymbol method &&
612foreach (var localFunction in DataFlowAnalysisContext.ControlFlowGraph.LocalFunctions)
630private bool IsStandaloneAnalysisRequiredForLocalFunction(IMethodSymbol localFunction)
835if (OwningSymbol is IMethodSymbol method &&
980private bool IsContractCheckMethod(IMethodSymbol method)
991var 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));
1006private bool IsAnyDebugAssertMethod(IMethodSymbol method) =>
1012protected bool IsAnyAssertMethod(IMethodSymbol method)
1764bool IsOverrideOrImplementationOfEquatableEquals(IMethodSymbol methodSymbol)
1775var equalsMember = interfaceType.GetMembers("Equals").OfType<IMethodSymbol>().FirstOrDefault();
2125IMethodSymbol invokedMethod,
2201IMethodSymbol invokedMethod,
2239int currentMethodCallCount = currentMethodsBeingAnalyzed.Count(m => !(m.OwningSymbol is IMethodSymbol ms && ms.IsLambdaOrLocalFunctionOrDelegate()));
2550if (argumentOperation.Parameter!.ContainingSymbol is IMethodSymbol method &&
2594IMethodSymbol invokedMethod,
2631private void PerformStandaloneLocalFunctionInterproceduralAnalysis(IMethodSymbol localFunction)
2732IMethodSymbol invokedMethod)
3160var method = operation.Constructor!;
3179foreach ((IMethodSymbol method, _) in resolvedMethodTargetsOpt)
3225void PostVisitInvocation(IMethodSymbol targetMethod, ImmutableArray<IArgumentOperation> arguments)
3250void ProcessInterlockedOperation(IMethodSymbol targetMethod, ImmutableArray<IArgumentOperation> arguments, INamedTypeSymbol interlockedType)
3285using var methodTargetsOptBuilder = PooledHashSet<(IMethodSymbol method, IOperation? instance)>.GetInstance();
3310PooledHashSet<(IMethodSymbol method, IOperation? instance)> methodTargetsOptBuilder,
3316PooledHashSet<(IMethodSymbol method, IOperation? instance)> methodTargetsOptBuilder,
3323PooledHashSet<(IMethodSymbol method, IOperation? instance)> methodTargetsOptBuilder,
3334var targetMethod = invocation.TargetMethod;
3377void AddMethodTarget(IMethodSymbol method, IOperation? instance)
3436out ImmutableHashSet<(IMethodSymbol method, IOperation? instance)>? resolvedMethodTargets)
3440using var methodTargetsOptBuilder = PooledHashSet<(IMethodSymbol method, IOperation? instance)>.GetInstance();
3532IMethodSymbol method,
3545private ControlFlowGraph? GetInterproceduralControlFlowGraph(IMethodSymbol method)
3575IMethodSymbol localFunction,
4194private IMethodSymbol? DebugAssertMethod { get; }
4223private protected DisposeMethodKind GetDisposeMethodKind(IMethodSymbol method)
Microsoft.CodeAnalysis.BannedApiAnalyzers (149)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IEnumerableOfIMethodSymbolExtensions.cs (25)
16/// <param name="methods">List of <see cref="IMethodSymbol"/> to filter.</param>
19public static IEnumerable<IMethodSymbol> WhereMethodDoesNotContainAttribute(
20this IEnumerable<IMethodSymbol> methods,
36/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
37/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
40public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtLeadingOrTrailing(
41this IEnumerable<IMethodSymbol> methods,
42IMethodSymbol selectedOverload,
93/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
94/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
96public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtTrailing(
97this IEnumerable<IMethodSymbol> methods,
98IMethodSymbol selectedOverload,
105/// Gets the <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>.
107/// <param name="members">The sequence of <see cref="IMethodSymbol"/>s to search.</param>
110/// The first <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>, or <langword>null</langword> if
113public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, params ITypeSymbol[] expectedParameterTypesInOrder)
139public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterInfos(this IEnumerable<IMethodSymbol>? members, params ParameterInfo[] expectedParameterTypesInOrder)
181/// Given an <see cref="IEnumerable{IMethodSymbol}"/>, returns the <see cref="IMethodSymbol"/> whose parameter list
190public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, IReadOnlyList<ITypeSymbol> expectedParameterTypesInOrder)
195foreach (var member in members)
203bool Predicate(IMethodSymbol member)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (66)
28public static bool IsObjectEqualsOverride(this IMethodSymbol method)
42public static bool IsObjectEquals(this IMethodSymbol method)
56public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
71public static bool IsGetHashCodeOverride(this IMethodSymbol method)
84public static bool IsToStringOverride(this IMethodSymbol method)
97private static bool IsObjectMethodOverride(IMethodSymbol method)
99IMethodSymbol overriddenMethod = method.OverriddenMethod;
116public static bool IsFinalizer(this IMethodSymbol method)
128IMethodSymbol overridden = method.OverriddenMethod;
141for (IMethodSymbol o = overridden.OverriddenMethod; o != null; o = o.OverriddenMethod)
153public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
157return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
164public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
173public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
183public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
205public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
227private static bool HasDisposeMethodSignature(this IMethodSymbol method)
236public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
246public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
263private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
272private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
279private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
295private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
308private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
320public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
335this IMethodSymbol method,
388public static bool IsOnDeserializationImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDeserializationCallback)
408public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
414public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
424public static bool IsPropertyGetter(this IMethodSymbol method)
433public static bool IsIndexerGetter(this IMethodSymbol method)
442public static bool IsPropertyAccessor(this IMethodSymbol method)
451public static bool IsEventAccessor(this IMethodSymbol method)
458public static bool IsOperator(this IMethodSymbol methodSymbol)
463public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
468public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
470var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
473foreach (var member in methods)
503public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
524public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
533public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
545public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
560private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
566public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
572IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
606public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
615public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
624public static int GetParameterIndex(this IMethodSymbol methodSymbol, IParameterSymbol parameterSymbol)
643public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType)
653public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
663public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
675public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
689public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
698public static bool IsOverrideOrVirtualMethodOf([NotNullWhen(returnValue: true)] this IMethodSymbol? methodSymbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? typeSymbol)
722public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
731public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
745public static bool IsAutoPropertyAccessor(this IMethodSymbol methodSymbol)
753public static bool IsTopLevelStatementsEntryPointMethod([NotNullWhen(true)] this IMethodSymbol? methodSymbol)
761public static bool IsGetAwaiterFromAwaitablePattern([NotNullWhen(true)] this IMethodSymbol? method,
783[NotNullWhen(true)] this IMethodSymbol? method,
804public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
806ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
823.OfType<IMethodSymbol>()
src\RoslynAnalyzers\Utilities\Compiler\Extensions\ISymbolExtensions.cs (28)
27return symbol is IMethodSymbol accessorSymbol &&
31public static IEnumerable<IMethodSymbol> GetAccessors(this ISymbol symbol)
99return symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
104return (symbol as IMethodSymbol)?.IsFinalizer() ?? false;
158return symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator };
163return symbol is IMethodSymbol { MethodKind: MethodKind.Conversion };
170IMethodSymbol m => m.Parameters,
234public static bool MatchMethodDerivedByName([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol type, string name)
316public static bool HasOverloadWithParameterOfType(this IEnumerable<IMethodSymbol> overloads, IMethodSymbol self, INamedTypeSymbol type, CancellationToken cancellationToken)
318foreach (var overload in overloads)
339public static IEnumerable<int> GetParameterIndices(this IMethodSymbol method, IEnumerable<IParameterSymbol> parameters, CancellationToken cancellationToken)
356public static bool ParametersAreSame(this IMethodSymbol method1, IMethodSymbol method2)
377public static bool ParameterTypesAreSame(this IMethodSymbol method1, IMethodSymbol method2, IEnumerable<int> parameterIndices, CancellationToken cancellationToken)
412public static bool ReturnTypeAndParametersAreSame(this IMethodSymbol method, IMethodSymbol otherMethod)
428public static IMethodSymbol? GetMatchingOverload(this IMethodSymbol method, IEnumerable<IMethodSymbol> overloads, int parameterIndex, INamedTypeSymbol type, CancellationToken cancellationToken)
430foreach (IMethodSymbol overload in overloads)
553IMethodSymbol methodSymbol => methodSymbol.OverriddenMethod,
568if (symbol is IMethodSymbol methodSymbol && !methodSymbol.ExplicitInterfaceImplementations.IsEmpty)
606IMethodSymbol methodSymbol => methodSymbol.ReturnType,
774public static bool HasDerivedMethodAttribute(this IMethodSymbol symbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? attribute)
832=> (symbol as IMethodSymbol)?.IsLambdaOrLocalFunction() == true;
861IMethodSymbol method => method.IsReadOnly,
Microsoft.CodeAnalysis.CodeStyle (273)
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)
114SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
378symbol = ((IMethodSymbol)symbol).GetConstructedReducedFrom()!;
383newSymbol = ((IMethodSymbol)newSymbol).GetConstructedReducedFrom()!;
403if (symbol is IMethodSymbol methodSymbol && newSymbol is IMethodSymbol newMethodSymbol)
477if (symbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } methodSymbol &&
478newSymbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } newMethodSymbol)
779GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
780GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
807private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
876=> 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 (302)
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)
168IMethodSymbol method => GenerateMethod(compilation, method, throughMember, modifiers, accessibility),
176Compilation compilation, IMethodSymbol method, ISymbol? throughMember,
211var getMethod = ShouldGenerateAccessor(property.GetMethod)
220var setMethod = ShouldGenerateAccessor(property.SetMethod)
247private IMethodSymbol? GetEventAddOrRemoveMethod(
248IEventSymbol @event, IMethodSymbol? accessor, ISymbol? throughMember,
266private bool ShouldGenerateAccessor([NotNullWhen(true)] IMethodSymbol? method)
src\Analyzers\Core\CodeFixes\ImplementInterface\ImplementInterfaceGenerator.cs (8)
266if (member is not IMethodSymbol method)
305IMethodSymbol method => [GenerateMethod(compilation, method, conflictingMember as IMethodSymbol, accessibility, modifiers, generateAbstractly, useExplicitInterfaceSymbol, memberName)],
314var accessor = CodeGenerationSymbolFactory.CreateAccessorSymbol(
329private IMethodSymbol? GetAddOrRemoveMethod(
330IEventSymbol @event, bool generateInvisibly, IMethodSymbol accessor, string memberName,
366if (member is IMethodSymbol method1 && baseMember is IMethodSymbol method2)
src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (9)
28bool keepVoid, IMethodSymbol methodSymbol, SyntaxNode node, KnownTaskTypes knownTypes, CancellationToken cancellationToken);
57var methodSymbol = GetMethodSymbol(semanticModel, node, cancellationToken);
86private static IMethodSymbol? GetMethodSymbol(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
90return symbol as IMethodSymbol;
115var methodSymbol = GetMethodSymbol(semanticModel, node, cancellationToken);
157IMethodSymbol methodSymbol,
176var newMethod = (IMethodSymbol)semanticModel.GetRequiredDeclaredSymbol(newNode, cancellationToken);
186IMethodSymbol 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)
38IMethodSymbol? addMethod = null,
39IMethodSymbol? removeMethod = null,
40IMethodSymbol? raiseMethod = null)
57IMethodSymbol? getMethod,
58IMethodSymbol? setMethod,
85ImmutableArray<IParameterSymbol> parameters, IMethodSymbol? getMethod, IMethodSymbol? setMethod,
124public static IMethodSymbol CreateConstructorSymbol(
143public static IMethodSymbol CreateDestructorSymbol(
152internal static IMethodSymbol CreateMethodSymbol(
159ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
177public static IMethodSymbol CreateMethodSymbol(
181ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
196public static IMethodSymbol CreateOperatorSymbol(
224public static IMethodSymbol CreateConversionSymbol(
249public static IMethodSymbol CreateConversionSymbol(
361internal static IMethodSymbol CreateAccessorSymbol(
362IMethodSymbol accessor,
365ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
387public static IMethodSymbol CreateAccessorSymbol(
475var invokeMethod = CreateMethodSymbol(
515internal static IMethodSymbol CreateMethodSymbol(
516IMethodSymbol method,
520ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
554IMethodSymbol? getMethod = null,
555IMethodSymbol? setMethod = null,
580IMethodSymbol? addMethod = null,
581IMethodSymbol? removeMethod = null)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
104protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
116if (impl is IMethodSymbol implMethod)
134.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
135SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
150.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
163(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
166return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
216public IMethodSymbol GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
219public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
222public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
249public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
261public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol primaryConstructor)
Microsoft.CodeAnalysis.CSharp (158)
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 (123)
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 (70)
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (9)
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 (50)
Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Features (279)
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)
519[SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")],
558semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
561semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C", syntaxMap: syntaxMapB)]),
EditAndContinue\StatementEditingTests.cs (5)
5248SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
5249SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")
5506SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, preserveLocalVariables: true, partialType: "C"));
5547SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, preserveLocalVariables: true, partialType: "C"));
8646SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, preserveLocalVariables: true, partialType: "C"));
EditAndContinue\TopLevelEditingTests.cs (56)
6994SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.M")),
7229semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMembers<IMethodSymbol>("C.F").Single(m => m.Parameters is [{ Type.SpecialType: SpecialType.System_Char }]))]),
7232semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMembers<IMethodSymbol>("C.F").Single(m => m.Parameters is [{ Type.SpecialType: SpecialType.System_Byte }]))]),
7535SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>("F")));
7550SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>("F")));
7591SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("S").GetMember<IMethodSymbol>("M")));
8699SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.M").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
8700SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.M").PartialImplementationPart, partialType: "C")
10274semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10295semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10312semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10314semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10335SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.F"), deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C")
10365semanticEdits: [SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C")]),
10388semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10390semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")])
10408semanticEdits: [SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart)]),
10452semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10478semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10502semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10504semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")]),
10532SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")
10553SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
10554SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")
10559SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
10560SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, partialType: "C")
11490SemanticEdit(SemanticEditKind.Update, c => c.GetMembers<IMethodSymbol>("C.Deconstruct").Single(m => m.Parameters is [_])),
11839SemanticEdit(SemanticEditKind.Update, c => c.GetMembers<IMethodSymbol>("C.Deconstruct").Single(m => m.Parameters is [_, _])),
12896SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>("C").PartialImplementationPart, partialType: "C"));
14433SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>("F")),
14454SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").GetMember<IMethodSymbol>("F")),
19687semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C")]),
19708semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C")]),
19725semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C")]),
19747SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C")
19771semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C")]),
19773semanticEdits: [SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C")])
19867SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C")
19896SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C"),
19926SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C"),
19948SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
19950SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C"),
19956SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
19958SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, partialType: "C"),
20564SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_Item").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
20565SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.set_Item").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
20567SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.get_Item").PartialImplementationPart, partialType: "C"),
20568SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.set_Item").PartialImplementationPart, partialType: "C"),
20574SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_Item").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
20575SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.set_Item").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
20577SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.get_Item").PartialImplementationPart, partialType: "C"),
20578SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.set_Item").PartialImplementationPart, partialType: "C"),
20682SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_Item").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
20683SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.set_Item").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
20685SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.get_Item").PartialImplementationPart, partialType: "C"),
20686SemanticEdit(SemanticEditKind.Insert, c => c.GetMember<IMethodSymbol>("C.set_Item").PartialImplementationPart, partialType: "C"),
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (7)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (315)
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (341)
Compilation\CompilationAPITests.cs (24)
1732var entryPoint = compilation.GetEntryPoint(default(CancellationToken));
1774var method = compilation.GetEntryPoint(default(CancellationToken));
1818var method = compilation.GetEntryPoint(default(CancellationToken));
2743var op = compilation.CreateBuiltinOperator(name, intType, intType, intType);
2761var op = compilation.CreateBuiltinOperator(name, boolType, intType, intType);
2780var op = compilation.CreateBuiltinOperator(WellKnownMemberNames.AdditionOperatorName, intType, intType, intType);
2847var addBuiltIn = compilation.CreateBuiltinOperator(WellKnownMemberNames.AdditionOperatorName, intType, intType, intType);
2848var addBuiltInChecked = compilation.CreateBuiltinOperator(WellKnownMemberNames.CheckedAdditionOperatorName, intType, intType, intType);
2849var subtractBuiltIn = compilation.CreateBuiltinOperator(WellKnownMemberNames.SubtractionOperatorName, intType, intType, intType);
2850var subtractBuiltInChecked = compilation.CreateBuiltinOperator(WellKnownMemberNames.CheckedSubtractionOperatorName, intType, intType, intType);
2882var addBuiltIn = compilation.CreateBuiltinOperator(WellKnownMemberNames.AdditionOperatorName, intType, intType, intType);
2883var addBuiltInChecked = compilation.CreateBuiltinOperator(WellKnownMemberNames.CheckedAdditionOperatorName, intType, intType, intType);
2884var subtractBuiltIn = compilation.CreateBuiltinOperator(WellKnownMemberNames.SubtractionOperatorName, intType, intType, intType);
2885var subtractBuiltInChecked = compilation.CreateBuiltinOperator(WellKnownMemberNames.CheckedSubtractionOperatorName, intType, intType, intType);
2914var addBuiltIn = compilation.CreateBuiltinOperator(WellKnownMemberNames.AdditionOperatorName, intType, intType, intType);
2915var addBuiltInChecked = compilation.CreateBuiltinOperator(WellKnownMemberNames.CheckedAdditionOperatorName, intType, intType, intType);
2916var subtractBuiltIn = compilation.CreateBuiltinOperator(WellKnownMemberNames.SubtractionOperatorName, intType, intType, intType);
2917var subtractBuiltInChecked = compilation.CreateBuiltinOperator(WellKnownMemberNames.CheckedSubtractionOperatorName, intType, intType, intType);
2939var op = compilation.CreateBuiltinOperator(name, intType, intType);
2951var op = compilation.CreateBuiltinOperator(name, boolType, boolType);
2970var op = compilation.CreateBuiltinOperator(WellKnownMemberNames.UnaryPlusOperatorName, intType, intType);
3066var genericMethod = (IMethodSymbol)comp.GetMember("Program.M");
3072var type = genericMethod.Construct(typeArguments, default);
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 (136)
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 (650)
Completion\Providers\ImportCompletionProvider\ExtensionMethodImportCompletionHelper.cs (5)
129Compilation compilation, ImmutableArray<IMethodSymbol> extentsionMethodSymbols, ImmutableArray<ITypeSymbol> targetTypeSymbols, CancellationToken cancellationToken)
133using var _2 = PooledDictionary<(string containingNamespace, string methodName, bool isGeneric), (IMethodSymbol bestSymbol, int overloadCount, bool includeInTargetTypedCompletion)>
137foreach (var symbol in extentsionMethodSymbols)
141IMethodSymbol bestSymbol;
198Compilation compilation, IMethodSymbol methodSymbol, ImmutableArray<ITypeSymbol> targetTypeSymbols,
Completion\Providers\ImportCompletionProvider\ExtensionMethodImportCompletionHelper.SymbolComputer.cs (15)
80public async Task<ImmutableArray<IMethodSymbol>> GetExtensionMethodSymbolsAsync(bool forceCacheCreation, bool hideAdvancedMembers, CancellationToken cancellationToken)
85var peReferenceMethodSymbolsTask = ProducerConsumer<IMethodSymbol?>.RunParallelAsync(
92var projectMethodSymbolsTask = ProducerConsumer<IMethodSymbol?>.RunParallelAsync(
101using var _ = ArrayBuilder<IMethodSymbol>.GetInstance(results[0].Length + results[1].Length, out var symbols);
136Action<IMethodSymbol?> callback,
181Action<IMethodSymbol?> callback,
223MultiDictionary<ITypeSymbol, IMethodSymbol> matchingMethodSymbols,
224Action<IMethodSymbol?> callback,
290MultiDictionary<ITypeSymbol, IMethodSymbol> matchingMethodSymbols,
291Action<IMethodSymbol?> callback,
326private MultiDictionary<ITypeSymbol, IMethodSymbol> GetPotentialMatchingSymbolsFromAssembly(
332var builder = new MultiDictionary<ITypeSymbol, IMethodSymbol>();
363var methodSymbols = containerSymbol.GetMembers(methodName).OfType<IMethodSymbol>();
365foreach (var methodSymbol in methodSymbols)
378static 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);
2435protected static bool ReturnTypesEquivalent(IMethodSymbol oldMethod, IMethodSymbol newMethod, bool exact)
2510var oldMethod = (IMethodSymbol)oldMember;
2511var newMethod = (IMethodSymbol)newMember;
2517var newInvokeMethod = ((INamedTypeSymbol)newMember).DelegateInvokeMethod;
2872var oldPrimaryConstructor = (IMethodSymbol)oldSymbol;
3184if (oldSymbol is IMethodSymbol)
3584Debug.Assert(member is IPropertySymbol or IMethodSymbol);
3593var primaryConstructor = (IMethodSymbol)member;
3629IMethodSymbol? constructor,
3630IMethodSymbol? otherConstructor,
3640void AddEdits(IMethodSymbol? constructor, Compilation otherCompilation, bool isDelete)
3686if (symbol is IMethodSymbol
3718case IMethodSymbol or IFieldSymbol:
3755case IMethodSymbol or IFieldSymbol:
3807if (oldSymbol.Name != newSymbol.Name || oldSymbol is IMethodSymbol or IFieldSymbol)
3957if (oldMember is IMethodSymbol oldMethod)
4120else if (oldSymbol is IMethodSymbol oldMethod && newSymbol is IMethodSymbol newMethod)
4202if (oldSymbol is not IMethodSymbol { AssociatedSymbol: not null })
4236else if (oldSymbol is IMethodSymbol oldMethod && newSymbol is IMethodSymbol newMethod)
4394if (oldSymbol is not IMethodSymbol { AssociatedSymbol: not null })
4470oldMember is not IMethodSymbol { AssociatedSymbol.Kind: SymbolKind.Property or SymbolKind.Event })
4494=> parameter is { Ordinal: 0, ContainingSymbol: IMethodSymbol { IsExtensionMethod: true } };
4565var oldPrimaryConstructor = (IMethodSymbol)oldContainingMember;
4566var newPrimaryConstructor = (IMethodSymbol)newContainingMember;
4572var oldSynthesizedDeconstructor = oldPrimaryConstructor.GetMatchingDeconstructor();
4573var newSynthesizedDeconstructor = newPrimaryConstructor.GetMatchingDeconstructor();
4610if (oldSymbol is IMethodSymbol oldMethod &&
4611newSymbol is IMethodSymbol newMethod)
4816if (newSymbol is IMethodSymbol or IEventSymbol or IPropertySymbol)
4882.FirstOrDefault(static (m, compilation) => m is IMethodSymbol { IsImplicitlyDeclared: true } method && HasPrintMembersSignature(method, compilation), compilation);
4889.FirstOrDefault(static m => m is IMethodSymbol { IsImplicitlyDeclared: true } method && HasIEquatableEqualsSignature(method));
4896.FirstOrDefault(static m => m is IMethodSymbol { IsImplicitlyDeclared: true } method && HasGetHashCodeSignature(method));
5363foreach (var newCtor in isStatic ? newType.StaticConstructors : newType.InstanceConstructors)
5382IMethodSymbol? oldCtor;
5405oldCtor = (IMethodSymbol)GetRequiredDeclaredSymbol(oldModel.RequiredModel, oldDeclaration, cancellationToken);
5422oldCtor = (IMethodSymbol?)resolution.Symbol;
5555private static IMethodSymbol? TryGetParameterlessConstructor(INamedTypeSymbol type, bool isStatic)
5633var oldLambdaSymbol = isNestedFunction ? GetLambdaExpressionSymbol(oldModel.RequiredModel, oldLambda, cancellationToken) : null;
5634var newLambdaSymbol = isNestedFunction ? GetLambdaExpressionSymbol(newModel.RequiredModel, newLambda, cancellationToken) : null;
5737var oldPrimaryConstructor = oldDeclaration != null && IsPrimaryConstructorDeclaration(oldDeclaration)
5738? (IMethodSymbol)oldMember
5741var newPrimaryConstructor = newDeclaration != null && IsPrimaryConstructorDeclaration(newDeclaration)
5742? (IMethodSymbol)newMember
5751var oldLiftingPrimaryConstructor = oldMember != oldPrimaryConstructor && oldDeclaration != null && !IsDeclarationWithInitializer(oldDeclaration) ? oldPrimaryConstructor : null;
5752var newLiftingPrimaryConstructor = newMember != newPrimaryConstructor && newDeclaration != null && !IsDeclarationWithInitializer(newDeclaration) ? newPrimaryConstructor : null;
5986public static VariableCaptureKey Create(ISymbol variable, IMethodSymbol? liftingPrimaryConstructor)
5990private static VariableCaptureKind GetCaptureKind(ISymbol variable, IMethodSymbol? liftingPrimaryConstructor)
5997IMethodSymbol? liftingPrimaryConstructor,
6074IMethodSymbol? oldLiftingPrimaryConstructor,
6076IMethodSymbol? newLiftingPrimaryConstructor,
6128IMethodSymbol? liftingPrimaryConstructor)
6164IMethodSymbol method => method.AssociatedSymbol,
6216var lambda = parameter.ContainingSymbol is IMethodSymbol { MethodKind: MethodKind.LambdaMethod or MethodKind.LocalFunction } containingLambda ?
6221if (parameter is { IsImplicitlyDeclared: true, ContainingSymbol: IMethodSymbol { AssociatedSymbol: { } associatedSymbol } })
6274IMethodSymbol? oldPrimaryConstructor,
6277IMethodSymbol? newPrimaryConstructor,
6452var oldLambdaSymbol = (IMethodSymbol)diagnosticContext.RequiredOldSymbol;
6453var newLambdaSymbol = (IMethodSymbol)diagnosticContext.RequiredNewSymbol;
6756=> symbol is IMethodSymbol { Name: WellKnownMemberNames.TopLevelStatementsEntryPointMethodName };
6764if (current is IMethodSymbol { Arity: > 0 })
6805public IMethodSymbol? GetPrimaryConstructor(INamedTypeSymbol typeSymbol, CancellationToken cancellationToken)
6810=> symbol is IMethodSymbol { IsStatic: false, MethodKind: MethodKind.Constructor, DeclaringSyntaxReferences: [_] } && IsPrimaryConstructorDeclaration(GetSymbolDeclarationSyntax(symbol, cancellationToken));
6826public IMethodSymbol? GetEncompassingPrimaryConstructor(SyntaxNode declaration, ISymbol symbol, CancellationToken cancellationToken)
6827=> IsPrimaryConstructorDeclaration(declaration) ? (IMethodSymbol)symbol :
6863if (newSymbol is IMethodSymbol { IsStatic: false, ContainingType.IsRecord: true, ReturnsVoid: true, Name: WellKnownMemberNames.DeconstructMethodName } method &&
6904if (newSymbol is IMethodSymbol { AssociatedSymbol: IPropertySymbol { } newProperty })
6906var oldProperty = ((IMethodSymbol)oldSymbol).AssociatedSymbol;
6916private static bool HasPrintMembersSignature(IMethodSymbol method, Compilation compilation)
6919private static bool HasIEquatableEqualsSignature(IMethodSymbol method)
6922private 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)
70IMethodSymbol methodSymbol,
103IMethodSymbol methodSymbol,
210document = await AddStringCheckAsync(document, parameter, functionDeclaration, (IMethodSymbol)parameter.ContainingSymbol, blockStatement, NullOrEmptySuffix, lazySimplifierOptions, cancellationToken).ConfigureAwait(false);
216(IMethodSymbol)parameter.ContainingSymbol, blockStatement, lazySimplifierOptions, cancellationToken).ConfigureAwait(false);
419private static (IMethodSymbol? GenericOverload, IMethodSymbol? NonGenericOverload) GetEnumIsDefinedMethods(Compilation compilation)
423var enumIsDefinedGenericMethod = (IMethodSymbol?)enumIsDefinedMembers.FirstOrDefault(m => m is IMethodSymbol { IsStatic: true, Arity: 1, Parameters.Length: 1 });
424var enumIsDefinedNonGenericMethod = (IMethodSymbol?)enumIsDefinedMembers.FirstOrDefault(m => m is IMethodSymbol { IsStatic: true, Arity: 0, Parameters.Length: 2 });
462private static bool IsEnumIsDefinedCheck(IOperation statement, IParameterSymbol parameter, IMethodSymbol? enumIsDefinedGenericMethod, IMethodSymbol? enumIsDefinedNonGenericMethod)
472var method = invocation.TargetMethod;
529var targetMethod = invocation.TargetMethod;
544IMethodSymbol method,
567IMethodSymbol method,
583IMethodSymbol method,
599IMethodSymbol method,
633IMethodSymbol method,
642var enumIsDefinedGenericMethod = enumType.GetMembers(nameof(Enum.IsDefined)).FirstOrDefault(m => m is IMethodSymbol { IsStatic: true, Arity: 1, Parameters.Length: 1 });
697.FirstOrDefault(s => s is IMethodSymbol { Parameters: [{ Type.SpecialType: SpecialType.System_Object }, ..] });
722.FirstOrDefault(s => s is IMethodSymbol { IsStatic: true, Arity: 1, Parameters.Length: 2 });
764.FirstOrDefault(s => s is IMethodSymbol { Parameters: [{ Type.SpecialType: SpecialType.System_String }, ..] });
799var methodSymbol = (IMethodSymbol)parameter.ContainingSymbol;
IntroduceParameter\AbstractIntroduceParameterCodeRefactoringProvider.cs (5)
46protected abstract bool IsDestructor(IMethodSymbol methodSymbol);
74if (containingSymbol is not IMethodSymbol methodSymbol)
140TExpressionSyntax expression, IMethodSymbol methodSymbol, SyntaxNode containingMethod,
237IMethodSymbol methodSymbol, SyntaxNode containingMethod, Dictionary<Document, List<TExpressionSyntax>> methodCallSites, bool allOccurrences, IntroduceParameterCodeActionKind selectedCodeAction,
270Document document, IMethodSymbol methodSymbol, CancellationToken cancellationToken)
ReplaceMethodWithProperty\ReplaceMethodWithPropertyCodeRefactoringProvider.cs (23)
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,
401MultiDictionary<DocumentId, IMethodSymbol>.ValueSet originalDefinitions,
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\GenerateParameterizedMember\AbstractGenerateParameterizedMemberService.State.cs (1)
83.OfType<IMethodSymbol>();
src\Analyzers\Core\CodeFixes\ImplementAbstractClass\ImplementAbstractClassData.cs (7)
168IMethodSymbol method => GenerateMethod(compilation, method, throughMember, modifiers, accessibility),
176Compilation compilation, IMethodSymbol method, ISymbol? throughMember,
211var getMethod = ShouldGenerateAccessor(property.GetMethod)
220var setMethod = ShouldGenerateAccessor(property.SetMethod)
247private IMethodSymbol? GetEventAddOrRemoveMethod(
248IEventSymbol @event, IMethodSymbol? accessor, ISymbol? throughMember,
266private bool ShouldGenerateAccessor([NotNullWhen(true)] IMethodSymbol? method)
src\Analyzers\Core\CodeFixes\ImplementInterface\ImplementInterfaceGenerator.cs (8)
266if (member is not IMethodSymbol method)
305IMethodSymbol method => [GenerateMethod(compilation, method, conflictingMember as IMethodSymbol, accessibility, modifiers, generateAbstractly, useExplicitInterfaceSymbol, memberName)],
314var accessor = CodeGenerationSymbolFactory.CreateAccessorSymbol(
329private IMethodSymbol? GetAddOrRemoveMethod(
330IEventSymbol @event, bool generateInvisibly, IMethodSymbol accessor, string memberName,
366if (member is IMethodSymbol method1 && baseMember is IMethodSymbol method2)
src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (9)
28bool keepVoid, IMethodSymbol methodSymbol, SyntaxNode node, KnownTaskTypes knownTypes, CancellationToken cancellationToken);
57var methodSymbol = GetMethodSymbol(semanticModel, node, cancellationToken);
86private static IMethodSymbol? GetMethodSymbol(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
90return symbol as IMethodSymbol;
115var methodSymbol = GetMethodSymbol(semanticModel, node, cancellationToken);
157IMethodSymbol methodSymbol,
176var newMethod = (IMethodSymbol)semanticModel.GetRequiredDeclaredSymbol(newNode, cancellationToken);
186IMethodSymbol 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 (3)
62var method = await TryGetBestMatchAsync(project, fullyQualifiedTypeName, methodNode, methodArguments, methodTypeArguments, cancellationToken).ConfigureAwait(false);
93DefinitionItem GetDefinition(IMethodSymbol method)
108private static async Task<IMethodSymbol?> TryGetBestMatchAsync(Project project, string fullyQualifiedTypeName, StackFrameSimpleNameNode methodNode, StackFrameParameterList methodArguments, StackFrameTypeArgumentList? methodTypeArguments, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.Features.Test.Utilities (1)
Microsoft.CodeAnalysis.LanguageServer (1)
Microsoft.CodeAnalysis.PublicApiAnalyzers (132)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IEnumerableOfIMethodSymbolExtensions.cs (25)
16/// <param name="methods">List of <see cref="IMethodSymbol"/> to filter.</param>
19public static IEnumerable<IMethodSymbol> WhereMethodDoesNotContainAttribute(
20this IEnumerable<IMethodSymbol> methods,
36/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
37/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
40public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtLeadingOrTrailing(
41this IEnumerable<IMethodSymbol> methods,
42IMethodSymbol selectedOverload,
93/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
94/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
96public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtTrailing(
97this IEnumerable<IMethodSymbol> methods,
98IMethodSymbol selectedOverload,
105/// Gets the <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>.
107/// <param name="members">The sequence of <see cref="IMethodSymbol"/>s to search.</param>
110/// The first <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>, or <langword>null</langword> if
113public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, params ITypeSymbol[] expectedParameterTypesInOrder)
139public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterInfos(this IEnumerable<IMethodSymbol>? members, params ParameterInfo[] expectedParameterTypesInOrder)
181/// Given an <see cref="IEnumerable{IMethodSymbol}"/>, returns the <see cref="IMethodSymbol"/> whose parameter list
190public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, IReadOnlyList<ITypeSymbol> expectedParameterTypesInOrder)
195foreach (var member in members)
203bool Predicate(IMethodSymbol member)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (63)
28public static bool IsObjectEqualsOverride(this IMethodSymbol method)
42public static bool IsObjectEquals(this IMethodSymbol method)
56public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
71public static bool IsGetHashCodeOverride(this IMethodSymbol method)
84public static bool IsToStringOverride(this IMethodSymbol method)
97private static bool IsObjectMethodOverride(IMethodSymbol method)
99IMethodSymbol overriddenMethod = method.OverriddenMethod;
116public static bool IsFinalizer(this IMethodSymbol method)
128IMethodSymbol overridden = method.OverriddenMethod;
141for (IMethodSymbol o = overridden.OverriddenMethod; o != null; o = o.OverriddenMethod)
153public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
157return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
164public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
173public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
183public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
205public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
227private static bool HasDisposeMethodSignature(this IMethodSymbol method)
236public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
246public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
263private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
272private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
279private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
295private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
308private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
320public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
335this IMethodSymbol method,
388public static bool IsOnDeserializationImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDeserializationCallback)
408public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
414public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
424public static bool IsPropertyGetter(this IMethodSymbol method)
433public static bool IsIndexerGetter(this IMethodSymbol method)
442public static bool IsPropertyAccessor(this IMethodSymbol method)
451public static bool IsEventAccessor(this IMethodSymbol method)
458public static bool IsOperator(this IMethodSymbol methodSymbol)
463public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
468public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
470var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
473foreach (var member in methods)
503public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
524public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
533public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
545public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
606public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
615public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
624public static int GetParameterIndex(this IMethodSymbol methodSymbol, IParameterSymbol parameterSymbol)
643public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType)
653public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
663public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
675public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
689public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
698public static bool IsOverrideOrVirtualMethodOf([NotNullWhen(returnValue: true)] this IMethodSymbol? methodSymbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? typeSymbol)
722public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
731public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
745public static bool IsAutoPropertyAccessor(this IMethodSymbol methodSymbol)
753public static bool IsTopLevelStatementsEntryPointMethod([NotNullWhen(true)] this IMethodSymbol? methodSymbol)
761public static bool IsGetAwaiterFromAwaitablePattern([NotNullWhen(true)] this IMethodSymbol? method,
783[NotNullWhen(true)] this IMethodSymbol? method,
804public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
806ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
823.OfType<IMethodSymbol>()
src\RoslynAnalyzers\Utilities\Compiler\Extensions\ISymbolExtensions.cs (27)
27return symbol is IMethodSymbol accessorSymbol &&
31public static IEnumerable<IMethodSymbol> GetAccessors(this ISymbol symbol)
99return symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
104return (symbol as IMethodSymbol)?.IsFinalizer() ?? false;
158return symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator };
163return symbol is IMethodSymbol { MethodKind: MethodKind.Conversion };
170IMethodSymbol m => m.Parameters,
234public static bool MatchMethodDerivedByName([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol type, string name)
316public static bool HasOverloadWithParameterOfType(this IEnumerable<IMethodSymbol> overloads, IMethodSymbol self, INamedTypeSymbol type, CancellationToken cancellationToken)
318foreach (var overload in overloads)
339public static IEnumerable<int> GetParameterIndices(this IMethodSymbol method, IEnumerable<IParameterSymbol> parameters, CancellationToken cancellationToken)
356public static bool ParametersAreSame(this IMethodSymbol method1, IMethodSymbol method2)
377public static bool ParameterTypesAreSame(this IMethodSymbol method1, IMethodSymbol method2, IEnumerable<int> parameterIndices, CancellationToken cancellationToken)
412public static bool ReturnTypeAndParametersAreSame(this IMethodSymbol method, IMethodSymbol otherMethod)
428public static IMethodSymbol? GetMatchingOverload(this IMethodSymbol method, IEnumerable<IMethodSymbol> overloads, int parameterIndex, INamedTypeSymbol type, CancellationToken cancellationToken)
430foreach (IMethodSymbol overload in overloads)
553IMethodSymbol methodSymbol => methodSymbol.OverriddenMethod,
568if (symbol is IMethodSymbol methodSymbol && !methodSymbol.ExplicitInterfaceImplementations.IsEmpty)
606IMethodSymbol methodSymbol => methodSymbol.ReturnType,
774public static bool HasDerivedMethodAttribute(this IMethodSymbol symbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? attribute)
832=> (symbol as IMethodSymbol)?.IsLambdaOrLocalFunction() == true;
Microsoft.CodeAnalysis.Rebuild (3)
Microsoft.CodeAnalysis.ResxSourceGenerator (148)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IEnumerableOfIMethodSymbolExtensions.cs (25)
16/// <param name="methods">List of <see cref="IMethodSymbol"/> to filter.</param>
19public static IEnumerable<IMethodSymbol> WhereMethodDoesNotContainAttribute(
20this IEnumerable<IMethodSymbol> methods,
36/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
37/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
40public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtLeadingOrTrailing(
41this IEnumerable<IMethodSymbol> methods,
42IMethodSymbol selectedOverload,
93/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
94/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
96public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtTrailing(
97this IEnumerable<IMethodSymbol> methods,
98IMethodSymbol selectedOverload,
105/// Gets the <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>.
107/// <param name="members">The sequence of <see cref="IMethodSymbol"/>s to search.</param>
110/// The first <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>, or <langword>null</langword> if
113public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, params ITypeSymbol[] expectedParameterTypesInOrder)
139public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterInfos(this IEnumerable<IMethodSymbol>? members, params ParameterInfo[] expectedParameterTypesInOrder)
181/// Given an <see cref="IEnumerable{IMethodSymbol}"/>, returns the <see cref="IMethodSymbol"/> whose parameter list
190public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, IReadOnlyList<ITypeSymbol> expectedParameterTypesInOrder)
195foreach (var member in members)
203bool Predicate(IMethodSymbol member)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (66)
28public static bool IsObjectEqualsOverride(this IMethodSymbol method)
42public static bool IsObjectEquals(this IMethodSymbol method)
56public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
71public static bool IsGetHashCodeOverride(this IMethodSymbol method)
84public static bool IsToStringOverride(this IMethodSymbol method)
97private static bool IsObjectMethodOverride(IMethodSymbol method)
99IMethodSymbol overriddenMethod = method.OverriddenMethod;
116public static bool IsFinalizer(this IMethodSymbol method)
128IMethodSymbol overridden = method.OverriddenMethod;
141for (IMethodSymbol o = overridden.OverriddenMethod; o != null; o = o.OverriddenMethod)
153public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
157return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
164public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
173public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
183public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
205public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
227private static bool HasDisposeMethodSignature(this IMethodSymbol method)
236public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
246public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
263private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
272private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
279private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
295private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
308private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
320public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
335this IMethodSymbol method,
388public static bool IsOnDeserializationImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDeserializationCallback)
408public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
414public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
424public static bool IsPropertyGetter(this IMethodSymbol method)
433public static bool IsIndexerGetter(this IMethodSymbol method)
442public static bool IsPropertyAccessor(this IMethodSymbol method)
451public static bool IsEventAccessor(this IMethodSymbol method)
458public static bool IsOperator(this IMethodSymbol methodSymbol)
463public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
468public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
470var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
473foreach (var member in methods)
503public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
524public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
533public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
545public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
560private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
566public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
572IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
606public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
615public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
624public static int GetParameterIndex(this IMethodSymbol methodSymbol, IParameterSymbol parameterSymbol)
643public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType)
653public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
663public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
675public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
689public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
698public static bool IsOverrideOrVirtualMethodOf([NotNullWhen(returnValue: true)] this IMethodSymbol? methodSymbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? typeSymbol)
722public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
731public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
745public static bool IsAutoPropertyAccessor(this IMethodSymbol methodSymbol)
753public static bool IsTopLevelStatementsEntryPointMethod([NotNullWhen(true)] this IMethodSymbol? methodSymbol)
761public static bool IsGetAwaiterFromAwaitablePattern([NotNullWhen(true)] this IMethodSymbol? method,
783[NotNullWhen(true)] this IMethodSymbol? method,
804public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
806ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
823.OfType<IMethodSymbol>()
src\RoslynAnalyzers\Utilities\Compiler\Extensions\ISymbolExtensions.cs (28)
27return symbol is IMethodSymbol accessorSymbol &&
31public static IEnumerable<IMethodSymbol> GetAccessors(this ISymbol symbol)
99return symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
104return (symbol as IMethodSymbol)?.IsFinalizer() ?? false;
158return symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator };
163return symbol is IMethodSymbol { MethodKind: MethodKind.Conversion };
170IMethodSymbol m => m.Parameters,
234public static bool MatchMethodDerivedByName([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol type, string name)
316public static bool HasOverloadWithParameterOfType(this IEnumerable<IMethodSymbol> overloads, IMethodSymbol self, INamedTypeSymbol type, CancellationToken cancellationToken)
318foreach (var overload in overloads)
339public static IEnumerable<int> GetParameterIndices(this IMethodSymbol method, IEnumerable<IParameterSymbol> parameters, CancellationToken cancellationToken)
356public static bool ParametersAreSame(this IMethodSymbol method1, IMethodSymbol method2)
377public static bool ParameterTypesAreSame(this IMethodSymbol method1, IMethodSymbol method2, IEnumerable<int> parameterIndices, CancellationToken cancellationToken)
412public static bool ReturnTypeAndParametersAreSame(this IMethodSymbol method, IMethodSymbol otherMethod)
428public static IMethodSymbol? GetMatchingOverload(this IMethodSymbol method, IEnumerable<IMethodSymbol> overloads, int parameterIndex, INamedTypeSymbol type, CancellationToken cancellationToken)
430foreach (IMethodSymbol overload in overloads)
553IMethodSymbol methodSymbol => methodSymbol.OverriddenMethod,
568if (symbol is IMethodSymbol methodSymbol && !methodSymbol.ExplicitInterfaceImplementations.IsEmpty)
606IMethodSymbol methodSymbol => methodSymbol.ReturnType,
774public static bool HasDerivedMethodAttribute(this IMethodSymbol symbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? attribute)
832=> (symbol as IMethodSymbol)?.IsLambdaOrLocalFunction() == true;
861IMethodSymbol method => method.IsReadOnly,
Microsoft.CodeAnalysis.Scripting (2)
Microsoft.CodeAnalysis.Test.Utilities (29)
Microsoft.CodeAnalysis.VisualBasic (125)
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 (17)
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 (501)
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)
114SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
378symbol = ((IMethodSymbol)symbol).GetConstructedReducedFrom()!;
383newSymbol = ((IMethodSymbol)newSymbol).GetConstructedReducedFrom()!;
403if (symbol is IMethodSymbol methodSymbol && newSymbol is IMethodSymbol newMethodSymbol)
477if (symbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } methodSymbol &&
478newSymbol is IMethodSymbol { MethodKind: MethodKind.LocalFunction } newMethodSymbol)
779GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
780GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
807private bool ReplacementBreaksForEachGetEnumerator(IMethodSymbol getEnumerator, IMethodSymbol newGetEnumerator, TExpressionSyntax newForEachStatementExpression)
876=> 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)
38IMethodSymbol? addMethod = null,
39IMethodSymbol? removeMethod = null,
40IMethodSymbol? raiseMethod = null)
57IMethodSymbol? getMethod,
58IMethodSymbol? setMethod,
85ImmutableArray<IParameterSymbol> parameters, IMethodSymbol? getMethod, IMethodSymbol? setMethod,
124public static IMethodSymbol CreateConstructorSymbol(
143public static IMethodSymbol CreateDestructorSymbol(
152internal static IMethodSymbol CreateMethodSymbol(
159ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
177public static IMethodSymbol CreateMethodSymbol(
181ImmutableArray<IMethodSymbol> explicitInterfaceImplementations,
196public static IMethodSymbol CreateOperatorSymbol(
224public static IMethodSymbol CreateConversionSymbol(
249public static IMethodSymbol CreateConversionSymbol(
361internal static IMethodSymbol CreateAccessorSymbol(
362IMethodSymbol accessor,
365ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
387public static IMethodSymbol CreateAccessorSymbol(
475var invokeMethod = CreateMethodSymbol(
515internal static IMethodSymbol CreateMethodSymbol(
516IMethodSymbol method,
520ImmutableArray<IMethodSymbol> explicitInterfaceImplementations = default,
554IMethodSymbol? getMethod = null,
555IMethodSymbol? setMethod = null,
580IMethodSymbol? addMethod = null,
581IMethodSymbol? removeMethod = null)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (13)
104protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync)
116if (impl is IMethodSymbol implMethod)
134.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnType: var returnType, Parameters.Length: 0 } &&
135SymbolEqualityComparer.Default.Equals(returnType, valueTaskType)) is IMethodSymbol disposeMethodFromPattern)
150.FirstOrDefault(m => m is IMethodSymbol { DeclaredAccessibility: Accessibility.Public, ReturnsVoid: true, Parameters.Length: 0 }) is IMethodSymbol disposeMethodFromPattern)
163(INamedTypeSymbol?, IMethodSymbol?) GetIDisposableInterfaceAndDisposeMethod(string typeName, string methodName)
166return (disposableType, disposableType?.GetMembers().OfType<IMethodSymbol>().FirstOrDefault(m => m.Parameters.Length == 0 && m.Name == methodName));
216public IMethodSymbol GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
219public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
222public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
249public ImmutableArray<IMethodSymbol> GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken)
261public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol primaryConstructor)
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 (7)
Microsoft.Extensions.Options.SourceGeneration (2)
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 (29)
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 (33)
Microsoft.VisualStudio.LanguageServices.CSharp (19)
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 (176)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IEnumerableOfIMethodSymbolExtensions.cs (25)
16/// <param name="methods">List of <see cref="IMethodSymbol"/> to filter.</param>
19public static IEnumerable<IMethodSymbol> WhereMethodDoesNotContainAttribute(
20this IEnumerable<IMethodSymbol> methods,
36/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
37/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
40public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtLeadingOrTrailing(
41this IEnumerable<IMethodSymbol> methods,
42IMethodSymbol selectedOverload,
93/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
94/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
96public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtTrailing(
97this IEnumerable<IMethodSymbol> methods,
98IMethodSymbol selectedOverload,
105/// Gets the <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>.
107/// <param name="members">The sequence of <see cref="IMethodSymbol"/>s to search.</param>
110/// The first <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>, or <langword>null</langword> if
113public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, params ITypeSymbol[] expectedParameterTypesInOrder)
139public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterInfos(this IEnumerable<IMethodSymbol>? members, params ParameterInfo[] expectedParameterTypesInOrder)
181/// Given an <see cref="IEnumerable{IMethodSymbol}"/>, returns the <see cref="IMethodSymbol"/> whose parameter list
190public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, IReadOnlyList<ITypeSymbol> expectedParameterTypesInOrder)
195foreach (var member in members)
203bool Predicate(IMethodSymbol member)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (66)
28public static bool IsObjectEqualsOverride(this IMethodSymbol method)
42public static bool IsObjectEquals(this IMethodSymbol method)
56public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
71public static bool IsGetHashCodeOverride(this IMethodSymbol method)
84public static bool IsToStringOverride(this IMethodSymbol method)
97private static bool IsObjectMethodOverride(IMethodSymbol method)
99IMethodSymbol overriddenMethod = method.OverriddenMethod;
116public static bool IsFinalizer(this IMethodSymbol method)
128IMethodSymbol overridden = method.OverriddenMethod;
141for (IMethodSymbol o = overridden.OverriddenMethod; o != null; o = o.OverriddenMethod)
153public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
157return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
164public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
173public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
183public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
205public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
227private static bool HasDisposeMethodSignature(this IMethodSymbol method)
236public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
246public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
263private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
272private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
279private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
295private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
308private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
320public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
335this IMethodSymbol method,
388public static bool IsOnDeserializationImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDeserializationCallback)
408public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
414public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
424public static bool IsPropertyGetter(this IMethodSymbol method)
433public static bool IsIndexerGetter(this IMethodSymbol method)
442public static bool IsPropertyAccessor(this IMethodSymbol method)
451public static bool IsEventAccessor(this IMethodSymbol method)
458public static bool IsOperator(this IMethodSymbol methodSymbol)
463public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
468public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
470var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
473foreach (var member in methods)
503public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
524public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
533public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
545public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
560private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
566public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
572IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
606public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
615public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
624public static int GetParameterIndex(this IMethodSymbol methodSymbol, IParameterSymbol parameterSymbol)
643public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType)
653public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
663public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
675public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
689public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
698public static bool IsOverrideOrVirtualMethodOf([NotNullWhen(returnValue: true)] this IMethodSymbol? methodSymbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? typeSymbol)
722public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
731public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
745public static bool IsAutoPropertyAccessor(this IMethodSymbol methodSymbol)
753public static bool IsTopLevelStatementsEntryPointMethod([NotNullWhen(true)] this IMethodSymbol? methodSymbol)
761public static bool IsGetAwaiterFromAwaitablePattern([NotNullWhen(true)] this IMethodSymbol? method,
783[NotNullWhen(true)] this IMethodSymbol? method,
804public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
806ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
823.OfType<IMethodSymbol>()
src\RoslynAnalyzers\Utilities\Compiler\Extensions\ISymbolExtensions.cs (28)
27return symbol is IMethodSymbol accessorSymbol &&
31public static IEnumerable<IMethodSymbol> GetAccessors(this ISymbol symbol)
99return symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
104return (symbol as IMethodSymbol)?.IsFinalizer() ?? false;
158return symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator };
163return symbol is IMethodSymbol { MethodKind: MethodKind.Conversion };
170IMethodSymbol m => m.Parameters,
234public static bool MatchMethodDerivedByName([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol type, string name)
316public static bool HasOverloadWithParameterOfType(this IEnumerable<IMethodSymbol> overloads, IMethodSymbol self, INamedTypeSymbol type, CancellationToken cancellationToken)
318foreach (var overload in overloads)
339public static IEnumerable<int> GetParameterIndices(this IMethodSymbol method, IEnumerable<IParameterSymbol> parameters, CancellationToken cancellationToken)
356public static bool ParametersAreSame(this IMethodSymbol method1, IMethodSymbol method2)
377public static bool ParameterTypesAreSame(this IMethodSymbol method1, IMethodSymbol method2, IEnumerable<int> parameterIndices, CancellationToken cancellationToken)
412public static bool ReturnTypeAndParametersAreSame(this IMethodSymbol method, IMethodSymbol otherMethod)
428public static IMethodSymbol? GetMatchingOverload(this IMethodSymbol method, IEnumerable<IMethodSymbol> overloads, int parameterIndex, INamedTypeSymbol type, CancellationToken cancellationToken)
430foreach (IMethodSymbol overload in overloads)
553IMethodSymbol methodSymbol => methodSymbol.OverriddenMethod,
568if (symbol is IMethodSymbol methodSymbol && !methodSymbol.ExplicitInterfaceImplementations.IsEmpty)
606IMethodSymbol methodSymbol => methodSymbol.ReturnType,
774public static bool HasDerivedMethodAttribute(this IMethodSymbol symbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? attribute)
832=> (symbol as IMethodSymbol)?.IsLambdaOrLocalFunction() == true;
861IMethodSymbol method => method.IsReadOnly,
Roslyn.Diagnostics.Analyzers.UnitTests (2)
Roslyn.Diagnostics.CSharp.Analyzers (7)
Roslyn.Diagnostics.VisualBasic.Analyzers (5)
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 (139)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IEnumerableOfIMethodSymbolExtensions.cs (25)
16/// <param name="methods">List of <see cref="IMethodSymbol"/> to filter.</param>
19public static IEnumerable<IMethodSymbol> WhereMethodDoesNotContainAttribute(
20this IEnumerable<IMethodSymbol> methods,
36/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
37/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
40public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtLeadingOrTrailing(
41this IEnumerable<IMethodSymbol> methods,
42IMethodSymbol selectedOverload,
93/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
94/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
96public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtTrailing(
97this IEnumerable<IMethodSymbol> methods,
98IMethodSymbol selectedOverload,
105/// Gets the <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>.
107/// <param name="members">The sequence of <see cref="IMethodSymbol"/>s to search.</param>
110/// The first <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>, or <langword>null</langword> if
113public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, params ITypeSymbol[] expectedParameterTypesInOrder)
139public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterInfos(this IEnumerable<IMethodSymbol>? members, params ParameterInfo[] expectedParameterTypesInOrder)
181/// Given an <see cref="IEnumerable{IMethodSymbol}"/>, returns the <see cref="IMethodSymbol"/> whose parameter list
190public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, IReadOnlyList<ITypeSymbol> expectedParameterTypesInOrder)
195foreach (var member in members)
203bool Predicate(IMethodSymbol member)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (66)
28public static bool IsObjectEqualsOverride(this IMethodSymbol method)
42public static bool IsObjectEquals(this IMethodSymbol method)
56public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
71public static bool IsGetHashCodeOverride(this IMethodSymbol method)
84public static bool IsToStringOverride(this IMethodSymbol method)
97private static bool IsObjectMethodOverride(IMethodSymbol method)
99IMethodSymbol overriddenMethod = method.OverriddenMethod;
116public static bool IsFinalizer(this IMethodSymbol method)
128IMethodSymbol overridden = method.OverriddenMethod;
141for (IMethodSymbol o = overridden.OverriddenMethod; o != null; o = o.OverriddenMethod)
153public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
157return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
164public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
173public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
183public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
205public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
227private static bool HasDisposeMethodSignature(this IMethodSymbol method)
236public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
246public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
263private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
272private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
279private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
295private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
308private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
320public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
335this IMethodSymbol method,
388public static bool IsOnDeserializationImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDeserializationCallback)
408public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
414public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
424public static bool IsPropertyGetter(this IMethodSymbol method)
433public static bool IsIndexerGetter(this IMethodSymbol method)
442public static bool IsPropertyAccessor(this IMethodSymbol method)
451public static bool IsEventAccessor(this IMethodSymbol method)
458public static bool IsOperator(this IMethodSymbol methodSymbol)
463public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
468public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
470var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
473foreach (var member in methods)
503public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
524public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
533public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
545public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
560private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
566public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
572IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
606public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
615public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
624public static int GetParameterIndex(this IMethodSymbol methodSymbol, IParameterSymbol parameterSymbol)
643public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType)
653public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
663public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
675public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
689public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
698public static bool IsOverrideOrVirtualMethodOf([NotNullWhen(returnValue: true)] this IMethodSymbol? methodSymbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? typeSymbol)
722public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
731public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
745public static bool IsAutoPropertyAccessor(this IMethodSymbol methodSymbol)
753public static bool IsTopLevelStatementsEntryPointMethod([NotNullWhen(true)] this IMethodSymbol? methodSymbol)
761public static bool IsGetAwaiterFromAwaitablePattern([NotNullWhen(true)] this IMethodSymbol? method,
783[NotNullWhen(true)] this IMethodSymbol? method,
804public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
806ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
823.OfType<IMethodSymbol>()
src\RoslynAnalyzers\Utilities\Compiler\Extensions\ISymbolExtensions.cs (28)
27return symbol is IMethodSymbol accessorSymbol &&
31public static IEnumerable<IMethodSymbol> GetAccessors(this ISymbol symbol)
99return symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
104return (symbol as IMethodSymbol)?.IsFinalizer() ?? false;
158return symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator };
163return symbol is IMethodSymbol { MethodKind: MethodKind.Conversion };
170IMethodSymbol m => m.Parameters,
234public static bool MatchMethodDerivedByName([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol type, string name)
316public static bool HasOverloadWithParameterOfType(this IEnumerable<IMethodSymbol> overloads, IMethodSymbol self, INamedTypeSymbol type, CancellationToken cancellationToken)
318foreach (var overload in overloads)
339public static IEnumerable<int> GetParameterIndices(this IMethodSymbol method, IEnumerable<IParameterSymbol> parameters, CancellationToken cancellationToken)
356public static bool ParametersAreSame(this IMethodSymbol method1, IMethodSymbol method2)
377public static bool ParameterTypesAreSame(this IMethodSymbol method1, IMethodSymbol method2, IEnumerable<int> parameterIndices, CancellationToken cancellationToken)
412public static bool ReturnTypeAndParametersAreSame(this IMethodSymbol method, IMethodSymbol otherMethod)
428public static IMethodSymbol? GetMatchingOverload(this IMethodSymbol method, IEnumerable<IMethodSymbol> overloads, int parameterIndex, INamedTypeSymbol type, CancellationToken cancellationToken)
430foreach (IMethodSymbol overload in overloads)
553IMethodSymbol methodSymbol => methodSymbol.OverriddenMethod,
568if (symbol is IMethodSymbol methodSymbol && !methodSymbol.ExplicitInterfaceImplementations.IsEmpty)
606IMethodSymbol methodSymbol => methodSymbol.ReturnType,
774public static bool HasDerivedMethodAttribute(this IMethodSymbol symbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? attribute)
832=> (symbol as IMethodSymbol)?.IsLambdaOrLocalFunction() == true;
861IMethodSymbol method => method.IsReadOnly,
Text.Analyzers (152)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IEnumerableOfIMethodSymbolExtensions.cs (25)
16/// <param name="methods">List of <see cref="IMethodSymbol"/> to filter.</param>
19public static IEnumerable<IMethodSymbol> WhereMethodDoesNotContainAttribute(
20this IEnumerable<IMethodSymbol> methods,
36/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
37/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
40public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtLeadingOrTrailing(
41this IEnumerable<IMethodSymbol> methods,
42IMethodSymbol selectedOverload,
93/// <param name="methods">List of <see cref="IMethodSymbol"/> to scan for possible overloads</param>
94/// <param name="selectedOverload"><see cref="IMethodSymbol"/> that is currently picked by the user</param>
96public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtTrailing(
97this IEnumerable<IMethodSymbol> methods,
98IMethodSymbol selectedOverload,
105/// Gets the <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>.
107/// <param name="members">The sequence of <see cref="IMethodSymbol"/>s to search.</param>
110/// The first <see cref="IMethodSymbol"/> in the sequence who's parameters match <paramref name="expectedParameterTypesInOrder"/>, or <langword>null</langword> if
113public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, params ITypeSymbol[] expectedParameterTypesInOrder)
139public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterInfos(this IEnumerable<IMethodSymbol>? members, params ParameterInfo[] expectedParameterTypesInOrder)
181/// Given an <see cref="IEnumerable{IMethodSymbol}"/>, returns the <see cref="IMethodSymbol"/> whose parameter list
190public static IMethodSymbol? GetFirstOrDefaultMemberWithParameterTypes(this IEnumerable<IMethodSymbol>? members, IReadOnlyList<ITypeSymbol> expectedParameterTypesInOrder)
195foreach (var member in members)
203bool Predicate(IMethodSymbol member)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IMethodSymbolExtensions.cs (66)
28public static bool IsObjectEqualsOverride(this IMethodSymbol method)
42public static bool IsObjectEquals(this IMethodSymbol method)
56public static bool IsStaticObjectEqualsOrReferenceEquals(this IMethodSymbol method)
71public static bool IsGetHashCodeOverride(this IMethodSymbol method)
84public static bool IsToStringOverride(this IMethodSymbol method)
97private static bool IsObjectMethodOverride(IMethodSymbol method)
99IMethodSymbol overriddenMethod = method.OverriddenMethod;
116public static bool IsFinalizer(this IMethodSymbol method)
128IMethodSymbol overridden = method.OverriddenMethod;
141for (IMethodSymbol o = overridden.OverriddenMethod; o != null; o = o.OverriddenMethod)
153public static bool IsImplementationOfInterfaceMethod(this IMethodSymbol method, ITypeSymbol? typeArgument, [NotNullWhen(returnValue: true)] INamedTypeSymbol? interfaceType, string interfaceMethodName)
157return constructedInterface?.GetMembers(interfaceMethodName).FirstOrDefault() is IMethodSymbol interfaceMethod &&
164public static bool IsDisposeImplementation(this IMethodSymbol method, Compilation compilation)
173public static bool IsAsyncDisposeImplementation(this IMethodSymbol method, Compilation compilation)
183public static bool IsDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDisposable)
205public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iAsyncDisposable, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTaskType)
227private static bool HasDisposeMethodSignature(this IMethodSymbol method)
236public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
246public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
263private static bool HasDisposeCloseMethodSignature(this IMethodSymbol method)
272private static bool HasDisposeCloseAsyncMethodSignature(this IMethodSymbol method, INamedTypeSymbol? taskType)
279private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
295private static bool HasOverriddenDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? task)
308private static bool HasVirtualOrOverrideDisposeCoreAsyncMethodSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? valueTask)
320public static DisposeMethodKind GetDisposeMethodKind(this IMethodSymbol method, Compilation compilation)
335this IMethodSymbol method,
388public static bool IsOnDeserializationImplementation([NotNullWhen(returnValue: true)] this IMethodSymbol? method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? iDeserializationCallback)
408public static bool IsSerializationConstructor([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
414public static bool IsGetObjectData([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol? serializationInfoType, INamedTypeSymbol? streamingContextType)
424public static bool IsPropertyGetter(this IMethodSymbol method)
433public static bool IsIndexerGetter(this IMethodSymbol method)
442public static bool IsPropertyAccessor(this IMethodSymbol method)
451public static bool IsEventAccessor(this IMethodSymbol method)
458public static bool IsOperator(this IMethodSymbol methodSymbol)
463public static bool HasOptionalParameters(this IMethodSymbol methodSymbol)
468public static IEnumerable<IMethodSymbol> GetOverloads(this IMethodSymbol? method)
470var methods = method?.ContainingType?.GetMembers(method.Name).OfType<IMethodSymbol>();
473foreach (var member in methods)
503public static bool IsCollectionAddMethod(this IMethodSymbol method, ImmutableHashSet<INamedTypeSymbol> iCollectionTypes)
524public static bool IsTaskFromResultMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskType)
533public static bool IsTaskConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? genericTaskType)
545public static bool IsAsyncDisposableConfigureAwaitMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? asyncDisposableType, [NotNullWhen(returnValue: true)] INamedTypeSymbol? taskAsyncEnumerableExtensions)
560private static readonly BoundedCache<Compilation, ConcurrentDictionary<IMethodSymbol, IBlockOperation?>> s_methodToTopmostOperationBlockCache
566public static IBlockOperation? GetTopmostOperationBlock(this IMethodSymbol method, Compilation compilation, CancellationToken cancellationToken = default)
572IBlockOperation? ComputeTopmostOperationBlock(IMethodSymbol unused)
606public static bool IsLambdaOrLocalFunctionOrDelegate(this IMethodSymbol method)
615public static bool IsLambdaOrLocalFunction(this IMethodSymbol method)
624public static int GetParameterIndex(this IMethodSymbol methodSymbol, IParameterSymbol parameterSymbol)
643public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType)
653public static bool IsLockMethod(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? systemThreadingMonitor)
663public static bool IsInterlockedExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
675public static bool IsInterlockedCompareExchangeMethod(this IMethodSymbol method, INamedTypeSymbol? systemThreadingInterlocked)
689public static bool HasParameterWithDelegateType(this IMethodSymbol methodSymbol)
698public static bool IsOverrideOrVirtualMethodOf([NotNullWhen(returnValue: true)] this IMethodSymbol? methodSymbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? typeSymbol)
722public static bool IsArgumentNullCheckMethod(this IMethodSymbol method)
731public static bool IsBenchmarkOrXUnitTestMethod(this IMethodSymbol method, ConcurrentDictionary<INamedTypeSymbol, bool> knownTestAttributes, INamedTypeSymbol? benchmarkAttribute, INamedTypeSymbol? xunitFactAttribute)
745public static bool IsAutoPropertyAccessor(this IMethodSymbol methodSymbol)
753public static bool IsTopLevelStatementsEntryPointMethod([NotNullWhen(true)] this IMethodSymbol? methodSymbol)
761public static bool IsGetAwaiterFromAwaitablePattern([NotNullWhen(true)] this IMethodSymbol? method,
783[NotNullWhen(true)] this IMethodSymbol? method,
804public static ImmutableArray<IMethodSymbol> GetOriginalDefinitions(this IMethodSymbol methodSymbol)
806ImmutableArray<IMethodSymbol>.Builder originalDefinitionsBuilder = ImmutableArray.CreateBuilder<IMethodSymbol>();
823.OfType<IMethodSymbol>()
src\RoslynAnalyzers\Utilities\Compiler\Extensions\ISymbolExtensions.cs (28)
27return symbol is IMethodSymbol accessorSymbol &&
31public static IEnumerable<IMethodSymbol> GetAccessors(this ISymbol symbol)
99return symbol is IMethodSymbol { MethodKind: MethodKind.Constructor };
104return (symbol as IMethodSymbol)?.IsFinalizer() ?? false;
158return symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator };
163return symbol is IMethodSymbol { MethodKind: MethodKind.Conversion };
170IMethodSymbol m => m.Parameters,
234public static bool MatchMethodDerivedByName([NotNullWhen(returnValue: true)] this IMethodSymbol? method, INamedTypeSymbol type, string name)
316public static bool HasOverloadWithParameterOfType(this IEnumerable<IMethodSymbol> overloads, IMethodSymbol self, INamedTypeSymbol type, CancellationToken cancellationToken)
318foreach (var overload in overloads)
339public static IEnumerable<int> GetParameterIndices(this IMethodSymbol method, IEnumerable<IParameterSymbol> parameters, CancellationToken cancellationToken)
356public static bool ParametersAreSame(this IMethodSymbol method1, IMethodSymbol method2)
377public static bool ParameterTypesAreSame(this IMethodSymbol method1, IMethodSymbol method2, IEnumerable<int> parameterIndices, CancellationToken cancellationToken)
412public static bool ReturnTypeAndParametersAreSame(this IMethodSymbol method, IMethodSymbol otherMethod)
428public static IMethodSymbol? GetMatchingOverload(this IMethodSymbol method, IEnumerable<IMethodSymbol> overloads, int parameterIndex, INamedTypeSymbol type, CancellationToken cancellationToken)
430foreach (IMethodSymbol overload in overloads)
553IMethodSymbol methodSymbol => methodSymbol.OverriddenMethod,
568if (symbol is IMethodSymbol methodSymbol && !methodSymbol.ExplicitInterfaceImplementations.IsEmpty)
606IMethodSymbol methodSymbol => methodSymbol.ReturnType,
774public static bool HasDerivedMethodAttribute(this IMethodSymbol symbol, [NotNullWhen(returnValue: true)] INamedTypeSymbol? attribute)
832=> (symbol as IMethodSymbol)?.IsLambdaOrLocalFunction() == true;
861IMethodSymbol method => method.IsReadOnly,