Repository navigation
Use Volatile.ReadBarrier in JsonArray/JsonObject.GetUnderlyingReprese… - #136156
Merged
eiriktsarpalis merged 2 commits intoOct 21, 2026
Merged
Conversation
…ntation on .NET 10+
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-text-json |
Contributor
Author
|
No measurable difference on my machine (x64 Ryzen 7500F) using this benchmark But the lock instruction is gone from the JIT output. JsonArray.WriteTo before: After: |
Member
|
Not sure if this change is correct, but if it is - please introduce a pollyfill (C# 14.0 extension) for |
Contributor
Author
|
@EgorBo, done |
eiriktsarpalis
approved these changes
Oct 21, 2026
This was referenced Oct 21, 2026
eiriktsarpalis
added a commit
that referenced
this pull request
Oct 22, 2026
<!-- --> Use C# extension-member polyfills to consolidate framework-compatibility code across `src/libraries`, following [#136156](#136156). Call sites use framework API names while downlevel implementations remain in internal polyfill containers. Targets that already provide a member continue to bind to the framework implementation. The cleanup extends beyond System.Text.Json and its source generator to CBOR, Metadata/NRBF, xxHash, Packaging, Dataflow, MEF2, DiagnosticSource, Server-Sent Events, and several Microsoft.Extensions libraries. It includes: - Shared static-member and property polyfills for type and enum inspection, bit and endian conversions, multiplication, array limits, elapsed time, Unix epoch, and platform checks. - Reuse of existing span, collection, stack, string, decimal, and uninitialized-object polyfills instead of local compatibility helpers and conditional branches. - Standard argument guards in place of equivalent manual checks, preserving validation order and parameter names. - The same consolidation in existing CBOR tests and shared assertion utilities, removing the paired CBOR test-helper files without adding test coverage. The source generator's `IsClosed` helper is expressed as an extension property while retaining its existing Roslyn light-up and syntax-fallback behavior. There are no public API changes or new test cases. Initial Release validation passed `.\build.cmd libs -rc Release -lc Release /p:RunAnalyzersInBuild=true /p:RunILLinkInBuild=true`, followed by targeted compatibility builds and existing test-suite runs on CoreCLR and .NET Framework. Subsequent review adjustments were covered by targeted rebuilds and tests. > [!NOTE] > This pull request was generated with GitHub Copilot. --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3c692d8a-03a2-4ed9-b337-2066c25a3cb6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use
Volatile.ReadBarrierinstead ofInterlocked.MemoryBarrierinJsonArray/JsonObject.GetUnderlyingRepresentationon .NET 10+