-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Set default JSON type resolver if not set #49393
Conversation
bc3077d
to
f47b5f4
Compare
FYI - If you wanted to write some tests for this, you could do them like this: aspnetcore/src/Mvc/Mvc.Core/test/JsonOptionsTest.cs Lines 29 to 44 in 238dabc
You would just be setting the bool to false. |
@@ -18,6 +18,7 @@ public static bool ShouldUseWith(this JsonTypeInfo jsonTypeInfo, [NotNullWhen(fa | |||
|
|||
public static JsonTypeInfo GetReadOnlyTypeInfo(this JsonSerializerOptions options, Type type) | |||
{ | |||
options.TypeInfoResolver ??= new EmptyJsonTypeInfoResolver(); |
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.
Looks good. You can avoid creating a custom resolver if you just use JsonTypeInfoResolver.Combine()
with no arguments.
Closes #49360