Skip to content

Commit d157abc

Browse files
authored
Merge branch 'main' into merges/release/dev17.9-to-main
2 parents 86d05ef + 1816538 commit d157abc

File tree

424 files changed

+35464
-8333
lines changed

Some content is hidden

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

424 files changed

+35464
-8333
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
22
{
33
"name": "F#",
4-
"image": "mcr.microsoft.com/dotnet/sdk:8.0.100-rc.1",
4+
"image": "mcr.microsoft.com/dotnet/sdk:8.0",
55
"features": {
66
"ghcr.io/devcontainers/features/common-utils:2": {},
77
"ghcr.io/devcontainers/features/git:1": {},

.fantomasignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ src/Compiler/Checking/AccessibilityLogic.fs
2020
src/Compiler/Checking/AttributeChecking.fs
2121
src/Compiler/Checking/AugmentWithHashCompare.fs
2222
src/Compiler/Checking/CheckBasics.fs
23-
src/Compiler/Checking/CheckComputationExpressions.fs
2423
src/Compiler/Checking/CheckDeclarations.fs
2524
src/Compiler/Checking/CheckExpressions.fs
2625
src/Compiler/Checking/CheckFormatStrings.fs

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Format src/Compiler/Checking/CheckComputationExpressions.fs, https://github.com/dotnet/fsharp/pull/16512
2+
603a310cdfd9902ec1d29b399377dcc9ac56235b

DEVGUIDE.md

Lines changed: 20 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Install the latest released [Visual Studio](https://visualstudio.microsoft.com/v
4949
* .NET desktop development (also check F# desktop support, as this will install some legacy templates)
5050
* Visual Studio extension development
5151

52-
You will also need the latest .NET 7 SDK installed from [here](https://dotnet.microsoft.com/download/dotnet/7.0).
52+
You will also need .NET SDK installed from [here](https://dotnet.microsoft.com/download/dotnet), exact version can be found in the global.json file in the root of the repository.
5353

5454
Building is simple:
5555

@@ -76,7 +76,7 @@ If you are just developing the core compiler and library then building ``FSharp.
7676
We recommend installing the latest Visual Studio preview and using that if you are on Windows. However, if you prefer not to do that, you will need to install the following:
7777

7878
* [.NET Framework 4.7.2](https://dotnet.microsoft.com/download/dotnet-framework/net472)
79-
* [.NET 7](https://dotnet.microsoft.com/download/dotnet/7.0)
79+
* [.NET SDK](https://dotnet.microsoft.com/download/dotnet) (see exact version in global.json file in the repository root).
8080

8181
You'll need to pass an additional flag to the build script:
8282

@@ -275,9 +275,25 @@ Where `<version>` corresponds to the latest Visual Studio version on your machin
275275

276276
Use the `Debug` configuration to test your changes locally. It is the default. Do not use the `Release` configuration! Local development and testing of Visual Studio tooling is not designed for the `Release` configuration.
277277

278-
### Writing and running benchmarks
278+
### Benchmarking
279279

280-
Existing compiler benchmarks can be found in `tests\benchmarks\`.
280+
Existing compiler benchmarks can be found in `tests\benchmarks\`. The folder contains READMEs describing specific benchmark projects as well as guidelines for creating new benchmarks. There is also `FSharp.Benchmarks.sln` solution containing all the benchmark project and their dependencies.
281+
282+
To exercise the benchmarking infrastructure locally, run:
283+
284+
(Windows)
285+
```cmd
286+
build.cmd -configuration Release -testBenchmarks
287+
```
288+
289+
(Linux/Mac)
290+
```shell
291+
./build.sh --configuration Release --testBenchmarks
292+
```
293+
294+
This is executed in CI as well. It does the following:
295+
- builds all the benchmarking projects
296+
- does smoke testing for fast benchmarks (executes them once to check they don't fail in the runtime)
281297

282298
### Benchmarking and profiling the compiler
283299

@@ -286,151 +302,6 @@ Existing compiler benchmarks can be found in `tests\benchmarks\`.
286302
* Always build both versions of compiler/FCS from source and not use pre-built binaries from SDK (SDK binaries are crossgen'd, which can affect performance).
287303
* To run `Release` build of compiler/FCS.
288304

289-
### Example benchmark setup using [BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet)
290-
291-
1. Perform a clean build of the compiler and FCS from source (as described in this document, build can be done with `-noVisualStudio` in case if FCS/FSharp.Core is being benchmarked/profiled).
292-
293-
2. Create a benchmark project (in this example, the project will be created in `tests\benchmarks\FCSBenchmarks`).
294-
295-
```shell
296-
cd tests\benchmarks\FCSBenchmarks
297-
dotnet new console -o FcsBench --name FcsBench -lang F#
298-
```
299-
300-
3. Add needed packages and project references.
301-
302-
```shell
303-
cd FcsBench
304-
dotnet add package BenchmarkDotNet
305-
dotnet add reference ..\..\..\src\Compiler\FSharp.Compiler.Service.fsproj
306-
```
307-
308-
4. Additionally, if you want to test changes to the FSharp.Core (note that the relative path can be different)
309-
310-
```shell
311-
dotnet add reference ..\..\..\src\FSharp.Core\FSharp.Core.fsproj
312-
```
313-
314-
> as well as the following property have to be added to `FcsBench.fsproj`:
315-
316-
```xml
317-
<PropertyGroup>
318-
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
319-
</PropertyGroup>
320-
```
321-
322-
5. Add a new benchmark for FCS/FSharp.Core by editing `Program.fs`.
323-
324-
```fsharp
325-
open System.IO
326-
open FSharp.Compiler.CodeAnalysis
327-
open FSharp.Compiler.Diagnostics
328-
open FSharp.Compiler.Text
329-
open BenchmarkDotNet.Attributes
330-
open BenchmarkDotNet.Running
331-
332-
[<MemoryDiagnoser>]
333-
type CompilerService() =
334-
let mutable checkerOpt = None
335-
let mutable sourceOpt = None
336-
337-
let parsingOptions =
338-
{
339-
SourceFiles = [|"CheckExpressions.fs"|]
340-
ConditionalDefines = []
341-
DiagnosticOptions = FSharpDiagnosticOptions.Default
342-
LangVersionText = "default"
343-
IsInteractive = false
344-
LightSyntax = None
345-
CompilingFsLib = false
346-
IsExe = false
347-
}
348-
349-
[<GlobalSetup>]
350-
member _.Setup() =
351-
match checkerOpt with
352-
| None ->
353-
checkerOpt <- Some(FSharpChecker.Create(projectCacheSize = 200))
354-
| _ -> ()
355-
356-
match sourceOpt with
357-
| None ->
358-
sourceOpt <- Some <| SourceText.ofString(File.ReadAllText("""C:\Users\vlza\code\fsharp\src\Compiler\Checking\CheckExpressions.fs"""))
359-
| _ -> ()
360-
361-
362-
[<Benchmark>]
363-
member _.ParsingTypeCheckerFs() =
364-
match checkerOpt, sourceOpt with
365-
| None, _ -> failwith "no checker"
366-
| _, None -> failwith "no source"
367-
| Some(checker), Some(source) ->
368-
let results = checker.ParseFile("CheckExpressions.fs", source, parsingOptions) |> Async.RunSynchronously
369-
if results.ParseHadErrors then failwithf "parse had errors: %A" results.Diagnostics
370-
371-
[<IterationCleanup(Target = "ParsingTypeCheckerFs")>]
372-
member _.ParsingTypeCheckerFsSetup() =
373-
match checkerOpt with
374-
| None -> failwith "no checker"
375-
| Some(checker) ->
376-
checker.InvalidateAll()
377-
checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
378-
checker.ParseFile("dummy.fs", SourceText.ofString "dummy", parsingOptions) |> Async.RunSynchronously |> ignore
379-
380-
[<EntryPoint>]
381-
let main _ =
382-
BenchmarkRunner.Run<CompilerService>() |> ignore
383-
0
384-
```
385-
386-
> For more detailed information about available BenchmarkDotNet options, please refer to [BenchmarkDotNet Documentation](https://benchmarkdotnet.org/articles/overview.html).
387-
388-
6. Build and run the benchmark.
389-
390-
```shell
391-
dotnet build -c Release
392-
dotnet run -c Release
393-
```
394-
395-
7. You can find results in `.\BenchmarkDotNet.Artifacts\results\` in the current benchmark project directory.
396-
397-
```shell
398-
> ls .\BenchmarkDotNet.Artifacts\results\
399-
400-
Directory: C:\Users\vlza\code\fsharp\tests\benchmarks\FCSBenchmarks\FcsBench\BenchmarkDotNet.Artifacts\results
401-
402-
Mode LastWriteTime Length Name
403-
---- ------------- ------ ----
404-
-a--- 4/25/2022 1:42 PM 638 Program.CompilerService-report-github.md
405-
-a--- 4/25/2022 1:42 PM 1050 Program.CompilerService-report.csv
406-
-a--- 4/25/2022 1:42 PM 1169 Program.CompilerService-report.html
407-
```
408-
409-
> *-report-github.md can be used to post benchmark results to GitHub issue/PR/discussion or RFC.
410-
>
411-
>*-report.csv can be used for comparison purposes.
412-
413-
**Example output:**
414-
415-
``` ini
416-
417-
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.25102
418-
Intel Core i7-8750H CPU 2.20GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
419-
.NET SDK=6.0.200
420-
[Host] : .NET 6.0.3 (6.0.322.12309), X64 RyuJIT DEBUG
421-
Job-GDIBXX : .NET 6.0.3 (6.0.322.12309), X64 RyuJIT
422-
423-
InvocationCount=1 UnrollFactor=1
424-
425-
```
426-
427-
| Method | Mean | Error | StdDev | Median | Gen 0 | Gen 1 | Allocated |
428-
|--------------------- |---------:|--------:|--------:|---------:|----------:|----------:|----------:|
429-
| ParsingTypeCheckerFs | 199.4 ms | 3.84 ms | 9.78 ms | 195.5 ms | 4000.0000 | 1000.0000 | 28 MB |
430-
431-
8. Repeat for any number of changes you would like to test.
432-
9. **Optionally:** benchmark code and results can be included as part of the PR for future reference.
433-
434305
## Additional resources
435306

436307
The primary technical guide to the core compiler code is [The F# Compiler Technical Guide](https://github.com/dotnet/fsharp/blob/main/docs/index.md). Please read and contribute to that guide.

Directory.Build.props

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
<LangVersion Condition="'$(FSharpLangVersion)' != ''">$(FSharpLangVersion)</LangVersion>
55
<RepoRoot Condition="'$(RepoRoot)' == ''">$(MSBuildThisFileDirectory)</RepoRoot>
66
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
7+
<FSharpNetCoreProductDefaultTargetFramework>net8.0</FSharpNetCoreProductDefaultTargetFramework>
78
</PropertyGroup>
89
<!--
910
When developers load the FSharp.Compiler.Service solution we set FSHARPCORE_USE_PACKAGE to true if it hasn't already been set to a value.
10-
This option ensures that building and testing uses the specified FSharp.Core nuget package instead of the local
11-
FSharp.Core project.
12-
We also disable arcade and reset certain artifacts and compiler paths to use default ones
11+
This option ensures that building and testing uses the specified FSharp.Core nuget package instead of the local FSharp.Core project.
12+
We also disable arcade and reset certain artifacts and compiler paths to use default ones.
1313
All settings below can be overriden via CLI switches if needed. -->
1414

1515
<PropertyGroup Condition="'$(SolutionName)' == 'FSharp.Compiler.Service' and '$(BUILDING_USING_DOTNET)' != 'false'">
@@ -21,7 +21,7 @@
2121
<BUILDING_USING_DOTNET>true</BUILDING_USING_DOTNET>
2222
</PropertyGroup>
2323

24-
<Import Project="$(RepoRoot)/Directory.Build.props.user" Condition = "Exists('$(RepoRoot)/Directory.Build.props.user')" />
24+
<Import Project="$(RepoRoot)/Directory.Build.props.user" Condition="Exists('$(RepoRoot)/Directory.Build.props.user')" />
2525

2626
<PropertyGroup Condition="'$(BUILDING_USING_DOTNET)' == 'true'">
2727
<DisableAutoSetFscCompilerPath>false</DisableAutoSetFscCompilerPath>
@@ -30,14 +30,40 @@
3030
<ArtifactsDir>$(MSBuildThisFileDirectory)artifacts/</ArtifactsDir>
3131
<OutputPath>$(ArtifactsDir)/bin/$(MSBuildProjectName)/$(Configuration)/</OutputPath>
3232
<IntermediateOutputPath>$(ArtifactsDir)obj/$(MSBuildProjectName)/$(Configuration)/</IntermediateOutputPath>
33-
<FsLexPath>$(ArtifactsDir)/bin/fslex/$(Configuration)/net8.0/fslex.dll</FsLexPath>
34-
<FsYaccPath>$(ArtifactsDir)/bin/fsyacc/$(Configuration)/net8.0/fsyacc.dll</FsYaccPath>
33+
<!-- Note, that default framework is used here (the one we use for development in the current cycle),
34+
since it's a non-arcade and non-sourcebuild scenario -->
35+
<FsLexPath>$(ArtifactsDir)/bin/fslex/$(Configuration)/$(FSharpNetCoreProductDefaultTargetFramework)/fslex.dll</FsLexPath>
36+
<FsYaccPath>$(ArtifactsDir)/bin/fsyacc/$(Configuration)/$(FSharpNetCoreProductDefaultTargetFramework)/fsyacc.dll</FsYaccPath>
37+
<DefineConstants>NO_CHECKNULLS;BUILDING_WITH_LKG;NO_NULLCHECKING_LIB_SUPPORT;$(DefineConstants)</DefineConstants>
3538
</PropertyGroup>
39+
<Import Project="$(MSBuildThisFileDirectory)/eng/Versions.props" Condition="'$(DISABLE_ARCADE)' == 'true'" />
3640

37-
<Import Project="$(MSBuildThisFileDirectory)/eng/Versions.props" Condition="'$(DISABLE_ARCADE)' == 'true'"/>
41+
<Import Project="FSharpBuild.Directory.Build.props" Condition=" '$(FSharpTestCompilerVersion)' == '' " />
42+
<!-- To support source-build for the "next" version of .NET without forcing this repo to use it,
43+
we can utilize arcade's $(NetCurrent) property, and set it ourselves in the arcade-less scenarios.
44+
For FCS solution, we set it to one for current dev cycle.
45+
When used with arcade, and inserting/building for net8 branches, it will set it to net8.0, for net9 branches to net9.0 and so on. -->
46+
<Choose>
47+
<!-- Once we move to OOP in VS, and major dependants of FCS will move to netcore (not netstandard),
48+
we should also support $(NetPrevious) for all releases.
49+
This will likely include FCS and FSharp.Core as well as shipped products.
50+
Right now, it only covers products we ship (FSC and FSI), not NuGet packages. -->
51+
<When Condition="'$(DotNetBuildFromSource)' == 'true' AND '$(DotNetBuildFromSourceFlavor)' == 'Product'">
52+
<PropertyGroup>
53+
<FSharpNetCoreProductTargetFramework>$(NetCurrent)</FSharpNetCoreProductTargetFramework>
54+
</PropertyGroup>
55+
</When>
56+
<Otherwise>
57+
<PropertyGroup>
58+
<FSharpNetCoreProductTargetFramework>$(FSharpNetCoreProductDefaultTargetFramework)</FSharpNetCoreProductTargetFramework>
59+
</PropertyGroup>
60+
</Otherwise>
61+
</Choose>
3862

39-
<Import Project="FSharpBuild.Directory.Build.props" Condition = " '$(FSharpTestCompilerVersion)' == '' "/>
40-
<Import Project="FSharpTests.Directory.Build.props" Condition = " '$(FSharpTestCompilerVersion)' != '' "/>
63+
<!-- It's important we set TFM before this, since FSharpTests.Directory.Build.props uses it.
64+
TODO(vlza): this build props looks outdated, since we only use $(FSharpTestCompilerVersion) in TP tests or cambridge suite (which we slowly want to migrate to xUnit).
65+
We probably should remove or revisit it. -->
66+
<Import Project="FSharpTests.Directory.Build.props" Condition=" '$(FSharpTestCompilerVersion)' != '' " />
4167

4268
<ItemGroup>
4369
<!-- If there is a README.md next to a project file, include it (for easier access in the IDE) -->

Directory.Build.targets

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@
1313
<PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitRunnerVersion)" />
1414
<PackageReference Include="NunitXml.TestLogger" Version="$(NunitXmlTestLoggerVersion)" />
1515
</ItemGroup>
16-
<ItemGroup>
17-
<PackageReference Condition="'$(BUILDING_USING_DOTNET)' == 'true'" Include="Microsoft.DotNet.XliffTasks" Version="$(MicrosoftDotNetXliffTasksVersion)" PrivateAssets="all" />
18-
</ItemGroup>
1916
</Project>

FSharp.Benchmarks.sln

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
23
# Visual Studio Version 17
34
VisualStudioVersion = 17.1.32113.165
45
MinimumVisualStudioVersion = 10.0.40219.1
@@ -24,10 +25,10 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Benchmarks"
2425
EndProject
2526
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FCSSourceFiles", "tests\benchmarks\FCSBenchmarks\FCSSourceFiles\FCSSourceFiles.fsproj", "{0E2A7B27-3AD3-4C1D-BA0D-008A1200946F}"
2627
EndProject
27-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fsharp.ProfilingStartpointProject", "tests\benchmarks\Fsharp.ProfilingStartpointProject\Fsharp.ProfilingStartpointProject.fsproj", "{9F27346B-2FC6-4FD5-A932-4E80F331E6D6}"
28-
EndProject
2928
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Test.Utilities", "tests\FSharp.Test.Utilities\FSharp.Test.Utilities.fsproj", "{0B149238-0912-493E-8877-F831AE01B942}"
3029
EndProject
30+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Benchmarks.Common", "tests\benchmarks\FSharp.Benchmarks.Common\FSharp.Benchmarks.Common.fsproj", "{62DED1EA-6A33-4537-8ED2-118462D0FEE5}"
31+
EndProject
3132
Global
3233
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3334
Debug|Any CPU = Debug|Any CPU
@@ -105,18 +106,20 @@ Global
105106
{0E2A7B27-3AD3-4C1D-BA0D-008A1200946F}.Release|Any CPU.Build.0 = Release|Any CPU
106107
{0E2A7B27-3AD3-4C1D-BA0D-008A1200946F}.ReleaseCompressed|Any CPU.ActiveCfg = Debug|Any CPU
107108
{0E2A7B27-3AD3-4C1D-BA0D-008A1200946F}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
108-
{9F27346B-2FC6-4FD5-A932-4E80F331E6D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
109-
{9F27346B-2FC6-4FD5-A932-4E80F331E6D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
110-
{9F27346B-2FC6-4FD5-A932-4E80F331E6D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
111-
{9F27346B-2FC6-4FD5-A932-4E80F331E6D6}.Release|Any CPU.Build.0 = Release|Any CPU
112-
{9F27346B-2FC6-4FD5-A932-4E80F331E6D6}.ReleaseCompressed|Any CPU.ActiveCfg = Debug|Any CPU
113-
{9F27346B-2FC6-4FD5-A932-4E80F331E6D6}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
114109
{0B149238-0912-493E-8877-F831AE01B942}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
115110
{0B149238-0912-493E-8877-F831AE01B942}.Debug|Any CPU.Build.0 = Debug|Any CPU
116111
{0B149238-0912-493E-8877-F831AE01B942}.Release|Any CPU.ActiveCfg = Release|Any CPU
117112
{0B149238-0912-493E-8877-F831AE01B942}.Release|Any CPU.Build.0 = Release|Any CPU
118113
{0B149238-0912-493E-8877-F831AE01B942}.ReleaseCompressed|Any CPU.ActiveCfg = Debug|Any CPU
119114
{0B149238-0912-493E-8877-F831AE01B942}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
115+
{62DED1EA-6A33-4537-8ED2-118462D0FEE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
116+
{62DED1EA-6A33-4537-8ED2-118462D0FEE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
117+
{62DED1EA-6A33-4537-8ED2-118462D0FEE5}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
118+
{62DED1EA-6A33-4537-8ED2-118462D0FEE5}.Proto|Any CPU.Build.0 = Debug|Any CPU
119+
{62DED1EA-6A33-4537-8ED2-118462D0FEE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
120+
{62DED1EA-6A33-4537-8ED2-118462D0FEE5}.Release|Any CPU.Build.0 = Release|Any CPU
121+
{62DED1EA-6A33-4537-8ED2-118462D0FEE5}.ReleaseCompressed|Any CPU.ActiveCfg = Release|Any CPU
122+
{62DED1EA-6A33-4537-8ED2-118462D0FEE5}.ReleaseCompressed|Any CPU.Build.0 = Release|Any CPU
120123
EndGlobalSection
121124
GlobalSection(SolutionProperties) = preSolution
122125
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)