Skip to content

Comments

Add serde.NET to the feature comparison table#453

Merged
AArnott merged 1 commit intomainfrom
serde-dotnet-comparison
Jun 10, 2025
Merged

Add serde.NET to the feature comparison table#453
AArnott merged 1 commit intomainfrom
serde-dotnet-comparison

Conversation

@AArnott
Copy link
Owner

@AArnott AArnott commented Jun 9, 2025

No description provided.

@AArnott AArnott added the documentation Improvements or additions to documentation label Jun 9, 2025
@AArnott
Copy link
Owner Author

AArnott commented Jun 9, 2025

@agocke would you care to review this? I want to report accurately.

@agocke
Copy link

agocke commented Jun 9, 2025

Happy to, thanks. Do you have a section on unsafe code? That might be relevant from a security perspective.

@AArnott
Copy link
Owner Author

AArnott commented Jun 9, 2025

Do you have a section on unsafe code?

No. Would it cover what the library uses internally, or what it source generates?

And what is unsafe code? C#'s unsafe keyword comes to mind, but I've seen very unsafe code written without unsafe and plenty of good, safe code within unsafe blocks. I don't think I'd want to contribute to the misconception that everything is safe unless you use unsafe. But I suppose within source generated code, knowing whether the unsafe keyword is used is important because it means the csproj will need to be changed to allow it.

@AArnott
Copy link
Owner Author

AArnott commented Jun 9, 2025

@agocke for your convenience in reviewing, here is the rendered version.

@agocke
Copy link

agocke commented Jun 10, 2025

Re unsafe, I think this is relevant context: dotnet/designs#330. In other words, yes there are lots of things that may play into unsafe, even though they're not currently marked as such

Copy link

@agocke agocke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks right to me, for now. Some stuff may change assuming I get more time to work on this

Surrogate types for automatic serialization of unserializable types | [✅](surrogate-types.md) | ❌ | [✅](https://serdedotnet.github.io/foreign-types.html) |
Custom converters | [✅](custom-converters.md) | ✅ | [✅](https://serdedotnet.github.io/customization.html)
Stateful converters | [✅](custom-converters.md#stateful-converters) | ❌ | ❌ |
Deserialization callback | [✅](xref:Nerdbank.MessagePack.IMessagePackSerializationCallbacks) | [✅](https://github.com/MessagePack-CSharp/MessagePack-CSharp?tab=readme-ov-file#serialization-callback) | ❌ |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, how does this work? How can you call an instance method on an object before it has been deserialized?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We invoke the callbacks between running the constructor and setting the properties.
This has its limitations, of course. And in particular with PolyType, once a type has required or init properties, all property sets are grouped within the pseudo-constructor, so we don't do an OnBeforeDeserialization callback there. But OnAfterDeserialization of course works.

Reference preservation | [✅](xref:Nerdbank.MessagePack.MessagePackSerializer.PreserveReferences) | ❌ | ❌ |
Cyclical references | [✅](xref:Nerdbank.MessagePack.MessagePackSerializer.PreserveReferences) | ❌ | ❌ |
JSON schema export | [✅](xref:Nerdbank.MessagePack.MessagePackSerializer.GetJsonSchema*) | ❌ | ❌ |
Secure defaults | [✅](security.md) | ❌ | ❌ |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is an example of a problematic structure Dictionary<int, int> because it's not collision-resistant?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not an example I would use because I don't know how well int as a key works in the dictionary for collision resistance. But that might be a good one.
I would tend to all the other types, including user-defined types, for which GetHashCode is implemented without collision resistance in mind.

@AArnott
Copy link
Owner Author

AArnott commented Jun 10, 2025

Thanks for reviewing. I'll be happy to update (or take PRs) to update this column as you make updates to serde.NET.

@AArnott AArnott merged commit ca5a9ff into main Jun 10, 2025
4 checks passed
@AArnott AArnott deleted the serde-dotnet-comparison branch June 10, 2025 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants