Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into otel
Browse files Browse the repository at this point in the history
  • Loading branch information
safesparrow committed Sep 3, 2022
2 parents 679d2aa + e06e079 commit c86c851
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 20 deletions.
14 changes: 8 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ stages:
- name: _SignType
value: Test
pool:
name: NetCore1ESPool-Public
name: NetCore-Public
demands: ImageOverride -equals $(WindowsMachineQueueName)
timeoutInMinutes: 90
steps:
Expand Down Expand Up @@ -283,7 +283,7 @@ stages:
# WindowsMachineQueueName=Windows.vs2022.amd64.open
# and there is an alternate build definition that sets this to a queue that is always scouting the
# next preview of Visual Studio.
name: NetCore1ESPool-Public
name: NetCore-Public
demands: ImageOverride -equals $(WindowsMachineQueueName)
timeoutInMinutes: 120
strategy:
Expand Down Expand Up @@ -341,7 +341,7 @@ stages:
# WindowsMachineQueueName=Windows.vs2022.amd64.open
# and there is an alternate build definition that sets this to a queue that is always scouting the
# next preview of Visual Studio.
name: NetCore1ESPool-Public
name: NetCore-Public
demands: ImageOverride -equals $(WindowsMachineQueueName)
timeoutInMinutes: 120
strategy:
Expand Down Expand Up @@ -395,7 +395,7 @@ stages:
# Mock official build
- job: MockOfficial
pool:
name: NetCore1ESPool-Public
name: NetCore-Public
demands: ImageOverride -equals $(WindowsMachineQueueName)
steps:
- checkout: self
Expand Down Expand Up @@ -445,6 +445,7 @@ stages:

# MacOS
- job: MacOS
condition: eq(1,2)
pool:
vmImage: $(MacOSMachineQueueName)
variables:
Expand Down Expand Up @@ -486,7 +487,7 @@ stages:
# End to end build
- job: EndToEndBuildTests
pool:
name: NetCore1ESPool-Public
name: NetCore-Public
demands: ImageOverride -equals $(WindowsMachineQueueName)
steps:
- checkout: self
Expand All @@ -511,7 +512,7 @@ stages:
# Plain build Windows
- job: Plain_Build_Windows
pool:
name: NetCore1ESPool-Public
name: NetCore-Public
demands: ImageOverride -equals $(WindowsMachineQueueName)
variables:
- name: _BuildConfig
Expand Down Expand Up @@ -575,6 +576,7 @@ stages:

# Plain build Mac
- job: Plain_Build_MacOS
condition: eq(1,2)
pool:
vmImage: $(MacOSMachineQueueName)
variables:
Expand Down
2 changes: 1 addition & 1 deletion eng/common/templates/job/source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
# source-build builds run in Docker, including the default managed platform.
pool:
${{ if eq(variables['System.TeamProject'], 'public') }}:
name: NetCore1ESPool-Public
name: NetCore-Public
demands: ImageOverride -equals Build.Ubuntu.1804.Amd64.Open
${{ if eq(variables['System.TeamProject'], 'internal') }}:
name: NetCore1ESPool-Internal
Expand Down
2 changes: 1 addition & 1 deletion eng/common/templates/job/source-index-stage1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
${{ if eq(parameters.pool, '') }}:
pool:
${{ if eq(variables['System.TeamProject'], 'public') }}:
name: NetCore1ESPool-Public
name: NetCore-Public
demands: ImageOverride -equals windows.vs2019.amd64.open
${{ if eq(variables['System.TeamProject'], 'internal') }}:
name: NetCore1ESPool-Internal
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/AbstractIL/ilwrite.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4122,7 +4122,7 @@ let writeBinaryAux (stream: Stream, options: options, modul, normalizeAssemblyRe
| Some AMD64 -> writeInt32AsUInt16 os 0x8664 // Machine - IMAGE_FILE_MACHINE_AMD64
| Some IA64 -> writeInt32AsUInt16 os 0x200 // Machine - IMAGE_FILE_MACHINE_IA64
| Some ARM64 -> writeInt32AsUInt16 os 0xaa64 // Machine - IMAGE_FILE_MACHINE_ARM64
| Some ARM -> writeInt32AsUInt16 os 0x1c0 // Machine - IMAGE_FILE_MACHINE_ARM
| Some ARM -> writeInt32AsUInt16 os 0x1c4 // Machine - IMAGE_FILE_MACHINE_ARMNT
| _ -> writeInt32AsUInt16 os 0x014c // Machine - IMAGE_FILE_MACHINE_I386

writeInt32AsUInt16 os numSections
Expand Down
18 changes: 17 additions & 1 deletion src/Compiler/Checking/NicePrint.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2420,7 +2420,23 @@ module InferredSigPrinting =
modNameEqualsL @@* basic
layoutXmlDoc denv true mspec.XmlDoc basicL

imdefL denv expr
let emptyModuleOrNamespace mspec =
let innerPath = (fullCompPathOfModuleOrNamespace mspec).AccessPath
let pathL = innerPath |> List.map (fst >> ConvertLogicalNameToDisplayLayout (tagNamespace >> wordL))

let keyword =
if not mspec.IsImplicitNamespace && mspec.IsNamespace then
"namespace"
else
"module"

wordL (tagKeyword keyword) ^^ sepListL SepL.dot pathL

match expr with
| EmptyModuleOrNamespaces mspecs ->
List.map emptyModuleOrNamespace mspecs
|> aboveListL
| expr -> imdefL denv expr

//--------------------------------------------------------------------------

Expand Down
32 changes: 32 additions & 0 deletions src/Compiler/TypedTree/TypedTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10360,3 +10360,35 @@ let isFSharpExceptionTy g ty =
| ValueSome tcref -> tcref.IsFSharpException
| _ -> false

let (|EmptyModuleOrNamespaces|_|) (moduleOrNamespaceContents: ModuleOrNamespaceContents) =
match moduleOrNamespaceContents with
| TMDefs(defs = defs) ->
let mdDefsLength =
defs
|> List.count (function
| ModuleOrNamespaceContents.TMDefRec _
| ModuleOrNamespaceContents.TMDefs _ -> true
| _ -> false)

let emptyModuleOrNamespaces =
defs
|> List.choose (function
| ModuleOrNamespaceContents.TMDefRec _ as defRec
| ModuleOrNamespaceContents.TMDefs(defs = [ ModuleOrNamespaceContents.TMDefRec _ as defRec ]) ->
match defRec with
| TMDefRec(bindings = [ ModuleOrNamespaceBinding.Module(mspec, ModuleOrNamespaceContents.TMDefs(defs = defs)) ]) ->
defs
|> List.forall (function
| ModuleOrNamespaceContents.TMDefOpens _
| ModuleOrNamespaceContents.TMDefDo _
| ModuleOrNamespaceContents.TMDefRec (isRec = true; tycons = []; bindings = []) -> true
| _ -> false)
|> fun isEmpty -> if isEmpty then Some mspec else None
| _ -> None
| _ -> None)

if mdDefsLength = emptyModuleOrNamespaces.Length then
Some emptyModuleOrNamespaces
else
None
| _ -> None
6 changes: 6 additions & 0 deletions src/Compiler/TypedTree/TypedTreeOps.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -2676,3 +2676,9 @@ type TraitConstraintInfo with

/// Get the key associated with the member constraint.
member GetWitnessInfo: unit -> TraitWitnessInfo

/// Matches a ModuleOrNamespaceContents that is empty from a signature printing point of view.
/// Signatures printed via the typed tree in NicePrint don't print TMDefOpens or TMDefDo.
/// This will match anything that does not have any types or bindings.
val (|EmptyModuleOrNamespaces|_|):
moduleOrNamespaceContents: ModuleOrNamespaceContents -> (ModuleOrNamespace list) option
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,58 @@ namespace Fantomas.Core
val genExpr: e: FSharp.Compiler.Syntax.SynExpr -> ctx: Context.Context -> Context.Context
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)"""

[<Fact>]
let ``Empty namespace`` () =
FSharp
"""
namespace System
open System.Runtime.CompilerServices
[<assembly: InternalsVisibleTo("Fantomas.Core.Tests")>]
do ()
"""
|> printSignatures
|> should equal "namespace System"

[<Fact>]
let ``Empty module`` () =
FSharp
"""
module Foobar
do ()
"""
|> printSignatures
|> should equal "module Foobar"

[<Fact>]
let ``Two empty namespaces`` () =
FSharp
"""
namespace Foo
do ()
namespace Bar
do ()
"""
|> printSignatures
|> prependNewline
|> should equal """
namespace Foo
namespace Bar"""

[<Fact>]
let ``Empty namespace module`` () =
FSharp
"""
namespace rec Foobar
do ()
"""
|> printSignatures
|> should equal "namespace Foobar"
4 changes: 3 additions & 1 deletion tests/fsharp/core/load-script/out.stdout.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ World
-the end
Test 3=================================================

> [Loading D:\staging\staging\src\tests\fsharp\core\load-script\1.fsx
> module FSI_0001

[Loading D:\staging\staging\src\tests\fsharp\core\load-script\1.fsx
Loading D:\staging\staging\src\tests\fsharp\core\load-script\2.fsx
Loading D:\staging\staging\src\tests\fsharp\core\load-script\3.fsx]
Hello
Expand Down
6 changes: 5 additions & 1 deletion tests/fsharp/core/printing/output.1000.stdout.bsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

module FSI_0001

> val it: unit = ()

> val repeatId: string = "A"
Expand Down Expand Up @@ -234,7 +236,9 @@ module D1 =
val words: System.Collections.Generic.IDictionary<string,int>
val words2000: System.Collections.Generic.IDictionary<int,string>

> > module D2 =
> module FSI_0020

> module D2 =
val words: IDictionary<string,int>
val words2000: IDictionary<int,string>
val opt1: 'a option
Expand Down
6 changes: 5 additions & 1 deletion tests/fsharp/core/printing/output.200.stdout.bsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

module FSI_0001

> val it: unit = ()

> val repeatId: string = "A"
Expand Down Expand Up @@ -129,7 +131,9 @@ module D1 =
val words: System.Collections.Generic.IDictionary<string,int>
val words2000: System.Collections.Generic.IDictionary<int,string>

> > module D2 =
> module FSI_0020

> module D2 =
val words: IDictionary<string,int>
val words2000: IDictionary<int,string>
val opt1: 'a option
Expand Down
8 changes: 6 additions & 2 deletions tests/fsharp/core/printing/output.47.stdout.bsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

> val repeatId: string = "A"
> module FSI_0001

val repeatId: string = "A"

> val repeatId: string = "B"

Expand Down Expand Up @@ -249,7 +251,9 @@ module D1 =
val words: System.Collections.Generic.IDictionary<string,int>
val words2000: System.Collections.Generic.IDictionary<int,string>

> > module D2 =
> module FSI_0019

> module D2 =
val words: IDictionary<string,int>
val words2000: IDictionary<int,string>
val opt1: 'a option
Expand Down
8 changes: 6 additions & 2 deletions tests/fsharp/core/printing/output.multiemit.stdout.bsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

> val repeatId: string = "A"
> module FSI_0001

val repeatId: string = "A"

> val repeatId: string = "B"

Expand Down Expand Up @@ -249,7 +251,9 @@ module D1 =
val words: System.Collections.Generic.IDictionary<string,int>
val words2000: System.Collections.Generic.IDictionary<int,string>

> > module D2 =
> module FSI_0019

> module D2 =
val words: IDictionary<string,int>
val words2000: IDictionary<int,string>
val opt1: 'a option
Expand Down
6 changes: 5 additions & 1 deletion tests/fsharp/core/printing/output.off.stdout.bsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

module FSI_0001

> val it: unit = ()

> val repeatId: string
Expand Down Expand Up @@ -94,7 +96,9 @@ module D1 =
val words: System.Collections.Generic.IDictionary<string,int>
val words2000: System.Collections.Generic.IDictionary<int,string>

> > module D2 =
> module FSI_0020

> module D2 =
val words: IDictionary<string,int>
val words2000: IDictionary<int,string>
val opt1: 'a option
Expand Down
8 changes: 6 additions & 2 deletions tests/fsharp/core/printing/output.stdout.bsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

> val repeatId: string = "A"
> module FSI_0001

val repeatId: string = "A"

> val repeatId: string = "B"

Expand Down Expand Up @@ -249,7 +251,9 @@ module D1 =
val words: System.Collections.Generic.IDictionary<string,int>
val words2000: System.Collections.Generic.IDictionary<int,string>

> > module D2 =
> module FSI_0019

> module D2 =
val words: IDictionary<string,int>
val words2000: IDictionary<int,string>
val opt1: 'a option
Expand Down

0 comments on commit c86c851

Please sign in to comment.