private static AttributeTargets GetDeclarationType()

in resharper/resharper-unity/src/Unity/CSharp/Daemon/Stages/Analysis/RedundantAttributeOnTargetProblemAnalyzer.cs [72:101]


        private static AttributeTargets GetDeclarationType(IAttribute attribute, ITreeNode declaration)
        {
            switch (declaration)
            {
                case IMultipleEventDeclaration _:
                    return attribute.Target == AttributeTarget.Field ? AttributeTargets.Field : AttributeTargets.Event;
                case IMultipleFieldDeclaration _: return AttributeTargets.Field;
                case IMultipleConstantDeclaration _: return AttributeTargets.Field;
                case IClassDeclaration _: return AttributeTargets.Class;
                case IStructDeclaration _: return AttributeTargets.Struct;
                case IEnumDeclaration _: return AttributeTargets.Enum;
                case IConstructorDeclaration _: return AttributeTargets.Constructor;
                case IDelegateDeclaration _: return AttributeTargets.Delegate;
                case IMethodDeclaration _:
                    return attribute.Target == AttributeTarget.Return
                        ? AttributeTargets.ReturnValue
                        : AttributeTargets.Method;
                case IPropertyDeclaration _:
                    return attribute.Target == AttributeTarget.Field
                        ? AttributeTargets.Field
                        : AttributeTargets.Property;
                case IFieldDeclaration _: return AttributeTargets.Field;
                case IEventDeclaration _: return AttributeTargets.Event;
                case IInterfaceDeclaration _: return AttributeTargets.Interface;
                case IParameterDeclaration _: return AttributeTargets.Parameter;
                case ITypeParameterDeclaration _: return AttributeTargets.GenericParameter;
            }

            return AttributeTargets.Assembly;
        }