10

I am currently working on a project to implementing mutation-testing for F#. To access the FCS process I am using the FSharp.Compiler.Service package.

I am having some trouble with the compilation process and the compiled DLL.

I'm using FSharp.Compiler.Service to compile a project's AST's to

  • a dll. Another program references this dll. When compiled in visual studio everything works. When compiled from the AST's using compiler services I get method not found exceptions on every call.

  • an executable dll. However I always get the error entrypoint is not the last declaration. When inspecting what I pass to the compilation the entrypoint AST is the last AST in the list, and the entrypoint node is the last node in the AST. When compiling in visual studio there are no issues.

Has anyone encountered these issues before? Or knows a way to fix the errors I’m getting?

dukedagmor
  • 171
  • 5

2 Answers2

3

I have done this many times. You might want to post what the input arguments are when you are trying to compile, the lack of something in the input is often the cause for an error.

7sharp9
  • 2,147
  • 16
  • 27
  • this is my current method: ```private (bool, FSharpErrorInfo[]) TryCompilation(FSharpChecker checker, FSharpList trees, List pathlist, FSharpList dependencies , List pdblist) { Tuple result = FSharpAsync.RunSynchronously( checker.Compile( trees, AssemblyName, pathlist.First(), dependencies, null, true, rue, null), null, null); return (result.Item2 == 0, result.Item1); }``` I've tried it with pdb but that doesn't seem to make a difference – dukedagmor Nov 20 '20 at 18:15
  • 1
    I meant like these type inputs: https://github.com/7sharp9/soothsayer/blob/master/soothsayer/soothsayer.fs#L27-L39 – 7sharp9 Nov 20 '20 at 18:21
  • there is no way to give those to the compile function when using AST (that I am aware of) – dukedagmor Nov 20 '20 at 18:24
  • @7sharp9 We don't get our inputs from fsharp compiler services, we get all our inputs from a tool called Buildalyzer. Do you think some of the AST's or references might by missing? – Mobrockers Nov 21 '20 at 21:49
  • I have never heard of `Buildalyzer` sorry. – 7sharp9 Nov 25 '20 at 13:09
  • What I would do is manually build up what you think the inputs should be, removing Buildalyzer from the equation. Without any reference code its difficult to make many suggestions. – 7sharp9 Nov 25 '20 at 13:11
2

Updating from FSharp.Compiler.Service 37 to 38 has resolved the methodnotfound error

By hardcoding the islastcompiled in the parsedinput (syntaxtree) to Tuple(true,true) in the syntaxtree containing the entrypoint, the error doesn't trigger.

The islastcompiled solution is sketchy and I would like to have a better way to do this.

dukedagmor
  • 171
  • 5