fsharp / fsharp-compiler-docs Goto Github PK
View Code? Open in Web Editor NEWDoc build for FSharp.Compiler.Service
Home Page: https://fsharp.github.io/fsharp-compiler-docs
License: MIT License
Doc build for FSharp.Compiler.Service
Home Page: https://fsharp.github.io/fsharp-compiler-docs
License: MIT License
The tooltips usually show something like JsonProvider<...>.TypeA
. When you're trying to refactor code and need to put type annotation, this is not every useful, because you can't put this type there. It would be better if it shown a type alias if there is one (there usually is in type provider usage), otherwise it's very confusing for new users.
This also affects VS, but if we could fix it here (which would then propagate to XS), we could later try the VS team to get it also
It's always set to false, even when the parameter has IsOptional set to true and there's a default value in the DefaultValue property.
Hi. I'm trying to add the xml docs from typeproviders to FSharp.Formatting. I noticed that XmlDoc has content for them, but not XmlDocSig, which is what's FSharp.Formatting is using. Can someone please explain me the difference from XmlDocSig and XmlDoc in FSharpEntity?
With recently added multi-project analysis, it would be great if we are able to check which assembly/project a symbol is declared.
This information enables us to analyze projects more efficiently without resorting to analyzing all projects every time.
After initializing the fsiSession
using the standard snippet from the documentation, the following returns None
:
fsiSession.EvalExpression("(fun a -> a + 1)")
However, the following works fine:
fsiSession.EvalExpression("System.Func<int, int>(fun a -> a + 1)")
See also StackOverflow question.
The FSharp.Compiler.Service has a FileSystem API available through the following mutable global:
Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.Shim.FileSystem
Setting this means that all file system operations (e.g. "open c:\foo\bar.dll") go through this shim. This can be used to simulate a file system or project context when hosting the compiler in a very different logical context, e.g. in an application.
We should document how to this API as it is very important for many hosting situations.
Much of the compiler code base currently relies on global mutable state. This comes with the following implications:
We should improve this situation, either by making global mutable state thread safe or even completely refactoring the relevant code so that it becomes referentially transparent.
File est.fs contains line:
System.Diagnostics.Debug.Assert(false, e.ToString()) // what other exceptions might occur?
The answer is "System.UnauthorizedAccessException"
For example:
let f x =
match x with
| [h]
| [_; h]
| [_; _; h] -> h
| _ -> 0
If getting symbol uses where cursor is at the last occurrence of h
, only two symbol uses (the first and the last occurrence of h
) are returned.
Related to fsprojects-archive/zzarchive-VisualFSharpPowerTools#139.
Moving this issue here: fsprojects/zarchive-fsharpbinding#303
Analysing the code below caused a problem in Xamarin Studio
let ratherlongfunction(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) =
a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z
let ratherlongfunction2 a b c d e f g h i j k l m n o p q r s t u v w x y z =
a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z
I get the following error when I execute the GenerateDocs target:
Finished Target: RunTests
Finished Target: All
Finished Target: PrepareRelease
Deleting contents of docs/output
Finished Target: CleanDocs
fsharpi --define:RELEASE generate.fsx
Copying file: /Users/dave/code/FSharp.Compiler.Service_/docs/output/.DS_Store
Copying file: /Users/dave/code/FSharp.Compiler.Service_/docs/output/images/logo.png
Copying styles and scripts: /Users/dave/code/FSharp.Compiler.Service_/docs/output/content/style.css
Copying styles and scripts: /Users/dave/code/FSharp.Compiler.Service_/docs/output/content/tips.js
Generating 'compiler.html'
System.Exception: Generating HTML failed.
at Microsoft.FSharp.Core.Operators.FailWith[String] (System.String message) [0x00000] in <filename unknown>:0
at FSharp.Literate.RazorRender.ProcessFile[IDictionary`2] (System.String source, Microsoft.FSharp.Core.FSharpOption`1 properties) [0x00000] in <filename unknown>:0
at FSharp.Literate.Templating.generateFile (System.String contentTag, IEnumerable`1 parameters, Microsoft.FSharp.Core.FSharpOption`1 templateOpt, System.String output, IEnumerable`1 layoutRoots) [0x00000] in <filename unknown>:0
at FSharp.Literate.Templating.processFile (FSharp.Literate.LiterateDocument doc, System.String output, FSharp.Literate.ProcessingContext ctx) [0x00000] in <filename unknown>:0
at FSharp.Literate.Literate.ProcessScriptFile (System.String input, Microsoft.FSharp.Core.FSharpOption`1 templateFile, Microsoft.FSharp.Core.FSharpOption`1 output, Microsoft.FSharp.Core.FSharpOption`1 format, Microsoft.FSharp.Core.FSharpOption`1 formatAgent, Microsoft.FSharp.Core.FSharpOption`1 prefix, Microsoft.FSharp.Core.FSharpOption`1 compilerOptions, Microsoft.FSharp.Core.FSharpOption`1 lineNumbers, Microsoft.FSharp.Core.FSharpOption`1 references, Microsoft.FSharp.Core.FSharpOption`1 replacements, Microsoft.FSharp.Core.FSharpOption`1 includeSource, Microsoft.FSharp.Core.FSharpOption`1 layoutRoots) [0x00000] in <filename unknown>:0
at <StartupCode$FSharp-Literate>[email protected] (System.String file, System.String output) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Core.FSharpFunc`2[System.String,System.String].InvokeFast[Unit] (Microsoft.FSharp.Core.FSharpFunc`2 func, System.String arg1, System.String arg2) [0x00000] in <filename unknown>:0
at <StartupCode$FSharp-Literate>[email protected] (System.String indir, System.String outdir) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Core.FSharpFunc`2[System.String,System.String].InvokeFast[Unit] (Microsoft.FSharp.Core.FSharpFunc`2 func, System.String arg1, System.String arg2) [0x00000] in <filename unknown>:0
at FSharp.Literate.Literate.ProcessDirectory (System.String inputDirectory, Microsoft.FSharp.Core.FSharpOption`1 templateFile, Microsoft.FSharp.Core.FSharpOption`1 outputDirectory, Microsoft.FSharp.Core.FSharpOption`1 format, Microsoft.FSharp.Core.FSharpOption`1 formatAgent, Microsoft.FSharp.Core.FSharpOption`1 prefix, Microsoft.FSharp.Core.FSharpOption`1 compilerOptions, Microsoft.FSharp.Core.FSharpOption`1 lineNumbers, Microsoft.FSharp.Core.FSharpOption`1 references, Microsoft.FSharp.Core.FSharpOption`1 replacements, Microsoft.FSharp.Core.FSharpOption`1 includeSource, Microsoft.FSharp.Core.FSharpOption`1 layoutRoots) [0x00000] in <filename unknown>:0
at FSI_0002.buildDocumentation () [0x00000] in <filename unknown>:0
at <StartupCode$FSI_0002>.$FSI_0002.main@ () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
Processing the file '/Users/dave/code/FSharp.Compiler.Service_/docs/tools/../../packages/FSharp.Formatting.2.3.4-beta/templates/docpage.cshtml' failed
Source written to: '/var/folders/5v/p_5h35nd70s8x7fh8fqn7hyh0000gn/T/tmp647f9dac.tmp.cs'
Compilation errors:
Stopped due to error
see http://fsharp.github.io/FSharp.Compiler.Service/interactive.html
the code is very big and rendered over the menu.
Add some line breaks in the code samples
Given the following code:
module Lists =
let testDate = System.DateTime.DaysInMonth(2014, 1)
module BoilerPlateForForm =
[<System.STAThread>]
do ()
If a symbol request is made at: let testDate = System.D§ateTime.DaysInMonth(2014, 1)
then the following range is returned:
Symbol usage: ("/Users/dave/Projects/tutorial/tutorial/Tutorial.fs", ((1, 26), (1, 34)))
which is DateTime
However if this is requested: let testDate = System.DateTime.D§aysInMonth(2014, 1)
Then the following is returned:
Symbol usage: ("/Users/dave/Projects/tutorial/tutorial/Tutorial.fs", ((1, 19), (1, 46)))
which is System.DateTime.DaysInMonth
I tried building the source and I'm getting three test failures on my machine. Here are the details for one of them:
1) Test Error : FSharp.Compiler.Service.Tests.FscTests.1. PEVerifier sanity check
System.InvalidOperationException : Cannot start process because a file name has not been provided.
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at FSharp.Compiler.Service.Tests.FscTests.PEVerifier.execute(String fileName, String arguments) in c:\Tomas\Public\FSharp.Compiler.Service\tests\service\FscTests.fs:line 40
at FSharp.Compiler.Service.Tests.FscTests.PEVerifier.Verify(String assemblyPath) in c:\Tomas\Public\FSharp.Compiler.Service\tests\service\FscTests.fs:line 47
at FSharp.Compiler.Service.Tests.FscTests.1. PEVerifier sanity check() in c:\Tomas\Public\FSharp.Compiler.Service\tests\service\FscTests.fs:line 102
The other test failures look the same and are in:
Given a snippet thats matching a FSharpSymbol:
match fsSymbol with
...
// Members, Module-defined functions and Module-definned values
| :? FSharpMemberFunctionOrValue as fsMember when fsMember.IsModuleValueOrMember ->
let fsEntity = fsMember.EnclosingEntity
let assemblyFilename = match fsEntity.Assembly.FileName with None -> "" | Some
...
The fsEntity.Assembly.FileName
will be None, but `fsSymbol.Assembly.FileName will be Some.
Is that expected?
I think FSharp.PowerPack.Metadata would be excellent for assembly-based features.
FSharp.Formatting has already used it for API documentation. Moreover, View F# signature in VS/XS could be implemented using FSharp.PowerPack.Metadata. Maintaining it here would avoid fragmentation, and have improvements/bug fixes in a central place.
I could submit a pull request if needed.
IsInfinity
here:
let inline check< ^T when ^T : (static member IsInfinity : ^T -> bool)> (num: ^T) : ^T option =
if (^T : (static member IsInfinity: ^T -> bool) (num)) then None
else Some num
The following code tests different ways to reference an assembly using various combinations of command-line and/or #-directives.
let test otherFlags sourceBeginning =
let source = sourceBeginning + "open IntelliFactory.Core;;"
let ic = InteractiveChecker.Create()
let options = ic.GetProjectOptionsFromScript(@"C:\file.fsx", source, otherFlags = otherFlags)
let parseResults = ic.ParseFileInProject(@"C:\file.fsx", source, options)
match ic.CheckFileInProject(parseResults, @"C:\file.fsx", 1, source, options) |> Async.RunSynchronously with
| CheckFileAnswer.Aborted -> ()
| CheckFileAnswer.Succeeded checkResult ->
printfn "%i errors." checkResult.Errors.Length
for error in checkResult.Errors do
printfn "%s" error.Message
printfn ""
let asmname = "IntelliFactory.Core.dll"
let dirname = "c:/path/to/where/IntelliFactory.Core/is"
printfn "Using absolute -r:"
test [| sprintf "-r:%s/%s" dirname asmname |] ""
printfn "Using -I and relative -r:"
test [| sprintf "-I:%s" dirname; sprintf "-r:%s" asmname |] ""
printfn "Using -I and relative #r:"
test [| sprintf "-I:%s" dirname |] (sprintf """#r "%s";;""" asmname)
printfn "Using #i and relative #r:"
test [||] (sprintf """#I "%s";; #r "%s";;""" dirname asmname)
printfn "Using absolute #r:"
test [||] (sprintf """#r "%s/%s";;""" dirname asmname)
The output is:
Using absolute -r:
0 errors.
Using -I and relative -r:
0 errors.
Using -I and relative #r:
3 errors.
Assembly reference 'IntelliFactory.Core.dll' was not found or is invalid
Assembly reference 'IntelliFactory.Core.dll' was not found or is invalid
The namespace or module 'IntelliFactory' is not defined
Using #i and relative #r:
0 errors.
Using absolute #r:
0 errors.
As you can see, when passing the include directory via the command line and referencing the assembly via #r, the reference is not found.
This is of course inconsistent with fsi
's behavior, which finds the reference correctly:
$ fsi -I:c:/path/to/where/IntelliFactory.Core/is --nologo <<EOF
> #r "IntelliFactory.Core.dll"
> open IntelliFactory.Core
> EOF
>
--> Referenced 'c:/path/to/where/IntelliFactory.Core/is\IntelliFactory.Core.dll'
$
Running the unit tests for F# Formatting currently gives the following error (see travis log):
Errors and Failures:
1) Test Error : FSharp.MetadataFormat.Tests.MetadataFormat works on sample Deedle assembly
System.InvalidOperationException : not a named type
at <StartupCode$FSharp-Compiler-Service>[email protected] (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.SourceCodeServices.Impl.protect[FSharpEntity] (Microsoft.FSharp.Core.FSharpFunc`2 f) [0x00000] in <filename unknown>:0
I believe this used to work in the earlier version - do we need to change something somewhere in F# Formatting?
I couldn't find any notes about this requirement, but is it intended?
When I uninstall "F# Tools for Visual Studio Express 2012 for Web",
I've got the following errors when running "build.cmd RunTests" command:
***** FSharp.Compiler.Service.Tests.FscTests.2. Simple FSC library test
args: [|"fsc.exe"; "--target:library"; "--debug:pdbonly";
"--pdb:C:\Users\yukitos\AppData\Local\Temp\2\Foo.pdb";
"--out:C:\Users\yukitos\AppData\Local\Temp\2\Foo.dll";
"C:\Users\yukitos\AppData\Local\Temp\2\Foo.fs"|]
error: unknown (0,0)-(0,80) parse error File 'C:\work\github\FSharp.Compiler.Service\bin\FSharp.Core.optdata' not found alongside FSharp.Core
error: unknown (0,0)-(0,80) parse error Error opening binary file 'C:\work\github\FSharp.Compiler.Service\bin\FSharp.Core.dll': File 'C:\work\github\FSharp.Compiler.Service\bin\FSharp.Core.optdata' not found alongside FSharp.Core
error: unknown (0,0)-(0,80) parse error Problem reading assembly 'FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a': Error opening binary file 'C:\work\github\FSharp.Compiler.Service\bin\FSharp.Core.dll': File 'C:\work\github\FSharp.Compiler.Service\bin\FSharp.Core.optdata' not found alongside FSharp.Core
These errors have also been occurred during "3. Simple FSC executable test".
Please let me clarify requirements.
Thanks and regards,
EvalExpression and EvalInteraction need to have better specified exception behaviour
Hi,
In the documentation tutorial (Tokenizing single line: http://fsharp.github.io/FSharp.Compiler.Service/tokenizer.html)
If you print out the state of the tokenizer, you will see that the state returned by the ScanToken method is a constant value, whatever the token is.
Something like 32769L (sorry I'm on a mobile I can't verify).
That makes the tokenizer undeterministic and stateful, is that expected?
Thanks :)
On adding the missing SimpleSourceCodeServices the following are missing on compilation:
.../FSharp.Compiler.Service_/src/fsharp/vs/SimpleServices.fs(178,23): error FS0039: The type 'ErrorLoggerProvider' is not defined
.../FSharp.Compiler.Service_/src/fsharp/vs/SimpleServices.fs(186,21): error FS0039: The value or constructor 'typecheckAndCompile' is not defined
Would be really excellent to host the F# compiler within a Windows Store, Windows Phone, etc. application for the purposes of exposing F# Interactive scripting, assuming that will eventually make it into this project.
All file system operations in FSharp.Compiler.Service should go through the FileSystem API in the compiler, to allow the file system to be replaced by the host of this component.
This was carefully checked for F# 3.0, but we shold also check this for F# 3.1 code additions.
Trying to run fsformatting.exe on our project, some assemblies were not properly resolved. After debugging, I found out, that the assembly search paths are in fact correctly passed to the InteractiveChecker.
But as it turns out, the assemblies that could not be resolved are all .exe assemblies, which hints towards not fully implemented assembly resolving in the interactive checker or somewhere else in FSharp.Compiler.Service
I had to add:
to get the code from the docs to run. Should this be in the docs?
When using CheckFileInProject, the whole project is checked before results are returned.
Only the prefix of the project should be checked. This is particularly important for ecficiency with rename refactoring and other such operations.
This was originally raised in the F# addin (Rename misses method in implementation class)
OS: Mac OS X 10.9.1
Xamarin Studio: 4.2.3 (Build 54) [beta channel]
Mono: 3.2.6
F#: 3.0
F#Binding: 4.2.3 (manually installed from recent dfba3089ae217b82089a80fd4f9175d4f00f9ccc)
Having the following code:
type IFoo =
abstract member name: string
type FooImpl(name: string) =
interface IFoo with
member this.name = name
let name_of (foo: IFoo) =
foo.name
if I rename the name
member to myName
, then it is not refactored in the implementing class FooImpl
(but it is refactored in the using function name_of
). What I actually get after the rename is:
type IFoo =
abstract member myName: string
type FooImpl(name: string) =
interface IFoo with
member this.name = name
let name_of (foo: IFoo) =
foo.myName
Given the following code:
module Lists =
let testDate = System.DateTime.DaysInMonth(2014, 1)
module BoilerPlateForForm =
[<System.STAThread>]
do ()
With a symbol request of let testDate = S§ystem.DateTime.DaysInMonth(2014, 1)
using: GetSymbolAtLocation: line: 1, Col: 20, Line: let testDate = System.DateTime.DaysInMonth(2014, 1), ident: ["System"]
No result is returned
To be able to do fsprojects/FSharp.Formatting#143 properly
Analysis and refactoring tools require deep understanding of F# types and name resolution. SourceCodeServices
is good enough for editors, but too restrictive for the tools above.
It would be great to have name resolution (e.g. https://github.com/fsharp/FSharp.Compiler.Service/blob/master/src/fsharp/nameres.fsi#L85) and typed ASTs (as per https://github.com/fsharp/FSharp.Compiler.Service/blob/master/src/fsharp/tast.fs#L13) to be exposed. With this information, we don't have to reconstruct name resolution and type information by ourselves.
Does this make sense to do? I heard something to be done in this area, but I'm not sure what the agenda is.
It's found in FSharpVSPowerTools
here:
Related issue fsprojects-archive/zzarchive-VisualFSharpPowerTools#29
Let me start by saying that I am very pleased to see this project turn up, particularly since it has the potential of making my work with mbrace much easier. I am refering to the mbrace shell, which is essentially a modified fsi capable of persisting interactions to assembly files for distribution.
I would like to propose adding a custom version of F# interactive that is capable of introspecting the AST's (be they typed or untyped) of its own interactions. The api would be something along the lines of adding a static facade in the FSharp.Compiler.Service.Shell
namespace that looks like this:
type ShellIntrospection =
class
static member IsFsiProcess : bool
static member GetInteractionAst : idx:int -> ParsedInput list
end
Assuming that the IsFsiProcess
property is true, calling GetInteractionAst
with argument 1 would return the AST for interaction FSI_0001
, assuming it has already materialized.
If you want, I could contribute the relevant code.
It would provide the basis to bring cross-F#-project rename refactoring and find all references to Xamarin Studio and Visual Studio.
We can use single-project analysis, resolve project dependencies and recompile everything as a workaround. However, it loses incrementality property which is a must for the scale of multi-project analysis.
This would provide useful information in manipulating symbols.
See related thread fsprojects-archive/zzarchive-VisualFSharpPowerTools#143.
Perhaps I've watched one too many Alan Kay talks. Nevertheless, I'll throw this out there: I would like to invoke the compiler from within a F# project on itself. In other words, while writing the code, I would like to be able to have the compiler service build the current library by executing the compiler within the library.
I hope that makes sense. I know what I want to do, but I'm not sure how to explain it. Assuming you understand my request, does this version of the compiler allow it?
Given the following example:
module Lists =
let list1 = [ ] /// an empty list
let list2 = [ 1; 2; 3 ] /// list of 3 elements
let list3 = 42 :: list2 /// a new list with '42' added to the beginning
let numberList = [ 1 .. 1000 ] /// list of integers from 1 to 1000
let fred = System.Text.StringBuilder()
module BoilerPlateForForm =
[<System.STAThread>]
do ()
If I ask for symbols at let fr§ed = System.Text.StringBuilder()
I get back two usages rather than the expected one:
Symbol display name: fred
Symbol range: ("/Users/dave/Projects/tutorial/tutorial/Tutorial.fs", ((10, 8), (10, 12)))
Symbol usage: ("/Users/dave/Projects/tutorial/tutorial/Tutorial.fs", ((10, 8), (10, 12)))
There is a cache of recent checking results in FCS, used to return results when sources match - viaTryGetRecentCheckResults.
CheckFileInProject should also make use of this cache when both sources and antecedent context match.
Heres a smaple stack trace that was reported from bugzilla 17796
System.Exception: Could not find requested input '(startup (1,0--1,80)
IsSynthetic=false,
"C:\ws\Mono\GitHub\XaOpenXC\XaOpenXCCore\TinyLogging.fs", false)' named
'FileNames' in set [(0, Available('(startup (1,0--1,80) IsSynthetic=false,
C:\ws\Mono\GitHub\XaOpenXC\XaOpenXC\Resources\Resource.designer.fs, False)' as
of 2/15/2014 7:59:10 PM)); (1, Available('(startup (1,0--1,80)
IsSynthetic=false,
C:\ws\Mono\GitHub\XaOpenXC\XaOpenXC\Properties\AssemblyInfo.fs, False)' as of
2/15/2014 7:59:10 PM)); (2, Available('(startup (1,0--1,80) IsSynthetic=false,
C:\ws\Mono\GitHub\XaOpenXC\XaOpenXC\GaugeView.fs, False)' as of 2/15/2014
7:59:10 PM)); ... ]
at
Microsoft.FSharp.Control.CancellationTokenOps.Start@1192-1.Invoke(Exception e)
at <StartupCode$FSharp-Core>.$Control.loop@419-40(Trampoline this,
FSharpFunc`2 action)
at Microsoft.FSharp.Control.Trampoline.ExecuteAction(FSharpFunc`2
firstAction)
at Microsoft.FSharp.Control.TrampolineHolder.Protect(FSharpFunc`2
firstAction)
at <StartupCode$FSharp-Core>[email protected](Object state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object
state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state, Boolean preserveSyncCtx)
at
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
We should integrate the F# 3.1 changes and republish the nuget package so Emacs/MD/XS binding will support F# 3.1.
For example:
let (|Even|Odd|) input = if input % 2 = 0 then Even else Odd
let TestNumber input =
match input with
| Even -> printfn "%d is even" input
| Odd -> printfn "%d is odd" input
I would like to check whether Even
and Odd
symbols are Active Patterns labels. It's currently not possible with FSharpSymbol
.
Also please provide a way to get these labels from Active Patterns functions e.g. (|Even|Odd|)
.
(See related comment fsprojects-archive/zzarchive-VisualFSharpPowerTools#77 (comment))
When I use a SqlDataConnection type provider and use the CompileToDynamicAssembly method to compile, the following exception is thrown: System.ArgumentException: Duplicate type name within an assembly.
The exception is not thrown if the regular Compile() method is used.
Relevant code
#r @"FSharp.Compiler.Service.dll"
open System.IO
open Microsoft.FSharp.Compiler.SimpleSourceCodeServices
let scs = SimpleSourceCodeServices()
let sourceFileName = @"Test.fsx"
let dllFileName = Path.ChangeExtension(sourceFileName, "dll")
let code = @"
#r ""System.Data.dll""
#r ""FSharp.Data.TypeProviders.dll""
#r ""System.Data.Linq.dll""
open Microsoft.FSharp.Data.TypeProviders
type dbSchema = SqlDataConnection<ConnectionString = ""Data Source=localhost\sqlexpress;Initial Catalog=master;Integrated Security=True;"">
"
File.WriteAllText(sourceFileName, code)
// build the arguments
let arguments =
[|
yield "fsc.exe"
yield "-o"
yield dllFileName
yield "-a"
yield sourceFileName
|]
let (errors, exitCode, assembly) = scs.CompileToDynamicAssembly(arguments, None) // exception
let (errors2, exitCode2) = scs.Compile(arguments) // no exception
I just read http://fsharp.github.io/FSharp.Compiler.Service/interactive.html and saw fsiSession.EvalExpression(text) allows to evaluate an expression.
For fsprojects/FAKE#41 I would need an EvalScript method.
Is this possible?
FCS currently accepts and reports line numbers using a mix of zero-based (Line0, Pos01, Range01) and 1-based (pos, range) types.
I propose we remove the use of zero-based line numbers and use 1-based line numbers consistently throughout the API. MonoDevelop/XS and most other clients expect 1-based line counting.
It is not possible to normalize to 0-based line counting since 1-based line counnting is now revealed in the untyped syntax AST.
The biggest challenge is adjusting client code like GetDeclarations
that accept an integer line number:
member GetDeclarations : ... * line: Line0 * ...
Here changing to line: int
would not give a type error in client code. We could either make the change and list the places that people have to search for, or obsolete GetDeclarations, replacing it with:
member GetDeclarations1 : ... * line: int * ...
plus a nice warning on GetDeclarations saying you now have to use 1-based line counting, please adjust your code. The latter is probably safest given the growing number of clients of FCS.
Please add your comments about this below.
x.Name
here:
type TypeWithProperties() =
member x.Name
with get() = 0
and set (v: int) = ()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.