Skip to content

Commit 7dd40ee

Browse files
committed
merge main
2 parents d62ec6e + b897908 commit 7dd40ee

File tree

50 files changed

+517
-404
lines changed

Some content is hidden

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

50 files changed

+517
-404
lines changed

azure-pipelines.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CI and PR triggers
1+
# CI and PR triggers
22
trigger:
33
branches:
44
include:
@@ -433,6 +433,10 @@ stages:
433433
vs_release:
434434
_configuration: Release
435435
_testKind: testVs
436+
transparent_compiler_release:
437+
_configuration: Release
438+
_testKind: testCoreclr
439+
436440
${{ if eq(variables['Build.Reason'], 'Flaky, disabled, was PullRequest') }}:
437441
inttests_release:
438442
_configuration: Release
@@ -450,7 +454,15 @@ stages:
450454
env:
451455
NativeToolsOnMachine: true
452456
displayName: Build / Test
453-
condition: ne(variables['_testKind'], 'testIntegration')
457+
condition: and( ne(variables['_testKind'], 'testIntegration'), ne(variables['System.JobName'], 'transparent_compiler_release') )
458+
459+
- script: eng\CIBuild.cmd -compressallmetadata -configuration $(_configuration) -$(_testKind)
460+
env:
461+
TEST_TRANSPARENT_COMPILER: 1
462+
NativeToolsOnMachine: true
463+
displayName: Build / Test Transparent Compiler
464+
condition: and( eq(variables['System.JobName'], 'transparent_compiler_release'), ne(variables['_testKind'], 'testIntegration') )
465+
454466
- script: eng\CIBuild.cmd -compressallmetadata -configuration $(_configuration) -$(_testKind)
455467
env:
456468
NativeToolsOnMachine: true

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Dependencies>
33
<ProductDependencies>
4-
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.24105.3">
4+
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.24107.1">
55
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
6-
<Sha>ffac2194c39660f03761ba81bdd6026202942184</Sha>
6+
<Sha>a739c05eb1a5200d7fa2f1e3977b4dc54fdec36a</Sha>
77
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
88
</Dependency>
99
<!-- Intermediate is necessary for source build. -->

src/Compiler/Service/FSharpCheckerResults.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ open Internal.Utilities.Hashing
6060

6161
type FSharpUnresolvedReferencesSet = FSharpUnresolvedReferencesSet of UnresolvedAssemblyReference list
6262

63+
[<RequireQualifiedAccess>]
64+
type DocumentSource =
65+
| FileSystem
66+
| Custom of (string -> Async<ISourceText option>)
67+
6368
[<Sealed>]
6469
type DelayedILModuleReader =
6570
val private name: string

src/Compiler/Service/FSharpCheckerResults.fsi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ open FSharp.Compiler.Text
3030

3131
open Internal.Utilities.Collections
3232

33+
[<Experimental "This type is experimental and likely to be removed in the future.">]
34+
[<RequireQualifiedAccess>]
35+
type DocumentSource =
36+
| FileSystem
37+
| Custom of (string -> Async<ISourceText option>)
38+
3339
/// Delays the creation of an ILModuleReader
3440
[<Sealed>]
3541
type DelayedILModuleReader =

src/Compiler/Service/FSharpProjectSnapshot.fs

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,25 @@ type FSharpFileSnapshot(FileName: string, Version: string, GetSource: unit -> Ta
8282
|> Task.FromResult
8383
)
8484

85+
static member CreateFromDocumentSource(fileName: string, documentSource: DocumentSource) =
86+
87+
match documentSource with
88+
| DocumentSource.Custom f ->
89+
let version = DateTime.Now.Ticks.ToString()
90+
91+
FSharpFileSnapshot(
92+
fileName,
93+
version,
94+
fun () ->
95+
task {
96+
match! f fileName |> Async.StartAsTask with
97+
| Some source -> return SourceTextNew.ofISourceText source
98+
| None -> return failwith $"Couldn't get source for file {f}"
99+
}
100+
)
101+
102+
| DocumentSource.FileSystem -> FSharpFileSnapshot.CreateFromFileSystem fileName
103+
85104
member public _.FileName = FileName
86105
member _.Version = Version
87106
member _.GetSource() = GetSource()
@@ -604,13 +623,22 @@ and [<Experimental("This FCS API is experimental and subject to change.")>] FSha
604623
return snapshotAccumulator[options]
605624
}
606625

607-
static member internal GetFileSnapshotFromDisk _ fileName =
608-
FSharpFileSnapshot.CreateFromFileSystem fileName |> async.Return
609-
610-
static member FromOptions(options: FSharpProjectOptions) =
611-
FSharpProjectSnapshot.FromOptions(options, FSharpProjectSnapshot.GetFileSnapshotFromDisk)
626+
static member FromOptions(options: FSharpProjectOptions, documentSource: DocumentSource) =
627+
FSharpProjectSnapshot.FromOptions(
628+
options,
629+
fun _ fileName ->
630+
FSharpFileSnapshot.CreateFromDocumentSource(fileName, documentSource)
631+
|> async.Return
632+
)
612633

613-
static member FromOptions(options: FSharpProjectOptions, fileName: string, fileVersion: int, sourceText: ISourceText) =
634+
static member FromOptions
635+
(
636+
options: FSharpProjectOptions,
637+
fileName: string,
638+
fileVersion: int,
639+
sourceText: ISourceText,
640+
documentSource: DocumentSource
641+
) =
614642

615643
let getFileSnapshot _ fName =
616644
if fName = fileName then
@@ -620,7 +648,7 @@ and [<Experimental("This FCS API is experimental and subject to change.")>] FSha
620648
fun () -> Task.FromResult(SourceTextNew.ofISourceText sourceText)
621649
)
622650
else
623-
FSharpFileSnapshot.CreateFromFileSystem fName
651+
FSharpFileSnapshot.CreateFromDocumentSource(fName, documentSource)
624652
|> async.Return
625653

626654
FSharpProjectSnapshot.FromOptions(options, getFileSnapshot)

src/Compiler/Service/TransparentCompiler.fs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,11 @@ type internal TransparentCompiler
325325
useSyntaxTreeCache
326326
) as self =
327327

328+
let documentSource =
329+
match getSource with
330+
| Some getSource -> DocumentSource.Custom getSource
331+
| None -> DocumentSource.FileSystem
332+
328333
// Is having just one of these ok?
329334
let lexResourceManager = Lexhelp.LexResourceManager()
330335

@@ -1470,8 +1475,6 @@ type internal TransparentCompiler
14701475
let tcSymbolUses = sink.GetSymbolUses()
14711476
let tcOpenDeclarations = sink.GetOpenDeclarations()
14721477

1473-
let tcDependencyFiles = [] // TODO add as a set to TcIntermediate
1474-
14751478
// TODO: Apparently creating diagnostics can produce further diagnostics. So let's capture those too. Hopefully there is a more elegant solution...
14761479
// Probably diagnostics need to be evaluated during typecheck anyway for proper formatting, which might take care of this too.
14771480
let extraLogger = CapturingDiagnosticsLogger("DiagnosticsWhileCreatingDiagnostics")
@@ -1531,7 +1534,7 @@ type internal TransparentCompiler
15311534
projectSnapshot.IsIncompleteTypeCheckEnvironment,
15321535
None,
15331536
projectSnapshot.ToOptions(),
1534-
Array.ofList tcDependencyFiles,
1537+
Array.ofList tcInfo.tcDependencyFiles,
15351538
creationDiags,
15361539
parseResults.Diagnostics,
15371540
tcDiagnostics,
@@ -1931,7 +1934,7 @@ type internal TransparentCompiler
19311934
userOpName: string
19321935
) : Async<FSharpCheckFileAnswer> =
19331936
async {
1934-
let! snapshot = FSharpProjectSnapshot.FromOptions(options, fileName, fileVersion, sourceText)
1937+
let! snapshot = FSharpProjectSnapshot.FromOptions(options, fileName, fileVersion, sourceText, documentSource)
19351938

19361939
ignore parseResults
19371940

@@ -1950,7 +1953,7 @@ type internal TransparentCompiler
19501953
userOpName: string
19511954
) : Async<FSharpCheckFileAnswer option> =
19521955
async {
1953-
let! snapshot = FSharpProjectSnapshot.FromOptions(options, fileName, fileVersion, sourceText)
1956+
let! snapshot = FSharpProjectSnapshot.FromOptions(options, fileName, fileVersion, sourceText, documentSource)
19541957

19551958
ignore parseResults
19561959

@@ -2001,7 +2004,8 @@ type internal TransparentCompiler
20012004
) : Async<seq<range>> =
20022005
async {
20032006
ignore canInvalidateProject
2004-
let! snapshot = FSharpProjectSnapshot.FromOptions options
2007+
2008+
let! snapshot = FSharpProjectSnapshot.FromOptions(options, documentSource)
20052009

20062010
return! this.FindReferencesInFile(fileName, snapshot.ProjectSnapshot, symbol, userOpName)
20072011
}
@@ -2014,7 +2018,8 @@ type internal TransparentCompiler
20142018

20152019
member this.GetAssemblyData(options: FSharpProjectOptions, fileName, userOpName: string) : Async<ProjectAssemblyDataResult> =
20162020
async {
2017-
let! snapshot = FSharpProjectSnapshot.FromOptions options
2021+
let! snapshot = FSharpProjectSnapshot.FromOptions(options, documentSource)
2022+
20182023
return! this.GetAssemblyData(snapshot.ProjectSnapshot, fileName, userOpName)
20192024
}
20202025

@@ -2033,7 +2038,7 @@ type internal TransparentCompiler
20332038
userOpName: string
20342039
) : Async<FSharpParseFileResults * FSharpCheckFileResults> =
20352040
async {
2036-
let! snapshot = FSharpProjectSnapshot.FromOptions options
2041+
let! snapshot = FSharpProjectSnapshot.FromOptions(options, documentSource)
20372042

20382043
match! this.ParseAndCheckFileInProject(fileName, snapshot.ProjectSnapshot, userOpName) with
20392044
| parseResult, FSharpCheckFileAnswer.Succeeded checkResult -> return parseResult, checkResult
@@ -2047,7 +2052,8 @@ type internal TransparentCompiler
20472052
userOpName: string
20482053
) : Async<FSharpParseFileResults> =
20492054
async {
2050-
let! snapshot = FSharpProjectSnapshot.FromOptions options
2055+
let! snapshot = FSharpProjectSnapshot.FromOptions(options, documentSource)
2056+
20512057
return! this.ParseFile(fileName, snapshot.ProjectSnapshot, userOpName)
20522058
}
20532059

@@ -2061,7 +2067,7 @@ type internal TransparentCompiler
20612067
async {
20622068
ignore builder
20632069

2064-
let! snapshot = FSharpProjectSnapshot.FromOptions(options, fileName, 1, sourceText)
2070+
let! snapshot = FSharpProjectSnapshot.FromOptions(options, fileName, 1, sourceText, documentSource)
20652071

20662072
match! this.ParseAndCheckFileInProject(fileName, snapshot.ProjectSnapshot, "GetCachedCheckFileResult") with
20672073
| parseResult, FSharpCheckFileAnswer.Succeeded checkResult -> return Some(parseResult, checkResult)
@@ -2110,7 +2116,9 @@ type internal TransparentCompiler
21102116
) : Async<EditorServices.SemanticClassificationView option> =
21112117
async {
21122118
ignore userOpName
2113-
let! snapshot = FSharpProjectSnapshot.FromOptions options
2119+
2120+
let! snapshot = FSharpProjectSnapshot.FromOptions(options, documentSource)
2121+
21142122
return! ComputeSemanticClassification(fileName, snapshot.ProjectSnapshot)
21152123
}
21162124

@@ -2132,7 +2140,7 @@ type internal TransparentCompiler
21322140
userOpName: string
21332141
) : Async<FSharpParseFileResults * FSharpCheckFileAnswer> =
21342142
async {
2135-
let! snapshot = FSharpProjectSnapshot.FromOptions(options, fileName, fileVersion, sourceText)
2143+
let! snapshot = FSharpProjectSnapshot.FromOptions(options, fileName, fileVersion, sourceText, documentSource)
21362144

21372145
return! this.ParseAndCheckFileInProject(fileName, snapshot.ProjectSnapshot, userOpName)
21382146
}
@@ -2143,7 +2151,9 @@ type internal TransparentCompiler
21432151
member this.ParseAndCheckProject(options: FSharpProjectOptions, userOpName: string) : Async<FSharpCheckProjectResults> =
21442152
async {
21452153
ignore userOpName
2146-
let! snapshot = FSharpProjectSnapshot.FromOptions options
2154+
2155+
let! snapshot = FSharpProjectSnapshot.FromOptions(options, documentSource)
2156+
21472157
return! ComputeParseAndCheckProject snapshot.ProjectSnapshot
21482158
}
21492159

src/Compiler/Service/service.fs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ open FSharp.Compiler.Text.Range
3737
open FSharp.Compiler.TcGlobals
3838
open FSharp.Compiler.BuildGraph
3939

40-
[<RequireQualifiedAccess>]
41-
type DocumentSource =
42-
| FileSystem
43-
| Custom of (string -> Async<ISourceText option>)
44-
4540
/// Callback that indicates whether a requested result has become obsolete.
4641
[<NoComparison; NoEquality>]
4742
type IsResultObsolete = IsResultObsolete of (unit -> bool)

src/Compiler/Service/service.fsi

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ open FSharp.Compiler.Syntax
1919
open FSharp.Compiler.Text
2020
open FSharp.Compiler.Tokenization
2121

22-
[<Experimental "This type is experimental and likely to be removed in the future.">]
23-
[<RequireQualifiedAccess>]
24-
type DocumentSource =
25-
| FileSystem
26-
| Custom of (string -> Async<ISourceText option>)
27-
2822
/// Used to parse and check F# source code.
2923
[<Sealed; AutoSerializable(false)>]
3024
type public FSharpChecker =

tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ type internal EventRecorder<'a, 'b, 'c when 'a : equality and 'b : equality>(mem
5454
let actual = events |> Seq.toArray
5555
Assert.Equal<_ array>(expected, actual)
5656

57+
member _.Sequence = events |> Seq.map id
58+
5759

5860
[<Fact>]
5961
let ``Basics``() =
@@ -63,10 +65,8 @@ let ``Basics``() =
6365
return key * 2
6466
}
6567

66-
let eventLog = ConcurrentBag()
67-
6868
let memoize = AsyncMemoize<int, int, int>()
69-
memoize.OnEvent(fun (e, (_label, k, _version)) -> eventLog.Add (e, k))
69+
let events = EventRecorder(memoize)
7070

7171
let result =
7272
seq {
@@ -84,7 +84,9 @@ let ``Basics``() =
8484

8585
Assert.Equal<int array>(expected, result)
8686

87-
let groups = eventLog |> Seq.groupBy snd |> Seq.toList
87+
(waitUntil (events.CountOf Finished) 3).Wait()
88+
89+
let groups = events.Sequence |> Seq.groupBy snd |> Seq.toList
8890
Assert.Equal(3, groups.Length)
8991
for key, events in groups do
9092
Assert.Equal<Set<(JobEvent * int)>>(Set [ Requested, key; Started, key; Finished, key ], Set events)

tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MethodResolution.fs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,23 @@ extends [runtime]System.Object
7676
7777
}
7878
79-
.method assembly specialname static class [runtime]System.Tuple`2<bool,int32>
80-
get_patternInput@9() cil managed
79+
.method assembly specialname static class [runtime]System.Tuple`2<bool,int32> get_patternInput@9() cil managed
8180
{
8281
8382
.maxstack 8
8483
IL_0000: ldsfld class [runtime]System.Tuple`2<bool,int32> '<StartupCode$assembly>'.$OutOptionalTests::patternInput@9
8584
IL_0005: ret
8685
}
8786
88-
.method assembly specialname static int32
89-
get_outArg@9() cil managed
87+
.method assembly specialname static int32 get_outArg@9() cil managed
9088
{
9189
9290
.maxstack 8
9391
IL_0000: ldsfld int32 '<StartupCode$assembly>'.$OutOptionalTests::outArg@9
9492
IL_0005: ret
9593
}
9694
97-
.method assembly specialname static void
98-
set_outArg@9(int32 'value') cil managed
95+
.method assembly specialname static void set_outArg@9(int32 'value') cil managed
9996
{
10097
10198
.maxstack 8
@@ -104,26 +101,23 @@ extends [runtime]System.Object
104101
IL_0006: ret
105102
}
106103
107-
.method assembly specialname static class [runtime]System.Tuple`2<bool,int32>
108-
'get_patternInput@10-1'() cil managed
104+
.method assembly specialname static class [runtime]System.Tuple`2<bool,int32> 'get_patternInput@10-1'() cil managed
109105
{
110106
111107
.maxstack 8
112108
IL_0000: ldsfld class [runtime]System.Tuple`2<bool,int32> '<StartupCode$assembly>'.$OutOptionalTests::'patternInput@10-1'
113109
IL_0005: ret
114110
}
115111
116-
.method assembly specialname static int32
117-
'get_outArg@10-1'() cil managed
112+
.method assembly specialname static int32 'get_outArg@10-1'() cil managed
118113
{
119114
120115
.maxstack 8
121116
IL_0000: ldsfld int32 '<StartupCode$assembly>'.$OutOptionalTests::'outArg@10-1'
122117
IL_0005: ret
123118
}
124119
125-
.method assembly specialname static void
126-
'set_outArg@10-1'(int32 'value') cil managed
120+
.method assembly specialname static void 'set_outArg@10-1'(int32 'value') cil managed
127121
{
128122
129123
.maxstack 8
@@ -174,8 +168,7 @@ extends [runtime]System.Object
174168
.custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
175169
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
176170
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
177-
.method private specialname rtspecialname static
178-
void .cctor() cil managed
171+
.method private specialname rtspecialname static void .cctor() cil managed
179172
{
180173
181174
.maxstack 4

0 commit comments

Comments
 (0)