My Goal: Create a C# class for predefined errors that have both an ID and a Message. Here was what I tried:
public class MyError
{
public static readonly
The type is not mutable. The Code Analysis gets confused by having public readonly fields.
You can fix the code analysis issue by making your public fields public properties:
public MyError(int id, string message)
{
this.id = id;
this.message = message;
}
private readonly int id;
private readonly string message;
public int Id { get { return id; } }
public string Message { get { return message; } }