Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a build-time crash in the BindableTypeLinkerGeneratorTask by preventing infinite recursion when encountering self-referencing generic inheritance patterns during type graph traversal (notably in Native AOT builds).
Changes:
- Register types in
typesToPropertiesas soon as they’re discovered (placeholder entry), then update with computed properties to break recursive cycles. - Add a SamplesApp scenario that exercises the self-referencing generic base-type case via a
[Bindable]type property.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/SourceGenerators/Uno.UI.Tasks/LinkerHintsGenerator/BindableTypeLinkerGeneratorTask.cs | Adds early “seen” registration in AddDeclaredPropertyTypes to prevent stack overflow on recursive type graphs. |
| src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Views/Controls/SampleChooserCategory.cs | Introduces a self-referencing generic type pattern and a bindable property referencing it to reproduce/guard the scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23148/wasm-skia-net9/index.html |
|
|
Fixes: #23147 The `<BindableTypeLinkerGeneratorTask*/>` task didn't properly support types which reference themselves in the inheritance list, for example: public class SomeInfo<T> { } public class MyInfo : SomeInfo<MyInfo> { } [Microsoft.UI.Xaml.Data.Bindable] public partial class SampleChooserCategory { public MyInfo MyInfo => null; } `BindableTypeLinkerGeneratorTask.AddDeclaredPropertyTypes()`, would try to "fully process" a type before "registering" the type within `typesToProperties`. This fails in the above "self-referencing" scenario, because when processing `MyInfo`, it would first process the base class `SomeInfo<MyInfo>`, which would then process the type argument `MyInfo`, which would then process the base class `SomeInfo<MyInfo>`… and blow up with an MSB4217: % dotnet publish src/SamplesApp/SamplesApp.Skia.netcoremobile/SamplesApp.Skia.netcoremobile.csproj \ -r android-arm64 -f net10.0-android -p:UnoTargetFrameworkOverride=net10.0-android \ -p:ApplicationId=uno.platform.samplesapp.skia.nativeaot -p:SkiaPublishAot=true \ -p:SkiaSharpVersion=3.119.2-preview.1 -bl … …/src/SourceGenerators/Uno.UI.Tasks/Content/Uno.UI.Tasks.targets(483,3): error MSB4217: Task host node exited prematurely. Diagnostic information may be found in files in the temporary files directory named MSBuild_*.failure.txt. To fix this, "registring a type within `typesToProperties`" needs to be done as a *two step* process: 1. Register the type *as soon as it is seen*, by adding it to `typesToProperties` with an empty list of properties. 2. Once the properties have been computed, update the registration with the actual list of properties. This two step process allows the generator to "break the cycle" when processing such "self-referencing" types. Updates `src/SamplesApp` to include a "test" for this scenario.
28c2cf0 to
6024b09
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23148/wasm-skia-net9/index.html |
|
|
Fixes: #23147
The
<BindableTypeLinkerGeneratorTask*/>task didn't properly support types which reference themselves in the inheritance list, for example:BindableTypeLinkerGeneratorTask.AddDeclaredPropertyTypes(), would try to "fully process" a type before "registering" the type withintypesToProperties.This fails in the above "self-referencing" scenario, because when processing
MyInfo, it would first process the base classSomeInfo<MyInfo>, which would then process the type argumentMyInfo, which would then process the base classSomeInfo<MyInfo>… and blow up with an MSB4217:To fix this, "registring a type within
typesToProperties" needs to be done as a two step process:Register the type as soon as it is seen, by adding it to
typesToPropertieswith an empty list of properties.Once the properties have been computed, update the registration with the actual list of properties.
This two step process allows the generator to "break the cycle" when processing such "self-referencing" types.
Updates
src/SamplesAppto include a "test" for this scenario.GitHub Issue: closes #
PR Type:
What is the current behavior? 🤔
What is the new behavior? 🚀
PR Checklist ✅
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information ℹ️