Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "Metastate" Interface for BOs to Implement to Simplify Serialization #4263

Open
JasonBock opened this issue Oct 18, 2024 · 0 comments
Open

Comments

@JasonBock
Copy link
Contributor

JasonBock commented Oct 18, 2024

Is your feature request related to a problem? Please describe.
Right now, a serialization author needs to know inaccessible information about a BO to read/write it correctly via a serialization.

Describe the solution you'd like
I'm currently working on a source generator-based serializer for CSLA (https://github.com/JasonBock/CslaGeneratorSerialization). Recently, I updated to a preview version of CSLA (9.0.0-R24070301), and....something changed internally on a BO (BusinessBase<> I believe) such that it completely broke my Reflection-based code. I'd rather not write that code, but it's essential to properly handle serialization of BO types correctly. Really, what should happen is that a BO should know how to read/write its' own metastate, and a serialization author could then ask a BO to read/write its' state without having to worry about private field names and whatnot.

Therefore, I propose that CSLA adds an interface (I'll call it IMobileObjectMetastateFormatter for now, but the final name I'll leave up to Rocky) that has methods that a BO would implement:

public interface IMobileObjectMetastateFormatter
{
  void Write(Stream stream);
  void Read(Stream stream);
}

Then, as a serialization author, I could invoke these methods at the appropriate times so the values for "is new", "is dirty", etc. are saved and retrieved correctly, and I no longer care how that's done.

Describe alternatives you've considered
Leave things the way they are, and hope that future CSLA changes don't change how internal metastate is managed. (Or, if such a mechanism already exists in CSLA, please tell me :) ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants