fsprojects / fsprojects/FSharpLint
Original message: The type 'IServer' is required here and is unavailable.
Nobody has claimed this yet.
- Dominant language
- F#
- Stars
- 327
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
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 FSharp.Compiler.Infos.getInterfaces@125-3.Invoke(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>.$Symbols.get_AllInterfaces@588.GenerateNext(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 FSharpLint.Application.Lint.typeCheckSuggestion@249.Invoke(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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with FSharpLint.Core/Rules/Conventions/RedundantNewKeyword.fs, especially doesNotImplementIDisposable at line 32, where the stack trace shows the failure. Use the reported F# 6.0/.NET 6.0 scenario and its missing Microsoft.AspNetCore.Hosting.Server.Abstractions dependency to investigate; done means linting no longer throws and reports no error for the affected file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fsharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100