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

HybridCache: richer detection for field-only types (ref STJ) #6118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mgravell
Copy link
Member

@mgravell mgravell commented Mar 14, 2025

HybridCache uses System.Text.Json for the default serializer, which has some opinions on fields; this means that named-tuples (or value-tuples generally), and types that use value tuples or otherwise field-only values, can lose data.

We already detect value-tuples specifically as the root type, but real-world usage has highlit wider ranges of scenarios. This PR adds deeper detection for this scenario, applying the same workaround. It duly considers collection types and recursion scenarios.

fix dotnet/aspnetcore#60934

Microsoft Reviewers: Open in CodeFlow

@mgravell
Copy link
Member Author

mgravell commented Mar 14, 2025

Thought: we should explicitly restrict our override behaviour to scenarios that use the inbuilt STJ default options instance, not just ones that don't handle fields. If someone uses their own STJ options: we should respect it. The mechanism for people to do this is new and non-disclosed, so there is no issue changing that behaviour, i.e. right now the number of times anyone will have ever supplied a non-default STJ options is zero or a rounding error asymptotically approaching zero.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hybrid Cache silently fails to correctly handle cached tuples
1 participant