-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Changing msgpack options #20031
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
Changing msgpack options #20031
Conversation
…tance of MessagePackSerializerOptions
…olver and a CustomFormatter
src/SignalR/common/Protocols.MessagePack/src/Protocol/MessagePackHubProtocol.cs
Outdated
Show resolved
Hide resolved
I can't make pass all the I even updates locally Here is what i see : (Even using One example of error :
|
src/SignalR/common/Protocols.MessagePack/src/MessagePackHubProtocolOptions.cs
Show resolved
Hide resolved
Why is there no |
I don't think we build reference assemblies for it since it's not in the shared framework. |
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
public class MessagePackHubProtocolOptions
{
- public IList<IFormatterResolver> FormatterResolvers { get; set; }
+ public MessagePackSerializerOptions SerializerOptions { get; set; }
} We've already made a breaking change this release by upgrading to MessagePack 2.X which changes the API of custom formatters that users can register with the old options. |
can someone tag or associate the PR #18133 for upgrading msgpack to v2 in the preview3 release with this one ? as that PR did not seems to have a proper issue at that time or something else it did not showed up in preview1 release or links containing filters it might comes as a "surprise" for consumers already using msgpack as it was not part of the release note |
hummm i did not checked this link, you are absolutely right on this one, i followed the announcement and blog post for preview 1 there was a list for breaking change pointing here : It seems to be only filtering my bad |
Well it's new, I think those were added yesterday 😆 |
|
||
public IList<IFormatterResolver> FormatterResolvers | ||
public MessagePackSerializerOptions SerializerOptions |
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.
Lets add xml comments.
- Recommend setting
.WithSecurity(MessagePackSecurity.UntrustedData)
if they override the options - If you want to modify to the default options you need to assign the options back to the
SerializerOptions
after modifications:
SerializerOptions = SerializerOptions.WithResolver(new CustomResolver());
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.
quick question, as the API has been approuved, and thinking about the summary, i have a terrible idea....
This would make another PR i guess since this API Changed has been approuved already ?
(i have no idea if it's possible) but does adding this makes sense:
(pseudo code, i have no idea if it's something good or bad since it's intrusive and also how properly speak english and being both nice and clear to the customer)
if(env.IsDevelopment() && options.serializerOptions.MessagePackSecurity != MessagePackSecurity.UntrustedData)
{
if(options.EnableWarningForUntrustedData)
{
logger.LogWarning("MessagePackSerializerOptions have been overriden with a ... security settings ...blablabla if intended, you can turn this warning off by settings EnableWarningForUntrustedData to false")
could even points to a github issue explaining that API
}
}
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.
The options.serializerOptions.MessagePackSecurity != MessagePackSecurity.UntrustedData
would need some massaging because UntrustedData
is a copy-on-write object so if they've 'enhanced' it at all, you wouldn't want that to reactivate the failure. You'd want to look into the object to see what settings it has to determine whether it's a secure instance. But let's first wait to see what the ASP.NET Core folks think of your overall idea.
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.
as said it just something that crossed my mind while trying to find an idea for the summary (TBH I'm pretty bad at it)
Also i have no idea if it's even possible
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.
(previous rendering deleted)
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.
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.
welllll
I should remove the .
since the <code>
seems to create a paragraph right
@anurse ?
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.
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.
Good point. Yep, drop the .
after the <code>
.
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.
(done, do i mark this thread as resolved if summary if ok for you ?)
Do i rebase the branch ? |
…r idea on how to use it
src/SignalR/common/Protocols.MessagePack/src/MessagePackHubProtocolOptions.cs
Outdated
Show resolved
Hide resolved
src/SignalR/common/Protocols.MessagePack/src/MessagePackHubProtocolOptions.cs
Outdated
Show resolved
Hide resolved
src/SignalR/common/Protocols.MessagePack/src/MessagePackHubProtocolOptions.cs
Outdated
Show resolved
Hide resolved
src/SignalR/common/Protocols.MessagePack/src/MessagePackHubProtocolOptions.cs
Outdated
Show resolved
Hide resolved
…tocolOptions.cs Co-Authored-By: Brennan <[email protected]>
…tocolOptions.cs Co-Authored-By: Brennan <[email protected]>
…tocolOptions.cs Co-Authored-By: Brennan <[email protected]>
…tocolOptions.cs Co-Authored-By: Brennan <[email protected]>
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.
Words smithed
src/SignalR/common/Protocols.MessagePack/src/MessagePackHubProtocolOptions.cs
Outdated
Show resolved
Hide resolved
src/SignalR/common/Protocols.MessagePack/src/MessagePackHubProtocolOptions.cs
Outdated
Show resolved
Hide resolved
src/SignalR/common/Protocols.MessagePack/src/MessagePackHubProtocolOptions.cs
Show resolved
Hide resolved
src/SignalR/common/Protocols.MessagePack/src/MessagePackHubProtocolOptions.cs
Outdated
Show resolved
Hide resolved
src/SignalR/common/Protocols.MessagePack/src/MessagePackHubProtocolOptions.cs
Show resolved
Hide resolved
…tocolOptions.cs Co-Authored-By: Andrew Stanton-Nurse <[email protected]>
…tocolOptions.cs Co-Authored-By: Andrew Stanton-Nurse <[email protected]>
…tocolOptions.cs Co-Authored-By: Andrew Stanton-Nurse <[email protected]>
…tocolOptions.cs Co-Authored-By: Andrew Stanton-Nurse <[email protected]>
…tocolOptions.cs Co-Authored-By: Andrew Stanton-Nurse <[email protected]>
…d to avoid a lonely "." to the next line
(see #20031 (comment)) |
Thanks again @tebeco ! |
thx for your patience here ^^ |
Thanks for your patience. That was a lot of feedback to deal with. 🎉 |
Summary of the changes :
MessagePack-CSharp v2
there is aMessagePackSerializerOptions
class passed to the serializerMessagePackSerializerOptions
rather than anIList<IFormatterResolvers>
Addresses #18569
First Approach
Use an
IOptions<MessagePackSerializerOptions>
,an attempt was done here https://github.com/tebeco/AspNetCore/commit/56c457739c54677626fad11f2821f3c101d8e04c
BUT not possible since this type has no
public parameter less ctor
AND it's API if a Fluent/Immutable one making it impossible to do this :Other Approaches
IOptions<MessagePackHubProtocolOptions>
and expose directly a property of typeMessagePackSerializerOptions
IOptions<>
and create an overload accepting an instance ofMessagePackSerializerOptions
CustomFormatter
one, and clearly show DI issue + the use ofTryAddEnumerable
+captured Closure
closure
issue ... then why not anIOptions<>
... oO hello proposal 1Currently looking at
Approach 1