Skip to content

DCS work nicely with collectible AssemblyLoadContext #90437

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

Merged
merged 6 commits into from
Aug 14, 2023

Conversation

StephenMolloy
Copy link
Member

This replaces the draft PR (#88791) that I was using earlier. The pre-requisite changes that were staged in the first few commits of that draft got checked in under their own PR with proper contributor attribution (#73893), so this PR cherry-picks the rest of that draft and then addresses the feedback.

Fixes #77877

}

public DataContract? GetItem(int index) => _contracts[index].strong ?? (_contracts[index].weak?.TryGetTarget(out DataContract? ret) == true ? ret : null);

Copy link
Member

Choose a reason for hiding this comment

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

It's only a style thing, but did you consider having providing an indexer property instead of switching to Get and Set methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sort of an evolution of the context-aware side of the design that got away from the original usage pattern. An indexer would fit the original code. But the nullable notation of the original code was incorrect, even if our code was dilligent about null-checking. Maybe I've still got Monday brain, but I don't know of a way to make the getter nullable and the setter non-nullable... notation-wise anyway.

@mconnew
Copy link
Member

mconnew commented Aug 12, 2023

The only change that needs to happen is move the second check inside of the locks then this is good to merge.

…unning the 'create' delegate. Docs suggest this is intentional and will remain the case.
@StephenMolloy StephenMolloy merged commit adaebca into dotnet:main Aug 14, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 14, 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.

DataContractSerializer caches collectible types in statics
2 participants