#pragma warning disable RS1012 // Start action has no registered actions. private static bool ShouldAnalyzeMethod( IMethodSymbol method, OperationBlockStartAnalysisContext startOperationBlockContext, INamedTypeSymbol?eventsArgSymbol, ImmutableHashSet <INamedTypeSymbol?> attributeSetForMethodsToIgnore, INamedTypeSymbol?serializationInfoType, INamedTypeSymbol?streamingContextType) #pragma warning restore RS1012 // Start action has no registered actions. { // We only care about methods with parameters. if (method.Parameters.IsEmpty) { return(false); } // Ignore implicitly declared methods, extern methods, abstract methods, virtual methods, interface implementations and finalizers (FxCop compat). if (method.IsImplicitlyDeclared || method.IsExtern || method.IsAbstract || method.IsVirtual || method.IsOverride || method.IsImplementationOfAnyInterfaceMember() || method.IsFinalizer()) { return(false); } // Ignore property accessors. if (method.IsPropertyAccessor()) { return(false); } // Ignore serialization special methods if (method.IsSerializationConstructor(serializationInfoType, streamingContextType) || method.IsGetObjectData(serializationInfoType, streamingContextType)) { return(false); } // Ignore event handler methods "Handler(object, MyEventArgs)" if (method.HasEventHandlerSignature(eventsArgSymbol)) { return(false); } // Ignore methods with any attributes in 'attributeSetForMethodsToIgnore'. if (method.GetAttributes().Any(a => a.AttributeClass != null && attributeSetForMethodsToIgnore.Contains(a.AttributeClass))) { return(false); } // Bail out if user has configured to skip analysis for the method. if (!method.MatchesConfiguredVisibility( startOperationBlockContext.Options, Rule, startOperationBlockContext.Compilation, startOperationBlockContext.CancellationToken, defaultRequiredVisibility: SymbolVisibilityGroup.All)) { return(false); } // Check to see if the method just throws a NotImplementedException/NotSupportedException // We shouldn't warn about parameters in that case if (startOperationBlockContext.IsMethodNotImplementedOrSupported()) { return(false); } return(true); }
#pragma warning disable RS1012 // Start action has no registered actions. private static bool ShouldAnalyzeMethod( IMethodSymbol method, OperationBlockStartAnalysisContext startOperationBlockContext, INamedTypeSymbol?eventsArgSymbol, ImmutableHashSet <INamedTypeSymbol?> attributeSetForMethodsToIgnore) #pragma warning restore RS1012 // Start action has no registered actions. { // We only care about methods with parameters. if (method.Parameters.IsEmpty) { return(false); } // Ignore implicitly declared methods, extern methods, abstract methods, virtual methods, interface implementations and finalizers (FxCop compat). if (method.IsImplicitlyDeclared || method.IsExtern || method.IsAbstract || method.IsVirtual || method.IsOverride || method.IsImplementationOfAnyInterfaceMember() || method.IsFinalizer()) { return(false); } // Ignore property accessors. if (method.IsPropertyAccessor()) { return(false); } // Ignore event handler methods "Handler(object, MyEventArgs)" if (method.Parameters.Length == 2 && method.Parameters[0].Type.SpecialType == SpecialType.System_Object && // UWP has specific EventArgs not inheriting from System.EventArgs. It was decided to go for a suffix match rather than a whitelist. (method.Parameters[1].Type.Inherits(eventsArgSymbol) || method.Parameters[1].Type.Name.EndsWith("EventArgs", StringComparison.Ordinal))) { return(false); } // Ignore methods with any attributes in 'attributeSetForMethodsToIgnore'. if (method.GetAttributes().Any(a => a.AttributeClass != null && attributeSetForMethodsToIgnore.Contains(a.AttributeClass))) { return(false); } // Bail out if user has configured to skip analysis for the method. if (!method.MatchesConfiguredVisibility( startOperationBlockContext.Options, Rule, startOperationBlockContext.CancellationToken, defaultRequiredVisibility: SymbolVisibilityGroup.All)) { return(false); } // Check to see if the method just throws a NotImplementedException/NotSupportedException // We shouldn't warn about parameters in that case if (startOperationBlockContext.IsMethodNotImplementedOrSupported()) { return(false); } return(true); }