【问题标题】:FSharp.Compiler.Service compile to dll errorsFSharp.Compiler.Service 编译为 dll 错误
【发布时间】:2021-03-03 19:41:42
【问题描述】:

我目前正在开展一个为 F# 实施突变测试的项目。 为了访问 FCS 进程,我使用了 FSharp.Compiler.Service 包。

我在编译过程和编译的 DLL 方面遇到了一些问题。

我正在使用 FSharp.Compiler.Service 将项目的 AST 编译为

  • 一个dll。另一个程序引用了这个 dll。在 Visual Studio 中编译时,一切正常。当使用编译器服务从 AST 编译时,每次调用都会出现方法未找到异常。

  • 一个可执行的 dll。但是我总是得到错误入口点不是最后一个声明。在检查我传递给编译的内容时,入口点 AST 是列表中的最后一个 AST,入口点节点是 AST 中的最后一个节点。在 Visual Studio 中编译时没有问题。

以前有人遇到过这些问题吗?或者知道解决我遇到的错误的方法吗?

【问题讨论】:

    标签: .net dll f# mutation-testing


    【解决方案1】:

    我已经做过很多次了。您可能想在尝试编译时发布输入参数的内容,输入中缺少某些内容通常是导致错误的原因。

    【讨论】:

    • 这是我目前的方法:private (bool, FSharpErrorInfo[]) TryCompilation(FSharpChecker checker, FSharpList<ParsedInput> trees, List<string> pathlist, FSharpList<string> dependencies , List<string> pdblist) { Tuple<FSharpErrorInfo[], int> result = FSharpAsync.RunSynchronously( checker.Compile( trees, AssemblyName, pathlist.First(), dependencies, null, true, rue, null), null, null); return (result.Item2 == 0, result.Item1); } 我已经用 pdb 尝试过,但似乎没有什么不同
    • 我的意思是喜欢这些类型的输入:github.com/7sharp9/soothsayer/blob/master/soothsayer/…
    • 在使用 AST(我知道)时无法将它们提供给编译函数
    • @7sharp9 我们不是从 fsharp 编译器服务中获取输入,而是从一个名为 Buildalyzer 的工具中获取所有输入。您认为某些 AST 或参考文献可能会丢失吗?
    • 我从未听说过Buildalyzer 抱歉。
    【解决方案2】:

    从 FSharp.Compiler.Service 37 更新到 38 已解决methodnotfound错误

    通过将已解析输入(语法树)中的 islastcompiled 硬编码为包含入口点的语法树中的 Tuple(true,true),不会触发错误。

    islastcompiled 解决方案是粗略的,我希望有更好的方法来做到这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-09
      • 1970-01-01
      • 1970-01-01
      • 2015-12-06
      • 2014-10-21
      • 1970-01-01
      • 2011-06-14
      相关资源
      最近更新 更多