dotnet / linker

389 stars 127 forks source link

Warnings and errors should include more context when possible #1153

Open sbomer opened 4 years ago

sbomer commented 4 years ago

As we surface linker warnings/errors to users (see https://github.com/mono/linker/pull/1105 for example), we should revisit the messages to include more context when reasonable, and ensure that they convey the right amount of information.

For example:

marek-safar commented 4 years ago

It'd be great to add links to a few examples you found

sbomer commented 4 years ago

If I get more time, I'd like to do a more exhaustive pass, but here are two examples for now:

I added links to the above, too.

sbomer commented 4 years ago

This issue also contains a related ask for better diagnostics: https://github.com/dotnet/aspnetcore/issues/20145

The build log doesn't really why it was trying to resolve that assembly:

Fatal error in Mono IL Linker
C:\Users\…\.nuget\packages\microsoft.aspnetcore.components.webassembly.build\3.2.0-preview2.20160.5\targets\Blazor.MonoRuntime.targets(245,5): error : Unhandled exception. Mono.Linker.Steps.XmlResolutionException: Failed to process XML description: <unspecified> [C:\agent\_work\19\s\MyBlazorProject.Client\MyBlazorProject.Client.csproj]
---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.AspNetCore.Blazor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.AspNetCore.Blazor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
  at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
  at Mono.Linker.AssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
  at Mono.Linker.LinkContext.Resolve(IMetadataScope scope)
  at Mono.Linker.LinkContext.Resolve(IMetadataScope scope)
  at Mono.Linker.Steps.ResolveFromXmlStep.ProcessAssemblies(LinkContext context, XPathNodeIterator iterator)
  at Mono.Linker.Steps.ResolveFromXmlStep.Process()
  --- End of inner exception stack trace ---
  at Mono.Linker.Steps.ResolveFromXmlStep.Process()
  at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
  at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
  at Mono.Linker.Pipeline.Process(LinkContext context)
  at Mono.Linker.Driver.Run(ILogger customLogger)
  at Mono.Linker.Driver.Execute(String[] args, ILogger customLogger)
  at Mono.Linker.Driver.Main(String[] args)