Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/Compiler/Driver/CompilerConfig.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module internal FSharp.Compiler.CompilerConfig

open System
open System.Collections.Concurrent
open System.Runtime.InteropServices
open System.IO
open Internal.Utilities
open Internal.Utilities.FSharpEnvironment
Expand Down Expand Up @@ -1137,27 +1138,20 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
yield clrFacades

| None ->
// "there is no really good notion of runtime directory on .NETCore"
#if NETSTANDARD
let runtimeRoot = Path.GetDirectoryName(typeof<Object>.Assembly.Location)
#else
let runtimeRoot =
System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
#endif
let runtimeRootWithoutSlash = runtimeRoot.TrimEnd('/', '\\')
let runtimeRootFacades = Path.Combine(runtimeRootWithoutSlash, "Facades")
let runtimeRootWPF = Path.Combine(runtimeRootWithoutSlash, "WPF")

match data.resolutionEnvironment with
| LegacyResolutionEnvironment.CompilationAndEvaluation ->
// Default compilation-and-execution-time references on .NET Framework and Mono, e.g. for F# Interactive
//
// In the current way of doing things, F# Interactive refers to implementation assemblies.
let runtimeRoot = RuntimeEnvironment.GetRuntimeDirectory().TrimEnd('/', '\\')
yield runtimeRoot

let runtimeRootFacades = Path.Combine(runtimeRoot, "Facades")

if FileSystem.DirectoryExistsShim runtimeRootFacades then
yield runtimeRootFacades // System.Runtime.dll is in /usr/lib/mono/4.5/Facades

let runtimeRootWPF = Path.Combine(runtimeRoot, "WPF")

if FileSystem.DirectoryExistsShim runtimeRootWPF then
yield runtimeRootWPF // PresentationCore.dll is in C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF

Expand Down
5 changes: 1 addition & 4 deletions src/Compiler/Interactive/fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3379,22 +3379,19 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i
do tcConfigB.useFsiAuxLib <- fsi.UseFsiAuxLib
do tcConfigB.conditionalDefines <- "INTERACTIVE" :: tcConfigB.conditionalDefines

#if NETSTANDARD

do tcConfigB.SetUseSdkRefs true
do tcConfigB.useSimpleResolution <- true
do if isRunningOnCoreClr then SetTargetProfile tcConfigB "netcore" // always assume System.Runtime codegen
#endif

// Preset: --optimize+ -g --tailcalls+ (see 4505)
do SetOptimizeSwitch tcConfigB OptionSwitch.On
do SetDebugSwitch tcConfigB (Some "pdbonly") OptionSwitch.On
do SetTailcallSwitch tcConfigB OptionSwitch.On

#if NETSTANDARD
// set platform depending on whether the current process is a 64-bit process.
// BUG 429882 : FsiAnyCPU.exe issues warnings (x64 v MSIL) when referencing 64-bit assemblies
do tcConfigB.platform <- if IntPtr.Size = 8 then Some AMD64 else Some X86
#endif

let fsiStdinSyphon = FsiStdinSyphon(errorWriter)
let fsiConsoleOutput = FsiConsoleOutput(tcConfigB, outWriter, errorWriter)
Expand Down
11 changes: 1 addition & 10 deletions src/Compiler/Utilities/sformat.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1423,22 +1423,13 @@ module Display =

// massively reign in deep printing of properties
let nDepth = depthLim / 10
#if NETSTANDARD

Array.Sort(
propsAndFields,
{ new IComparer<MemberInfo> with
member this.Compare(p1, p2) = compare p1.Name p2.Name
}
)
#else
Array.Sort(
(propsAndFields :> Array),
{ new System.Collections.IComparer with
member this.Compare(p1, p2) =
compare ((p1 :?> MemberInfo).Name) ((p2 :?> MemberInfo).Name)
}
)
#endif

if propsAndFields.Length = 0 || (nDepth <= 0) then
basicL
Expand Down
7 changes: 1 addition & 6 deletions src/FSharp.Core/array2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ module Array2D =
[<CompiledName("ZeroCreateBased")>]
let zeroCreateBased (base1:int) (base2:int) (length1:int) (length2:int) =
if base1 = 0 && base2 = 0 then
#if NETSTANDARD
zeroCreate length1 length2
#else
// Note: this overload is available on Compact Framework and Silverlight, but not Portable
(System.Array.CreateInstance(typeof<'T>, [|length1;length2|]) :?> 'T[,])
#endif
zeroCreate length1 length2
else
(Array.CreateInstance(typeof<'T>, [|length1;length2|], [|base1;base2|]) :?> 'T[,])

Expand Down
66 changes: 4 additions & 62 deletions src/FSharp.Core/reflect.fs
Original file line number Diff line number Diff line change
Expand Up @@ -758,70 +758,12 @@ module internal Impl =
tyargs

let orderTupleProperties (props: PropertyInfo[]) =
// The tuple properties are of the form:
// Item1
// ..
// Item1, Item2, ..., Item<maxTuple-1>
// Item1, Item2, ..., Item<maxTuple-1>, Rest
// The PropertyInfo may not come back in order, so ensure ordering here.
#if !NETSTANDARD
assert (maxTuple < 10) // Alphasort will only works for upto 9 items: Item1, Item10, Item2, Item3, ..., Item9, Rest
#endif
let props = props |> Array.sortBy (fun p -> p.Name) // they are not always in alphabetic order
#if !NETSTANDARD
assert (props.Length <= maxTuple)

assert
(let haveNames = props |> Array.map (fun p -> p.Name)

let expectNames =
Array.init props.Length (fun i ->
let j = i + 1 // index j = 1, 2, .., props.Length <= maxTuple

if j < maxTuple then
"Item" + string j
elif j = maxTuple then
"Rest"
else
(assert false
"")) // dead code under prior assert, props.Length <= maxTuple

haveNames = expectNames)
#endif
props
// The PropertyInfo[] may not come back in order, so ensure ordering here.
props |> Array.sortBy (fun p -> p.Name) // alphabetic works because there is max. 8 of them

let orderTupleFields (fields: FieldInfo[]) =
// The tuple fields are of the form:
// Item1
// ..
// Item1, Item2, ..., Item<maxTuple-1>
// Item1, Item2, ..., Item<maxTuple-1>, Rest
// The PropertyInfo may not come back in order, so ensure ordering here.
#if !NETSTANDARD
assert (maxTuple < 10) // Alphasort will only works for upto 9 items: Item1, Item10, Item2, Item3, ..., Item9, Rest
#endif
let fields = fields |> Array.sortBy (fun fi -> fi.Name) // they are not always in alphabetic order
#if !NETSTANDARD
assert (fields.Length <= maxTuple)

assert
(let haveNames = fields |> Array.map (fun fi -> fi.Name)

let expectNames =
Array.init fields.Length (fun i ->
let j = i + 1 // index j = 1, 2, .., fields.Length <= maxTuple

if j < maxTuple then
"Item" + string j
elif j = maxTuple then
"Rest"
else
(assert false
"")) // dead code under prior assert, props.Length <= maxTuple

haveNames = expectNames)
#endif
fields
// The FieldInfo[] may not come back in order, so ensure ordering here.
fields |> Array.sortBy (fun fi -> fi.Name) // alphabetic works because there is max. 8 of them

let getTupleConstructorMethod (typ: Type) =
let ctor =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,7 @@ module Negative =
|> ignore


#if !NETCOREAPP
[<Fact(Skip = "IWSAMs are not supported by NET472.")>]
#else
[<Fact>]
#endif
[<FactForNETCOREAPP>]
let ``IWSAM warning`` () =
Fsx "let fExpectAWarning(x: Types.ISinOperator<'T>) = ()"
|> withReferences [typesModule]
Expand Down Expand Up @@ -415,11 +411,7 @@ module InvocationBehavior =
|> shouldFail
|> withErrorMessage "This function takes too many arguments, or is used in a context where a function is not expected"

#if !NETCOREAPP
[<Fact(Skip = "IWSAMs are not supported by NET472.")>]
#else
[<Fact>]
#endif
[<FactForNETCOREAPP>]
let ``IWSAM Delegate conversion works`` () =
Fsx
"""
Expand All @@ -436,11 +428,7 @@ module InvocationBehavior =
|> compileAndRun
|> shouldSucceed

#if !NETCOREAPP
[<Fact(Skip = "IWSAMs are not supported by NET472.")>]
#else
[<Fact>]
#endif
[<FactForNETCOREAPP>]
let ``IWSAM Expression conversion works`` () =
Fsx
"""
Expand Down Expand Up @@ -597,11 +585,7 @@ module ``Implicit conversion`` =
|> withLangVersion70
|> withOptions ["--nowarn:3535"]

#if !NETCOREAPP
[<Fact(Skip = "IWSAMs are not supported by NET472.")>]
#else
[<Fact>]
#endif
[<FactForNETCOREAPP>]
let ``Function implicit conversion not supported on constrained type`` () =
Fsx
"""
Expand All @@ -615,11 +599,7 @@ module ``Implicit conversion`` =
|> shouldFail
|> withDiagnosticMessageMatches "This expression was expected to have type\\s+'int'\\s+but here has type\\s+''T'"

#if !NETCOREAPP
[<Fact(Skip = "IWSAMs are not supported by NET472.")>]
#else
[<Fact>]
#endif
[<FactForNETCOREAPP>]
let ``Method implicit conversion not supported on constrained type`` () =
Fsx
"""
Expand All @@ -633,11 +613,7 @@ module ``Implicit conversion`` =
|> shouldFail
|> withDiagnosticMessageMatches "This expression was expected to have type\\s+'int'\\s+but here has type\\s+''T'"

#if !NETCOREAPP
[<Fact(Skip = "IWSAMs are not supported by NET472.")>]
#else
[<Fact>]
#endif
[<FactForNETCOREAPP>]
let ``Function explicit conversion works on constrained type`` () =
Fsx
"""
Expand All @@ -650,11 +626,7 @@ module ``Implicit conversion`` =
|> compile
|> shouldSucceed

#if !NETCOREAPP
[<Fact(Skip = "IWSAMs are not supported by NET472.")>]
#else
[<Fact>]
#endif
[<FactForNETCOREAPP>]
let ``Method explicit conversion works on constrained type`` () =
Fsx
"""
Expand Down Expand Up @@ -752,11 +724,7 @@ module ``Active patterns`` =
|> withName "Potato"
|> withOptions ["--nowarn:3535"]

#if !NETCOREAPP
[<Fact(Skip = "IWSAMs are not supported by NET472.")>]
#else
[<Fact>]
#endif
[<FactForNETCOREAPP>]
let ``Using IWSAM in active pattern`` () =
FSharp """
module Potato.Test
Expand Down Expand Up @@ -786,11 +754,7 @@ module ``Active patterns`` =
"""
]

#if !NETCOREAPP
[<Fact(Skip = "IWSAMs are not supported by NET472.")>]
#else
[<Fact>]
#endif
[<FactForNETCOREAPP>]
let ``Using IWSAM equality in active pattern uses generic equality intrinsic`` () =
FSharp """
module Potato.Test
Expand Down Expand Up @@ -828,11 +792,7 @@ module ``Active patterns`` =

module ``Suppression of System Numerics interfaces on unitized types`` =

#if !NETCOREAPP
[<Fact(Skip = "IWSAMs are not supported by NET472.")>]
#else
[<Fact>]
#endif
[<FactForNETCOREAPP>]
let Baseline () =
Fsx """
open System.Numerics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ namespace FSharp.Compiler.ComponentTests.EmittedIL
open Xunit
open FSharp.Test.Compiler

#if NETCOREAPP
module ``SkipLocalsInit`` =
[<Fact>]
[<FSharp.Test.FactForNETCOREAPP>]
let ``Init in function and closure not emitted when applied on function``() =
FSharp """
module SkipLocalsInit
Expand Down Expand Up @@ -35,7 +34,7 @@ let x () =
.maxstack 6
.locals (int32 V_0)"""]

[<Fact>]
[<FSharp.Test.FactForNETCOREAPP>]
let ``Init in static method not emitted when applied on class``() =
FSharp """
module SkipLocalsInit
Expand All @@ -60,7 +59,7 @@ type X () =
.maxstack 4
.locals (int32 V_0)"""]

[<Fact>]
[<FSharp.Test.FactForNETCOREAPP>]
let ``Init in static method and function not emitted when applied on module``() =
FSharp """
[<System.Runtime.CompilerServices.SkipLocalsInitAttribute>]
Expand Down Expand Up @@ -97,7 +96,7 @@ type X () =
.maxstack 4
.locals (int32 V_0)"""]

[<Fact>]
[<FSharp.Test.FactForNETCOREAPP>]
let ``Init in method and closure not emitted when applied on method``() =
FSharp """
module SkipLocalsInit
Expand Down Expand Up @@ -131,7 +130,7 @@ type X () =
.locals (int32 V_0)
""" ]

[<Fact>]
[<FSharp.Test.FactForNETCOREAPP>]
let ``Zero init performed to get defaults despite the attribute``() =
FSharp """
module SkipLocalsInit
Expand Down Expand Up @@ -180,5 +179,4 @@ IL_0019: ldarg.0
IL_001a: ldloc.0
IL_001b: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<valuetype [runtime]System.Nullable`1<int64>,!!a>::Invoke(!0)
IL_0020: stloc.2
IL_0021: ret"""]
#endif
IL_0021: ret"""]
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace FSharp.Compiler.ComponentTests.ErrorMessages

#if NETCOREAPP
open Xunit
open FSharp.Test.Compiler

module ``Unsupported Attributes`` =

[<Fact>]
[<FSharp.Test.FactForNETCOREAPP>]
let ``Warn successfully`` () =
"""
open System.Runtime.CompilerServices
Expand Down Expand Up @@ -51,5 +50,4 @@ type C() =
EndColumn = 56 }
Message =
"This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect." }
]
#endif
]
Loading