Skip to content

Commit 0db0079

Browse files
KevinRansombaronfel
authored andcommitted
Set compiler libraries to netstandard2.0" (#6311)
* Set compiler libraries to netstandard2.0" * Clean up #ifs * Standardize on NETSTANDARD * more
1 parent a65aae4 commit 0db0079

File tree

20 files changed

+25
-170
lines changed

20 files changed

+25
-170
lines changed

FSharp.Profiles.props

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
<PropertyGroup Condition="$(TargetFramework.StartsWith('netstandard')) OR $(TargetFramework.StartsWith('netcoreapp'))">
1313
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
14-
<DefineConstants>$(DefineConstants);NETSTANDARD1_6</DefineConstants>
1514
<DefineConstants>$(DefineConstants);FX_NO_APP_DOMAINS</DefineConstants>
1615
<DefineConstants>$(DefineConstants);FX_NO_ARRAY_LONG_LENGTH</DefineConstants>
1716
<DefineConstants>$(DefineConstants);FX_NO_BEGINEND_READWRITE</DefineConstants>
@@ -21,9 +20,7 @@
2120
<DefineConstants>$(DefineConstants);FX_NO_CORHOST_SIGNER</DefineConstants>
2221
<DefineConstants>$(DefineConstants);FX_NO_EVENTWAITHANDLE_IDISPOSABLE</DefineConstants>
2322
<DefineConstants>$(DefineConstants);FX_NO_EXIT_CONTEXT_FLAGS</DefineConstants>
24-
<DefineConstants>$(DefineConstants);FX_NO_HEAPTERMINATION</DefineConstants>
2523
<DefineConstants>$(DefineConstants);FX_NO_LINKEDRESOURCES</DefineConstants>
26-
<DefineConstants>$(DefineConstants);FX_NO_LOADER_OPTIMIZATION</DefineConstants>
2724
<DefineConstants>$(DefineConstants);FX_NO_PARAMETERIZED_THREAD_START</DefineConstants>
2825
<DefineConstants>$(DefineConstants);FX_NO_PDB_READER</DefineConstants>
2926
<DefineConstants>$(DefineConstants);FX_NO_PDB_WRITER</DefineConstants>

fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace FSharp.Compiler.SourceCodeServices
22

3-
#if !NETSTANDARD1_6
3+
#if !NETSTANDARD
44
open System.Runtime.Serialization.Json
55
open System.Runtime
66
open System.Diagnostics
@@ -60,7 +60,7 @@ type ProjectCracker =
6060
let enableLogging = defaultArg enableLogging true
6161

6262

63-
#if NETSTANDARD1_6
63+
#if NETSTANDARD
6464
let arguments = [|
6565
yield projectFileName
6666
yield enableLogging.ToString()

fcs/samples/FscExe/FscMain.fs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,7 @@ module Driver =
288288
for error in errors do eprintfn "%s" (error.ToString())
289289
exitCode
290290

291-
#if !FX_NO_DEFAULT_DEPENDENCY_TYPE
292291
[<Dependency("FSharp.Compiler",LoadHint.Always)>]
293-
#endif
294292
do ()
295293

296294
[<EntryPoint>]

fsharp.proj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@
6161
<AdditionalProperties Condition="'$(BuildDesktop)' == 'true'">TargetFramework=net46</AdditionalProperties>
6262
</Projects>
6363
<Projects Include="$(MSBuildThisFileDirectory)src\fsharp\FSharp.Compiler.Private\FSharp.Compiler.Private.fsproj">
64-
<AdditionalProperties Condition="'$(BuildNetcore)' == 'true'">TargetFramework=netstandard1.6</AdditionalProperties>
64+
<AdditionalProperties Condition="'$(BuildNetcore)' == 'true'">TargetFramework=netstandard2.0</AdditionalProperties>
6565
<AdditionalProperties Condition="'$(BuildDesktop)' == 'true'">TargetFramework=net46</AdditionalProperties>
6666
</Projects>
6767
<Projects Include="$(MSBuildThisFileDirectory)src\fsharp\FSharp.Compiler.Server.Shared\FSharp.Compiler.Server.Shared.fsproj">
6868
<AdditionalProperties Condition="'$(BuildDesktop)' == 'true'">TargetFramework=net46</AdditionalProperties>
6969
</Projects>
7070
<Projects Include="$(MSBuildThisFileDirectory)src\fsharp\FSharp.Compiler.Interactive.Settings\FSharp.Compiler.Interactive.Settings.fsproj">
71-
<AdditionalProperties Condition="'$(BuildNetcore)' == 'true'">TargetFramework=netstandard1.6</AdditionalProperties>
71+
<AdditionalProperties Condition="'$(BuildNetcore)' == 'true'">TargetFramework=netstandard2.0</AdditionalProperties>
7272
<AdditionalProperties Condition="'$(BuildDesktop)' == 'true'">TargetFramework=net46</AdditionalProperties>
7373
</Projects>
7474
<Projects Include="$(MSBuildThisFileDirectory)src\fsharp\fsc\fsc.fsproj">

src/fsharp/CompileOps.fs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ open FSharp.Compiler.ExtensionTyping
5050
open Microsoft.FSharp.Core.CompilerServices
5151
#endif
5252

53-
#if FX_RESHAPED_REFLECTION
54-
open Microsoft.FSharp.Core.ReflectionAdapters
55-
#endif
56-
5753
#if DEBUG
5854
[<AutoOpen>]
5955
module internal CompilerService =
@@ -2646,7 +2642,7 @@ let OpenILBinary(filename, reduceMemoryUsage, ilGlobals, pdbDirPath, shadowCopyR
26462642
tryGetMetadataSnapshot = tryGetMetadataSnapshot }
26472643

26482644
let location =
2649-
#if !FX_RESHAPED_REFLECTION // shadow copy not supported
2645+
#if FX_NO_APP_DOMAINS
26502646
// In order to use memory mapped files on the shadow copied version of the Assembly, we `preload the assembly
26512647
// We swallow all exceptions so that we do not change the exception contract of this API
26522648
if shadowCopyReferences then
@@ -2823,7 +2819,7 @@ type TcConfig private (data : TcConfigBuilder, validate:bool) =
28232819
// FUTURE: remove this, we only read the binary for the exception it raises
28242820
let fsharpBinariesDirValue =
28252821
// NOTE: It's not clear why this behaviour has been changed for the NETSTANDARD compilations of the F# compiler
2826-
#if NETSTANDARD1_6 || NETSTANDARD2_0
2822+
#if NETSTANDARD
28272823
ignore ilGlobals
28282824
data.defaultFSharpBinariesDir
28292825
#else
@@ -2987,7 +2983,7 @@ type TcConfig private (data : TcConfigBuilder, validate:bool) =
29872983

29882984
| None ->
29892985
// "there is no really good notion of runtime directory on .NETCore"
2990-
#if NETSTANDARD1_6 || NETSTANDARD2_0
2986+
#if NETSTANDARD
29912987
let runtimeRoot = Path.GetDirectoryName(typeof<System.Object>.Assembly.Location)
29922988
#else
29932989
let runtimeRoot = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()

src/fsharp/CompileOptions.fs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,11 @@ open FSharp.Compiler.Lib
2121
open FSharp.Compiler.Range
2222
open FSharp.Compiler.IlxGen
2323

24-
#if FX_RESHAPED_REFLECTION
25-
open Microsoft.FSharp.Core.ReflectionAdapters
26-
#endif
27-
2824
module Attributes =
2925
open System.Runtime.CompilerServices
3026

3127
//[<assembly: System.Security.SecurityTransparent>]
32-
#if !FX_NO_DEFAULT_DEPENDENCY_TYPE
3328
[<Dependency("FSharp.Core",LoadHint.Always)>]
34-
#endif
3529
do()
3630

3731
//----------------------------------------------------------------------------

src/fsharp/ExtensionTyping.fs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ module internal ExtensionTyping =
1818
open FSharp.Compiler.AbstractIL.Diagnostics // dprintfn
1919
open FSharp.Compiler.AbstractIL.Internal.Library // frontAndBack
2020

21-
#if FX_RESHAPED_REFLECTION
22-
open Microsoft.FSharp.Core.ReflectionAdapters
23-
#endif
24-
2521
type TypeProviderDesignation = TypeProviderDesignation of string
2622

2723
exception ProvidedTypeResolution of range * System.Exception
@@ -359,33 +355,14 @@ module internal ExtensionTyping =
359355
for KeyValue (st, tcref) in d2.Force() do dict.Add(st, f tcref)
360356
dict))
361357

362-
#if FX_NO_CUSTOMATTRIBUTEDATA
363-
type CustomAttributeData = Microsoft.FSharp.Core.CompilerServices.IProvidedCustomAttributeData
364-
type CustomAttributeNamedArgument = Microsoft.FSharp.Core.CompilerServices.IProvidedCustomAttributeNamedArgument
365-
type CustomAttributeTypedArgument = Microsoft.FSharp.Core.CompilerServices.IProvidedCustomAttributeTypedArgument
366-
#else
367358
type CustomAttributeData = System.Reflection.CustomAttributeData
368359
type CustomAttributeNamedArgument = System.Reflection.CustomAttributeNamedArgument
369360
type CustomAttributeTypedArgument = System.Reflection.CustomAttributeTypedArgument
370-
#endif
371361

372362
[<AllowNullLiteral; Sealed>]
373363
type ProvidedType (x:System.Type, ctxt: ProvidedTypeContext) =
374-
#if FX_RESHAPED_REFLECTION
375-
inherit ProvidedMemberInfo(x.GetTypeInfo(), ctxt)
376-
#if FX_NO_CUSTOMATTRIBUTEDATA
377-
let provide () = ProvidedCustomAttributeProvider.Create (fun provider -> provider.GetMemberCustomAttributesData(x.GetTypeInfo()) :> _)
378-
#else
379-
let provide () = ProvidedCustomAttributeProvider.Create (fun _provider -> x.GetTypeInfo().CustomAttributes)
380-
#endif
381-
#else
382364
inherit ProvidedMemberInfo(x, ctxt)
383-
#if FX_NO_CUSTOMATTRIBUTEDATA
384-
let provide () = ProvidedCustomAttributeProvider.Create (fun provider -> provider.GetMemberCustomAttributesData(x) :> _)
385-
#else
386365
let provide () = ProvidedCustomAttributeProvider.Create (fun _provider -> x.CustomAttributes)
387-
#endif
388-
#endif
389366
interface IProvidedCustomAttributeProvider with
390367
member __.GetHasTypeProviderEditorHideMethodsAttribute(provider) = provide().GetHasTypeProviderEditorHideMethodsAttribute(provider)
391368
member __.GetDefinitionLocationAttribute(provider) = provide().GetDefinitionLocationAttribute(provider)
@@ -514,12 +491,7 @@ module internal ExtensionTyping =
514491

515492
and [<AllowNullLiteral; AbstractClass>]
516493
ProvidedMemberInfo (x: System.Reflection.MemberInfo, ctxt) =
517-
#if FX_NO_CUSTOMATTRIBUTEDATA
518-
let provide () = ProvidedCustomAttributeProvider.Create (fun provider -> provider.GetMemberCustomAttributesData(x) :> _)
519-
#else
520494
let provide () = ProvidedCustomAttributeProvider.Create (fun _provider -> x.CustomAttributes)
521-
#endif
522-
523495
member __.Name = x.Name
524496
/// DeclaringType can be null if MemberInfo belongs to Module, not to Type
525497
member __.DeclaringType = ProvidedType.Create ctxt x.DeclaringType
@@ -531,18 +503,10 @@ module internal ExtensionTyping =
531503

532504
and [<AllowNullLiteral; Sealed>]
533505
ProvidedParameterInfo (x: System.Reflection.ParameterInfo, ctxt) =
534-
#if FX_NO_CUSTOMATTRIBUTEDATA
535-
let provide () = ProvidedCustomAttributeProvider.Create (fun provider -> provider.GetParameterCustomAttributesData(x) :> _)
536-
#else
537506
let provide () = ProvidedCustomAttributeProvider.Create (fun _provider -> x.CustomAttributes)
538-
#endif
539507
member __.Name = x.Name
540508
member __.IsOut = x.IsOut
541-
#if FX_NO_ISIN_ON_PARAMETER_INFO
542-
member __.IsIn = not x.IsOut
543-
#else
544509
member __.IsIn = x.IsIn
545-
#endif
546510
member __.IsOptional = x.IsOptional
547511
member __.RawDefaultValue = x.RawDefaultValue
548512
member __.HasDefaultValue = x.Attributes.HasFlag(System.Reflection.ParameterAttributes.HasDefault)

src/fsharp/ExtensionTyping.fsi

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ module internal ExtensionTyping =
8585

8686
/// Map the TyconRef objects, if any
8787
member RemapTyconRefs : (obj -> obj) -> ProvidedTypeContext
88-
89-
#if FX_NO_CUSTOMATTRIBUTEDATA
90-
type CustomAttributeData = Microsoft.FSharp.Core.CompilerServices.IProvidedCustomAttributeData
91-
type CustomAttributeNamedArgument = Microsoft.FSharp.Core.CompilerServices.IProvidedCustomAttributeNamedArgument
92-
type CustomAttributeTypedArgument = Microsoft.FSharp.Core.CompilerServices.IProvidedCustomAttributeTypedArgument
93-
#endif
9488

9589
type [<AllowNullLiteral; Sealed; Class>]
9690
ProvidedType =

src/fsharp/MSBuildReferenceResolver.fs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ module internal FSharp.Compiler.MSBuildReferenceResolver
66
open System.IO
77
open System.Reflection
88

9-
#if FX_RESHAPED_REFLECTION
10-
open Microsoft.FSharp.Core.ReflectionAdapters
11-
#endif
129
#if FX_RESHAPED_MSBUILD
1310
open FSharp.Compiler.MsBuildAdapters
1411
open FSharp.Compiler.ToolLocationHelper
@@ -20,6 +17,11 @@ module internal FSharp.Compiler.MSBuildReferenceResolver
2017
open Microsoft.Build.Utilities
2118
open Microsoft.Build.Framework
2219

20+
// Reflection wrapper for properties
21+
type System.Object with
22+
member this.GetPropertyValue(propName) =
23+
this.GetType().GetProperty(propName, BindingFlags.Public).GetValue(this, null)
24+
2325
/// Get the Reference Assemblies directory for the .NET Framework on Window.
2426
let DotNetFrameworkReferenceAssembliesRootDirectory =
2527
// ProgramFilesX86 is correct for both x86 and x64 architectures
@@ -97,7 +99,7 @@ module internal FSharp.Compiler.MSBuildReferenceResolver
9799
| _ -> []
98100

99101
let GetPathToDotNetFrameworkReferenceAssemblies(version) =
100-
#if NETSTANDARD1_6 || NETSTANDARD2_0
102+
#if NETSTANDARD
101103
ignore version
102104
let r : string list = []
103105
r
@@ -129,7 +131,7 @@ module internal FSharp.Compiler.MSBuildReferenceResolver
129131
else Net45 // version is 4.5 assumed since this code is running.
130132
with _ -> Net45
131133

132-
#if !FX_RESHAPED_REFLECTION
134+
#if !FX_RESHAPED_MSBUILD
133135
// 1. First look to see if we can find the highest installed set of dotnet reference assemblies, if yes then select that framework
134136
// 2. Otherwise ask msbuild for the highestinstalled framework
135137
let checkFrameworkForReferenceAssemblies (dotNetVersion:string) =
@@ -336,9 +338,6 @@ module internal FSharp.Compiler.MSBuildReferenceResolver
336338
FindSerializationAssemblies=false, Assemblies=assemblies,
337339
SearchPaths=searchPaths,
338340
AllowedAssemblyExtensions= [| ".dll" ; ".exe" |])
339-
#if FX_RESHAPED_REFLECTION
340-
ignore targetProcessorArchitecture // Not implemented in reshapedmsbuild.fs
341-
#else
342341
rar.TargetProcessorArchitecture <- targetProcessorArchitecture
343342
let targetedRuntimeVersionValue = typeof<obj>.Assembly.ImageRuntimeVersion
344343
#if ENABLE_MONO_SUPPORT
@@ -351,7 +350,6 @@ module internal FSharp.Compiler.MSBuildReferenceResolver
351350
rar.TargetedRuntimeVersion <- targetedRuntimeVersionValue
352351
rar.CopyLocalDependenciesWhenParentReferenceInGac <- true
353352
#endif
354-
#endif
355353

356354
let succeeded = rar.Execute()
357355

src/fsharp/PrettyNaming.fs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ module public FSharp.Compiler.PrettyNaming
1919
open Internal.Utilities.StructuredFormat
2020
open Internal.Utilities.StructuredFormat.LayoutOps
2121

22-
#if FX_RESHAPED_REFLECTION
23-
open Microsoft.FSharp.Core.ReflectionAdapters
24-
#endif
25-
2622
//------------------------------------------------------------------------
2723
// Operator name compilation
2824
//-----------------------------------------------------------------------

0 commit comments

Comments
 (0)