Fix net481 build break and private-constructor assert regressions from PR #130503#130618
Open
pavelsavara with Copilot wants to merge 1 commit into
Open
Fix net481 build break and private-constructor assert regressions from PR #130503#130618pavelsavara with Copilot wants to merge 1 commit into
pavelsavara with Copilot wants to merge 1 commit into
Conversation
Co-authored-by: pavelsavara <271576+pavelsavara@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
pavelsavara
July 13, 2026 12:44
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes regressions in System.Text.Json introduced by accessor selection changes: restores net481 test compilation and removes invalid debug assertions that rejected supported private [JsonConstructor] scenarios when using reflection-based accessors.
Changes:
- Guard the reflection-accessor RemoteExecutor regression test behind
#if NETto avoidRuntimeFeature.IsDynamicCodeCompiledreferences on .NET Framework. - Relax
Debug.Assertconstructor visibility checks inReflectionMemberAccessorandReflectionEmitMemberAccessorso private (but supported) constructors don’t trigger debug-time aborts.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/ExceptionTests.cs | Wraps the reflection-accessor test in #if NET so net481 builds compile successfully. |
| src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionMemberAccessor.cs | Removes constructor.IsPublic from constructor assertions to allow private [JsonConstructor] delegates without debug asserts firing. |
| src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionEmitMemberAccessor.cs | Removes constructor.IsPublic from constructor assertions; skipVisibility: true already supports invoking non-public ctors. |
eiriktsarpalis
approved these changes
Jul 13, 2026
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-text-json |
This was referenced Jul 13, 2026
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.
PR #130503 gated STJ member accessor selection on
RuntimeFeature.IsDynamicCodeCompiledand routed interpreter-only runtimes (WASM/iOS/Mono interpreter) throughReflectionMemberAccessor. This brokemainin two ways, reported in comment #4957325583 and comment #4957354177.Description
net481 compile break (
CS0117) —ExceptionTests.csreferencedRuntimeFeature.IsDynamicCodeCompiled, which does not exist on .NET Framework.[SkipOnTargetFramework(NetFramework)]only skips at runtime, so the file still failed to compile. Guarded the reflection-accessor test with#if NET(the scenario is meaningless on .NET Framework, where dynamic code is always compiled).Private-constructor assert crash on the reflection/emit accessors — routing to
ReflectionMemberAccessorsurfaced a latentDebug.Assert(... constructor.IsPublic ...)that aborts on supported private[JsonConstructor]constructors (e.g.PrivateParameterizedCtor_WithAttribute). Removed the invalidIsPublicclause from the asserts inReflectionMemberAccessor(3 sites) andReflectionEmitMemberAccessor(2 sites — it already invokes private ctors viaskipVisibility: true), keeping theDeclaringType/!IsStaticchecks.