Exemplo n.º 1
0
        // TODO: Remove the below suppression once the following Roslyn bug is fixed: https://github.com/dotnet/roslyn/issues/8884
#pragma warning disable CA1801
        private static List <MethodCategory> GetMethodCategories(Compilation compilation)
#pragma warning disable CA1801
        {
            var methodCategories = new List <MethodCategory> {
                new MethodCategory(IsPropertyGetter, true,
                                   PropertyGetterRule,
                                   WellKnownTypes.InvalidOperationException(compilation), WellKnownTypes.NotSupportedException(compilation)),

                new MethodCategory(IsIndexerGetter, true,
                                   PropertyGetterRule,
                                   WellKnownTypes.InvalidOperationException(compilation), WellKnownTypes.NotSupportedException(compilation),
                                   WellKnownTypes.ArgumentException(compilation), WellKnownTypes.KeyNotFoundException(compilation)),

                new MethodCategory(IsEventAccessor, true,
                                   HasAllowedExceptionsRule,
                                   WellKnownTypes.InvalidOperationException(compilation), WellKnownTypes.NotSupportedException(compilation),
                                   WellKnownTypes.ArgumentException(compilation)),

                new MethodCategory(IsGetHashCodeInterfaceImplementation, true,
                                   HasAllowedExceptionsRule,
                                   WellKnownTypes.ArgumentException(compilation)),

                new MethodCategory(IsEqualsOverrideOrInterfaceImplementation, true,
                                   NoAllowedExceptionsRule),

                new MethodCategory(IsEqualityOperator, true,
                                   NoAllowedExceptionsRule),

                new MethodCategory(IsGetHashCodeOverride, true,
                                   NoAllowedExceptionsRule),

                new MethodCategory(IsToString, true,
                                   NoAllowedExceptionsRule),

                new MethodCategory(IsImplicitCastOperator, true,
                                   NoAllowedExceptionsRule),

                new MethodCategory(IsStaticConstructor, false,
                                   NoAllowedExceptionsRule),

                new MethodCategory(IsFinalizer, false,
                                   NoAllowedExceptionsRule),

                new MethodCategory(IMethodSymbolExtensions.IsDisposeImplementation, true,
                                   NoAllowedExceptionsRule),
            };

            return(methodCategories);
        }