Skip to content

Commit c86c851

Browse files
committed
Merge remote-tracking branch 'upstream/main' into otel
2 parents 679d2aa + e06e079 commit c86c851

15 files changed

Lines changed: 157 additions & 20 deletions

File tree

azure-pipelines.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ stages:
210210
- name: _SignType
211211
value: Test
212212
pool:
213-
name: NetCore1ESPool-Public
213+
name: NetCore-Public
214214
demands: ImageOverride -equals $(WindowsMachineQueueName)
215215
timeoutInMinutes: 90
216216
steps:
@@ -283,7 +283,7 @@ stages:
283283
# WindowsMachineQueueName=Windows.vs2022.amd64.open
284284
# and there is an alternate build definition that sets this to a queue that is always scouting the
285285
# next preview of Visual Studio.
286-
name: NetCore1ESPool-Public
286+
name: NetCore-Public
287287
demands: ImageOverride -equals $(WindowsMachineQueueName)
288288
timeoutInMinutes: 120
289289
strategy:
@@ -341,7 +341,7 @@ stages:
341341
# WindowsMachineQueueName=Windows.vs2022.amd64.open
342342
# and there is an alternate build definition that sets this to a queue that is always scouting the
343343
# next preview of Visual Studio.
344-
name: NetCore1ESPool-Public
344+
name: NetCore-Public
345345
demands: ImageOverride -equals $(WindowsMachineQueueName)
346346
timeoutInMinutes: 120
347347
strategy:
@@ -395,7 +395,7 @@ stages:
395395
# Mock official build
396396
- job: MockOfficial
397397
pool:
398-
name: NetCore1ESPool-Public
398+
name: NetCore-Public
399399
demands: ImageOverride -equals $(WindowsMachineQueueName)
400400
steps:
401401
- checkout: self
@@ -445,6 +445,7 @@ stages:
445445

446446
# MacOS
447447
- job: MacOS
448+
condition: eq(1,2)
448449
pool:
449450
vmImage: $(MacOSMachineQueueName)
450451
variables:
@@ -486,7 +487,7 @@ stages:
486487
# End to end build
487488
- job: EndToEndBuildTests
488489
pool:
489-
name: NetCore1ESPool-Public
490+
name: NetCore-Public
490491
demands: ImageOverride -equals $(WindowsMachineQueueName)
491492
steps:
492493
- checkout: self
@@ -511,7 +512,7 @@ stages:
511512
# Plain build Windows
512513
- job: Plain_Build_Windows
513514
pool:
514-
name: NetCore1ESPool-Public
515+
name: NetCore-Public
515516
demands: ImageOverride -equals $(WindowsMachineQueueName)
516517
variables:
517518
- name: _BuildConfig
@@ -575,6 +576,7 @@ stages:
575576

576577
# Plain build Mac
577578
- job: Plain_Build_MacOS
579+
condition: eq(1,2)
578580
pool:
579581
vmImage: $(MacOSMachineQueueName)
580582
variables:

eng/common/templates/job/source-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
# source-build builds run in Docker, including the default managed platform.
4747
pool:
4848
${{ if eq(variables['System.TeamProject'], 'public') }}:
49-
name: NetCore1ESPool-Public
49+
name: NetCore-Public
5050
demands: ImageOverride -equals Build.Ubuntu.1804.Amd64.Open
5151
${{ if eq(variables['System.TeamProject'], 'internal') }}:
5252
name: NetCore1ESPool-Internal

eng/common/templates/job/source-index-stage1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
${{ if eq(parameters.pool, '') }}:
2929
pool:
3030
${{ if eq(variables['System.TeamProject'], 'public') }}:
31-
name: NetCore1ESPool-Public
31+
name: NetCore-Public
3232
demands: ImageOverride -equals windows.vs2019.amd64.open
3333
${{ if eq(variables['System.TeamProject'], 'internal') }}:
3434
name: NetCore1ESPool-Internal

src/Compiler/AbstractIL/ilwrite.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4122,7 +4122,7 @@ let writeBinaryAux (stream: Stream, options: options, modul, normalizeAssemblyRe
41224122
| Some AMD64 -> writeInt32AsUInt16 os 0x8664 // Machine - IMAGE_FILE_MACHINE_AMD64
41234123
| Some IA64 -> writeInt32AsUInt16 os 0x200 // Machine - IMAGE_FILE_MACHINE_IA64
41244124
| Some ARM64 -> writeInt32AsUInt16 os 0xaa64 // Machine - IMAGE_FILE_MACHINE_ARM64
4125-
| Some ARM -> writeInt32AsUInt16 os 0x1c0 // Machine - IMAGE_FILE_MACHINE_ARM
4125+
| Some ARM -> writeInt32AsUInt16 os 0x1c4 // Machine - IMAGE_FILE_MACHINE_ARMNT
41264126
| _ -> writeInt32AsUInt16 os 0x014c // Machine - IMAGE_FILE_MACHINE_I386
41274127

41284128
writeInt32AsUInt16 os numSections

src/Compiler/Checking/NicePrint.fs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2420,7 +2420,23 @@ module InferredSigPrinting =
24202420
modNameEqualsL @@* basic
24212421
layoutXmlDoc denv true mspec.XmlDoc basicL
24222422

2423-
imdefL denv expr
2423+
let emptyModuleOrNamespace mspec =
2424+
let innerPath = (fullCompPathOfModuleOrNamespace mspec).AccessPath
2425+
let pathL = innerPath |> List.map (fst >> ConvertLogicalNameToDisplayLayout (tagNamespace >> wordL))
2426+
2427+
let keyword =
2428+
if not mspec.IsImplicitNamespace && mspec.IsNamespace then
2429+
"namespace"
2430+
else
2431+
"module"
2432+
2433+
wordL (tagKeyword keyword) ^^ sepListL SepL.dot pathL
2434+
2435+
match expr with
2436+
| EmptyModuleOrNamespaces mspecs ->
2437+
List.map emptyModuleOrNamespace mspecs
2438+
|> aboveListL
2439+
| expr -> imdefL denv expr
24242440

24252441
//--------------------------------------------------------------------------
24262442

src/Compiler/TypedTree/TypedTreeOps.fs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10360,3 +10360,35 @@ let isFSharpExceptionTy g ty =
1036010360
| ValueSome tcref -> tcref.IsFSharpException
1036110361
| _ -> false
1036210362

10363+
let (|EmptyModuleOrNamespaces|_|) (moduleOrNamespaceContents: ModuleOrNamespaceContents) =
10364+
match moduleOrNamespaceContents with
10365+
| TMDefs(defs = defs) ->
10366+
let mdDefsLength =
10367+
defs
10368+
|> List.count (function
10369+
| ModuleOrNamespaceContents.TMDefRec _
10370+
| ModuleOrNamespaceContents.TMDefs _ -> true
10371+
| _ -> false)
10372+
10373+
let emptyModuleOrNamespaces =
10374+
defs
10375+
|> List.choose (function
10376+
| ModuleOrNamespaceContents.TMDefRec _ as defRec
10377+
| ModuleOrNamespaceContents.TMDefs(defs = [ ModuleOrNamespaceContents.TMDefRec _ as defRec ]) ->
10378+
match defRec with
10379+
| TMDefRec(bindings = [ ModuleOrNamespaceBinding.Module(mspec, ModuleOrNamespaceContents.TMDefs(defs = defs)) ]) ->
10380+
defs
10381+
|> List.forall (function
10382+
| ModuleOrNamespaceContents.TMDefOpens _
10383+
| ModuleOrNamespaceContents.TMDefDo _
10384+
| ModuleOrNamespaceContents.TMDefRec (isRec = true; tycons = []; bindings = []) -> true
10385+
| _ -> false)
10386+
|> fun isEmpty -> if isEmpty then Some mspec else None
10387+
| _ -> None
10388+
| _ -> None)
10389+
10390+
if mdDefsLength = emptyModuleOrNamespaces.Length then
10391+
Some emptyModuleOrNamespaces
10392+
else
10393+
None
10394+
| _ -> None

src/Compiler/TypedTree/TypedTreeOps.fsi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,3 +2676,9 @@ type TraitConstraintInfo with
26762676

26772677
/// Get the key associated with the member constraint.
26782678
member GetWitnessInfo: unit -> TraitWitnessInfo
2679+
2680+
/// Matches a ModuleOrNamespaceContents that is empty from a signature printing point of view.
2681+
/// Signatures printed via the typed tree in NicePrint don't print TMDefOpens or TMDefDo.
2682+
/// This will match anything that does not have any types or bindings.
2683+
val (|EmptyModuleOrNamespaces|_|):
2684+
moduleOrNamespaceContents: ModuleOrNamespaceContents -> (ModuleOrNamespace list) option

tests/FSharp.Compiler.ComponentTests/Signatures/ModuleOrNamespaceTests.fs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,58 @@ namespace Fantomas.Core
142142
val genExpr: e: FSharp.Compiler.Syntax.SynExpr -> ctx: Context.Context -> Context.Context
143143
144144
val genLambdaArrowWithTrivia: bodyExpr: (FSharp.Compiler.Syntax.SynExpr -> Context.Context -> Context.Context) -> body: FSharp.Compiler.Syntax.SynExpr -> arrowRange: FSharp.Compiler.Text.Range option -> (Context.Context -> Context.Context)"""
145+
146+
[<Fact>]
147+
let ``Empty namespace`` () =
148+
FSharp
149+
"""
150+
namespace System
151+
152+
open System.Runtime.CompilerServices
153+
154+
[<assembly: InternalsVisibleTo("Fantomas.Core.Tests")>]
155+
156+
do ()
157+
"""
158+
|> printSignatures
159+
|> should equal "namespace System"
160+
161+
[<Fact>]
162+
let ``Empty module`` () =
163+
FSharp
164+
"""
165+
module Foobar
166+
167+
do ()
168+
"""
169+
|> printSignatures
170+
|> should equal "module Foobar"
171+
172+
[<Fact>]
173+
let ``Two empty namespaces`` () =
174+
FSharp
175+
"""
176+
namespace Foo
177+
178+
do ()
179+
180+
namespace Bar
181+
182+
do ()
183+
"""
184+
|> printSignatures
185+
|> prependNewline
186+
|> should equal """
187+
namespace Foo
188+
namespace Bar"""
189+
190+
[<Fact>]
191+
let ``Empty namespace module`` () =
192+
FSharp
193+
"""
194+
namespace rec Foobar
195+
196+
do ()
197+
"""
198+
|> printSignatures
199+
|> should equal "namespace Foobar"

tests/fsharp/core/load-script/out.stdout.bsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ World
1616
-the end
1717
Test 3=================================================
1818

19-
> [Loading D:\staging\staging\src\tests\fsharp\core\load-script\1.fsx
19+
> module FSI_0001
20+
21+
[Loading D:\staging\staging\src\tests\fsharp\core\load-script\1.fsx
2022
Loading D:\staging\staging\src\tests\fsharp\core\load-script\2.fsx
2123
Loading D:\staging\staging\src\tests\fsharp\core\load-script\3.fsx]
2224
Hello

tests/fsharp/core/printing/output.1000.stdout.bsl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
module FSI_0001
3+
24
> val it: unit = ()
35

46
> val repeatId: string = "A"
@@ -234,7 +236,9 @@ module D1 =
234236
val words: System.Collections.Generic.IDictionary<string,int>
235237
val words2000: System.Collections.Generic.IDictionary<int,string>
236238

237-
> > module D2 =
239+
> module FSI_0020
240+
241+
> module D2 =
238242
val words: IDictionary<string,int>
239243
val words2000: IDictionary<int,string>
240244
val opt1: 'a option

0 commit comments

Comments
 (0)