Skip to content
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

Unresolvable type cases InvalidOperationException in ReflectionMethodBodyScanner.GetValueNodeFromGenericArgument #1500

Closed
pranavkm opened this issue Sep 19, 2020 · 6 comments

Comments

@pranavkm
Copy link

pranavkm commented Sep 19, 2020

ILLink : error IL1005: Blazor.FileReader.SetupExtension.AddFileReaderService(IServiceCollection): Error processing method 'Blazor.FileReader.SetupExtension.AddFileReaderService(IServiceCollection)' in assembly 'Blazor.FileReader.Wasm.dll' [D:\temp\OAT\OAT.Blazor\OAT.Blazor.csproj]
  Mono.Linker.LinkerFatalErrorException: ILLink: error IL1005: Blazor.FileReader.SetupExtension.AddFileReaderService(IServiceCollection): Error processing method 'Blazor.FileReader.SetupExtension.AddFileReaderService(IServiceCollection)' in assembly 'Blazor.FileReader.Wasm.dll'
   ---> System.InvalidOperationException: Operation is not valid due to the current state of the object.
     at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.GetValueNodeFromGenericArgument(TypeReference genericArgument)
     at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.ProcessGenericArgumentDataFlow(GenericParameter genericParameter, TypeReference genericArgument, IMemberDefinition source)
     at Mono.Linker.Steps.MarkStep.MarkGenericArgumentConstructors(IGenericInstance instance, IMemberDefinition sourceLocationMember)
     at Mono.Linker.Steps.MarkStep.MarkGenericArguments(IGenericInstance instance, IMemberDefinition sourceLocationMember)
     at Mono.Linker.Steps.MarkStep.GetOriginalMethod(MethodReference method, DependencyInfo reason, IMemberDefinition sourceLocationMember)

Reproduced using SDK v5.0.100-rc.1.20452.10.

@marek-safar
Copy link
Contributor

@MichalStrehovsky could you investigate ?

@MichalStrehovsky
Copy link
Member

@MichalStrehovsky could you investigate ?

I think @vitek-karas would be more up to speed on this.

@vitek-karas
Copy link
Member

There's a "failure" before this happens that linker can't resolve assembly Blazor.FileReader.
The failure itself is caused by an unresolvable type reference to Blazor.FileReader.FileReaderService. The project references assembly called Tewr.Blazor.FileReader which seem to contain all the right types, but the assembly names don't match.

As for linker, I need to figure out what is the correct way to handle unresolvable type references - linker should report a meaningful error and not what's effectively a "crash".

@gfs
Copy link

gfs commented Sep 21, 2020

@vitek-karas

I tried with a default project with just blazor file reader and didn't encounter the same issue. (https://github.com/Tewr/BlazorFileReader/tree/master/src/Demo/Blazor.FileReader.Wasm.Demo)

I also searched the OAT code for any referenced to "Blazor.FileReader" without "Tewr" and didn't find one. Is there something in my configuration that is causing this or is it a linker issue?

@vitek-karas
Copy link
Member

The problem with this project is big mismatch in dependent NuGet package versions.
The OAT.Blazor project has a package reference to Tewr.Blazor.FileReader.Wasm, version=0.11.19128. This package has a dependency on Tewr.Blazor.FileReader, version=0.11.19128.
But the project OAT.Blazor.Components has a package reference to Tewr.Blazor.FileReader, version=2.0.0.20242.
So the whole solution ends up using Tewr.Blazor.FileReader, version=2.0.0.20242.
Apparently there's been assembly renames since the early versions of the FileReader and so the jump from 0.11.19128 to 2.0.0.20242 is a binary incompatible breaking change (due to assembly renames).

The assembly Blazor.FileReader.Wasm, version=0.11.19128.0 has an assembly reference to Blazor.FileReader - which has been renamed to Tewr.Blazor.FileReader.

The Tewr.Blazor.FileReader.Wasm package is marked as deprecated and instead just the Twer.Blazor.FileReader should be used (according to https://www.nuget.org/packages/Tewr.Blazor.FileReader.Wasm/)

I'll leave this issue opened to fix the wrong exception in this case.

@vitek-karas vitek-karas changed the title InvalidOperationException in ReflectionMethodBodyScanner.GetValueNodeFromGenericArgument Unresolvable type cases InvalidOperationException in ReflectionMethodBodyScanner.GetValueNodeFromGenericArgument Oct 9, 2020
@marek-safar marek-safar modified the milestones: .NET 5.0, .NET 5.0.x Nov 19, 2020
@marek-safar
Copy link
Contributor

Duplicate of #1634

@marek-safar marek-safar marked this as a duplicate of #1634 Nov 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants