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

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

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

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

0101 opened this issue Sep 26, 2024 · 3 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())

@github-actions github-actions bot added this to the Backlog milestone Sep 26, 2024
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants