Skip to content

Commit b0292b8

Browse files
dsymecartermp
authored andcommitted
Anonymous record support for expressions in FCS (#6257)
* fix flakey test (?) * use runsettings * same fix for FCS tests2 * anonymous record support for expressions in FCS * anonymous record support for expressions in FCS * add tests for anonymous records and fix service testing with F# interactive * fix FCS docs * fix build * add diagnostics * update other baseline * fix final parallel case * try again to fix test * update test fixes
1 parent 78c7b17 commit b0292b8

42 files changed

Lines changed: 200 additions & 142 deletions

Some content is hidden

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

fcs/docsrc/content/caches.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(*** hide ***)
2-
#I "../../bin/v4.5/"
2+
#I "../../../artifacts/bin/fcs/net45"
33
(**
44
Compiler Services: Notes on the FSharpChecker caches
55
=================================================

fcs/docsrc/content/compiler.fsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(*** hide ***)
2-
#I "../../bin/v4.5/"
2+
#I "../../../artifacts/bin/fcs/net45"
33
(**
44
Hosted Compiler
55
===============
@@ -55,7 +55,9 @@ let x = 3 + 4
5555
Now invoke the compiler:
5656
*)
5757

58-
let errors1, exitCode1 = checker.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |])
58+
let errors1, exitCode1 =
59+
checker.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |])
60+
|> Async.RunSynchronously
5961

6062
(**
6163
@@ -68,7 +70,9 @@ module M
6870
let x = 1.0 + "" // a type error
6971
""")
7072

71-
let errors1b, exitCode1b = checker.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |])
73+
let errors1b, exitCode1b =
74+
checker.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |])
75+
|> Async.RunSynchronously
7276

7377
(**
7478
@@ -85,10 +89,12 @@ The 'None' option indicates that the initiatlization code for the assembly is no
8589
*)
8690
let errors2, exitCode2, dynAssembly2 =
8791
checker.CompileToDynamicAssembly([| "-o"; fn3; "-a"; fn2 |], execute=None)
92+
|> Async.RunSynchronously
8893

8994
(*
9095
Passing 'Some' for the 'execute' parameter executes the initiatlization code for the assembly.
9196
*)
9297
let errors3, exitCode3, dynAssembly3 =
9398
checker.CompileToDynamicAssembly([| "-o"; fn3; "-a"; fn2 |], Some(stdout,stderr))
99+
|> Async.RunSynchronously
94100

fcs/docsrc/content/corelib.fsx

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(*** hide ***)
2-
#I "../../bin/v4.5/"
2+
#I "../../../artifacts/bin/fcs/net45"
33
(**
44
Compiler Services: Notes on FSharp.Core.dll
55
=================================================
@@ -13,14 +13,11 @@ include a copy of FSharp.Core.dll as part of your application.
1313
For example, if you build a ``HostedCompiler.exe``, you will normally place an FSharp.Core.dll (say 4.3.1.0) alongside
1414
your ``HostedCompiler.exe``.
1515
16-
If doing dynamic compilation and execution you may also need to include
17-
an FSharp.Core.optdata and FSharp.Core.sigdata, see below for guidance.
18-
1916
Binding redirects for your application
2017
--------------------------------------
2118
2219
The FSharp.Compiler.Service.dll component depends on FSharp.Core 4.4.0.0. Normally your application will target
23-
a later version of FSharp.Core, and you will need a [binding redirect](http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx) to ensure
20+
a later version of FSharp.Core, and you may need a [binding redirect](http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx) to ensure
2421
that other versions of FSharp.Core forward to the final version of FSharp.Core.dll your application uses.
2522
Binding redirect files are normally generated automatically by build tools. If not, you can use one like this
2623
(if your tool is called ``HostedCompiler.exe``, the binding redirect file is called ``HostedCompiler.exe.config``)
@@ -80,27 +77,12 @@ by the following choice:
8077
8178
2. If there is no static reference to FSharp.Core in the host assembly, then
8279
83-
- For FSharp.Compiler.Service 0.x series, a reference to FSharp.Core version 4.3.0.0 is added
84-
85-
- For FSharp.Compiler.Service 1.3.1.x (F# 3.1 series), a reference to FSharp.Core version 4.3.1.0 is added
86-
87-
- For FSharp.Compiler.Service 1.4.0.x (F# 4.0 series), a reference to FSharp.Core version 4.4.0.0 is added
80+
- For FSharp.Compiler.Service 1.4.0.x above (F# 4.0 series), a reference to FSharp.Core version 4.4.0.0 is added
8881
8982
Do I need to include FSharp.Core.optdata and FSharp.Core.sigdata?
9083
--------------------------------------
9184
92-
If your compilation arguments explicitly reference an FSharp.Core.dll from an SDK location, then FSharp.Core.sigdata and FSharp.Core.optdata should be alongside the DLL
93-
(if these files are not installed, then that's a bug in the F# SDK installation). If your compilation
94-
arguments are always making an explicit reference, then you should _not_ include FSharp.Core.optdata and FSharp.Core.sigdata as part of your application.
95-
96-
If you are relying on an implicit reference (e.g. for script processing, see above), this means your tool may reference the FSharp.Core.dll
97-
that is part of your application. In this case, you may either get an error that FSharp.Core.optdata and FSharp.Core.sigdata are not
98-
found alongside FSharp.Core.dll. **If you want to implicitly reference the FSharp.Core.dll you are including in your application,
99-
then also add FSharp.Core.sigdata and FSharp.Core.optdata as two additional files to your application**. When using ``CompileToDynamicAssembly``, this problem
100-
can also manifest itself as [a stack overflow during assembly resolution](https://github.com/fsharp/FSharp.Compiler.Service/issues/258).
101-
102-
Tools that dynamically compile and execute code (e.g. a ``HostedExecution.exe``) often make an implicit
103-
reference to FSharp.Core.dll, which means they normally also include FSharp.Core.optdata and FSharp.Core.sigdata.
85+
No, unless you are doing something with very old FSharp.Core.dll.
10486
10587
Summary
10688
-------

fcs/docsrc/content/editor.fsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(*** hide ***)
2-
#I "../../bin/v4.5/"
2+
#I "../../../artifacts/bin/fcs/net45"
33
(**
44
Compiler Services: Editor services
55
==================================
@@ -52,7 +52,7 @@ let input =
5252
let inputLines = input.Split('\n')
5353
let file = "/home/user/Test.fsx"
5454

55-
let projOptions =
55+
let projOptions, errors =
5656
checker.GetProjectOptionsFromScript(file, input)
5757
|> Async.RunSynchronously
5858

@@ -131,7 +131,7 @@ open FSharp.Compiler
131131
let identToken = FSharpTokenTag.Identifier
132132

133133
// Get tool tip at the specified location
134-
let tip = checkFileResults.GetToolTipTextAlternate(4, 7, inputLines.[1], ["foo"], identToken)
134+
let tip = checkFileResults.GetToolTipText(4, 7, inputLines.[1], ["foo"], identToken)
135135
printfn "%A" tip
136136

137137
(**
@@ -165,7 +165,7 @@ where we need to perform the completion.
165165
// Get declarations (autocomplete) for a location
166166
let decls =
167167
checkFileResults.GetDeclarationListInfo
168-
(Some parseFileResults, 7, 23, inputLines.[6], [], "msg", fun _ -> false)
168+
(Some parseFileResults, 7, inputLines.[6], PartialLongName.Empty 23, (fun () -> []), fun _ -> false)
169169
|> Async.RunSynchronously
170170

171171
// Print the names of available items
@@ -197,7 +197,7 @@ changes):
197197
*)
198198
// Get overloads of the String.Concat method
199199
let methods =
200-
checkFileResults.GetMethodsAlternate(5, 27, inputLines.[4], Some ["String"; "Concat"])
200+
checkFileResults.GetMethods(5, 27, inputLines.[4], Some ["String"; "Concat"])
201201
|> Async.RunSynchronously
202202

203203
// Print concatenated parameter lists

fcs/docsrc/content/filesystem.fsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(*** hide ***)
2-
#I "../../bin/v4.5/"
2+
#I "../../../artifacts/bin/fcs/net45"
33
(**
44
Compiler Services: Virtualized File System
55
==========================================
@@ -59,25 +59,34 @@ let B = File1.A + File1.A"""
5959
// Implement the service related to temporary paths and file time stamps
6060
member __.GetTempPathShim() =
6161
defaultFileSystem.GetTempPathShim()
62+
6263
member __.GetLastWriteTimeShim(fileName) =
6364
defaultFileSystem.GetLastWriteTimeShim(fileName)
65+
6466
member __.GetFullPathShim(fileName) =
6567
defaultFileSystem.GetFullPathShim(fileName)
68+
6669
member __.IsInvalidPathShim(fileName) =
6770
defaultFileSystem.IsInvalidPathShim(fileName)
71+
6872
member __.IsPathRootedShim(fileName) =
6973
defaultFileSystem.IsPathRootedShim(fileName)
7074

75+
member __.IsStableFileHeuristic(fileName) =
76+
defaultFileSystem.IsStableFileHeuristic(fileName)
77+
7178
// Implement the service related to file existence and deletion
7279
member __.SafeExists(fileName) =
7380
files.ContainsKey(fileName) || defaultFileSystem.SafeExists(fileName)
81+
7482
member __.FileDelete(fileName) =
7583
defaultFileSystem.FileDelete(fileName)
7684

7785
// Implement the service related to assembly loading, used to load type providers
7886
// and for F# interactive.
7987
member __.AssemblyLoadFrom(fileName) =
8088
defaultFileSystem.AssemblyLoadFrom fileName
89+
8190
member __.AssemblyLoad(assemblyName) =
8291
defaultFileSystem.AssemblyLoad assemblyName
8392

@@ -131,7 +140,11 @@ let projectOptions =
131140
yield "-r:" + r |]
132141

133142
{ ProjectFileName = @"c:\mycode\compilation.fsproj" // Make a name that is unique in this directory.
134-
ProjectFileNames = [| fileName1; fileName2 |]
143+
ProjectId = None
144+
SourceFiles = [| fileName1; fileName2 |]
145+
OriginalLoadReferences = []
146+
ExtraProjectInfo=None
147+
Stamp = None
135148
OtherOptions = allFlags
136149
ReferencedProjects = [| |]
137150
IsIncompleteTypeCheckEnvironment = false

fcs/docsrc/content/interactive.fsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(*** hide ***)
2-
#I "../../bin/v4.5/"
2+
#I "../../../artifacts/bin/fcs/net45"
33
(**
44
Interactive Service: Embedding F# Interactive
55
=============================================
@@ -211,7 +211,9 @@ fsiSession.EvalInteraction "let xxx = 1 + 1"
211211
Now you want to typecheck the partially complete code `xxx + xx`
212212
*)
213213

214-
let parseResults, checkResults, checkProjectResults = fsiSession.ParseAndCheckInteraction("xxx + xx")
214+
let parseResults, checkResults, checkProjectResults =
215+
fsiSession.ParseAndCheckInteraction("xxx + xx")
216+
|> Async.RunSynchronously
215217

216218
(**
217219
The `parseResults` and `checkResults` have types `ParseFileResults` and `CheckFileResults`
@@ -228,7 +230,7 @@ You can also request declaration list information, tooltip text and symbol resol
228230
open FSharp.Compiler
229231

230232
// get a tooltip
231-
checkResults.GetToolTipTextAlternate(1, 2, "xxx + xx", ["xxx"], FSharpTokenTag.IDENT)
233+
checkResults.GetToolTipText(1, 2, "xxx + xx", ["xxx"], FSharpTokenTag.IDENT)
232234

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

fcs/docsrc/content/ja/compiler.fsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(*** hide ***)
2-
#I "../../../../debug/bin/net45/"
2+
#I "../../../../artifacts/bin/fcs/net45"
33
(**
44
コンパイラの組み込み
55
====================
@@ -18,10 +18,10 @@
1818
*)
1919

2020
#r "FSharp.Compiler.Service.dll"
21-
open FSharp.Compiler.SimpleSourceCodeServices
21+
open FSharp.Compiler.SourceCodeServices
2222
open System.IO
2323

24-
let scs = SimpleSourceCodeServices()
24+
let scs = FSharpChecker.Create()
2525

2626
(**
2727
次に、一時ファイルへコンテンツを書き込みます:
@@ -44,7 +44,7 @@ let x = 3 + 4
4444
そしてコンパイラを呼び出します:
4545
*)
4646

47-
let errors1, exitCode1 = scs.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |])
47+
let errors1, exitCode1 = scs.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |]) |> Async.RunSynchronously
4848

4949
(**
5050
@@ -57,7 +57,7 @@ module M
5757
let x = 1.0 + "" // a type error
5858
""")
5959

60-
let errors1b, exitCode1b = scs.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |])
60+
let errors1b, exitCode1b = scs.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |]) |> Async.RunSynchronously
6161

6262
if exitCode1b <> 0 then
6363
errors1b
@@ -79,11 +79,11 @@ if exitCode1b <> 0 then
7979
'execute' 引数に 'None' を指定するとアセンブリ用の初期化コードが実行されません。
8080
*)
8181
let errors2, exitCode2, dynAssembly2 =
82-
scs.CompileToDynamicAssembly([| "-o"; fn3; "-a"; fn2 |], execute=None)
82+
scs.CompileToDynamicAssembly([| "-o"; fn3; "-a"; fn2 |], execute=None) |> Async.RunSynchronously
8383

8484
(**
8585
'Some' を指定するとアセンブリ用の初期化コードが実行されます。
8686
*)
8787
let errors3, exitCode3, dynAssembly3 =
88-
scs.CompileToDynamicAssembly([| "-o"; fn3; "-a"; fn2 |], Some(stdout,stderr))
88+
scs.CompileToDynamicAssembly([| "-o"; fn3; "-a"; fn2 |], Some(stdout,stderr)) |> Async.RunSynchronously
8989

fcs/docsrc/content/ja/corelib.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(*** hide ***)
2-
#I "../../bin/v4.5/"
2+
#I "../../../../artifacts/bin/fcs/net45"
33
(**
44
コンパイラサービス: FSharp.Core.dll についてのメモ
55
==================================================

0 commit comments

Comments
 (0)