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

Implement JsonTypeInfoResolver.WithAddedModifier #88255

Merged

Conversation

eiriktsarpalis
Copy link
Member

Fix #86440.

@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@eiriktsarpalis eiriktsarpalis self-assigned this Jun 30, 2023
@eiriktsarpalis eiriktsarpalis added this to the 8.0.0 milestone Jun 30, 2023
@ghost
Copy link

ghost commented Jun 30, 2023

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

Fix #86440.

Author: eiriktsarpalis
Assignees: -
Labels:

area-System.Text.Json, new-api-needs-documentation

Milestone: -

internal sealed class JsonTypeInfoResolverWithAddedModifiers : IJsonTypeInfoResolver
{
private readonly IJsonTypeInfoResolver _source;
private readonly Action<JsonTypeInfo>[] _modifiers;
Copy link
Member

@krwq krwq Jul 5, 2023

Choose a reason for hiding this comment

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

I'm curious if you could support it by List and count (you always append so technically you could reuse same instance) or ImmutableArray/List - not a big deal - this is not in a hot path

Copy link
Member Author

Choose a reason for hiding this comment

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

We want the resolver instances to be immutable -- if we reused the same List<T> then calling var bar = foo.WithAddedModifiers(...); then foo would be mutated.

@eiriktsarpalis eiriktsarpalis merged commit 7fe6609 into dotnet:main Jul 5, 2023
103 checks passed
@eiriktsarpalis eiriktsarpalis deleted the typeinforesolver-added-modifier branch July 5, 2023 12:55
@dotnet dotnet locked as resolved and limited conversation to collaborators Aug 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a JsonTypeInfoResolver.WithModifier extension method
2 participants