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

Literate.ProcessScriptFile Broken with "System.TypeLoadException: Method 'get_LineCount' in type 'lexer@289' from assembly 'FSharp.CodeFormat, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation." #277

Closed
Indy9000 opened this issue Apr 4, 2015 · 10 comments · Fixed by #283

Comments

@Indy9000
Copy link
Contributor

Indy9000 commented Apr 4, 2015

Tried out with the default instructions on page F# Formatting: Literate programming
and updated the nuget packages to latest

Here's the build script

#I @"..\packages\FSharp.Formatting.2.7.5\lib\net40"
#I @"..\packages\FSharpVSPowerTools.Core.1.8.0\lib\net45"
#I @"..\packages\FSharp.Compiler.Service.0.0.87\lib\net45"
#r "FSharpVSPowerTools.Core.dll"
#r "FSharp.CodeFormat.dll"
#r "FSharp.Literate.dll"

open FSharp.Literate
open System.IO

let relative subdir = Path.Combine(__SOURCE_DIRECTORY__, subdir)

let file = relative "demo.fsx"
let output = relative "output/demo-script.html"
let template = relative "../templates/template-file.html"
Literate.ProcessScriptFile(file, template, output)

Error:

>System.TypeLoadException: Method 'get_LineCount' in type 'lexer@289' from assembly 'FSharp.CodeFormat, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
>   at FSharp.CodeFormat.CodeFormatAgent.ParseSource(String file, String source, FSharpOption`1 options, FSharpOption`1 defines) in c:\Tomas\Public\FSharp.Formatting\src\FSharp.CodeFormat\CodeFormatAgent.fs:line 389
>   at FSharp.Literate.ParseScript.parseScriptFile(String file, String content, CompilerContext ctx) in c:\Tomas\Public\FSharp.Formatting\src\FSharp.Literate\ParseScript.fs:line 197
>   at FSharp.Literate.Literate.ParseScriptFile[d](String path, FSharpOption`1 formatAgent, FSharpOption`1 compilerOptions, FSharpOption`1 definedSymbols, FSharpOption`1 references, FSharpOption`1 fsiEvaluator) in c:\Tomas\Public\FSharp.Formatting\src\FSharp.Literate\Main.fs:line 62
>   at FSharp.Literate.Literate.ProcessScriptFile(String input, FSharpOption`1 templateFile, FSharpOption`1 output, FSharpOption`1 format, FSharpOption`1 formatAgent, FSharpOption`1 prefix, FSharpOption`1 compilerOptions, FSharpOption`1 lineNumbers, FSharpOption`1 references, FSharpOption`1 fsiEvaluator, FSharpOption`1 replacements, FSharpOption`1 includeSource, FSharpOption`1 layoutRoots, FSharpOption`1 generateAnchors, FSharpOption`1 assemblyReferences) in c:\Tomas\Public\FSharp.Formatting\src\FSharp.Literate\Main.fs:line 152
@tpetricek
Copy link
Member

Can you try referencing the F# Formatting library using the load script FSharp.Formatting.fsx (rather than referencing individual packages using #r)?

Basically, I think that replacing the first 6 lines with the following should work:

 #load @"..\packages\FSharp.Formatting.2.7.5\FSharp.Formatting.fsx"

If this works, it would be great if you can send a pull request to update the "typical literate setup" section in the documentation (so that it recommends to use the load script): https://github.com/tpetricek/FSharp.Formatting/blob/master/docs/content/literate.fsx

@Indy9000
Copy link
Contributor Author

Indy9000 commented Apr 4, 2015

This doesn't work. Looks like it's FSharpVSPowerTools.Core.1.8.0 that's breaking it.
If I downgrade to version 1.7.0 it works.

@tpetricek
Copy link
Member

cc @vasily-kirichenko @dungpa I suppose that having a dependency on "any version newer than 1.7.0" is causing the troubles here. Should we have a dependency on exact version? Or should we just include the current version of PowerTools DLL in the package? (I guess that's what @forki would suggest and I think that might save us some pain...)

@dsyme
Copy link
Contributor

dsyme commented Apr 6, 2015

This is busted for me too. I used

nuget FSharp.Formatting 2.8.0
nuget FSharpVSPowerTools.Core 1.7.0

to work around it

matthid added a commit to matthid/Yaaf.AdvancedBuilding that referenced this issue Apr 6, 2015
dsyme added a commit to fsprojects/ProjectScaffold that referenced this issue Apr 6, 2015
This is a temporary fix for #156 until the problem with FSharp.Formatting is fixed (see fsprojects/FSharp.Formatting#277)
dungpa added a commit to dungpa/FSharp.Formatting that referenced this issue Apr 7, 2015
@dungpa
Copy link
Contributor

dungpa commented Apr 7, 2015

Sorry, it was a non-obvious breaking change. I sent a PR to pin VFPT to v1.8.0 exactly.

@tpetricek
Copy link
Member

Thanks!

@tpetricek
Copy link
Member

Well, the dependencies are causing more pain here....

Apparently, when we create FsiEvaluator from an FSI session, on .NET this loads whatever version of FSharp.Compiler.Service is already loaded (even if it is a different one (?)), but on Mono, this fails.

So, if we download FSharp.Compiler.Service version 0.89, but VFPT requires 0.87, then creating FsiEvaluator fails because it cannot find it (and since this is in FSI session started by FAKE, I really don't know where I would put binding redirects...).

I'll try fixing F# Compiler Service version too - basically, it looks like we should make sure that F# Formatting is compiled against the same version as VFPT (or ILMerge all the things...)

@tpetricek
Copy link
Member

(@dsyme Tried to explain to me at F# eXchange how deal with references properly, but I still don't get it... so maybe I'm missing something here. A better solution would be nice.)

@matthid
Copy link
Member

matthid commented Apr 24, 2015

See #303

@matthid
Copy link
Member

matthid commented Apr 24, 2015

@tpetricek Is there a way to reproduce the issue, just updating FCS seems to work: See #304. Maybe we should add a testcase to make that fail?

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

Successfully merging a pull request may close this issue.

5 participants