I have a bit of a peculiar problem at work: In this project all of the ErrorCodes are defined in the code base. They look somewhat like this:
public readonly ErrorMessageCode 00001 = new ErrorMessageCode()
{
MessageKey = "00001",
Title = "Error!",
Message = "You did something wrong!"
};
There’s hunderds of those, spread along a couple different classes in even different projects. The thing is: One MessageKey must not be used twice! (Because that’s the primary key they get in the database…)
So I’d like to add an AnalyzerRule that checks whether MessageKeys are unique. I’ve so far never written an AnalyzerRule, so I’m not really sure if that’s even possible. We do already have a few custom AnalyzerRules in place, but that’s more about using dependencies that are not allowed.