Skip to content

Commit e75d850

Browse files
committed
integrate
2 parents 036ed13 + 926a9da commit e75d850

File tree

111 files changed

+5440
-952
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+5440
-952
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ sudo: false
1313
install:
1414

1515
script:
16-
- ./build.sh
16+
- ./build.sh NuGet

FSharp.Compiler.Service.sln

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 14
33
VisualStudioVersion = 14.0.24720.0
4+
VisualStudioVersion = 14.0.23107.0
45
MinimumVisualStudioVersion = 10.0.40219.1
56
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{B6B68AE6-E7A4-4D43-9B34-FFA74BFE192B}"
67
ProjectSection(SolutionItems) = preProject
78
build.fsx = build.fsx
89
nuget\FSharp.Compiler.Service.nuspec = nuget\FSharp.Compiler.Service.nuspec
910
paket.dependencies = paket.dependencies
11+
nuget\paket.template = nuget\paket.template
1012
README.md = README.md
1113
RELEASE_NOTES.md = RELEASE_NOTES.md
1214
EndProjectSection
@@ -57,6 +59,9 @@ EndProject
5759
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharp_Analysis", "tests\service\data\CSharp_Analysis\CSharp_Analysis.csproj", "{887630A3-4B1D-40EA-B8B3-2D842E9C40DB}"
5860
EndProject
5961
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsiExe", "samples\FsiExe\FsiExe.fsproj", "{F9540CA8-1CE0-4546-A23A-A461E416E95B}"
62+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.ProjectCrackerTool", "src\fsharp\FSharp.Compiler.Service.ProjectCrackerTool\FSharp.Compiler.Service.ProjectCrackerTool.fsproj", "{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}"
63+
EndProject
64+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.ProjectCracker", "src\fsharp\FSharp.Compiler.Service.ProjectCracker\FSharp.Compiler.Service.ProjectCracker.fsproj", "{893C3CD9-5AF8-4027-A667-21E62FC2C703}"
6065
EndProject
6166
Global
6267
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -209,6 +214,36 @@ Global
209214
{F9540CA8-1CE0-4546-A23A-A461E416E95B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
210215
{F9540CA8-1CE0-4546-A23A-A461E416E95B}.Release|x86.ActiveCfg = Release|Any CPU
211216
{F9540CA8-1CE0-4546-A23A-A461E416E95B}.Release|x86.Build.0 = Release|Any CPU
217+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
218+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
219+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
220+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
221+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Debug|x86.ActiveCfg = Debug|Any CPU
222+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Proto|Any CPU.ActiveCfg = Release|Any CPU
223+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Proto|Any CPU.Build.0 = Release|Any CPU
224+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Proto|Mixed Platforms.ActiveCfg = Release|Any CPU
225+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Proto|Mixed Platforms.Build.0 = Release|Any CPU
226+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Proto|x86.ActiveCfg = Release|Any CPU
227+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
228+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|Any CPU.Build.0 = Release|Any CPU
229+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
230+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
231+
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|x86.ActiveCfg = Release|Any CPU
232+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
233+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Any CPU.Build.0 = Debug|Any CPU
234+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
235+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
236+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|x86.ActiveCfg = Debug|Any CPU
237+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Proto|Any CPU.ActiveCfg = Release|Any CPU
238+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Proto|Any CPU.Build.0 = Release|Any CPU
239+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Proto|Mixed Platforms.ActiveCfg = Release|Any CPU
240+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Proto|Mixed Platforms.Build.0 = Release|Any CPU
241+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Proto|x86.ActiveCfg = Release|Any CPU
242+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Any CPU.ActiveCfg = Release|Any CPU
243+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Any CPU.Build.0 = Release|Any CPU
244+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
245+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Mixed Platforms.Build.0 = Release|Any CPU
246+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|x86.ActiveCfg = Release|Any CPU
212247
EndGlobalSection
213248
GlobalSection(SolutionProperties) = preSolution
214249
HideSolutionNode = FALSE

RELEASE_NOTES.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
#### 2.0.0.1-beta
2+
* Fix 452 - FSharpField.IsMutable = true for BCL enum cases
3+
* Fix 452 - FSharpField.IsMutable = true for BCL enum cases
4+
* Fix 414 - Add IsInstanceMemberInCompiledCode
5+
6+
#### 2.0.0.0-beta
7+
* Feature #470, #478, #479 - Move ProjectCracker to separate nuget package and DLL, used ProjectCrackerTool.exe to run
8+
* Feature #463 - Expose slot signatures of members in object expressions
9+
* Feature #469, #475 - Add EvalExpressionNonThrowing, EvalInteractionNonThrowing, EvalScriptNonThrowing
10+
* Fix #456 - FCS makes calls to kernel32.dll when running on OSX
11+
* Fix #473 - stack overflow in resolution logic
12+
* Fix #460 - Failure getting expression for a provided method call
13+
114
#### 1.4.2.3 -
215
* Fix bug in loop optimization, apply https://github.com/Microsoft/visualfsharp/pull/756/
316

build.fsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ open SourceLink
2020

2121
let project = "FSharp.Compiler.Service"
2222
let authors = ["Microsoft Corporation, Dave Thomas, Anh-Dung Phan, Tomas Petricek"]
23-
let summary = "F# compiler services for creating IDE tools, language extensions and for F# embedding"
24-
let description = """
25-
The F# compiler services package contains a custom build of the F# compiler that
26-
exposes additional functionality for implementing F# language bindings, additional
27-
tools based on the compiler or refactoring tools. The package also includes F#
28-
interactive service that can be used for embedding F# scripting into your applications."""
29-
let tags = "F# fsharp interactive compiler editor"
3023

3124
let gitOwner = "fsharp"
3225
let gitHome = "https://github.com/" + gitOwner
@@ -142,19 +135,25 @@ Target "RunTests" (fun _ ->
142135
// Build a NuGet package
143136

144137
Target "NuGet" (fun _ ->
145-
NuGet (fun p ->
138+
Paket.Pack (fun p ->
146139
{ p with
147-
Authors = authors
148-
Project = project
149-
Summary = summary
150-
Description = description
151-
Version = buildVersion
152-
ReleaseNotes = release.Notes |> toLines
153-
Tags = tags
140+
TemplateFile = "nuget/paket.template"
141+
Version = release.NugetVersion
154142
OutputPath = buildDir
155-
AccessKey = getBuildParamOrDefault "nugetkey" ""
156-
Publish = hasBuildParam "nugetkey" })
157-
("nuget/" + project + ".nuspec")
143+
ReleaseNotes = toLines release.Notes })
144+
Paket.Pack (fun p ->
145+
{ p with
146+
TemplateFile = "nuget/projectcracker.template"
147+
Version = release.NugetVersion
148+
OutputPath = buildDir
149+
ReleaseNotes = toLines release.Notes })
150+
)
151+
152+
153+
Target "PublishNuGet" (fun _ ->
154+
Paket.Push (fun p ->
155+
{ p with
156+
WorkingDir = buildDir })
158157
)
159158

160159
// --------------------------------------------------------------------------------------
@@ -241,6 +240,7 @@ Target "All" DoNothing
241240
==> "GenerateDocsJa"
242241
==> "GenerateDocs"
243242
==> "ReleaseDocs"
243+
==> "PublishNuGet"
244244
==> "Release"
245245

246246
RunTargetOrDefault "All"

docs/content/interactive.fsx

Lines changed: 117 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ First, we need to reference the libraries that contain F# interactive service:
3131
*)
3232

3333
#r "FSharp.Compiler.Service.dll"
34+
open Microsoft.FSharp.Compiler.SourceCodeServices
3435
open Microsoft.FSharp.Compiler.Interactive.Shell
3536

3637
(**
@@ -62,7 +63,7 @@ let fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, outSt
6263
Evaluating and executing code
6364
-----------------------------
6465
65-
The F# interactive service exposes two methods that can be used for interaction. The first
66+
The F# interactive service exposes several methods that can be used for evaluation. The first
6667
is `EvalExpression` which evaluates an expression and returns its result. The result contains
6768
the returned value (as `obj`) and the statically inferred type of the value:
6869
*)
@@ -71,31 +72,128 @@ let evalExpression text =
7172
match fsiSession.EvalExpression(text) with
7273
| Some value -> printfn "%A" value.ReflectionValue
7374
| None -> printfn "Got no result!"
75+
7476
(**
75-
The `EvalInteraction` method has no result. It can be used to evaluate side-effectful operations
76-
such as printing, or other interactions that are not valid F# expressions, but can be entered in
77-
the F# Interactive console. Such commands include `#time "on"` (and other directives), `open System`
78-
and other top-level statements.
77+
This takes a string as an argument and evaluates (i.e. executes) it as F# code.
7978
*)
80-
/// Evaluate interaction & ignore the result
81-
let evalInteraction text =
82-
fsiSession.EvalInteraction(text)
79+
evalExpression "42+1" // prints '43'
80+
8381
(**
84-
The two functions take string as an argument and evaluate (or execute) it as F# code. The code
85-
passed to them does not require `;;` at the end. Just enter the code that you want to execute:
82+
This can be used in a strongly typed way as follows:
8683
*)
87-
evalExpression "42+1"
88-
evalInteraction "printfn \"bye\""
84+
85+
/// Evaluate expression & return the result, strongly typed
86+
let evalExpressionTyped<'T> (text) =
87+
match fsiSession.EvalExpression(text) with
88+
| Some value -> value.ReflectionValue |> unbox<'T>
89+
| None -> failwith "Got no result!"
90+
91+
evalExpressionTyped<int> "42+1" // gives '43'
92+
93+
94+
(**
95+
The `EvalInteraction` method can be used to evaluate side-effectful operations
96+
such as printing, declarations, or other interactions that are not valid F# expressions, but can be entered in
97+
the F# Interactive console. Such commands include `#time "on"` (and other directives), `open System`
98+
all declarations and other top-level statements. The code
99+
does not require `;;` at the end. Just enter the code that you want to execute:
100+
*)
101+
fsiSession.EvalInteraction "printfn \"bye\""
102+
89103

90104
(**
91105
The `EvalScript` method allows to evaluate a complete .fsx script.
92106
*)
93-
/// Evaluate script & ignore the result
94-
let evalScript scriptPath =
95-
fsiSession.EvalScript(scriptPath)
96107

97108
File.WriteAllText("sample.fsx", "let twenty = 10 + 10")
98-
evalScript "sample.fsx"
109+
fsiSession.EvalScript "sample.fsx"
110+
111+
(**
112+
Catching errors
113+
------------------
114+
115+
``EvalExpression``, ``EvalInteraction`` and ``EvalScript`` are awkward if the
116+
code has type checking warnings or errors, or if evaluation fails with an exception.
117+
In these cases you can use ``EvalExpressionNonThrowing``, ``EvalInteractionNonThrowing``
118+
and ``EvalScriptNonThrowing``. These return a tuple of a result and an array of ``FSharpErrorInfo`` values.
119+
These represent the errors and warnings. The result part is a ``Choice<_,_>`` between an actual
120+
result and an exception.
121+
122+
The result part of ``EvalExpression`` and ``EvalExpressionNonThrowing`` is an optional ``FSharpValue``.
123+
If that value is not present then it just indicates that the expression didn't have a tangible
124+
result that could be represented as a .NET object. This siutation shouldn't actually
125+
occur for any normal input expressions, and only for primitives used in libraries.
126+
*)
127+
128+
File.WriteAllText("sample.fsx", "let twenty = 'a' + 10.0")
129+
let result, warnings = fsiSession.EvalScriptNonThrowing "sample.fsx"
130+
131+
// show the result
132+
match result with
133+
| Choice1Of2 () -> printfn "checked and executed ok"
134+
| Choice2Of2 exn -> printfn "execution exception: %s" exn.Message
135+
136+
137+
(**
138+
Gives:
139+
140+
execution exception: Operation could not be completed due to earlier error
141+
*)
142+
143+
// show the errors and warnings
144+
for w in warnings do
145+
printfn "Warning %s at %d,%d" w.Message w.StartLineAlternate w.StartColumn
146+
147+
(**
148+
Gives:
149+
150+
Warning The type 'float' does not match the type 'char' at 1,19
151+
Warning The type 'float' does not match the type 'char' at 1,17
152+
153+
For expressions:
154+
*)
155+
156+
157+
let evalExpressionTyped2<'T> text =
158+
let res, warnings = fsiSession.EvalExpressionNonThrowing(text)
159+
for w in warnings do
160+
printfn "Warning %s at %d,%d" w.Message w.StartLineAlternate w.StartColumn
161+
match res with
162+
| Choice1Of2 (Some value) -> value.ReflectionValue |> unbox<'T>
163+
| Choice1Of2 None -> failwith "null or no result"
164+
| Choice2Of2 (exn:exn) -> failwith (sprintf "exception %s" exn.Message)
165+
166+
evalExpressionTyped2<int> "42+1" // gives '43'
167+
168+
169+
(**
170+
Executing in parallel
171+
------------------
172+
173+
By default the code passed to ``EvalExpression`` is executed immediately. To execute in parallel, submit a computation that starts a task:
174+
*)
175+
176+
open System.Threading.Tasks
177+
178+
let sampleLongRunningExpr =
179+
"""
180+
async {
181+
// The code of what you want to run
182+
do System.Threading.Thread.Sleep 5000
183+
return 10
184+
}
185+
|> Async.StartAsTask"""
186+
187+
let task1 = evalExpressionTyped<Task<int>>(sampleLongRunningExpr)
188+
let task2 = evalExpressionTyped<Task<int>>(sampleLongRunningExpr)
189+
190+
(**
191+
Both computations have now started. You can now fetch the results:
192+
*)
193+
194+
195+
task1.Result // gives the result after completion (up to 5 seconds)
196+
task2.Result // gives the result after completion (up to 5 seconds)
99197

100198
(**
101199
Type checking in the evaluation context
@@ -106,7 +204,7 @@ in the context of the F# Interactive scripting session. For example, you first
106204
evaluation a declaration:
107205
*)
108206

109-
evalInteraction "let xxx = 1 + 1"
207+
fsiSession.EvalInteraction "let xxx = 1 + 1"
110208

111209
(**
112210
@@ -129,29 +227,11 @@ You can also request declaration list information, tooltip text and symbol resol
129227
*)
130228
open Microsoft.FSharp.Compiler
131229

132-
let identToken = Parser.tagOfToken(Parser.token.IDENT(""))
133-
checkResults.GetToolTipTextAlternate(1, 2, "xxx + xx", ["xxx"], identToken) // a tooltip
230+
// get a tooltip
231+
checkResults.GetToolTipTextAlternate(1, 2, "xxx + xx", ["xxx"], FSharpTokenTag.IDENT)
134232

135233
checkResults.GetSymbolUseAtLocation(1, 2, "xxx + xx", ["xxx"]) // symbol xxx
136234

137-
(**
138-
Exception handling
139-
------------------
140-
141-
If you want to handle compiler errors in a nicer way and report a useful error message, you might
142-
want to use something like this:
143-
*)
144-
145-
try
146-
evalExpression "42 + 1.0"
147-
with e ->
148-
match e.InnerException with
149-
| null ->
150-
printfn "Error evaluating expression (%s)" e.Message
151-
//| WrappedError(err, _) ->
152-
// printfn "Error evaluating expression (Wrapped: %s)" err.Message
153-
| _ ->
154-
printfn "Error evaluating expression (%s)" e.Message
155235
(**
156236
The 'fsi' object
157237
------------------

0 commit comments

Comments
 (0)