Skip to content

Commit

Permalink
Merge pull request #888 from baronfel/anonymous-records-in-fcs
Browse files Browse the repository at this point in the history
Merge in visualfsharp master, including better FCS support for Anonymous records
  • Loading branch information
dsyme authored Feb 22, 2019
2 parents 379e1c1 + 1257ce8 commit 88e5f8e
Show file tree
Hide file tree
Showing 244 changed files with 3,963 additions and 3,483 deletions.
26 changes: 24 additions & 2 deletions .vsts-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ jobs:
vmImage: ubuntu-16.04
timeoutInMinutes: 90
strategy:
maxParallel: 2
maxParallel: 3
matrix:
dotnet_sdk:
_command: make
_args: Configuration=release
# disabled until it can be properly fixed
release_fcs:
_command: ./fcs/build.sh
_args: Build
Expand All @@ -23,6 +22,29 @@ jobs:
continueOnError: true
condition: failed()

- job: MacOS
pool:
vmImage: macOS-10.13
timeoutInMinutes: 90
strategy:
maxParallel: 3
matrix:
dotnet_sdk:
_command: make
_args: Configuration=release
release_fcs:
_command: ./fcs/build.sh
_args: Build
steps:
- script: $(_command) $(_args)
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/TestResults'
ArtifactName: 'MacOS $(_command) $(_args)'
publishLocation: Container
continueOnError: true
condition: failed()

- job: Windows
pool:
vmImage: vs2017-win2016
Expand Down
21 changes: 19 additions & 2 deletions FSharpBuild.Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,38 @@

<!-- nuget -->
<PropertyGroup>
<!-- Point to artifacts folder as an additional nuget package source -->
<RestoreAdditionalProjectSources Condition = "Exists('$(ArtifactsPackagesDir)') and '$(RestoreAdditionalProjectSources)' != ''">$(RestoreAdditionalProjectSources);$(ArtifactsPackagesDir)</RestoreAdditionalProjectSources>
<RestoreAdditionalProjectSources Condition = "Exists('$(ArtifactsPackagesDir)') and '$(RestoreAdditionalProjectSources)' == ''">$(ArtifactsPackagesDir)</RestoreAdditionalProjectSources>

<!-- default NuGet package restore location -->
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == ''">$(NUGET_PACKAGES)</NuGetPackageRoot>
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' AND '$(OS)' == 'Windows_NT'">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' AND '$(OS)' != 'Windows_NT'">$(HOME)/.nuget/packages/</NuGetPackageRoot>

<!-- ensure there is a trailing slash -->
<NuGetPackageRoot Condition="!HasTrailingSlash('$(NuGetPackageRoot)') AND '$(OS)' == 'Windows_NT'">$(NuGetPackageRoot)\</NuGetPackageRoot>
<NuGetPackageRoot Condition="!HasTrailingSlash('$(NuGetPackageRoot)') AND '$(OS)' != 'Windows_NT'">$(NuGetPackageRoot)/</NuGetPackageRoot>

<!-- ensure all NuGet packages come from the `$(NuGetPackageRoot)` variable -->
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>

<!-- mono -->
<PropertyGroup Condition="'$(OS)' == 'Unix'">
<MonoRoot Condition="'$(MonoRoot)' == '' and $([MSBuild]::IsOsPlatform('Linux'))">/usr</MonoRoot>
<MonoRoot Condition="'$(MonoRoot)' == '' and $([MSBuild]::IsOsPlatform('OSX'))">/Library/Frameworks/Mono.framework/Versions/Current</MonoRoot>
<MonoLibFolder>$(MonoRoot)/lib/mono</MonoLibFolder>
<MonoPackaging Condition="$(TargetFramework.StartsWith('net4'))">true</MonoPackaging>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net45'">/usr/lib/mono/4.5-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net46'">/usr/lib/mono/4.6-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net45'">$(MonoLibFolder)/4.5-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net451'">$(MonoLibFolder)/4.5.1-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net452'">$(MonoLibFolder)/4.5.2-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net46'">$(MonoLibFolder)/4.6-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net461'">$(MonoLibFolder)/4.6.1-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net462'">$(MonoLibFolder)/4.6.2-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net47'">$(MonoLibFolder)/4.7-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net471'">$(MonoLibFolder)/4.7.1-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net472'">$(MonoLibFolder)/4.7.2-api</FrameworkPathOverride>
</PropertyGroup>

<!-- signing -->
Expand All @@ -51,6 +67,7 @@
<StrongNames>true</StrongNames>
<DelaySign>true</DelaySign>
</PropertyGroup>

<PropertyGroup Condition="'$(MonoPackaging)' == 'true'">
<AssemblyOriginatorKeyFile>$(FSharpSourcesRoot)\fsharp\test.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/CompilerServiceBenchmarks/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
open System.IO
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
open Microsoft.FSharp.Compiler.ErrorLogger
open Microsoft.FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.SourceCodeServices
open System.Text

[<ClrJob(baseline = true)>]
Expand Down
3 changes: 2 additions & 1 deletion build/targets/AssemblyVersions.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<_Build_Number>$(BUILD_BUILDNUMBER.Substring(9))</_Build_Number>
<Build_FileVersion>$(_Build_Year).$(_Build_Month).$(_Build_Day).$(_Build_Number)</Build_FileVersion>

<FSCoreMajorVersion>4.5</FSCoreMajorVersion>
<FSLanguageVersion>4.5</FSLanguageVersion>
<FSCoreMajorVersion>$(FSLanguageVersion)</FSCoreMajorVersion>
<FSCorePackageVersion>$(FSCoreMajorVersion).5</FSCorePackageVersion>
<FSCoreVersion>$(FSCoreMajorVersion).0.0</FSCoreVersion>

Expand Down
8 changes: 5 additions & 3 deletions build/targets/ConvertPortablePdbs.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
<Target Name="ConvertPortablePdbs"
AfterTargets="AfterBuild"
Condition="'$(OS)' != 'Unix' AND
'$(SkipPDBConversion)' != 'true' AND
Exists('$(TargetPath)') AND
('$(DebugType)' == 'portable' OR '$(DebugType)' == 'embedded') AND
$(TargetFramework.StartsWith('net4')) AND
$(TargetFramework.StartsWith('net')) AND
'$(Configuration)' != 'Proto'">
<PropertyGroup>
<ConvertedPdbsDirectory>$(SymStoreDirectory)\$(TargetFramework)</ConvertedPdbsDirectory>
<PdbConverterExe>$(NuGetPackageRoot)Pdb2Pdb\$(Pdb2PdbPackageVersion)\tools\Pdb2Pdb.exe</PdbConverterExe>
<PdbConverterArgs>"$(TargetPath)" /out "$(SymStoreDirectory)\$(TargetName).pdb" /srcsvrvar SRC_INDEX=public</PdbConverterArgs>
<PdbConverterArgs>"$(TargetPath)" /out "$(ConvertedPdbsDirectory)\$(TargetName).pdb" /srcsvrvar SRC_INDEX=public</PdbConverterArgs>
</PropertyGroup>

<MakeDir Directories="$(SymStoreDirectory)" />
<MakeDir Directories="$(ConvertedPdbsDirectory)" />
<Exec Command='"$(PdbConverterExe)" $(PdbConverterArgs)' />
</Target>

Expand Down
4 changes: 2 additions & 2 deletions fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.FSharp.Compiler.SourceCodeServices
namespace FSharp.Compiler.SourceCodeServices

#if !NETSTANDARD1_6
open System.Runtime.Serialization.Json
Expand Down Expand Up @@ -69,7 +69,7 @@ type ProjectCracker =
yield v
|]

let ret, opts = Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool.ProjectCrackerTool.crackOpen arguments
let ret, opts = FSharp.Compiler.SourceCodeServices.ProjectCrackerTool.ProjectCrackerTool.crackOpen arguments
ignore ret
#else
let arguments = new StringBuilder()
Expand Down
2 changes: 1 addition & 1 deletion fcs/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool
namespace FSharp.Compiler.SourceCodeServices.ProjectCrackerTool

open System
open System.Reflection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool
namespace FSharp.Compiler.SourceCodeServices.ProjectCrackerTool

[<CLIMutable>]
type ProjectOptions =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool
namespace FSharp.Compiler.SourceCodeServices.ProjectCrackerTool

open System
open System.IO
Expand Down
8 changes: 8 additions & 0 deletions fcs/FSharp.Compiler.Service.Tests/app.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<MaxCpuCount>1</MaxCpuCount>
</RunConfiguration>

</RunSettings>
6 changes: 3 additions & 3 deletions fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
<LogicalName>FSStrings.resources</LogicalName>
</EmbeddedResource>
<FsYacc Include="$(FSharpSourcesRoot)\absil\ilpars.fsy">
<OtherFlags>--module Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiParser --open Microsoft.FSharp.Compiler.AbstractIL --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing</OtherFlags>
<OtherFlags>--module FSharp.Compiler.AbstractIL.Internal.AsciiParser --open FSharp.Compiler.AbstractIL --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing</OtherFlags>
<Link>ilpars.fsy</Link>
</FsYacc>
<FsYacc Include="$(FSharpSourcesRoot)\fsharp\pars.fsy">
<OtherFlags>--module Microsoft.FSharp.Compiler.Parser --open Microsoft.FSharp.Compiler --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing</OtherFlags>
<OtherFlags>--module FSharp.Compiler.Parser --open FSharp.Compiler --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing</OtherFlags>
<Link>pars.fsy</Link>
</FsYacc>
<Compile Include="$(FSharpSourcesRoot)/fsharp/Logger.fsi">
Expand Down Expand Up @@ -294,7 +294,7 @@
<Link>ParserAndUntypedAST/pplex.fsl</Link>
</FsLex>
<FsYacc Include="$(FSharpSourcesRoot)\fsharp\pppars.fsy">
<OtherFlags>--module Microsoft.FSharp.Compiler.PPParser --open Microsoft.FSharp.Compiler --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing</OtherFlags>
<OtherFlags>--module FSharp.Compiler.PPParser --open FSharp.Compiler --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing</OtherFlags>
<Link>ParserAndUntypedAST/pppars.fsy</Link>
</FsYacc>
<Compile Include="$(FSharpSourcesRoot)/fsharp/UnicodeLexing.fsi">
Expand Down
2 changes: 1 addition & 1 deletion fcs/docsrc/content/caches.fsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(*** hide ***)
#I "../../bin/v4.5/"
#I "../../../artifacts/bin/fcs/net45"
(**
Compiler Services: Notes on the FSharpChecker caches
=================================================
Expand Down
14 changes: 10 additions & 4 deletions fcs/docsrc/content/compiler.fsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(*** hide ***)
#I "../../bin/v4.5/"
#I "../../../artifacts/bin/fcs/net45"
(**
Hosted Compiler
===============
Expand Down Expand Up @@ -29,7 +29,7 @@ First, we need to reference the libraries that contain F# interactive service:

#r "FSharp.Compiler.Service.dll"
open System.IO
open Microsoft.FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.SourceCodeServices

// Create an interactive checker instance
let checker = FSharpChecker.Create()
Expand All @@ -55,7 +55,9 @@ let x = 3 + 4
Now invoke the compiler:
*)

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

(**
Expand All @@ -68,7 +70,9 @@ module M
let x = 1.0 + "" // a type error
""")

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

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

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

26 changes: 4 additions & 22 deletions fcs/docsrc/content/corelib.fsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(*** hide ***)
#I "../../bin/v4.5/"
#I "../../../artifacts/bin/fcs/net45"
(**
Compiler Services: Notes on FSharp.Core.dll
=================================================
Expand All @@ -13,14 +13,11 @@ include a copy of FSharp.Core.dll as part of your application.
For example, if you build a ``HostedCompiler.exe``, you will normally place an FSharp.Core.dll (say 4.3.1.0) alongside
your ``HostedCompiler.exe``.
If doing dynamic compilation and execution you may also need to include
an FSharp.Core.optdata and FSharp.Core.sigdata, see below for guidance.
Binding redirects for your application
--------------------------------------
The FSharp.Compiler.Service.dll component depends on FSharp.Core 4.4.0.0. Normally your application will target
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
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
that other versions of FSharp.Core forward to the final version of FSharp.Core.dll your application uses.
Binding redirect files are normally generated automatically by build tools. If not, you can use one like this
(if your tool is called ``HostedCompiler.exe``, the binding redirect file is called ``HostedCompiler.exe.config``)
Expand Down Expand Up @@ -80,27 +77,12 @@ by the following choice:
2. If there is no static reference to FSharp.Core in the host assembly, then
- For FSharp.Compiler.Service 0.x series, a reference to FSharp.Core version 4.3.0.0 is added
- For FSharp.Compiler.Service 1.3.1.x (F# 3.1 series), a reference to FSharp.Core version 4.3.1.0 is added
- For FSharp.Compiler.Service 1.4.0.x (F# 4.0 series), a reference to FSharp.Core version 4.4.0.0 is added
- 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
Do I need to include FSharp.Core.optdata and FSharp.Core.sigdata?
--------------------------------------
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
(if these files are not installed, then that's a bug in the F# SDK installation). If your compilation
arguments are always making an explicit reference, then you should _not_ include FSharp.Core.optdata and FSharp.Core.sigdata as part of your application.
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
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
found alongside FSharp.Core.dll. **If you want to implicitly reference the FSharp.Core.dll you are including in your application,
then also add FSharp.Core.sigdata and FSharp.Core.optdata as two additional files to your application**. When using ``CompileToDynamicAssembly``, this problem
can also manifest itself as [a stack overflow during assembly resolution](https://github.com/fsharp/FSharp.Compiler.Service/issues/258).
Tools that dynamically compile and execute code (e.g. a ``HostedExecution.exe``) often make an implicit
reference to FSharp.Core.dll, which means they normally also include FSharp.Core.optdata and FSharp.Core.sigdata.
No, unless you are doing something with very old FSharp.Core.dll.
Summary
-------
Expand Down
14 changes: 7 additions & 7 deletions fcs/docsrc/content/editor.fsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(*** hide ***)
#I "../../bin/v4.5/"
#I "../../../artifacts/bin/fcs/net45"
(**
Compiler Services: Editor services
==================================
Expand All @@ -26,7 +26,7 @@ of `InteractiveChecker`:
#r "FSharp.Compiler.Service.dll"

open System
open Microsoft.FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.SourceCodeServices

// Create an interactive checker instance
let checker = FSharpChecker.Create()
Expand All @@ -52,7 +52,7 @@ let input =
let inputLines = input.Split('\n')
let file = "/home/user/Test.fsx"

let projOptions =
let projOptions, errors =
checker.GetProjectOptionsFromScript(file, input)
|> Async.RunSynchronously

Expand Down Expand Up @@ -127,11 +127,11 @@ identifier (the other option lets you get tooltip with full assembly location wh
*)
// Get tag of the IDENT token to be used as the last argument
open Microsoft.FSharp.Compiler
open FSharp.Compiler
let identToken = FSharpTokenTag.Identifier

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

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

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

// Print concatenated parameter lists
Expand Down
Loading

0 comments on commit 88e5f8e

Please sign in to comment.