-
Notifications
You must be signed in to change notification settings - Fork 839
chore: Address "downstream" trimmer warnings in Uno.Xaml.dll #22226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
1826eb5 to
8861753
Compare
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22226/docs/index.html |
1 similar comment
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22226/docs/index.html |
ecdeb3a to
24651c2
Compare
$(IsAotCompatible)=true in Uno.Xaml|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22226/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22226/docs/index.html |
|
|
When *building* uno.chefs for NativeAOT with all warnings enabled: dotnet publish -c Release -r osx-x64 -f net10.0-desktop -p:TargetFrameworkOverride=net10.0-desktop \ -bl Chefs/Chefs.csproj -p:UseSkiaRendering=true -p:SelfContained=true \ -p:PublishAot=true -p:IsAotCompatible=true -p:TrimmerSingleWarn=false -p:_ExtraTrimmerArgs=--verbose \ -p:IlcGenerateMapFile=true -p:IlcGenerateMstatFile=true -p:IlcGenerateDgmlFile=true -p:IlcGenerateMetadataLog=true \ -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=`pwd`/_gen We observe the following warnings (among others): AOT analysis warning IL3050: Uno.Xaml.Schema.XamlTypeName.XamlTypeName(XamlType): Using member 'System.Linq.Queryable.AsQueryable<XamlType>(IEnumerable`1<XamlType>)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Enumerating in-memory collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling. AOT analysis warning IL3050: Uno.Xaml.XamlSchemaContext.ResolveXamlTypeName(String,String,IList`1<XamlType>): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime. At a glance, `XamlTypeName` is an easy enough fix: don't use `.AsQueryable()`. @jonpryor doesn't see any need for it here. `XamlSchemaContext.ResolveXamlTypeName()` looks similarly easy: just add `[UnconditionalSuppressMessage]`, as is already done elsewhere within `Uno.Xaml.dll`. Additional thinking occurs: shouldn't this assembly be marked as `$(IsAotCompatible)`=true? Try that, and: /usr/local/share/dotnet/sdk/10.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(120,5): warning NETSDK1210: IsAotCompatible and EnableAotAnalyzer are not supported for the target framework. Consider multi-targeting to a supported framework to enable ahead-of-time compilation analysis, and set IsAotCompatible only for the supported frameworks. For example: <IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</IsAotCompatible> At which point everything becomes much more complicated: `Uno.Xaml.csproj` targets `netstandard2.0`. When we multitarget *both* netstandard2.0 and net10.0, everything breaks. Because The World Has Moved On: src/SourceGenerators/System.Xaml/System.Xaml/XamlException.cs(78,24): error CS0672: Member 'XamlException.GetObjectData(SerializationInfo, StreamingContext)' overrides obsolete member 'Exception.GetObjectData(SerializationInfo, StreamingContext)'. … src/SourceGenerators/System.Xaml/System.Xaml/XamlException.cs(66,4): error SYSLIB0051: 'Exception.Exception(SerializationInfo, StreamingContext)' is obsolete: 'This API supports obsolete formatter-based serialization. It should not be called or extended by application code.' src/SourceGenerators/System.Xaml/System.Xaml/ParsedMarkupExtensionInfo.cs(153,31): error CA1865: Use 'string.StartsWith(char)' instead of 'string.StartsWith(string)' when you have a string with a single char … Explore this a bit, but ultimately come to the conclusion that it isn't worthwhile: 1. `Uno.Xaml.dll` needs to maintain netstandard2.0 compatibility, as it's refernced by source generators. 2. Multitargeting .NET 10 just adds "noise". 3. Attempting to fix warnings introduced by `$(IsAotCompatible)`=true is a fools errand: *everything* eventually hits various forms of Reflection such as `Type.MakeGenericType()` and/or `TypeDescriptor.GetConverter()`, meaning *everything* needs to be marked with `[RequiresDynamicCode]` and `[RequiresUnreferencedCode]`. *Other than* introducing lots of warnings in referencing code, how does this *benefit* us? (It doesn't.)
24651c2 to
f5f2ba7
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22226/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22226/docs/index.html |
When building uno.chefs for NativeAOT with all warnings enabled:
We observe the following warnings (among others):
At a glance,
XamlTypeNameis an easy enough fix: don't use.AsQueryable(). @jonpryor doesn't see any need for it here.XamlSchemaContext.ResolveXamlTypeName()looks similarly easy:just add
[UnconditionalSuppressMessage], as is already doneelsewhere within
Uno.Xaml.dll.Additional thinking occurs: shouldn't this assembly be marked
as
$(IsAotCompatible)=true? Try that, and:At which point everything becomes much more complicated:
Uno.Xaml.csprojtargetsnetstandard2.0. When we multitarget bothnetstandard2.0 and net10.0, everything breaks.
Because The World Has Moved On:
Explore this a bit, but ultimately come to the conclusion that it
isn't worthwhile:
Uno.Xaml.dllneeds to maintain netstandard2.0 compatibility,as it's refernced by source generators.
Multitargeting .NET 10 just adds "noise".
Attempting to fix warnings introduced by
$(IsAotCompatible)=trueis a fools errand: everything eventually hits various forms
of Reflection such as
Type.MakeGenericType()and/orTypeDescriptor.GetConverter(), meaning everything needs to bemarked with
[RequiresDynamicCode]and[RequiresUnreferencedCode]. Other than introducing lots ofwarnings in referencing code, how does this benefit us?
(It doesn't.)
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 ℹ️