question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FSharp.Compiler.Service v34.0 seems to have had a breaking API change

See original GitHub issue

Description

After updating a Fake script to v5.19.1 from v5.19 (which updated from FSharp.Compiler.Service (33.0.1) to FSharp.Compiler.Service (34.0.1)) and incidentally FSharpLint.Core from 0.12.5 to 0.12.10, the linting operation failed with exception

System.MissingMethodException: Method not found: 'FSharp.Compiler.SourceCodeServices.FSharpChecker FSharp.Compiler.SourceCodeServices.FSharpChecker.Create(Microsoft.FSharp.Core.FSharpOption`1<Int32>, Microsoft.FSharp.Core.FSharpOption`1<Boolean>, Microsoft.FSharp.Core.FSharpOption`1<Boolean>, Microsoft.FSharp.Core.FSharpOption`1<Resolver>, Microsoft.FSharp.Core.FSharpOption`1<Microsoft.FSharp.Core.FSharpFunc`2<System.Tuple`2<System.String,System.DateTime>,Microsoft.FSharp.Core.FSharpOption`1<System.Tuple`3<System.Object,IntPtr,Int32>>>>, Microsoft.FSharp.Core.FSharpOption`1<Boolean>)'.
           at FSharpLint.Application.Lint.lintFile(OptionalLintParameters optionalParams, String filepath)

Repro steps

Use the package versions specified above and run a Fake target like

_Target "Lint" (fun _ ->
  let failOnIssuesFound (issuesFound: bool) =
    Assert.That(issuesFound, Is.False, "Lint issues were found")
  try
    let settings =
      Configuration.SettingsFileName
      |> Path.getFullName
      |> File.ReadAllText

    let lintConfig =
      FSharpLint.Application.ConfigurationManagement.loadConfigurationFile settings
    let options =
      { Lint.OptionalLintParameters.Default with Configuration = Some lintConfig }

    !!"**/*.fsproj"
    |> Seq.collect (fun n -> !!(Path.GetDirectoryName n @@ "*.fs"))
    |> Seq.distinct
    |> Seq.map (fun f ->
         match Lint.lintFile options f with
         | Lint.LintResult.Failure x -> failwithf "%A" x
         | Lint.LintResult.Success w ->
           w
           |> Seq.filter (fun x ->
                match x.Fix with
                | None -> false
                | Some fix -> fix.FromText <> "AltCover_Fake")) // special case
    |> Seq.concat
    |> Seq.fold (fun _ x ->
         printfn "Info: %A\r\n Range: %A\r\n Fix: %A\r\n====" x.Info x.Range x.Fix
         true) false
    |> failOnIssuesFound
  with ex ->
    printfn "%A" ex
    reraise())

Expected behavior

Linting happens

Actual behavior

Exception thrown as above

Known workarounds

Back off to previous tool versions.

Related information

  • Operating system - Windows
  • Branch - NuGet released package
  • .NET Runtime, CoreCLR or Mono Version - .net core 3.1.101

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
SteveGilhamcommented, Feb 21, 2020

More digging – root cause is that the compiler services assembly doesn’t do semantic versioning properly, if at all.

Decompiling the v34.1 compiler services assembly shows that whether by design or oversight there’s a parameter not marked as [OptionalArgument], though the .fsi file check in that added the 2 new arguments marks all arguments with a leading ?

public static FSharpChecker Create([OptionalArgument] FSharpOption<int> projectCacheSize,
 [OptionalArgument] FSharpOption<bool> keepAssemblyContents,
 [OptionalArgument] FSharpOption<bool> keepAllBackgroundResolutions,
 [OptionalArgument] FSharpOption<ReferenceResolver.Resolver> legacyReferenceResolver,
 [OptionalArgument] FSharpOption<FSharpFunc<Tuple<string, DateTime>,
 FSharpOption<Tuple<object, IntPtr, int>>>> tryGetMetadataSnapshot,
 [OptionalArgument] FSharpOption<bool> suggestNamesForErrors,
 [OptionalArgument] FSharpOption<bool> keepAllBackgroundSymbolUses, 
[OptionalArgument] FSharpOption<bool> enableBackgroundItemKeyStoreAndSemanticClassification)

while decompiling the Create() call in FSharpLint 0.13.0 shows it’s expanded to the missing method signature with fewer trailing arguments

	FSharpChecker checker = FSharpChecker.Create((FSharpOption<int>)null,
 (FSharpOption<bool>)null,
 (FSharpOption<bool>)null,
 (FSharpOption<Resolver>)null,
 (FSharpOption<FSharpFunc<Tuple<string, DateTime>, FSharpOption<Tuple<object, IntPtr,
 int>>>>)null,
 (FSharpOption<bool>)null);
``
0reactions
SteveGilhamcommented, Feb 25, 2020

This issue no longer reproduces with 0.13.2, now that I’ve tracked the FSharpLint API change between 0.13.1 and 0.13.2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FSharp.Compiler.Service uses latest TargetFramework ...
After some investigation what seems to be happening is when FSharpChecker.Compile is given an fsx file, it implicitly creates an fsproj file ...
Read more >
A definitive guide to API-breaking changes in .NET
Source-level break - an API change that results in existing code written to compile against older version of the API potentially not compiling...
Read more >
ASP.NET Core updates in .NET 8 Preview 7
NET 8 Preview 7 is now available and includes many great new improvements to ASP.NET Core. Here's a summary of what's new in...
Read more >
FSharp.Compiler.Service
Service package is a component derived from the F# compiler source code that ... expressions and declarations, where names have been resolved to...
Read more >
Versioning limitations in .NET - Jon Skeet's coding blog
My guess is that that means there really have been 11 sets of breaking changes, but that they're sufficiently unlikely to cause real...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found