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

FSharp.Formatting error if I include FSharp.Data and use CSV type provider #309

Open
oscarvarto opened this issue Aug 28, 2017 · 1 comment

Comments

@oscarvarto
Copy link

oscarvarto commented Aug 28, 2017

Description

Adding type Stocks = CsvProvider<"./data/MSFT.csv"> to https://github.com/fsprojects/ProjectScaffold/blob/master/src/FSharp.ProjectTemplate/Library.fs causes a FSharp.Formatting Error

Repro steps

Please provide the steps required to reproduce the problem

1.a Use forge new scaffold to create a new Scaffold.
1.b Add nuget FSharp.Data to group Build in paket.dependencies: https://github.com/fsprojects/ProjectScaffold/blob/master/paket.dependencies#L18
1.c Modify https://github.com/fsprojects/ProjectScaffold/blob/master/src/FSharp.ProjectTemplate/Library.fs and call CsvProvider (something like this):

namespace ProcessingData

open FSharp.Data

/// Stock prices example
type Stocks = CsvProvider<"./data/MSFT.csv">

/// Documentation for my library
///
/// ## Example
///
///     let h = Library.hello 1
///     printfn "%d" h
///
module Library = 
  /// Returns 42
  ///
  /// ## Parameters
  ///  - `num` - whatever
  let hello num = 42

1.d Add a data folder inside project folder (in my case [root project folder]/src/ProcessingData) and put http://fsharp.github.io/FSharp.Data/data/MSFT.csv inside it.

  1. Use .\build.cmd to run all the targets.

Expected behavior

Build correctly.

Actual behavior

I am getting the following error for GenerateReferenceDocs target:

Starting Target: GenerateReferenceDocs (==> RunTests, GenerateHelp)                                                                                                      
Building documentation (Default), this could take some time, please wait...                                                                                              
C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\packages\build\FAKE\tools\FAKE.exe  --fsiargs -d:FAKE -d:RELEASE -d:REFERENCE "generate.fsx"                      
FSharp.Formatting Information: 0 : FSharp.Formatting Logging setup!                                                                                                      
Yaaf.FSharp.Scripting Information: 0 : Yaaf.FSharp.Scripting Logging setup!                                                                                              
Copying file: C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\docs\img\logo-template.pdn                                                                          
Copying file: C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\docs\img\logo.png                                                                                   
Copying styles and scripts: C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\docs\content\style.css                                                                
Copying styles and scripts: C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\docs\content\style.css.bak                                                            
Copying styles and scripts: C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\docs\content\style_light.css                                                          
Copying styles and scripts: C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\docs\content\tips.js                                                                  
Copying styles and scripts: C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\docs\content\img\github-blue.png                                                      
Copying styles and scripts: C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\docs\content\img\github.png                                                           
Deleting contents of C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\docsrc\tools\../../docs\reference                                                            
FSharp.Formatting Error: 0 : Could not read comments from entity 'ProcessingData.Stocks': Microsoft.FSharp.Compiler.ErrorLogger+ReportedError: Exception of type 'Microso
ft.FSharp.Compiler.Tast+InternalUndefinedItemRef' was thrown.                                                                                                            
   at Microsoft.FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.Error[b](ErrorLogger x, Exception exn) in C:\Users\robin\dev\FSharp.Compiler.Service\src\fs
harp\ErrorLogger.fs:line 313                                                                                                                                             
   at Microsoft.FSharp.Compiler.Tast.EntityRef.get_Deref() in C:\Users\robin\dev\FSharp.Compiler.Service\src\fsharp\tast.fs:line 2684                                    
   at Microsoft.FSharp.Compiler.Tastops.stripTyEqnsA(TcGlobals g, Boolean canShortcut, TType ty) in C:\Users\robin\dev\FSharp.Compiler.Service\src\fsharp\TastOps.fs:line
 627                                                                                                                                                                     
   at Microsoft.FSharp.Compiler.Tastops.extensionInfoOfTy(TcGlobals g, TType ty) in C:\Users\robin\dev\FSharp.Compiler.Service\src\fsharp\TastOps.fs:line 1464           
   at Microsoft.FSharp.Compiler.Tastops.metadataOfTy(TcGlobals g, TType ty) in C:\Users\robin\dev\FSharp.Compiler.Service\src\fsharp\TastOps.fs:line 1489                
   at Microsoft.FSharp.Compiler.Infos.GetImmediateIntrinsicPropInfosOfType(FSharpOption`1 optFilter, AccessorDomain ad, TcGlobals g, ImportMap amap, range m, TType typ) 
in C:\Users\robin\dev\FSharp.Compiler.Service\src\fsharp\infos.fs:line 3293                                                                                              
   at <StartupCode$FSharp-Compiler-Service>[email protected](IEnumerable`1& next) in C:\Users\robin\dev\FSharp.Compiler.Service\
src\fsharp\vs\Symbols.fs:line 426                                                                                                                                        
   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 <StartupCode$FSharp-Compiler-Service>[email protected](Unit unitVar0) in C:\Users\robin\dev\FSharp.Compiler.Service\src\fsharp\vs\
Symbols.fs:line 412                                                                                                                                                      
   at Microsoft.FSharp.Compiler.SourceCodeServices.Impl.protect[a](FSharpFunc`2 f) in C:\Users\robin\dev\FSharp.Compiler.Service\src\fsharp\vs\Symbols.fs:line 27        
   at Microsoft.FSharp.Compiler.SourceCodeServices.FSharpEntity.get_MembersFunctionsAndValues() in C:\Users\robin\dev\FSharp.Compiler.Service\src\fsharp\vs\Symbols.fs:li
ne 411                                                                                                                                                                   
   at [email protected](IEnumerable`1& next) in c:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:l
ine 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 [email protected](String cat, IDictionary`2 cmds, Comment comment) in c:\Tomas\Public\tpetricek\FSharp.Formatting\src\FSharp.Metada
taFormat\Main.fs:line 1070                                                                                                                                               
   at FSharp.MetadataFormat.Reader.readCommentsInto[a](FSharpSymbol sym, ReadingContext ctx, String xmlDoc, FSharpFunc`2 f) in c:\Tomas\Public\tpetricek\FSharp.Formattin
g\src\FSharp.MetadataFormat\Main.fs:line 944                                                                                                                             
FSharp.Formatting Information: 0 : Starting razor engine                                                                                                                 
FSharp.Formatting Information: 0 : Generating: index.html                                                                                                                
FSharp.Formatting Information: 0 : Generating modules...                                                                                                                 
FSharp.Formatting Information: 0 : Generating module: processingdata-library                                                                                             
FSharp.Formatting Information: 0 : Finished module: processingdata-library                                                                                               
FSharp.Formatting Information: 0 : Generating types...                                                                                                                   
Finished Target: GenerateReferenceDocs

Known workarounds

None yet :(

Related information

  • Operating system
    Windows 10 Pro 64 bits (running on top of Parallels 12 for Mac).

  • Branch

  • .NET Runtime, CoreCLR or Mono Version

** Verifying the fsc version:

fsc --help
Microsoft (R) F# Compiler version 14.0.23020.0
  • I have already installed VS 2017 15.3.2

  • PATH Environment variables:

PS C:\Users\oscarvarto> $env:path.split(";")
C:\Program Files\ConEmu\ConEmu\Scripts
C:\Program Files\ConEmu
C:\Program Files\ConEmu\ConEmu
C:\Program Files (x86)\Parallels\Parallels Tools\Applications
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\
C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\
C:\Program Files\Microsoft SQL Server\120\Tools\Binn\
C:\Program Files\Microsoft SQL Server\120\DTS\Binn\
C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\
C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\
C:\Program Files\Microsoft SQL Server\130\Tools\Binn\
C:\Program Files\dotnet\
C:\Program Files (x86)\Xoreax\IncrediBuild
C:\Program Files\Git\cmd
C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\
C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\
C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\
C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\
C:\ProgramData\chocolatey\bin
C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0
C:\Users\oscarvarto\scoop\shims
C:\Users\oscarvarto\AppData\Local\Microsoft\WindowsApps

I think my installation is not respecting/using this variable, because at the top of the build, I get a message saying that version 15.3.409.57025 of MSBuild is being used:

Starting Target: Build (==> AssemblyInfo)
Building project: C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\ProcessingData.sln
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe  C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\ProcessingData.sln /t:Rebuild /m  /nodeReuse:False    /p:RestorePackages="False" /p:Configuration="Release" /p:Configuration="Release" /p:Platform="Any CPU" /logger:Fake.MsBuildLogger+ErrorLogger,"C:\Users\oscarvarto\gitRepos\dotnetWork\ProcessingData\packages\build\FAKE\tools\FakeLib.dll"
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
  • FSHARPINSTALLDIR pointing to C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\ (I guess VS 2017 installation added that).

Maybe this variable is messing with my build, because I am also getting a message about F# 4.1 being used:

 CoreCompile:
         C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\fsc.exe -o:obj\Release\ProcessingData.dll
  • Related issues:

fsprojects/FSharp.Formatting#423
fsprojects/FSharp.Formatting#325

@pblasucci
Copy link
Collaborator

pblasucci commented Aug 29, 2017

So, here are my initial thoughts:

  • This is almost certainly not an issue with ProjectScaffold (that having been said...)

  • Have you tried deleting the FAKE cache (it's the .fake folder at the root of your local repository)?

  • Have you tried pinning (in Paket) the versions of FSharp.Compiler.Service and/or FSharp.Formatting (note: you may have to play around with going up or down a version or two in each project)?

  • Also, I'm pretty sure you do want to be using F# 4.1. But I agree the MSBuild versions are... troubling.

  • Oh, also, what version of the runtime are you targeting (e.g. .NET Framework 4.6.1, .NET Stanard 2.0, et cetera)?

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

No branches or pull requests

2 participants