-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Binaryformatter migration guide #41564
base: main
Are you sure you want to change the base?
Conversation
- remove the migration samples as we won't provide them (at least now) - remove WPF and WinForms part as it will be provided in Preview 7 - clarify the public type requirement for Messagepack - describe ArrayRecord and SZArrayRecord<T> - describe the OOB package
…but build produces warnings)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of time for today
docs/standard/serialization/binaryformatter-migration-guide/overview.md
Outdated
Show resolved
Hide resolved
|
||
Moreover, WinForms and WPF may require some additional changes starting from .NET 9 Preview 7. | ||
|
||
## Summary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the bullets here seem strongly related to the rest of the content on this page, so they're not really a Summary.
Are they left over from there being different content here that moved elsewhere?
(Maybe the idea is that they are summarizing the rest of the content across all other pages, but it doesn't quite feel like that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the idea is that they are summarizing the rest of the content across all other pages, but it doesn't quite feel like that
That was my intention.
docs/standard/serialization/binaryformatter-migration-guide/overview.md
Outdated
Show resolved
Hide resolved
docs/standard/serialization/binaryformatter-migration-guide/overview.md
Outdated
Show resolved
Hide resolved
* [DataContractSerializer](../../../fundamentals/runtime-libraries/system-runtime-serialization-datacontractserializer.md) is an XML serializer that **fully supports the serialization programming model that was used by the `BinaryFormatter`**. It requires the known types to be specified up-front (but most .NET collections and primitive types are on a default allow-list and don't need to be specified). **It's the serializer that requires the least amount of effort to migrate to**. | ||
* [System.Text.Json](./../system-text-json/overview.md) is strict by default and avoids any guessing or interpretation on the caller's behalf, emphasizing deterministic behavior. The library is intentionally designed this way for performance and security. In contrary to `BinaryFormatter`, by default it serializes **only public properties**. To deserialize a `readonly` field or property, `[JsonConstructor]` attribute needs be used to indicate that given constructor should be used to set these. It supports serialization and deserialization of most built-in collections, but it does not support dictionaries where keys are not primitive types. It supports polymorphic type hierarchy serialization and deserialization, but it needs to be explicitly enabled. The same goes for preserving the references and handling circular references. The default behavior can be changed by writing custom converters. | ||
* [MessagePack](https://github.com/MessagePack-CSharp/MessagePack-CSharp) provides a **highly efficient binary serialization format**, resulting in smaller message sizes compared to JSON and XML. It's **very performant** and ships with built-in support for LZ4 compression. It works best when all serializable public types and members are annotated with dedicated attributes. It does not serialize non-public types and members by default, but it can be customized. It supports readonly types and members, by trying to select the best matching constructor. The constructor can be selected in an explicit way by using the `[SerializationConstructor]` attribute. | ||
* `NrbfDecoder` should be used for reading any `BinaryFormatter` payload that was either persisted before the migration or comes from an actor that can not be migrated (example: client app owned by a 3rd party). This new type can read any NRBF (.NET Remoting Binary Format) payload, but it's mandatory to know the list of types that could have been serialized. Otherwise, it's impossible to create and hydrate the serialized objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the mandatory type list and hydration comments... I didn't think NrbfDecoder had hydration of anything other than NRBF primitive values and arrays thereof?
docs/standard/serialization/binaryformatter-migration-guide/reading-nrbf-payloads.md
Outdated
Show resolved
Hide resolved
docs/standard/serialization/binaryformatter-migration-guide/reading-nrbf-payloads.md
Outdated
Show resolved
Hide resolved
docs/standard/serialization/binaryformatter-migration-guide/reading-nrbf-payloads.md
Outdated
Show resolved
Hide resolved
docs/standard/serialization/binaryformatter-migration-guide/reading-nrbf-payloads.md
Outdated
Show resolved
Hide resolved
docs/standard/serialization/binaryformatter-migration-guide/reading-nrbf-payloads.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Jeremy Barton <[email protected]>
BinaryFormatter is getting removed in Preview 6, we need to provide the docs along with its public release.
I am able to address any feedback this week, after that I won't be available for some time (vacations).
Internal previews