Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

internal error: multiple methods appear with identical argument types #17796

Closed
0101 opened this issue Sep 26, 2024 · 6 comments · Fixed by #17804
Closed

internal error: multiple methods appear with identical argument types #17796

0101 opened this issue Sep 26, 2024 · 6 comments · Fixed by #17804
Assignees

Comments

@0101
Copy link
Contributor

0101 commented Sep 26, 2024

Please provide a succinct description of the issue.

Repro steps

Provide the steps required to reproduce the problem:

  1. Checkout lsp branch
  2. build.cmd -c Debug or just build FSharp.Compiler.LanguageServer project

Expected behavior

Build completes successfully

Actual behavior

We get

error FS0192 : internal error : multiple methods named AddSingleton appear with identical argument types in type Microsoft.Extensions.DependencyInjection.ServiceCollectionSer
viceExtensions [D:\code\fsharp\src\FSharp.Compiler.LanguageServer\FSharp.Compiler.LanguageServer.fsproj]

Related information

Here's the code that triggers the error:

let _ =
serviceCollection
.AddSingleton(initialWorkspace)
.AddSingleton<ContextHolder>()
.AddSingleton<IMethodHandler, InitializeHandler<InitializeParams, InitializeResult, FSharpRequestContext>>()
.AddSingleton<IMethodHandler, InitializedHandler<InitializedParams, FSharpRequestContext>>()
.AddSingleton<IMethodHandler, DocumentStateHandler>()
.AddSingleton<IMethodHandler, LanguageFeaturesHandler>()
.AddSingleton<ILspLogger>(logger)
.AddSingleton<IRequestContextFactory<FSharpRequestContext>, FShapRequestContextFactory>()
.AddSingleton<IHandlerProvider>(fun _ -> this.GetBaseHandlerProvider())
.AddSingleton<IInitializeManager<InitializeParams, InitializeResult>, CapabilitiesManager>()
.AddSingleton(this)
.AddSingleton<ILifeCycleManager>(new LspServiceLifeCycleManager())

@vzarytovskii
Copy link
Member

It might be caused by #16168 as well

@DedSec256
Copy link
Contributor

Referenced Microsoft.Extensions.DependencyInjection.Abstractions contains two extension methods with the same name AddSingleton and parameters count, but different number of generics

public static IServiceCollection AddSingleton<TService>(this IServiceCollection services)
public static IServiceCollection AddSingleton<TService, TImplementation>(this IServiceCollection services)

I think issue localized in this change from #17597

{20B9EFCA-9D59-4A0F-BDB7-9D6D96988964}

which triggers additional call of resolveILMethodRefWithRescope, which doesn't take generics into account when searching for methods, and therefore returns an error.

I managed to build the FSharp.Compiler.LanguageServer project locally after the revert of #17597

@T-Gro
Copy link
Member

T-Gro commented Sep 26, 2024

This makes sense Alex @DedSec256 , thanks. I will adjust that change.
Surprisingly, resolveILMethodRefWithRescope is not new a was already used at different places before.

@T-Gro T-Gro self-assigned this Sep 26, 2024
@T-Gro T-Gro modified the milestones: Backlog, September-2024 Sep 26, 2024
@T-Gro T-Gro linked a pull request Sep 27, 2024 that will close this issue
@rstm-sf
Copy link
Contributor

rstm-sf commented Oct 13, 2024

@T-Gro hello, could you tell how can check the fix? In RC2 I get something like this

@T-Gro
Copy link
Member

T-Gro commented Oct 14, 2024

Yes, RC2 has this error.
It has been fixed for the shipping version of the product and is fixed in code. But RC2 has it.

@Thorium
Copy link
Contributor

Thorium commented Nov 7, 2024

I'm having similar error after updating to latest VS2022 Prerelease v5, 9.0.100-rc.2.24474.11
In Prerelease 2.1 I didn't have this.

Edit: @xperiandri pointed out that having a global.json to hard-code a previous version does help.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants