Skip to content

[release/11.0] JsonNamingPolicyAttribute: Add missing PascalCase - #135325

Merged
artl93 merged 1 commit into
release/11.0from
backport/pr-135238-to-release/11.0
Oct 7, 2026
Merged

artl93 merged 1 commit into
release/11.0from
backport/pr-135238-to-release/11.0

Conversation

@github-actions

@github-actions github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #135238 to release/11.0

/cc @eiriktsarpalis @compujuckel

Customer Impact

  • Customer reported
  • Found internally

Fixes a customer reported issue where the newly introduced JsonNamingPolicyAttribute did not include support for the newly introduced PascalCase naming policy.

Regression

  • Yes
  • No

Testing

Added functional tests verifying the fix.

Risk

Low. Makes a targeted and straightfoward fix adding missing functionality.

Support for Pascal Case was added in
#124644.

However, JsonNamingPolicyAttribute was missed, leading to an exception
when doing something like this:
```csharp
[JsonNamingPolicy(JsonKnownNamingPolicy.PascalCase)]
public class TestClass
{
    public int Property { get; init; }
}
```

```
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'namingPolicy')
   at System.Text.Json.Serialization.JsonNamingPolicyAttribute.ResolveNamingPolicy(JsonKnownNamingPolicy namingPolicy)
   at System.Text.Json.Serialization.JsonNamingPolicyAttribute..ctor(JsonKnownNamingPolicy namingPolicy)
   at System.Reflection.CustomAttribute.<CreateCustomAttributeInstance>g____PInvoke|30_0(QCallModule __pModule_native, ObjectHandleOnStack __type_native, ObjectHandleOnStack __pCtor_native, IntPtr* __ppBlob_native, IntPtr __pEndBlob_native, Int32* __pcNamedArgs_native, ObjectHandleOnStack __instance_native)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
   at System.Text.Json.Serialization.Metadata.FSharpCoreReflectionProxy.GetFSharpCoreAssembly(Type type)
   at System.Text.Json.Serialization.Metadata.FSharpCoreReflectionProxy.IsFSharpType(Type type)
   at System.Text.Json.Serialization.Converters.FSharpTypeConverterFactory.CanConvert(Type typeToConvert)
   at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.GetBuiltInConverter(Type typeToConvert)
   at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.GetConverterForType(Type typeToConvert, JsonSerializerOptions options, Boolean resolveJsonConverterAttribute)
   at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.GetTypeInfo(Type type, JsonSerializerOptions options)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfoResolverChain.GetTypeInfo(Type type, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializerOptions.GetTypeInfoNoCaching(Type type)
   at System.Text.Json.JsonSerializerOptions.CachingContext.CreateCacheEntry(Type type, CachingContext context)
--- End of stack trace from previous location ---
[...]
```

After adding that line, the attribute works as expected.
@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@eiriktsarpalis eiriktsarpalis added this to the 11.0.0 milestone Oct 7, 2026
@eiriktsarpalis eiriktsarpalis added the Servicing-consider Issue for next servicing release review label Oct 7, 2026
@eiriktsarpalis
eiriktsarpalis requested a review from artl93 October 7, 2026 06:40

@artl93 artl93 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Missing thing - approved.

@eiriktsarpalis eiriktsarpalis added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Oct 7, 2026
@eiriktsarpalis

Copy link
Copy Markdown
Member

Approved over email

@eiriktsarpalis

Copy link
Copy Markdown
Member

/ba-g No test failures, but ba is hung.

@artl93
artl93 merged commit b468728 into release/11.0 Oct 7, 2026
99 of 104 checks passed
@artl93
artl93 deleted the backport/pr-135238-to-release/11.0 branch October 7, 2026 20:41
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Text.Json Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants