79733028

Date: 2025-08-12 10:41:56
Score: 1.5
Natty:
Report link

I'm seeing this only when the JsonProperty("xxx") attribute is unnecessary because, as @Alexander Petrov points out, the variable name matches the "xxx" in case too. It's a bit of a false message. It should say that it's unnecessary because the name of the variable matches the "xxx" part.

Its misleading tough. If a developer follows the warning's advice and someone else changes the name of the variable in the future (for whatever reason that doesn't matter at all), then the class/record will no longer process the JSON correctly.

Also, it looks strange to any future developer who sees that 99 out of 100 of the variables have the JsonProperty attribute.

I always favor defensive programming. I always thing of what the next person to work on my code will have to deal with.

Ironically, if you choose to suppress it, you get a new message for unnecessary suppression.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • User mentioned (1): @Alexander
  • Low reputation (0.5):
Posted by: Andrew