fsprojects / ProjectScaffold

A prototypical .NET solution (file system layout and tooling), recommended for F# projects
http://fsprojects.github.io/ProjectScaffold
The Unlicense
515 stars 154 forks source link

Generating reference documentation fails for PCL Profile259 and System.IO.* #211

Closed adamchester closed 8 years ago

adamchester commented 8 years ago

I created a new blank ProjectScaffold, added an F# PCL (Profile259) Library (VS 2015), added member x.TestMe = new System.IO.StringWriter(), then executed build. It fails to build.

projectscaffoldpcldocfailure

I don't fully understand why, but it seems that F# Formatting doesn't know what to do with the PCL types... Do I need to add some references somewhere? Is this a problem I need to raise with F# formatting, or here?

The relevant build error follows:

Generating 'C:\My\repo\TestPclScaffold\docs\tools\..\content/release-notes.html'
Help generated
Finished Target: GenerateHelp
Starting Target: GenerateReferenceDocs (==> RunTests, GenerateHelp)
FSharp.Formatting Information: 0 : FSharp.Formatting Logging setup!
Yaaf.FSharp.Scriping Information: 0 : Yaaf.FSharp.Scripting Logging setup!
Copying file: C:\My\repo\TestPclScaffold\docs\output\img\logo-template.pdn
Copying file: C:\My\repo\TestPclScaffold\docs\output\img\logo.png
Copying styles and scripts: C:\My\repo\TestPclScaffold\docs\output\content\style.css
Copying styles and scripts: C:\My\repo\TestPclScaffold\docs\output\content\style.css.bak
Copying styles and scripts: C:\My\repo\TestPclScaffold\docs\output\content\style_light.css
Copying styles and scripts: C:\My\repo\TestPclScaffold\docs\output\content\tips.js
Copying styles and scripts: C:\My\repo\TestPclScaffold\docs\output\content\img\github-blue.png
Copying styles and scripts: C:\My\repo\TestPclScaffold\docs\output\content\img\github.png
Creating C:\My\repo\TestPclScaffold\docs\output\reference
System.InvalidOperationException: The entity or value 'System.IO.StringWriter' does not exist or is in an unresolved assembly. You may need to add a reference to assembly 'System.IO'
   at Microsoft.FSharp.Compiler.SourceCodeServices.Impl.dflt@76[a](String asmName, String path) in C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\Symbols.fs:line 37
   at Microsoft.FSharp.Compiler.SourceCodeServices.Impl.protect[a](FSharpFunc`2 f) in C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\Symbols.fs:line 36
   at Microsoft.FSharp.Compiler.SourceCodeServices.FSharpEntity.get_MembersFunctionsAndValues() in C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\Symbols.fs:line 416
   at FSharp.MetadataFormat.Reader.getMembers@889-1.GenerateNext(IEnumerable`1& next) in C:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:line 0
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   at FSharp.MetadataFormat.Reader.readType@885.Invoke(String cat, IDictionary`2 cmds, Comment comment) in C:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:line 900
   at FSharp.MetadataFormat.Reader.readCommentsInto[a](ReadingContext ctx, String xmlDoc, FSharpFunc`2 f) in C:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:line 790
   at FSharp.MetadataFormat.Reader.readType(ReadingContext ctx, FSharpEntity typ) in C:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:line 885
   at FSharp.MetadataFormat.Reader.readModulesAndTypes@878-2.Invoke(ReadingContext ctx, FSharpEntity typ) in C:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:line 878
   at Microsoft.FSharp.Collections.IEnumerator.choose@202.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   at FSharp.MetadataFormat.Reader.readModulesAndTypes(ReadingContext ctx, IEnumerable`1 entities) in C:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:line 879
   at FSharp.MetadataFormat.Reader.readNamespace(ReadingContext ctx, String ns, IEnumerable`1 entities) in C:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:line 957
   at FSharp.MetadataFormat.Reader.readAssembly@997-1.Invoke(Tuple`2 tupledArg) in C:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:line 997
   at Microsoft.FSharp.Collections.IEnumerator.map@111.DoMoveNext(b& )
   at Microsoft.FSharp.Collections.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   at FSharp.MetadataFormat.Reader.readAssembly(FSharpAssembly assembly, Boolean publicOnly, String xmlFile, FSharpOption`1 sourceFolderRepo, FSharpFunc`2 urlRangeHighlight, Boolean markDownComments, IUrlHolder urlMap, String codeFormatCompilerArgs) in C:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:line 1000
   at <StartupCode$FSharp-MetadataFormat>.$Main.assemblies@1118-2.Invoke(Tuple`2 _arg2) in C:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:line 1123
   at Microsoft.FSharp.Collections.ListModule.chooseAllAcc[a,b](FSharpFunc`2 f, FSharpList`1 xs, FSharpList`1 acc)
   at FSharp.MetadataFormat.MetadataFormat.Generate(FSharpList`1 dllFiles, String outDir, FSharpList`1 layoutRoots, FSharpOption`1 parameters, FSharpOption`1 namespaceTemplate, FSharpOption`1 moduleTemplate, FSharpOption`1 typeTemplate, FSharpOption`1 xmlFile, FSharpOption`1 sourceRepo, FSharpOption`1 sourceFolder, FSharpOption`1 publicOnly, FSharpOption`1 libDirs, FSharpOption`1 otherFlags, FSharpOption`1 markDownComments, FSharpOption`1 urlRangeHighlight, FSharpOption`1 assemblyReferences) in C:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:line 1118
   at <StartupCode$FSI_0003>.$FSI_0003.main@() in C:\My\repo\TestPclScaffold\docs\tools\generate.fsx:line 140
Stopped due to error
Running build failed.
Error:
System.Exception: generating reference documentation failed
   at FSI_0001.Build.clo@185-19.Invoke(Unit _arg11)
   at Fake.TargetHelper.runSingleTarget(TargetTemplate`1 target) in C:\code\fake\src\app\FakeLib\TargetHelper.fs:line 483

---------------------------------------------------------------------
Build Time Report
---------------------------------------------------------------------
Target         Duration
------         --------
Clean          00:00:00.0067298
AssemblyInfo   00:00:00.0190892
Build          00:00:01.5366830
CopyBinaries   00:00:00.0193597
RunTests       00:00:01.2451498
CleanDocs      00:00:00.0105662
GenerateHelp   00:00:05.8688994
Total:         00:00:13.2202441
Status:        Failure
---------------------------------------------------------------------
  1) System.Exception: generating reference documentation failed
   at FSI_0001.Build.clo@185-19.Invoke(Unit _arg11)
   at Fake.TargetHelper.runSingleTarget(TargetTemplate`1 target) in C:\code\fake\src\app\FakeLib\TargetHelper.fs:line 483
---------------------------------------------------------------------

C:\My\repo\TestPclScaffold>
matthid commented 8 years ago

I think the problem is that we (in FSF) add references for the currently running runtime, but not for the runtime of the assembly we analyze. It's not that easy to solve this problem because we would need to be able to somehow read the interesting metadata from the project (see my comment here which resulted from the same underlying problem).

I think you can make this work by adding the required references yourself, or by compiling the project again for .net45 and use those assembly with FSF (which is what I usually do). Paket already adds the references the correct way so building for another framework is quite simple.

Is this a problem I need to raise with F# formatting?

Yes

adamchester commented 8 years ago

Thanks @matthid, I have now raised a new issue here https://github.com/tpetricek/FSharp.Formatting/issues/346