Repository navigation
Closed
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzersin-prThere is an active PR which will close this issue when it is merged
Milestone
Description
Repro:
dotnet new console
app.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishTrimmed>true</PublishTrimmed>
<WarningsAsErrors>false</WarningsAsErrors>
<NoWarn>NU1605;NU1603;NU1701</NoWarn>
</PropertyGroup>
<ItemGroup>
<TrimmerRootAssembly Include="Syncfusion.Maui.Gauges" />
<PackageReference Include="Syncfusion.Maui.Gauges" Version="20.4.40" />
</ItemGroup>
</Project>dotnet publish
Stack trace from the output:
---> System.ArgumentException: Member 'Syncfusion.Maui.Graphics.Internals.IDrawableView' is declared in another modu
le and needs to be imported
at Mono.Cecil.MetadataBuilder.LookupToken(IMetadataTokenProvider provider)
at Mono.Cecil.SignatureWriter.MakeTypeDefOrRefCodedRID(TypeReference type)
at Mono.Cecil.SignatureWriter.WriteTypeSignature(TypeReference type)
at Mono.Cecil.SignatureWriter.WriteGenericInstanceSignature(IGenericInstance instance)
at Mono.Cecil.SignatureWriter.WriteTypeSignature(TypeReference type)
at Mono.Cecil.MetadataBuilder.GetTypeSpecSignature(TypeReference type)
at Mono.Cecil.MetadataBuilder.GetTypeSpecToken(TypeReference type)
at Mono.Cecil.MetadataBuilder.GetTypeToken(TypeReference type)
at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddTypes()
at Mono.Cecil.MetadataBuilder.BuildTypes()
at Mono.Cecil.MetadataBuilder.BuildModule()
at Mono.Cecil.MetadataBuilder.BuildMetadata()
at Mono.Cecil.ModuleWriter.<>c.<BuildMetadata>b__2_0(MetadataBuilder builder, MetadataReader _)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
at Mono.Cecil.AssemblyDefinition.Write(String fileName, WriterParameters parameters)
at Mono.Linker.Steps.OutputStep.WriteAssembly(AssemblyDefinition assembly, String directory, WriterParameters writ
erParameters)
/cc @LakshanF
Metadata
Metadata
Assignees
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzersin-prThere is an active PR which will close this issue when it is merged
Type
Projects
- StatusShow more project fieldsNo status
Activity
vitek-karas commentedon Nov 7, 2023
Similar failure on a different package - worth validating on the same fix:
app.csproj:Stack trace:
danmoseley commentedon Apr 17, 2024
is the bug here that it should not be dumping stack? or that it should not be failing? I was going to open a bug for the former, perhaps this covers it. dumping stack when it's not a bug on us is ugly.
sbomer commentedon Jun 17, 2024
Confirmed the first repro provided. Here's what happens:
SfDrawableViewHandlerderived fromViewHandler<IDrawableView, object>.ViewHandleris defined inMicrosoft.Maui, which is not referenced in the console app.SfDrawableViewHandlerwe fail to resolve the base type so we don't markIDrawableView(which is also defined in Syncfusion.Maui.Core.dll).IDrawableViewbecause it wasn't marked.ViewHandler<IDrawableView, object>, but at this point it fails because IDrawableView'sModuleisnull.For comparison, Native AOT fails on the same input with:
sbomer commentedon Jun 21, 2024
The fundamental problem is that the input was missing a referenced assembly. This caused some inconsistent marking for generics, leading to downstream failures. I can see two solutions to this:
I opened #103831 for 2, but I don't think we should do that in .NET 9 so I am leaning towards 1 for a .NET 9 fix.
jkotas commentedon Jun 21, 2024
NativeAOT tries to be resilient against missing assemblies where possible. It is not 100% resilient, but it covers a lot of the common situations. We have actually done work to make native AOT more resilient based on customer reports. There are a lot of assemblies and packages with dangling references in the wild.
cc @MichalStrehovsky
sbomer commentedon Jun 21, 2024
Good to know, thanks for the context. Would the Native AOT error in #93797 (comment) be considered a bug?
jkotas commentedon Jun 21, 2024
I think so. (It would not be must-fix bug - we would be ok with won't fixing it if the fix is too complicated or invasive.)
Mark generic arguments for unresolved generic types (dotnet#103844)