Skip to content

Fix Nullable<T> detection inside MetadataLoadContext to emit proper BamlRecordType - #11816

Open
h3xds1nz wants to merge 3 commits into
dotnet:mainfrom
h3xds1nz:fix-nullable-on-net-11
Open

Fix Nullable<T> detection inside MetadataLoadContext to emit proper BamlRecordType#11816
h3xds1nz wants to merge 3 commits into
dotnet:mainfrom
h3xds1nz:fix-nullable-on-net-11

Conversation

@h3xds1nz

@h3xds1nz h3xds1nz commented Aug 4, 2026

Copy link
Copy Markdown
Member

Fixes #11815

Description

Fixes detection of Nullable types on SDK-style builds where a new API for detecting Nullable<T> types was added (dotnet/runtime#124216). GetNullableUnderlyingType checks the IsGenericType for us.

Customer Impact

Well, the customer impact depends on how many years does it take for a PR to land in dotnet/wpf.

Regression

Regression for SDK-style projects. Otherwise this has been the case since MetadataLoadContext is available (which is the time when WPF was opensourced).

Testing

The repro included in the original issue. Using dotnet build for any TFM after swapping PBT in SDK.

Also verified builds in Visual Studio which use the net472 build of PBT.

Risk

There shouldn't be any, though I'm unsure at the moment if we can surface a non-in-box Type to check on inside WPF code so that such code would need to override this new method to not receive a random NotSupportedException. Eitherway, all inbox types ship with overrides and if a custom type override wants to work with nullables, they should override it.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz
h3xds1nz requested a review from a team August 4, 2026 11:04
@h3xds1nz
h3xds1nz requested a review from a team as a code owner August 4, 2026 11:04
@h3xds1nz
h3xds1nz marked this pull request as draft August 4, 2026 11:04
@dotnet-policy-service dotnet-policy-service Bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Aug 4, 2026
@lindexi

lindexi commented Aug 5, 2026

Copy link
Copy Markdown
Member

Oh, my experiment failed and I left some junk on your PR — turns out my WpfRuntime project hasn't been upgraded to .NET 11 yet. I'm still maintaining the older version and haven't added multi-targeting support. So when building, anything outside #if PBTCOMPILER can't find _metadataLoadContext and the build just breaks.

@h3xds1nz

h3xds1nz commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

@lindexi No worries, yeah this assumes that the ReflectionHelper is only built for .NET 11 or in PBT context for NETFX; I don't see a reason to complicate this since it doesn't count on any backporting.

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

Labels

Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PresentationBuildTasks emits BamlRecordType.Property (5) instead of PropertyWithConverter (36) for Nullable<T> properties

2 participants