[Serializable]
public struct Foo
{
public string Info { get; }
}
[Serializable]
public class ExceptionA : Exception
{
public IEnumerable<Foo> Foos { get { return _foos; } }
private List<Foo> _foos;
}
The C# compiler will complain that "Field _foos is a member of type ExceptionA which is serializable but is of type System.Collection.Generic.List which is not serializable"
How can I solve it? (Don't suppress CA2235, don't mark it as [NonSerialized])