S109 - magic numbers on attributes

We are using a lot of numbers in data transfer object attributes, so in each file we have to suppress this warning.
Currently C# does not support using variables in attributes, so there’s no way to avoid magic numbers from being used in attributes:

        [Properties(ModelMap: "key", Order: 10)]
        public int? PrimaryKey { get; set; }

hi @donatasj87

in this case, it looks like it would be easier to disable the rule for your project

I don’t want to disable it for all project, because it is quite useful rule in other parts of the project, so I end up disabling it on each file. Would be nice if sonar could detect it and ignore automatically.

No, but it can still use constants

    [MyCustom(AttributeUsage.MAGIC)]
    public class AttributeUsage
    {
        private const int MAGIC = 10;
        [MyCustom(MAGIC)]
        public int? Foo { get; set; }

    }

    class MyCustomAttribute : Attribute
    {
        public int ParamValue { get; set; }
        public MyCustomAttribute(int paramValue)
        {
            this.ParamValue = paramValue;
        }
    }

Correct. It is useful for static and reusable values, but in some cases each properties have different values, like ordering for example, so in this case creating constant for each one would be a waste of keystrokes.