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

Original message: The type 'IServer' is required here and is unavailable. #575

Open
abelbraaksma opened this issue Oct 21, 2022 · 6 comments

Comments

@abelbraaksma
Copy link
Member

Description

When checking for redunant 'new' keyword, FSharpLint can throw when dependencies aren't readily available. I'm not quite sure how to make a minimal repro, but it basically seems that FSL doesn't get all dependencies properly.

Normal compile is fine, as is running, so all dependencies are resolves properly by F#.

Repro steps

Not sure, this is a rather large project, but I'll try to make a smallish repro, unless the reflection-walk in the offending code has a clear location where this goes haywire.

Expected behavior

No error

Actual behavior

Getting this error:

Failed to parse file d:\Projects\Test\MyManagement.Tests\Host\WebHostTestServer.fs
Exception Message:
The exception has been reported. This internal exception should now be caught at an error recovery point on the stack. Original message: The type 'IServer' is required here and is unavailable. You must add a reference to assembly 'Microsoft.AspNetCore.Hosting.Server.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.)
Exception Stack Trace:
   at FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.Error[b](ErrorLogger x, Exception exn) in D:\workspace\_work\1\s\src\fsharp\ErrorLogger.fs:line 390
   at FSharp.Compiler.Import.ImportTypeRefData(ImportMap env, Range m, ILScopeRef scoref, String[] path, String typeName) in D:\workspace\_work\1\s\src\fsharp\import.fs:line 118
   at FSharp.Compiler.Import.ImportILTypeRefUncached(ImportMap env, Range m, ILTypeRef tref) in D:\workspace\_work\1\s\src\fsharp\import.fs:line 141
   at FSharp.Compiler.Import.ImportILTypeRef(ImportMap env, Range m, ILTypeRef tref) in D:\workspace\_work\1\s\src\fsharp\import.fs:line 153
   at FSharp.Compiler.Import.ImportILType(ImportMap env, Range m, FSharpList`1 tinst, ILType ty) in D:\workspace\_work\1\s\src\fsharp\import.fs:line 180
   at [email protected](ILType ity) in D:\workspace\_work\1\s\src\fsharp\infos.fs:line 127
   at Microsoft.FSharp.Primitives.Basics.List.choose[T,TResult](FSharpFunc`2 f, FSharpList`1 xs) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 189
   at FSharp.Compiler.Infos.GetImmediateInterfacesOfType(SkipUnrefInterfaces skipUnref, TcGlobals g, ImportMap amap, Range m, TType ty) in D:\workspace\_work\1\s\src\fsharp\infos.fs:line 174
   at FSharp.Compiler.Infos.loop@185-42[a](Boolean followInterfaces, AllowMultiIntfInstantiations allowMultiIntfInst, SkipUnrefInterfaces skipUnref, FSharpFunc`2 visitor, TcGlobals g, ImportMap amap, Range m, Int32 ndeep, TType ty, Tuple`3 state) in D:\workspace\_work\1\s\src\fsharp\infos.fs:line 252
   at FSharp.Compiler.Infos.FoldHierarchyOfTypeAux[a](Boolean followInterfaces, AllowMultiIntfInstantiations allowMultiIntfInst, SkipUnrefInterfaces skipUnref, FSharpFunc`2 visitor, TcGlobals g, ImportMap amap, Range m, TType ty, a acc) in D:\workspace\_work\1\s\src\fsharp\lib.fs:line 256
   at FSharp.Compiler.Infos.AllSuperTypesOfType(TcGlobals g, ImportMap amap, Range m, AllowMultiIntfInstantiations allowMultiIntfInst, TType ty) in D:\workspace\_work\1\s\src\fsharp\infos.fs:line 282
   at <StartupCode$FSharp-Compiler-Service>[email protected](IEnumerable`1& next) in D:\workspace\_work\1\s\src\fsharp\symbols\Symbols.fs:line 588
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl() in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\seqcore.fs:line 368
   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   at FSharp.Compiler.Symbols.FSharpEntity.get_AllInterfaces() in D:\workspace\_work\1\s\src\fsharp\symbols\Symbols.fs:line 587
   at FSharpLint.Rules.RedundantNewKeyword.doesNotImplementIDisposable(FSharpCheckFileResults checkFile, LongIdentWithDots ident, Unit unitVar0) in D:\a\FSharpLint\FSharpLint\src\FSharpLint.Core\Rules\Conventions\RedundantNewKeyword.fs:line 32
   at Microsoft.FSharp.Collections.ListModule.Fold[T,TState](FSharpFunc`2 folder, TState state, FSharpList`1 list) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\list.fs:line 222
   at [email protected](LintWarning suggestion) in D:\a\FSharpLint\FSharpLint\src\FSharpLint.Core\Application\Lint.fs:line 249
   at Microsoft.FSharp.Collections.Internal.IEnumerator.choose@171.System.Collections.IEnumerator.MoveNext() in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 179
   at Microsoft.FSharp.Collections.SeqModule.Iterate[T](FSharpFunc`2 action, IEnumerable`1 source) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 496
   at FSharpLint.Application.Lint.lint(LintInfo lintInfo, FileParseInfo fileInfo) in D:\a\FSharpLint\FSharpLint\src\FSharpLint.Core\Application\Lint.fs:line 243

Known workarounds

None

Related information

Latest FSharpLint, F# 6.0, .NET 6.0, Windows

@abelbraaksma
Copy link
Member Author

Actually, that wasn't entirely correct. A working workaround is to add the redundant, transient dependency by hand.
Do note, though, that the reported version number in the error is wrong, but at least the error is gone now.

@knocte
Copy link
Collaborator

knocte commented Oct 26, 2022

Hey Abel, thanks for filing this bug and providing a workaround.

Do note, though, that the reported version number in the error is wrong

You mean the version contained in the text "Microsoft.AspNetCore.Hosting.Server.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60"? Unfortunately, the culprit with that issue might just be that the version listed in the nuget package is not the same as the ASSEMBLY version. This happens quite often in many libraries :(

@abelbraaksma
Copy link
Member Author

@knocte ah, yes, that makes sense (re version weirdness)

@knocte
Copy link
Collaborator

knocte commented Dec 29, 2023

@abelbraaksma hello Abel, we have a new prerelease that is completely transitioned to .net6.0 and I have the feeling that it might have some impact on this bug. Do you mind upgrading to it and re-testing?

@knocte
Copy link
Collaborator

knocte commented Dec 29, 2023

@abelbraaksma
Copy link
Member Author

abelbraaksma commented Dec 29, 2023

I'll give it a go, I'd love to use it again! Great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants