Search code examples
c#attributeshardcoded

Coding conventions and standards


Can anyone tell if the values written in attributes are considered as hardcoded values.

For example customerId written in JsonProperty

{
        [JsonProperty("customerId")]
        public int CustomerId { get; set; }

        [JsonProperty("name")]
        public string Name { get; set; }

        [JsonProperty("phoneNumber")]
        public long PhoneNumber { get; set; }
}

Solution

  • If they are in an attribute, they need to be constants and cannot be variables. I have not come across any coding guide that has said this should be avoided.