You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[MemoryPackable]
class A
{
[MemoryPackInclude]
public string SomeProperty { get; private set; }
}
When generating code for such class, MemoryPack will silently skip setting SomeProperty (but will generate code to write/read it), because it doesn't have accessible setter (because it will be unable to properly generate code for SET label, but since this is not a readonly field, it doesn't get passed to constructor, so both paths fail). This leads to many hours of debugging, because if you're adding attributes to existing fields, private, or omitted setters are easy to miss (doubly so, if you're doing it using some kind of automation in a big project).
I propose extending the check for readonly fields to properties that are marked with [MemoryPackInclude] attribute, because it explicitly tells the generator I want this property serialized. If it is absent, and the field is public, the situation becomes less clear, but maybe a warning would appropriate, too?
The text was updated successfully, but these errors were encountered:
When generating code for such class, MemoryPack will silently skip setting SomeProperty (but will generate code to write/read it), because it doesn't have accessible setter (because it will be unable to properly generate code for SET label, but since this is not a readonly field, it doesn't get passed to constructor, so both paths fail). This leads to many hours of debugging, because if you're adding attributes to existing fields, private, or omitted setters are easy to miss (doubly so, if you're doing it using some kind of automation in a big project).
I propose extending the check for readonly fields to properties that are marked with [MemoryPackInclude] attribute, because it explicitly tells the generator I want this property serialized. If it is absent, and the field is public, the situation becomes less clear, but maybe a warning would appropriate, too?
The text was updated successfully, but these errors were encountered: