Skip to content

Getting "Method reference is used with definition return type / parameter." / Due to TypeForwardedTo type #359

@deniszykov

Description

@deniszykov

Issue:

I'm getting following warning message:

WARNING: Method reference is used with definition return type / parameter. Indicates a likely invalid set of assemblies, consider one of the following
WARNING:  - Remove the assembly defining Microsoft.Extensions.DependencyInjection.IServiceCollection from the merge
WARNING:  - Add assembly defining Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Extensions.Logging.ILoggingBuilder::get_Services() to the merge

Because ReferenceFixator is failing to map declaring type of ILoggingBuilder::get_Services() method in ReferenceFixator.cs: 436

TypeReference declaringType = Fix(method.DeclaringType);

and it is failing because TypeReference.Scope for method.DeclaringType is Microsoft.Extensions.Logging while type is declared in Microsoft.Extensions.Logging.Abstractions and being forwarded:

// Microsoft.Extensions.Logging, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
[assembly: TypeForwardedTo(typeof(ILoggingBuilder))]

Steps to reproduce:

  1. Take these assemblies
  2. Merge them
/target:exe  "/lib:%UserProfile%\.nuget\packages\microsoft.netcore.app.ref\6.0.0\ref\net6.0" "/out:Test.dll" "Microsoft.Extensions.Logging.Configuration.dll" "Microsoft.Extensions.DependencyInjection.Abstractions.dll" "Microsoft.Extensions.DependencyInjection.dll"  "Microsoft.Extensions.Logging.Abstractions.dll"

libs.zip

Expected:

Type forwarding is respected. Probably type is registered twice in MappingHandler with both scopes when it is forwarded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions