diff --git a/.gitignore b/.gitignore
index 3c609f19391..ec2166b3fc3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -100,7 +100,9 @@ ossreadme*.txt
*.log
*.jrs
*.chk
-*.bak
+*.bak
+*.vserr
+*.err
*.orig
*.mdf
*.ldf
diff --git a/DEVGUIDE.md b/DEVGUIDE.md
index b17fed89880..5c6f51c3c8e 100644
--- a/DEVGUIDE.md
+++ b/DEVGUIDE.md
@@ -53,7 +53,17 @@ After you build the first time you can open and use this solution in Visual Stud
If you don't have everything installed yet, you'll get prompted by Visual Studio to install a few more things. This is because we use a `.vsconfig` file that specifies all our dependencies.
-## Developing on Windows - No Visual Studio
+If you are just developing the core compiler and library then building ``FSharp.sln`` will be enough.
+
+### Developing the F# Compiler (Linux/macOS)
+
+For Linux/Mac:
+
+ ./build.sh
+
+Running tests:
+
+ ./build.sh --test
We recommend installing the latest released Visual Studio and using that if you are on Windows. However, if you prefer not to do that, you will need to install the following:
diff --git a/FSharp.Profiles.props b/FSharp.Profiles.props
index bc6988d0bac..c9e761c997a 100644
--- a/FSharp.Profiles.props
+++ b/FSharp.Profiles.props
@@ -11,35 +11,18 @@
$(DefineConstants);NETSTANDARD$(DefineConstants);FX_NO_APP_DOMAINS
- $(DefineConstants);FX_NO_ARRAY_LONG_LENGTH
- $(DefineConstants);FX_NO_BEGINEND_READWRITE
- $(DefineConstants);FX_NO_BINARY_SERIALIZATION
- $(DefineConstants);FX_NO_CONVERTER
- $(DefineConstants);FX_NO_DEFAULT_DEPENDENCY_TYPE$(DefineConstants);FX_NO_CORHOST_SIGNER$(DefineConstants);FX_NO_EVENTWAITHANDLE_IDISPOSABLE$(DefineConstants);FX_NO_EXIT_CONTEXT_FLAGS$(DefineConstants);FX_NO_PARAMETERIZED_THREAD_START$(DefineConstants);FX_NO_PDB_READER$(DefineConstants);FX_NO_PDB_WRITER
- $(DefineConstants);FX_NO_REFLECTION_MODULE_HANDLES
- $(DefineConstants);FX_NO_REFLECTION_ONLY
- $(DefineConstants);FX_NO_RUNTIMEENVIRONMENT
- $(DefineConstants);FX_NO_SECURITY_PERMISSIONS
- $(DefineConstants);FX_NO_SERVERCODEPAGES$(DefineConstants);FX_NO_SYMBOLSTORE$(DefineConstants);FX_NO_SYSTEM_CONFIGURATION
- $(DefineConstants);FX_NO_THREAD
- $(DefineConstants);FX_NO_THREADABORT
- $(DefineConstants);FX_NO_WAITONE_MILLISECONDS
- $(DefineConstants);FX_NO_WEB_CLIENT$(DefineConstants);FX_NO_WIN_REGISTRY$(DefineConstants);FX_NO_WINFORMS$(DefineConstants);FX_NO_INDENTED_TEXT_WRITER
- $(DefineConstants);FX_REDUCED_EXCEPTIONS$(DefineConstants);FX_RESHAPED_REFEMIT
- $(DefineConstants);FX_RESHAPED_GLOBALIZATION
- $(DefineConstants);FX_RESHAPED_REFLECTION$(DefineConstants);FX_RESHAPED_MSBUILD$(OtherFlags) --simpleresolution
diff --git a/FSharpBuild.Directory.Build.props b/FSharpBuild.Directory.Build.props
index 6687fb40888..95fa8fcd020 100644
--- a/FSharpBuild.Directory.Build.props
+++ b/FSharpBuild.Directory.Build.props
@@ -94,6 +94,10 @@
true
+
+ $(DefineConstants);TESTING_ON_LINUX
+
+
$(ProtoOutputPath)\fsc\Microsoft.FSharp.Targets
diff --git a/FSharpTests.Directory.Build.targets b/FSharpTests.Directory.Build.targets
index fe916bf2df2..8ae8c562556 100644
--- a/FSharpTests.Directory.Build.targets
+++ b/FSharpTests.Directory.Build.targets
@@ -13,6 +13,7 @@
DisabledWarnings="$(NoWarn)"
DotnetFsiCompilerPath="$(DotnetFsiCompilerPath)"
FsiExec="@(FsiExec)"
+ LangVersion="$(LangVersion)"
LCID="$(LCID)"
LoadSources="@(LoadSource)"
NoFramework="false"
diff --git a/Makefile b/Makefile
index 10de364b677..a002620f232 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ restore:
build: proto restore
$(DotNetExe) build-server shutdown
- $(DotNetExe) build -c $(Configuration) -f netstandard1.6 src/fsharp/FSharp.Core/FSharp.Core.fsproj
+ $(DotNetExe) build -c $(Configuration) -f netstandard2.0 src/fsharp/FSharp.Core/FSharp.Core.fsproj
$(DotNetExe) build -c $(Configuration) -f netstandard2.0 src/fsharp/FSharp.Build/FSharp.Build.fsproj
$(DotNetExe) build -c $(Configuration) -f netstandard2.0 src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj
$(DotNetExe) build -c $(Configuration) -f netcoreapp2.1 src/fsharp/fsc/fsc.fsproj
diff --git a/eng/Build.ps1 b/eng/Build.ps1
index 1d64fc8460d..4d503dbedaa 100644
--- a/eng/Build.ps1
+++ b/eng/Build.ps1
@@ -195,6 +195,7 @@ function BuildSolution() {
/p:QuietRestore=$quietRestore `
/p:QuietRestoreBinaryLog=$binaryLog `
/p:TestTargetFrameworks=$testTargetFrameworks `
+ /v:$verbosity `
$suppressExtensionDeployment `
@properties
}
diff --git a/eng/Versions.props b/eng/Versions.props
index 3556edc478f..8efcedaa538 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -12,25 +12,25 @@
beta
- 4.6
+ 4.7$(FSLanguageVersion)
- $(FSCoreMajorVersion).3
+ $(FSCoreMajorVersion).1$(FSCoreMajorVersion).0$(FSCoreVersionPrefix).0
- 4.6.2
+ 4.7.0$(FSCorePackageVersion)-$(PreReleaseVersionLabel).*
- 10.5
+ 10.6$(FSPackageMajorVersion).0$(FSPackageVersion)$(FSPackageVersion).016
- 2
+ 3$(VSMajorVersion).0$(VSMajorVersion).$(VSMinorVersion).0$(VSAssemblyVersionPrefix).0
@@ -55,7 +55,6 @@
https://dotnet.myget.org/F/roslyn-tools/api/v3/index.json;
https://api.nuget.org/v3/index.json;
https://dotnet.myget.org/F/roslyn/api/v3/index.json;
- https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json;
https://dotnet.myget.org/F/symreader-converter/api/v3/index.json;
https://dotnet.myget.org/F/interactive-window/api/v3/index.json;
https://myget.org/F/vs-devcore/api/v3/index.json;
diff --git a/eng/build.sh b/eng/build.sh
index e7627f2bd48..cda4795f873 100755
--- a/eng/build.sh
+++ b/eng/build.sh
@@ -246,6 +246,7 @@ function BuildSolution {
# do real build
MSBuild $toolset_build_proj \
$bl \
+ /v:$verbosity \
/p:Configuration=$configuration \
/p:Projects="$projects" \
/p:RepoRoot="$repo_root" \
@@ -278,3 +279,4 @@ if [[ "$test_core_clr" == true ]]; then
fi
ExitWithExitCode 0
+
diff --git a/eng/common/templates/job/publish-build-assets.yml b/eng/common/templates/job/publish-build-assets.yml
index b722975f9c2..5dca87c5db2 100644
--- a/eng/common/templates/job/publish-build-assets.yml
+++ b/eng/common/templates/job/publish-build-assets.yml
@@ -61,6 +61,7 @@ jobs:
/p:MaestroApiEndpoint=https://maestro-prod.westus2.cloudapp.azure.com
/p:PublishUsingPipelines=${{ parameters.publishUsingPipelines }}
/p:Configuration=$(_BuildConfig)
+ /v:detailed
condition: ${{ parameters.condition }}
continueOnError: ${{ parameters.continueOnError }}
diff --git a/eng/common/tools.sh b/eng/common/tools.sh
index 757d5b9ea46..cdba97ac8b8 100755
--- a/eng/common/tools.sh
+++ b/eng/common/tools.sh
@@ -379,6 +379,8 @@ function MSBuild-Core {
}
}
+. "$scriptroot/pipeline-logging-functions.sh"
+
ResolvePath "${BASH_SOURCE[0]}"
_script_dir=`dirname "$_ResolvePath"`
diff --git a/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj
index c3125e32d13..d6c71b55456 100644
--- a/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj
+++ b/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj
@@ -12,13 +12,9 @@
true
- $(DefineConstants);FX_NO_RUNTIMEENVIRONMENT$(DefineConstants);NO_PROJECTCRACKER
-
- ReshapedReflection.fs
-
FsUnit.fs
diff --git a/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj b/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj
index 1c258ad3087..04389899a26 100644
--- a/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj
+++ b/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj
@@ -33,7 +33,6 @@
$(DefineConstants);FX_NO_PDB_WRITER$(DefineConstants);FX_NO_SYMBOLSTORE$(DefineConstants);FX_NO_APP_DOMAINS
- $(DefineConstants);FX_NO_RUNTIMEENVIRONMENT$(DefineConstants);FX_NO_WIN_REGISTRY$(DefineConstants);FX_NO_SYSTEM_CONFIGURATION$(DefineConstants);FX_RESHAPED_REFEMIT
@@ -66,9 +65,6 @@
Logger.fs
-
- Reshaped/reshapedreflection.fs
-
ErrorText/sformat.fsi
@@ -81,6 +77,12 @@
ErrorText/sr.fs
+
+ Driver\LanguageFeatures.fsi
+
+
+ Driver\LanguageFeatures.fs
+
LexYaccRuntime/prim-lexing.fsi
@@ -156,6 +158,9 @@
Utilities/bytes.fs
+
+ Utilities\XmlAdapters.fs
+
Utilities/lib.fs
@@ -269,6 +274,9 @@
AbsIL/ilreflect.fs
+
+ ReferenceResolution/reshapedmsbuild.fs
+
ReferenceResolution/ReferenceResolver.fs
@@ -593,9 +601,6 @@
Service/ServiceUntypedParse.fs
-
- Service/reshapedmsbuild.fs
-
Service/ServiceDeclarationLists.fsi
diff --git a/src/absil/illib.fs b/src/absil/illib.fs
index fea0fd92a97..68b7c8d40a8 100644
--- a/src/absil/illib.fs
+++ b/src/absil/illib.fs
@@ -12,10 +12,6 @@ open System.Reflection
open System.Threading
open System.Runtime.CompilerServices
-#if FX_RESHAPED_REFLECTION
-open Microsoft.FSharp.Core.ReflectionAdapters
-#endif
-
// Logical shift right treating int32 as unsigned integer.
// Code that uses this should probably be adjusted to use unsigned integer types.
let (>>>&) (x: int32) (n: int32) = int32 (uint32 x >>> n)
@@ -258,12 +254,6 @@ module Option =
module List =
- //let item n xs = List.nth xs n
-#if FX_RESHAPED_REFLECTION
- open PrimReflectionAdapters
- open Microsoft.FSharp.Core.ReflectionAdapters
-#endif
-
let sortWithOrder (c: IComparer<'T>) elements = List.sortWith (Order.toFunction c) elements
let splitAfter n l =
@@ -1272,11 +1262,6 @@ type LayeredMultiMap<'Key, 'Value when 'Key : equality and 'Key : comparison>(co
[]
module Shim =
-#if FX_RESHAPED_REFLECTION
- open PrimReflectionAdapters
- open Microsoft.FSharp.Core.ReflectionAdapters
-#endif
-
type IFileSystem =
/// A shim over File.ReadAllBytes
diff --git a/src/absil/ilreflect.fs b/src/absil/ilreflect.fs
index 152b2bf54d5..cf43af269e6 100644
--- a/src/absil/ilreflect.fs
+++ b/src/absil/ilreflect.fs
@@ -24,10 +24,6 @@ open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.Range
open FSharp.Core.Printf
-#if FX_RESHAPED_REFLECTION
-open Microsoft.FSharp.Core.ReflectionAdapters
-#endif
-
let codeLabelOrder = ComparisonIdentity.Structural
// Convert the output of convCustomAttr
@@ -314,10 +310,8 @@ let convAssemblyRef (aref: ILAssemblyRef) =
asmName.Version <- System.Version (int32 version.Major, int32 version.Minor, int32 version.Build, int32 version.Revision)
Option.iter setVersion aref.Version
// asmName.ProcessorArchitecture <- System.Reflection.ProcessorArchitecture.MSIL
-#if !FX_RESHAPED_GLOBALIZATION
//Option.iter (fun name -> asmName.CultureInfo <- System.Globalization.CultureInfo.CreateSpecificCulture name) aref.Locale
asmName.CultureInfo <- System.Globalization.CultureInfo.InvariantCulture
-#endif
asmName
/// The global environment.
@@ -665,9 +659,6 @@ let TypeBuilderInstantiationT =
ty
let typeIsNotQueryable (ty: Type) =
-#if FX_RESHAPED_REFLECTION
- let ty = ty.GetTypeInfo()
-#endif
(ty :? TypeBuilder) || ((ty.GetType()).Equals(TypeBuilderInstantiationT))
//----------------------------------------------------------------------------
// convFieldSpec
@@ -796,11 +787,7 @@ let queryableTypeGetMethod cenv emEnv parentT (mref: ILMethodRef) =
parentT.GetMethod(mref.Name, cconv ||| BindingFlags.Public ||| BindingFlags.NonPublic,
null,
argTs,
-#if FX_RESHAPED_REFLECTION
- (null: obj[]))
-#else
(null: ParameterModifier[]))
-#endif
// This can fail if there is an ambiguity w.r.t. return type
with _ -> null
if (isNonNull methInfo && equalTypes resT methInfo.ReturnType) then
@@ -1436,11 +1423,7 @@ let buildGenParamsPass1 _emEnv defineGenericParameters (gps: ILGenericParameterD
let buildGenParamsPass1b cenv emEnv (genArgs: Type array) (gps: ILGenericParameterDefs) =
-#if FX_RESHAPED_REFLECTION
- let genpBs = genArgs |> Array.map (fun x -> (x.GetTypeInfo() :?> GenericTypeParameterBuilder))
-#else
let genpBs = genArgs |> Array.map (fun x -> (x :?> GenericTypeParameterBuilder))
-#endif
gps |> List.iteri (fun i (gp: ILGenericParameterDef) ->
let gpB = genpBs.[i]
// the Constraints are either the parent (base) type or interfaces.
diff --git a/src/absil/ilwrite.fs b/src/absil/ilwrite.fs
index f46b33176c7..dbd8a288755 100644
--- a/src/absil/ilwrite.fs
+++ b/src/absil/ilwrite.fs
@@ -3037,9 +3037,6 @@ module FileSystemUtilites =
open System
open System.Reflection
open System.Globalization
-#if FX_RESHAPED_REFLECTION
- open Microsoft.FSharp.Core.ReflectionAdapters
-#endif
let progress = try System.Environment.GetEnvironmentVariable("FSharp_DebugSetFilePermissions") <> null with _ -> false
let setExecutablePermission (filename: string) =
diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs
index 0f39af500bc..624a27f92d9 100644
--- a/src/fsharp/CompileOps.fs
+++ b/src/fsharp/CompileOps.fs
@@ -29,6 +29,7 @@ open FSharp.Compiler.AttributeChecking
open FSharp.Compiler.ConstraintSolver
open FSharp.Compiler.DiagnosticMessage
open FSharp.Compiler.ErrorLogger
+open FSharp.Compiler.Features
open FSharp.Compiler.Import
open FSharp.Compiler.Infos
open FSharp.Compiler.Lexhelp
@@ -1740,7 +1741,7 @@ let CollectDiagnostic (implicitIncludeDir, showFullPaths, flattenErrors, errorSt
let os = System.Text.StringBuilder()
OutputPhasedDiagnostic os err flattenErrors canSuggestNames
errors.Add( Diagnostic.Short(isError, os.ToString()) )
-
+
relatedErrors |> List.iter OutputRelatedError
match err with
@@ -1790,7 +1791,7 @@ let OutputDiagnosticContext prefix fileLineFn os err =
let (++) x s = x @ [s]
-//----------------------------------------------------------------------------
+//--------------------------------------------------------------------------
// General file name resolver
//--------------------------------------------------------------------------
@@ -1975,7 +1976,7 @@ type ICompilationThread =
/// Enqueue work to be done on a compilation thread.
abstract EnqueueWork: (CompilationThreadToken -> unit) -> unit
-type ImportedBinary =
+type ImportedBinary =
{ FileName: string
RawMetadata: IRawFSharpAssemblyData
#if !NO_EXTENSIONTYPING
@@ -1986,7 +1987,7 @@ type ImportedBinary =
ILAssemblyRefs: ILAssemblyRef list
ILScopeRef: ILScopeRef }
-type ImportedAssembly =
+type ImportedAssembly =
{ ILScopeRef: ILScopeRef
FSharpViewOfMetadata: CcuThunk
AssemblyAutoOpenAttributes: string list
@@ -2001,7 +2002,7 @@ type AvailableImportedAssembly =
| ResolvedImportedAssembly of ImportedAssembly
| UnresolvedImportedAssembly of string
-type CcuLoadFailureAction =
+type CcuLoadFailureAction =
| RaiseError
| ReturnNone
@@ -2161,8 +2162,10 @@ type TcConfigBuilder =
mutable internalTestSpanStackReferring: bool
mutable noConditionalErasure: bool
-
+
mutable pathMap: PathMap
+
+ mutable langVersion: LanguageVersion
}
static member Initial =
@@ -2205,7 +2208,7 @@ type TcConfigBuilder =
debuginfo = false
testFlagEmitFeeFeeAs100001 = false
dumpDebugInfo = false
- debugSymbolFile = None
+ debugSymbolFile = None
(* Backend configuration *)
typeCheckOnly = false
@@ -2300,6 +2303,7 @@ type TcConfigBuilder =
internalTestSpanStackReferring = false
noConditionalErasure = false
pathMap = PathMap.empty
+ langVersion = LanguageVersion("default")
}
static member CreateNew(legacyReferenceResolver, defaultFSharpBinariesDir, reduceMemoryUsage, implicitIncludeDir,
@@ -2720,6 +2724,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
member x.emitTailcalls = data.emitTailcalls
member x.deterministic = data.deterministic
member x.pathMap = data.pathMap
+ member x.langVersion = data.langVersion
member x.preferredUiLang = data.preferredUiLang
member x.lcid = data.lcid
member x.optsOn = data.optsOn
@@ -3097,7 +3102,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
member tcConfig.PrimaryAssemblyDllReference() = primaryAssemblyReference
member tcConfig.CoreLibraryDllReference() = fslibReference
-
+
let ReportWarning options err =
warningOn err (options.WarnLevel) (options.WarnOn) && not (List.contains (GetDiagnosticNumber err) (options.WarnOff))
@@ -3448,8 +3453,8 @@ let ParseOneInputFile (tcConfig: TcConfig, lexResourceManager, conditionalCompil
if List.exists (Filename.checkSuffix lower) (FSharpSigFileSuffixes@FSharpImplFileSuffixes) then
if not(FileSystem.SafeExists filename) then
error(Error(FSComp.SR.buildCouldNotFindSourceFile filename, rangeStartup))
- // bug 3155: if the file name is indirect, use a full path
- let lexbuf = UnicodeLexing.UnicodeFileAsLexbuf(filename, tcConfig.inputCodePage, retryLocked)
+ let isFeatureSupported featureId = tcConfig.langVersion.SupportsFeature featureId
+ let lexbuf = UnicodeLexing.UnicodeFileAsLexbuf(isFeatureSupported, filename, tcConfig.inputCodePage, retryLocked)
ParseOneInputLexbuf(tcConfig, lexResourceManager, conditionalCompilationDefines, lexbuf, filename, isLastCompiland, errorLogger)
else error(Error(FSComp.SR.buildInvalidSourceFileExtension(SanitizeFileName filename tcConfig.implicitIncludeDir), rangeStartup))
with e -> (* errorR(Failure("parse failed")); *) errorRecovery e rangeStartup; None
@@ -4693,7 +4698,7 @@ and [] TcImports(tcConfigP: TcConfigProvider, initialResolutions: TcAsse
let tcGlobals = TcGlobals(tcConfig.compilingFslib, ilGlobals, fslibCcu,
tcConfig.implicitIncludeDir, tcConfig.mlCompatibility,
tcConfig.isInteractive, tryFindSysTypeCcu, tcConfig.emitDebugInfoInQuotations,
- tcConfig.noDebugData, tcConfig.pathMap)
+ tcConfig.noDebugData, tcConfig.pathMap, tcConfig.langVersion)
#if DEBUG
// the global_g reference cell is used only for debug printing
@@ -4978,11 +4983,13 @@ module private ScriptPreprocessClosure =
| CodeContext.CompilationAndEvaluation -> ["INTERACTIVE"]
| CodeContext.Compilation -> ["COMPILED"]
| CodeContext.Editing -> "EDITING" :: (if IsScript filename then ["INTERACTIVE"] else ["COMPILED"])
- let lexbuf = UnicodeLexing.SourceTextAsLexbuf(sourceText)
-
+
+ let isFeatureSupported featureId = tcConfig.langVersion.SupportsFeature featureId
+ let lexbuf = UnicodeLexing.SourceTextAsLexbuf(isFeatureSupported, sourceText)
+
let isLastCompiland = (IsScript filename), tcConfig.target.IsExe // The root compiland is last in the list of compilands.
ParseOneInputLexbuf (tcConfig, lexResourceManager, defines, lexbuf, filename, isLastCompiland, errorLogger)
-
+
/// Create a TcConfig for load closure starting from a single .fsx file
let CreateScriptTextTcConfig
(legacyReferenceResolver, defaultFSharpBinariesDir,
@@ -5194,7 +5201,7 @@ module private ScriptPreprocessClosure =
useSimpleResolution, useFsiAuxLib, useSdkRefs,
lexResourceManager: Lexhelp.LexResourceManager,
applyCommmandLineArgs, assumeDotNetFramework,
- tryGetMetadataSnapshot, reduceMemoryUsage) =
+ tryGetMetadataSnapshot, reduceMemoryUsage) =
// Resolve the basic references such as FSharp.Core.dll first, before processing any #I directives in the script
//
@@ -5292,11 +5299,8 @@ let CheckSimulateException(tcConfig: TcConfig) =
| Some("tc-oom") -> raise(System.OutOfMemoryException())
| Some("tc-an") -> raise(System.ArgumentNullException("simulated"))
| Some("tc-invop") -> raise(System.InvalidOperationException())
-#if FX_REDUCED_EXCEPTIONS
-#else
| Some("tc-av") -> raise(System.AccessViolationException())
| Some("tc-nfn") -> raise(System.NotFiniteNumberException())
-#endif
| Some("tc-aor") -> raise(System.ArgumentOutOfRangeException())
| Some("tc-dv0") -> raise(System.DivideByZeroException())
| Some("tc-oe") -> raise(System.OverflowException())
diff --git a/src/fsharp/CompileOps.fsi b/src/fsharp/CompileOps.fsi
index 8a017c1e327..34e25a21f17 100644
--- a/src/fsharp/CompileOps.fsi
+++ b/src/fsharp/CompileOps.fsi
@@ -17,6 +17,7 @@ open FSharp.Compiler.TypeChecker
open FSharp.Compiler.Range
open FSharp.Compiler.Ast
open FSharp.Compiler.ErrorLogger
+open FSharp.Compiler.Features
open FSharp.Compiler.Tast
open FSharp.Compiler.TcGlobals
open FSharp.Compiler.Text
@@ -383,6 +384,8 @@ type TcConfigBuilder =
mutable noConditionalErasure: bool
mutable pathMap : PathMap
+
+ mutable langVersion : LanguageVersion
}
static member Initial: TcConfigBuilder
@@ -543,6 +546,7 @@ type TcConfig =
member copyFSharpCore: CopyFSharpCoreFlag
member shadowCopyReferences: bool
member useSdkRefs: bool
+ member langVersion: LanguageVersion
static member Create: TcConfigBuilder * validate: bool -> TcConfig
diff --git a/src/fsharp/CompileOptions.fs b/src/fsharp/CompileOptions.fs
index a3c0f5c3279..c4595d2dc24 100644
--- a/src/fsharp/CompileOptions.fs
+++ b/src/fsharp/CompileOptions.fs
@@ -18,6 +18,7 @@ open FSharp.Compiler.TcGlobals
open FSharp.Compiler.Tast
open FSharp.Compiler.Tastops
open FSharp.Compiler.ErrorLogger
+open FSharp.Compiler.Features
open FSharp.Compiler.Lib
open FSharp.Compiler.Range
open FSharp.Compiler.IlxGen
@@ -527,6 +528,7 @@ let tagAlgorithm = "{SHA1|SHA256}"
let tagInt = ""
let tagPathMap = ""
let tagNone = ""
+let tagLangVersionValues = "{?|version|latest|preview}"
// PrintOptionInfo
//----------------
@@ -814,28 +816,41 @@ let codeGenerationFlags isFsi (tcConfigB: TcConfigBuilder) =
//----------------------
let defineSymbol tcConfigB s = tcConfigB.conditionalCompilationDefines <- s :: tcConfigB.conditionalCompilationDefines
-
+
let mlCompatibilityFlag (tcConfigB: TcConfigBuilder) =
CompilerOption
("mlcompatibility", tagNone,
OptionUnit (fun () -> tcConfigB.mlCompatibility<-true; tcConfigB.TurnWarningOff(rangeCmdArgs, "62")), None,
Some (FSComp.SR.optsMlcompatibility()))
+/// LanguageVersion management
+let setLanguageVersion (specifiedVersion) =
+
+ let languageVersion = new LanguageVersion(specifiedVersion)
+ let dumpAllowedValues () =
+ printfn "%s" (FSComp.SR.optsSupportedLangVersions())
+ for v in languageVersion.ValidOptions do printfn "%s" v
+ for v in languageVersion.ValidVersions do printfn "%s" v
+ exit 0
+
+ if specifiedVersion = "?" then dumpAllowedValues ()
+ if not (languageVersion.ContainsVersion specifiedVersion) then error(Error(FSComp.SR.optsUnrecognizedLanguageVersion specifiedVersion, rangeCmdArgs))
+ languageVersion
+
let languageFlags tcConfigB =
[
- CompilerOption
- ("checked", tagNone,
- OptionSwitch (fun switch -> tcConfigB.checkOverflow <- (switch = OptionSwitch.On)), None,
- Some (FSComp.SR.optsChecked()))
-
- CompilerOption
- ("define", tagString,
- OptionString (defineSymbol tcConfigB), None,
- Some (FSComp.SR.optsDefine()))
-
+ // -langversion:? Display the allowed values for language version
+ // -langversion: Specify language version such as
+ // 'default' (latest major version), or
+ // 'latest' (latest version, including minor versions),
+ // 'preview' (features for preview)
+ // or specific versions like '4.7'
+ CompilerOption("langversion", tagLangVersionValues, OptionString (fun switch -> tcConfigB.langVersion <- setLanguageVersion(switch)), None, Some (FSComp.SR.optsLangVersion()))
+
+ CompilerOption("checked", tagNone, OptionSwitch (fun switch -> tcConfigB.checkOverflow <- (switch = OptionSwitch.On)), None, Some (FSComp.SR.optsChecked()))
+ CompilerOption("define", tagString, OptionString (defineSymbol tcConfigB), None, Some (FSComp.SR.optsDefine()))
mlCompatibilityFlag tcConfigB
]
-
// OptionBlock: Advanced user options
//-----------------------------------
@@ -1606,16 +1621,10 @@ let ReportTime (tcConfig:TcConfig) descr =
| Some("fsc-oom") -> raise(System.OutOfMemoryException())
| Some("fsc-an") -> raise(System.ArgumentNullException("simulated"))
| Some("fsc-invop") -> raise(System.InvalidOperationException())
-#if FX_REDUCED_EXCEPTIONS
-#else
| Some("fsc-av") -> raise(System.AccessViolationException())
-#endif
| Some("fsc-aor") -> raise(System.ArgumentOutOfRangeException())
| Some("fsc-dv0") -> raise(System.DivideByZeroException())
-#if FX_REDUCED_EXCEPTIONS
-#else
| Some("fsc-nfn") -> raise(System.NotFiniteNumberException())
-#endif
| Some("fsc-oe") -> raise(System.OverflowException())
| Some("fsc-atmm") -> raise(System.ArrayTypeMismatchException())
| Some("fsc-bif") -> raise(System.BadImageFormatException())
diff --git a/src/fsharp/ConstraintSolver.fs b/src/fsharp/ConstraintSolver.fs
index 188eba19cb2..1e59e05b526 100644
--- a/src/fsharp/ConstraintSolver.fs
+++ b/src/fsharp/ConstraintSolver.fs
@@ -2730,9 +2730,26 @@ let UndoIfFailed f =
ReportWarnings warns
true
+let UndoIfFailedOrWarnings f =
+ let trace = Trace.New()
+ let res =
+ try
+ f trace
+ |> CheckNoErrorsAndGetWarnings
+ with e -> None
+ match res with
+ | Some [] ->
+ true
+ | _ ->
+ trace.Undo()
+ false
+
let AddCxTypeEqualsTypeUndoIfFailed denv css m ty1 ty2 =
UndoIfFailed (fun trace -> SolveTypeEqualsTypeKeepAbbrevs (MakeConstraintSolverEnv ContextInfo.NoContext css m denv) 0 m (WithTrace trace) ty1 ty2)
+let AddCxTypeEqualsTypeUndoIfFailedOrWarnings denv css m ty1 ty2 =
+ UndoIfFailedOrWarnings (fun trace -> SolveTypeEqualsTypeKeepAbbrevs (MakeConstraintSolverEnv ContextInfo.NoContext css m denv) 0 m (WithTrace trace) ty1 ty2)
+
let AddCxTypeEqualsTypeMatchingOnlyUndoIfFailed denv css m ty1 ty2 =
let csenv = { MakeConstraintSolverEnv ContextInfo.NoContext css m denv with MatchingOnly = true }
UndoIfFailed (fun trace -> SolveTypeEqualsTypeKeepAbbrevs csenv 0 m (WithTrace trace) ty1 ty2)
diff --git a/src/fsharp/ConstraintSolver.fsi b/src/fsharp/ConstraintSolver.fsi
index 59c271b126b..1fce009f616 100644
--- a/src/fsharp/ConstraintSolver.fsi
+++ b/src/fsharp/ConstraintSolver.fsi
@@ -126,6 +126,7 @@ val CheckDeclaredTypars : DisplayEnv -> ConstraintSolverSt
val AddConstraint : ConstraintSolverEnv -> int -> Range.range -> OptionalTrace -> Typar -> TyparConstraint -> OperationResult
val AddCxTypeEqualsType : ContextInfo -> DisplayEnv -> ConstraintSolverState -> range -> TType -> TType -> unit
val AddCxTypeEqualsTypeUndoIfFailed : DisplayEnv -> ConstraintSolverState -> range -> TType -> TType -> bool
+val AddCxTypeEqualsTypeUndoIfFailedOrWarnings : DisplayEnv -> ConstraintSolverState -> range -> TType -> TType -> bool
val AddCxTypeEqualsTypeMatchingOnlyUndoIfFailed : DisplayEnv -> ConstraintSolverState -> range -> TType -> TType -> bool
val AddCxTypeMustSubsumeType : ContextInfo -> DisplayEnv -> ConstraintSolverState -> range -> OptionalTrace -> TType -> TType -> unit
val AddCxTypeMustSubsumeTypeUndoIfFailed : DisplayEnv -> ConstraintSolverState -> range -> TType -> TType -> bool
diff --git a/src/fsharp/ErrorLogger.fs b/src/fsharp/ErrorLogger.fs
index 2f9c07173b5..5760aef8a2a 100755
--- a/src/fsharp/ErrorLogger.fs
+++ b/src/fsharp/ErrorLogger.fs
@@ -351,10 +351,6 @@ module ErrorLoggerExtensions =
/// Reraise an exception if it is one we want to report to Watson.
let ReraiseIfWatsonable(exn:exn) =
-#if FX_REDUCED_EXCEPTIONS
- ignore exn
- ()
-#else
match exn with
// These few SystemExceptions which we don't report to Watson are because we handle these in some way in Build.fs
| :? System.Reflection.TargetInvocationException -> ()
@@ -366,7 +362,6 @@ module ErrorLoggerExtensions =
PreserveStackTrace exn
raise exn
| _ -> ()
-#endif
type ErrorLogger with
@@ -404,10 +399,7 @@ module ErrorLoggerExtensions =
// Throws StopProcessing and exceptions raised by the DiagnosticSink(exn) handler.
match exn with
(* Don't send ThreadAbortException down the error channel *)
-#if FX_REDUCED_EXCEPTIONS
-#else
| :? System.Threading.ThreadAbortException | WrappedError((:? System.Threading.ThreadAbortException), _) -> ()
-#endif
| ReportedError _ | WrappedError(ReportedError _, _) -> ()
| StopProcessing | WrappedError(StopProcessing, _) ->
PreserveStackTrace exn
@@ -679,7 +671,7 @@ type public FSharpErrorSeverityOptions =
// See https://github.com/Microsoft/visualfsharp/issues/6417, if a compile of the FSharp.Compiler.Services.dll or other compiler
-// binary produces exactly 65536 methods then older versions of the compiler raise a bug. If you hit this bug again then try removing
-// this.
-let dummyMethodFOrBug6417A() = ()
-let dummyMethodFOrBug6417B() = ()
+// binary produces exactly 65536 methods then older versions of the compiler raise a bug. If you hit this bug again then try adding
+// this back in.
+// let dummyMethodFOrBug6417A() = ()
+// let dummyMethodFOrBug6417B() = ()
diff --git a/src/fsharp/ExtensionTyping.fs b/src/fsharp/ExtensionTyping.fs
index 0513bcf2eea..c075e0dbe96 100755
--- a/src/fsharp/ExtensionTyping.fs
+++ b/src/fsharp/ExtensionTyping.fs
@@ -140,9 +140,7 @@ module internal ExtensionTyping =
let StripException (e: exn) =
match e with
-#if !FX_REDUCED_EXCEPTIONS
| :? System.Reflection.TargetInvocationException as e -> e.InnerException
-#endif
| :? TypeInitializationException as e -> e.InnerException
| _ -> e
@@ -417,6 +415,7 @@ module internal ExtensionTyping =
member __.IsEnum = x.IsEnum
member __.IsClass = x.IsClass
member __.IsSealed = x.IsSealed
+ member __.IsAbstract = x.IsAbstract
member __.IsInterface = x.IsInterface
member __.GetArrayRank() = x.GetArrayRank()
member __.GenericParameterPosition = x.GenericParameterPosition
diff --git a/src/fsharp/ExtensionTyping.fsi b/src/fsharp/ExtensionTyping.fsi
index 5049fffa778..5c679fe69e1 100755
--- a/src/fsharp/ExtensionTyping.fsi
+++ b/src/fsharp/ExtensionTyping.fsi
@@ -120,6 +120,7 @@ module internal ExtensionTyping =
member IsInterface : bool
member IsClass : bool
member IsSealed : bool
+ member IsAbstract : bool
member IsPublic : bool
member IsNestedPublic : bool
member GenericParameterPosition : int
diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt
index 65cdd47d5be..096da0a7cc7 100644
--- a/src/fsharp/FSComp.txt
+++ b/src/fsharp/FSComp.txt
@@ -73,6 +73,7 @@ buildProductNameCommunity,"F# Compiler for F# %s"
pickleErrorReadingWritingMetadata,"Error reading/writing metadata for the F# compiled DLL '%s'. Was the DLL compiled with an earlier version of the F# compiler? (error: '%s')."
245,tastTypeOrModuleNotConcrete,"The type/module '%s' is not a concrete module or type"
tastTypeHasAssemblyCodeRepresentation,"The type '%s' has an inline assembly code representation"
+246,optsUnrecognizedLanguageVersion,"Unrecognized value '%s' for --langversion use --langversion:? for complete list"
247,tastNamespaceAndModuleWithSameNameInAssembly,"A namespace and a module named '%s' both occur in two parts of this assembly"
248,tastTwoModulesWithSameNameInAssembly,"Two modules named '%s' occur in two parts of this assembly"
249,tastDuplicateTypeDefinitionInAssembly,"Two type definitions named '%s' occur in namespace '%s' in two parts of this assembly"
@@ -420,6 +421,7 @@ parsAttributesMustComeBeforeVal,"Attributes should be placed before 'val'"
568,parsAllEnumFieldsRequireValues,"All enum fields must be given values"
569,parsInlineAssemblyCannotHaveVisibilityDeclarations,"Accessibility modifiers are not permitted on inline assembly code types"
571,parsUnexpectedIdentifier,"Unexpected identifier: '%s'"
+10,parsUnexpectedSymbolDot,"Unexpected symbol '.' in member definition. Expected 'with', '=' or other token."
572,parsUnionCasesCannotHaveVisibilityDeclarations,"Accessibility modifiers are not permitted on union cases. Use 'type U = internal ...' or 'type U = private ...' to give an accessibility to the whole representation."
573,parsEnumFieldsCannotHaveVisibilityDeclarations,"Accessibility modifiers are not permitted on enumeration fields"
parsConsiderUsingSeparateRecordType,"Consider using a separate record type instead"
@@ -1462,9 +1464,13 @@ notAFunctionButMaybeDeclaration,"This value is not a function and cannot be appl
3244,parsInvalidAnonRecdType,"Invalid anonymous record type"
3245,tcCopyAndUpdateNeedsRecordType,"The input to a copy-and-update expression that creates an anonymous record must be either an anonymous record or a record"
3246,tcAugmentationsCannotHaveAttributes,"Attributes cannot be applied to type extensions."
+3250,expressionHasNoName,"Expression does not have a name."
+3251,chkNoFirstClassNameOf,"Using the 'nameof' operator as a first-class function value is not permitted."
3300,chkInvalidFunctionParameterType,"The parameter '%s' has an invalid type '%s'. This is not permitted by the rules of Common IL."
3301,chkInvalidFunctionReturnType,"The function or method has an invalid return type '%s'. This is not permitted by the rules of Common IL."
useSdkRefs,"Use reference assemblies for .NET framework references when available (Enabled by default)."
fSharpBannerVersion,"%s for F# %s"
nativeResourceFormatError,"Stream does not begin with a null resource and is not in '.RES' format."
-nativeResourceHeaderMalformed,"Resource header beginning at offset %s is malformed."
\ No newline at end of file
+nativeResourceHeaderMalformed,"Resource header beginning at offset %s is malformed."
+optsLangVersion,"Display the allowed values for language version, specify language version such as 'latest' or 'preview'"
+optsSupportedLangVersions,"Supported language versions:"
diff --git a/src/fsharp/FSharp.Build/FSharp.Build.fsproj b/src/fsharp/FSharp.Build/FSharp.Build.fsproj
index e22c8797018..76b9c7043e9 100644
--- a/src/fsharp/FSharp.Build/FSharp.Build.fsproj
+++ b/src/fsharp/FSharp.Build/FSharp.Build.fsproj
@@ -19,7 +19,6 @@
-
diff --git a/src/fsharp/FSharp.Build/Fsc.fs b/src/fsharp/FSharp.Build/Fsc.fs
index 8080637fcdf..25bdfa38d3a 100644
--- a/src/fsharp/FSharp.Build/Fsc.fs
+++ b/src/fsharp/FSharp.Build/Fsc.fs
@@ -40,6 +40,7 @@ type public Fsc () as this =
let mutable generateInterfaceFile : string = null
let mutable highEntropyVA : bool = false
let mutable keyFile : string = null
+ let mutable langVersion : string = null
let mutable noFramework = false
let mutable optimize : bool = true
let mutable otherFlags : string = null
@@ -103,15 +104,15 @@ type public Fsc () as this =
| "EMBEDDED" -> "embedded"
| "FULL" -> "full"
| _ -> null)
- if embedAllSources then
- builder.AppendSwitch("--embed+")
+ if embedAllSources then builder.AppendSwitch("--embed+")
if embeddedFiles <> null then
for item in embeddedFiles do
builder.AppendSwitchIfNotNull("--embed:", item.ItemSpec)
builder.AppendSwitchIfNotNull("--sourcelink:", sourceLink)
+ builder.AppendSwitchIfNotNull("--langversion:", langVersion)
// NoFramework
- if noFramework then
- builder.AppendSwitch("--noframework")
+ if noFramework then
+ builder.AppendSwitch("--noframework")
// BaseAddress
builder.AppendSwitchIfNotNull("--baseaddress:", baseAddress)
// DefineConstants
@@ -120,7 +121,6 @@ type public Fsc () as this =
builder.AppendSwitchIfNotNull("--define:", item.ItemSpec)
// DocumentationFile
builder.AppendSwitchIfNotNull("--doc:", documentationFile)
-
// GenerateInterfaceFile
builder.AppendSwitchIfNotNull("--sig:", generateInterfaceFile)
// KeyFile
@@ -343,6 +343,10 @@ type public Fsc () as this =
with get() = keyFile
and set(s) = keyFile <- s
+ member fsc.LangVersion
+ with get() = langVersion
+ and set(s) = langVersion <- s
+
member fsc.LCID
with get() = vslcid
and set(p) = vslcid <- p
@@ -376,7 +380,7 @@ type public Fsc () as this =
member fsc.PathMap
with get() = pathMap
and set(s) = pathMap <- s
-
+
// --pdb :
// Name the debug output file
member fsc.PdbFile
diff --git a/src/fsharp/FSharp.Build/Fsi.fs b/src/fsharp/FSharp.Build/Fsi.fs
index 93d8fc66590..ed1aae5e132 100644
--- a/src/fsharp/FSharp.Build/Fsi.fs
+++ b/src/fsharp/FSharp.Build/Fsi.fs
@@ -29,6 +29,7 @@ type public Fsi () as this =
let mutable disabledWarnings : string = null
let mutable dotnetFsiCompilerPath : string = null
let mutable fsiExec = false
+ let mutable langVersion : string = null
let mutable noFramework = false
let mutable optimize = true
let mutable otherFlags : string = null
@@ -67,6 +68,7 @@ type public Fsi () as this =
builder.AppendSwitchIfNotNull("--codepage:", codePage)
+ builder.AppendSwitchIfNotNull("--langversion:", langVersion)
if noFramework then builder.AppendSwitch("--noframework")
if defineConstants <> null then
@@ -167,6 +169,10 @@ type public Fsi () as this =
with get() = vslcid
and set(p) = vslcid <- p
+ member fsc.LangVersion
+ with get() = langVersion
+ and set(s) = langVersion <- s
+
// --noframework
member fsi.NoFramework
with get() = noFramework
diff --git a/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets b/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets
index a5d036b885a..8421c8ea504 100644
--- a/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets
+++ b/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets
@@ -273,8 +273,8 @@ this file.
-
-
+
+ Win32ResourceFile="$(Win32Resource)">
diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ja.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ja.xlf
index 2cbcdb1927b..558d9a4705d 100644
--- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ja.xlf
+++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ja.xlf
@@ -4,7 +4,7 @@
- F# {1} の {0}
+ F# {1} のための {0}
diff --git a/src/fsharp/FSharp.Compiler.Interactive.Settings/FSharp.Compiler.Interactive.Settings.fsproj b/src/fsharp/FSharp.Compiler.Interactive.Settings/FSharp.Compiler.Interactive.Settings.fsproj
index 70c01bec4f0..75af428f4f1 100644
--- a/src/fsharp/FSharp.Compiler.Interactive.Settings/FSharp.Compiler.Interactive.Settings.fsproj
+++ b/src/fsharp/FSharp.Compiler.Interactive.Settings/FSharp.Compiler.Interactive.Settings.fsproj
@@ -21,7 +21,6 @@
-
diff --git a/src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj b/src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj
index 1b8ddb24d37..d8f5341a8a2 100644
--- a/src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj
+++ b/src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj
@@ -63,12 +63,6 @@
Logger.fs
-
- Reflection\reshapedreflection.fs
-
-
- Reflection\reshapedmsbuild.fs
-
ErrorText\sformat.fsi
@@ -81,6 +75,12 @@
ErrorText\sr.fs
+
+ Driver\LanguageFeatures.fsi
+
+
+ Driver\LanguageFeatures.fs
+
LexYaccRuntime\prim-lexing.fsi
@@ -147,6 +147,9 @@
Utilities\bytes.fs
+
+ Utilities\XmlAdapters.fs
+
Utilities\InternalCollections.fsi
@@ -272,7 +275,9 @@
ReferenceResolution\ReferenceResolver.fs
-
+
+ ReferenceResolution/reshapedmsbuild.fs
+
ReferenceResolution/LegacyMSBuildReferenceResolver.fsi
@@ -636,9 +641,6 @@
Service/ServiceXmlDocParser.fs
-
- Service/reshapedmsbuild.fs
-
Service/ExternalSymbol.fsi
diff --git a/src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.netcore.nuspec b/src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.netcore.nuspec
index 2133f3bcf14..e8af5ff0e4a 100644
--- a/src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.netcore.nuspec
+++ b/src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.netcore.nuspec
@@ -4,7 +4,7 @@
FSharp.Compiler.Private.netcore
.NET Core compatible version of the fsharp compiler service dll
- Supported Platforms: - .NET Core (netstandard1.6)
+ Supported Platforms: - .NET Core (netstandard2.0)
en-UStrue
@@ -15,7 +15,7 @@
$tags$
-
+
diff --git a/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec b/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec
index a82fbb1ac3e..dd9293cd88c 100644
--- a/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec
+++ b/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec
@@ -45,7 +45,7 @@
-
+
-
+ true
- net45;netstandard1.6
+ net45;netstandard2.0FSharp.CoreFSharp.Core.nuspectrue
diff --git a/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec b/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec
index ee7a88b29d6..e94b3a547c3 100644
--- a/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec
+++ b/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec
@@ -5,50 +5,23 @@
https://fsharp.org/img/logo.pngen-US
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
+
diff --git a/src/fsharp/FSharp.Core/FSCore.resx b/src/fsharp/FSharp.Core/FSCore.resx
index 8b74b1d039c..b90b5442f20 100644
--- a/src/fsharp/FSharp.Core/FSCore.resx
+++ b/src/fsharp/FSharp.Core/FSCore.resx
@@ -540,4 +540,7 @@
This is not a valid query expression. The construct '{0}' was used in a query but is not recognized by the F#-to-LINQ query translator. Check the specification of permitted queries and consider moving some of the operations out of the query expression.
+
+ maxDegreeOfParallelism must be positive, was {0}
+
\ No newline at end of file
diff --git a/src/fsharp/FSharp.Core/FSharp.Core.fsproj b/src/fsharp/FSharp.Core/FSharp.Core.fsproj
index 03a83fca87e..ef68a28e6d6 100644
--- a/src/fsharp/FSharp.Core/FSharp.Core.fsproj
+++ b/src/fsharp/FSharp.Core/FSharp.Core.fsproj
@@ -4,8 +4,8 @@
Library
- net45;netstandard1.6
- netstandard1.6
+ net45;netstandard2.0
+ netstandard2.0$(NoWarn);45;55;62;75;1204true$(DefineConstants);FSHARP_CORE
@@ -113,9 +113,6 @@
Collections/set.fs
-
- Reflection/reshapedreflection.fs
-
Reflection/reflect.fsi
@@ -217,11 +214,6 @@
-
-
-
-
-
diff --git a/src/fsharp/FSharp.Core/Linq.fs b/src/fsharp/FSharp.Core/Linq.fs
index e4deedbf077..fb9432075c4 100644
--- a/src/fsharp/FSharp.Core/Linq.fs
+++ b/src/fsharp/FSharp.Core/Linq.fs
@@ -162,11 +162,6 @@ open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open Microsoft.FSharp.Quotations.DerivedPatterns
-#if FX_RESHAPED_REFLECTION
-open PrimReflectionAdapters
-open ReflectionAdapters
-#endif
-
module LeafExpressionConverter =
// The following is recognized as a LINQ 'member initialization pattern' in a quotation.
@@ -219,11 +214,7 @@ module LeafExpressionConverter =
SubstHelperRaw(q, x, y) |> Expr.Cast
let showAll =
-#if FX_RESHAPED_REFLECTION
- true
-#else
BindingFlags.Public ||| BindingFlags.NonPublic
-#endif
let NullableConstructor =
typedefof>.GetConstructors().[0]
diff --git a/src/fsharp/FSharp.Core/Query.fs b/src/fsharp/FSharp.Core/Query.fs
index cd681e77936..92ee2451844 100644
--- a/src/fsharp/FSharp.Core/Query.fs
+++ b/src/fsharp/FSharp.Core/Query.fs
@@ -302,11 +302,6 @@ open Microsoft.FSharp.Quotations.DerivedPatterns
open Microsoft.FSharp.Linq.QueryRunExtensions
-#if FX_RESHAPED_REFLECTION
-open PrimReflectionAdapters
-open ReflectionAdapters
-#endif
-
[]
module Query =
diff --git a/src/fsharp/FSharp.Core/QueryExtensions.fs b/src/fsharp/FSharp.Core/QueryExtensions.fs
index 4885899fe89..bfddf7e57ef 100644
--- a/src/fsharp/FSharp.Core/QueryExtensions.fs
+++ b/src/fsharp/FSharp.Core/QueryExtensions.fs
@@ -15,11 +15,6 @@ open System.Collections.Generic
open System.Linq
open System.Linq.Expressions
-#if FX_RESHAPED_REFLECTION
-open PrimReflectionAdapters
-open ReflectionAdapters
-#endif
-
// ----------------------------------------------------------------------------
/// A type used to reconstruct a grouping after applying a mutable->immutable mapping transformation
@@ -171,11 +166,7 @@ module internal Adapters =
let (|RecordFieldGetSimplification|_|) (expr:Expr) =
match expr with
| Patterns.PropertyGet(Some (Patterns.NewRecord(typ,els)),propInfo,[]) ->
-#if FX_RESHAPED_REFLECTION
- let fields = Microsoft.FSharp.Reflection.FSharpType.GetRecordFields(typ, true)
-#else
let fields = Microsoft.FSharp.Reflection.FSharpType.GetRecordFields(typ,System.Reflection.BindingFlags.Public|||System.Reflection.BindingFlags.NonPublic)
-#endif
match fields |> Array.tryFindIndex (fun p -> p = propInfo) with
| None -> None
| Some i -> if i < els.Length then Some els.[i] else None
diff --git a/src/fsharp/FSharp.Core/array.fs b/src/fsharp/FSharp.Core/array.fs
index 8d7ce38869d..0ac47bd39a6 100644
--- a/src/fsharp/FSharp.Core/array.fs
+++ b/src/fsharp/FSharp.Core/array.fs
@@ -10,9 +10,6 @@ namespace Microsoft.FSharp.Collections
open Microsoft.FSharp.Core.Operators
open Microsoft.FSharp.Core.CompilerServices
open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators
-#if FX_RESHAPED_REFLECTION
- open System.Reflection
-#endif
/// Basic operations on arrays
[]
@@ -191,11 +188,7 @@ namespace Microsoft.FSharp.Collections
[]
let countBy (projection: 'T->'Key) (array: 'T[]) =
checkNonNull "array" array
-#if FX_RESHAPED_REFLECTION
- if (typeof<'Key>).GetTypeInfo().IsValueType
-#else
if typeof<'Key>.IsValueType
-#endif
then countByValueType projection array
else countByRefType projection array
@@ -445,11 +438,7 @@ namespace Microsoft.FSharp.Collections
[]
let groupBy (projection: 'T->'Key) (array: 'T[]) =
checkNonNull "array" array
-#if FX_RESHAPED_REFLECTION
- if (typeof<'Key>).GetTypeInfo().IsValueType
-#else
if typeof<'Key>.IsValueType
-#endif
then groupByValueType projection array
else groupByRefType projection array
diff --git a/src/fsharp/FSharp.Core/async.fs b/src/fsharp/FSharp.Core/async.fs
index 1f20f7c8110..1d4eb37ecc3 100644
--- a/src/fsharp/FSharp.Core/async.fs
+++ b/src/fsharp/FSharp.Core/async.fs
@@ -17,10 +17,6 @@ namespace Microsoft.FSharp.Control
open Microsoft.FSharp.Control
open Microsoft.FSharp.Collections
-#if FX_RESHAPED_REFLECTION
- open ReflectionAdapters
-#endif
-
type LinkedSubSource(cancellationToken: CancellationToken) =
let failureCTS = new CancellationTokenSource()
@@ -168,13 +164,11 @@ namespace Microsoft.FSharp.Control
let f = unbox<(unit -> AsyncReturn)> o
this.ExecuteWithTrampoline f |> unfake)
-#if !FX_NO_PARAMETERIZED_THREAD_START
// Preallocate this delegate and keep it in the trampoline holder.
let threadStartCallbackForStartThreadWithTrampoline =
ParameterizedThreadStart (fun o ->
let f = unbox<(unit -> AsyncReturn)> o
this.ExecuteWithTrampoline f |> unfake)
-#endif
/// Execute an async computation after installing a trampoline on its synchronous stack.
[]
@@ -196,22 +190,10 @@ namespace Microsoft.FSharp.Control
| null -> this.QueueWorkItemWithTrampoline f
| _ -> this.PostWithTrampoline syncCtxt f
-#if FX_NO_PARAMETERIZED_THREAD_START
- // This should be the only call to Thread.Start in this library. We must always install a trampoline.
- member this.StartThreadWithTrampoline (f: unit -> AsyncReturn) =
-#if FX_NO_THREAD
- this.QueueWorkItemWithTrampoline f
-#else
- (new Thread((fun _ -> this.Execute f |> unfake), IsBackground=true)).Start()
- fake()
-#endif
-
-#else
// This should be the only call to Thread.Start in this library. We must always install a trampoline.
member __.StartThreadWithTrampoline (f: unit -> AsyncReturn) =
(new Thread(threadStartCallbackForStartThreadWithTrampoline, IsBackground=true)).Start(f|>box)
fake()
-#endif
/// Save the exception continuation during propagation of an exception, or prior to raising an exception
member inline __.OnExceptionRaised econt =
@@ -731,12 +713,7 @@ namespace Microsoft.FSharp.Control
match resEvent with
| null -> ()
| ev ->
-#if FX_NO_EVENTWAITHANDLE_IDISPOSABLE
- ev.Dispose()
- System.GC.SuppressFinalize ev
-#else
ev.Close()
-#endif
resEvent <- null)
interface IDisposable with
@@ -824,15 +801,7 @@ namespace Microsoft.FSharp.Control
| None ->
// OK, let's really wait for the Set signal. This may block.
let timeout = defaultArg timeout Threading.Timeout.Infinite
-#if FX_NO_EXIT_CONTEXT_FLAGS
-#if FX_NO_WAITONE_MILLISECONDS
- let ok = resHandle.WaitOne(TimeSpan(int64 timeout*10000L))
-#else
- let ok = resHandle.WaitOne(millisecondsTimeout= timeout)
-#endif
-#else
let ok = resHandle.WaitOne(millisecondsTimeout= timeout, exitContext=true)
-#endif
if ok then
// Now the result really must be available
result
@@ -1196,7 +1165,13 @@ namespace Microsoft.FSharp.Control
async { let! cancellationToken = cancellationTokenAsync
return AsyncPrimitives.StartAsTask cancellationToken computation taskCreationOptions }
- static member Parallel (computations: seq>) =
+ static member Parallel (computations: seq>) = Async.Parallel(computations, ?maxDegreeOfParallelism=None)
+
+ static member Parallel (computations: seq>, ?maxDegreeOfParallelism: int) =
+ match maxDegreeOfParallelism with
+ | Some x when x < 1 -> raise(System.ArgumentException(String.Format(SR.GetString(SR.maxDegreeOfParallelismNotPositive), x), "maxDegreeOfParallelism"))
+ | _ -> ()
+
MakeAsync (fun ctxt ->
let tasks, result =
try
@@ -1251,19 +1226,61 @@ namespace Microsoft.FSharp.Control
| _ -> ()
finishTask(Interlocked.Decrement &count)
- tasks |> Array.iteri (fun i p ->
- QueueAsync
+ // If maxDegreeOfParallelism is set but is higher then the number of tasks we have we set it back to None to fall into the simple
+ // queue all items branch
+ let maxDegreeOfParallelism =
+ match maxDegreeOfParallelism with
+ | None -> None
+ | Some maxDegreeOfParallelism -> if maxDegreeOfParallelism >= tasks.Length then None else Some maxDegreeOfParallelism
+
+ // Simple case (no maxDegreeOfParallelism) just queue all the work, if we have maxDegreeOfParallelism set we start that many workers
+ // which will make progress on the actual computations
+ match maxDegreeOfParallelism with
+ | None ->
+ tasks |> Array.iteri (fun i p ->
+ QueueAsync
+ innerCTS.Token
+ // on success, record the result
+ (fun res -> recordSuccess i res)
+ // on exception...
+ (fun edi -> recordFailure (Choice1Of2 edi))
+ // on cancellation...
+ (fun cexn -> recordFailure (Choice2Of2 cexn))
+ p
+ |> unfake)
+ | Some maxDegreeOfParallelism ->
+ let mutable i = -1
+ let worker = MakeAsync (fun _ ->
+ while i < tasks.Length do
+ let j = Interlocked.Increment &i
+ if j < tasks.Length then
+ let trampolineHolder = new TrampolineHolder()
+ trampolineHolder.ExecuteWithTrampoline (fun () ->
+ let ctxt =
+ AsyncActivation.Create
+ innerCTS.Token
+ trampolineHolder
+ (fun res -> recordSuccess j res)
+ (fun edi -> recordFailure (Choice1Of2 edi))
+ (fun cexn -> recordFailure (Choice2Of2 cexn))
+ tasks.[j].Invoke ctxt
+ )
+ |> unfake
+ fake()
+ )
+ for x = 1 to maxDegreeOfParallelism do
+ QueueAsync
innerCTS.Token
- // on success, record the result
- (fun res -> recordSuccess i res)
- // on exception...
+ (fun _ -> fake())
(fun edi -> recordFailure (Choice1Of2 edi))
- // on cancellation...
(fun cexn -> recordFailure (Choice2Of2 cexn))
- p
- |> unfake)
+ worker
+ |> unfake
+
fake()))
+ static member Sequential (computations: seq>) = Async.Parallel(computations, maxDegreeOfParallelism=1)
+
static member Choice(computations: Async<'T option> seq) : Async<'T option> =
MakeAsync (fun ctxt ->
let result =
@@ -1385,15 +1402,7 @@ namespace Microsoft.FSharp.Control
let millisecondsTimeout = defaultArg millisecondsTimeout Threading.Timeout.Infinite
if millisecondsTimeout = 0 then
async.Delay(fun () ->
-#if FX_NO_EXIT_CONTEXT_FLAGS
-#if FX_NO_WAITONE_MILLISECONDS
- let ok = waitHandle.WaitOne(TimeSpan 0L)
-#else
- let ok = waitHandle.WaitOne 0
-#endif
-#else
let ok = waitHandle.WaitOne(0, exitContext=false)
-#endif
async.Return ok)
else
CreateDelimitedUserCodeAsync(fun ctxt ->
@@ -1683,12 +1692,7 @@ namespace Microsoft.FSharp.Control
member stream.AsyncRead(buffer: byte[], ?offset, ?count) =
let offset = defaultArg offset 0
let count = defaultArg count buffer.Length
-#if FX_NO_BEGINEND_READWRITE
- // use combo CreateDelimitedUserCodeAsync + taskContinueWith instead of AwaitTask so we can pass cancellation token to the ReadAsync task
- CreateDelimitedUserCodeAsync (fun ctxt -> taskContinueWith (stream.ReadAsync(buffer, offset, count, ctxt.aux.token)) ctxt false)
-#else
Async.FromBeginEnd (buffer, offset, count, stream.BeginRead, stream.EndRead)
-#endif
[] // give the extension member a 'nice', unmangled compiled name, unique within this module
member stream.AsyncRead count =
@@ -1705,12 +1709,7 @@ namespace Microsoft.FSharp.Control
member stream.AsyncWrite(buffer:byte[], ?offset:int, ?count:int) =
let offset = defaultArg offset 0
let count = defaultArg count buffer.Length
-#if FX_NO_BEGINEND_READWRITE
- // use combo CreateDelimitedUserCodeAsync + taskContinueWithUnit instead of AwaitTask so we can pass cancellation token to the WriteAsync task
- CreateDelimitedUserCodeAsync (fun ctxt -> taskContinueWithUnit (stream.WriteAsync(buffer, offset, count, ctxt.aux.token)) ctxt false)
-#else
Async.FromBeginEnd (buffer, offset, count, stream.BeginWrite, stream.EndWrite)
-#endif
type IObservable<'Args> with
@@ -1746,8 +1745,6 @@ namespace Microsoft.FSharp.Control
| _ ->
None)
-#if !FX_NO_WEB_CLIENT
-
type System.Net.WebClient with
member inline private this.Download(event: IEvent<'T, _>, handler: _ -> 'T, start, result) =
let downloadAsync =
@@ -1799,5 +1796,3 @@ namespace Microsoft.FSharp.Control
start = (fun userToken -> this.DownloadFileAsync(address, fileName, userToken)),
result = (fun _ -> ())
)
-#endif
-
diff --git a/src/fsharp/FSharp.Core/async.fsi b/src/fsharp/FSharp.Core/async.fsi
index ae2cc882a51..fe4da64debd 100644
--- a/src/fsharp/FSharp.Core/async.fsi
+++ b/src/fsharp/FSharp.Core/async.fsi
@@ -161,6 +161,35 @@ namespace Microsoft.FSharp.Control
/// A computation that returns an array of values from the sequence of input computations.
static member Parallel : computations:seq> -> Async<'T[]>
+ /// Creates an asynchronous computation that executes all the given asynchronous computations,
+ /// initially queueing each as work items and using a fork/join pattern.
+ ///
+ /// If all child computations succeed, an array of results is passed to the success continuation.
+ ///
+ /// If any child computation raises an exception, then the overall computation will trigger an
+ /// exception, and cancel the others.
+ ///
+ /// The overall computation will respond to cancellation while executing the child computations.
+ /// If cancelled, the computation will cancel any remaining child computations but will still wait
+ /// for the other child computations to complete.
+ /// A sequence of distinct computations to be parallelized.
+ /// A computation that returns an array of values from the sequence of input computations.
+ static member Parallel : computations:seq> * ?maxDegreeOfParallelism : int -> Async<'T[]>
+
+ /// Creates an asynchronous computation that executes all the given asynchronous computations sequentially.
+ ///
+ /// If all child computations succeed, an array of results is passed to the success continuation.
+ ///
+ /// If any child computation raises an exception, then the overall computation will trigger an
+ /// exception, and cancel the others.
+ ///
+ /// The overall computation will respond to cancellation while executing the child computations.
+ /// If cancelled, the computation will cancel any remaining child computations but will still wait
+ /// for the other child computations to complete.
+ /// A sequence of distinct computations to be run in sequence.
+ /// A computation that returns an array of values from the sequence of input computations.
+ static member Sequential : computations:seq> -> Async<'T[]>
+
/// Creates an asynchronous computation that executes all given asynchronous computations in parallel,
/// returning the result of the first succeeding computation (one whose result is 'Some x').
/// If all child computations complete with None, the parent computation also returns None.
@@ -739,8 +768,7 @@ namespace Microsoft.FSharp.Control
/// An asynchronous computation that waits for response to the WebRequest.
[] // give the extension member a nice, unmangled compiled name, unique within this module
member AsyncGetResponse : unit -> Async
-
-#if !FX_NO_WEB_CLIENT
+
type System.Net.WebClient with
/// Returns an asynchronous computation that, when run, will wait for the download of the given URI.
@@ -761,7 +789,6 @@ namespace Microsoft.FSharp.Control
/// An asynchronous computation that will wait for the download of the URI to specified file.
[] // give the extension member a nice, unmangled compiled name, unique within this module
member AsyncDownloadFile : address:System.Uri * fileName: string -> Async
-#endif
// Internals used by MailboxProcessor
module internal AsyncBuilderImpl =
diff --git a/src/fsharp/FSharp.Core/event.fs b/src/fsharp/FSharp.Core/event.fs
index 4489c325d5a..8643b669c3e 100644
--- a/src/fsharp/FSharp.Core/event.fs
+++ b/src/fsharp/FSharp.Core/event.fs
@@ -11,10 +11,6 @@ namespace Microsoft.FSharp.Control
open System.Reflection
open System.Diagnostics
-#if FX_RESHAPED_REFLECTION
- open ReflectionAdapters
-#endif
-
[]
type DelegateEvent<'Delegate when 'Delegate :> System.Delegate>() =
let mutable multicast : System.Delegate = null
diff --git a/src/fsharp/FSharp.Core/fslib-extra-pervasives.fs b/src/fsharp/FSharp.Core/fslib-extra-pervasives.fs
index 0d6c3772c1b..b3fa821511a 100644
--- a/src/fsharp/FSharp.Core/fslib-extra-pervasives.fs
+++ b/src/fsharp/FSharp.Core/fslib-extra-pervasives.fs
@@ -166,21 +166,13 @@ module ExtraTopLevelOperators =
[]
let dict (keyValuePairs:seq<'Key*'T>) : IDictionary<'Key,'T> =
-#if FX_RESHAPED_REFLECTION
- if (typeof<'Key>).GetTypeInfo().IsValueType
-#else
if typeof<'Key>.IsValueType
-#endif
then dictValueType keyValuePairs :> _
else dictRefType keyValuePairs :> _
[]
let readOnlyDict (keyValuePairs:seq<'Key*'T>) : IReadOnlyDictionary<'Key,'T> =
-#if FX_RESHAPED_REFLECTION
- if (typeof<'Key>).GetTypeInfo().IsValueType
-#else
if typeof<'Key>.IsValueType
-#endif
then dictValueType keyValuePairs :> _
else dictRefType keyValuePairs :> _
diff --git a/src/fsharp/FSharp.Core/list.fs b/src/fsharp/FSharp.Core/list.fs
index 653c557a455..e7fd17ee52d 100644
--- a/src/fsharp/FSharp.Core/list.fs
+++ b/src/fsharp/FSharp.Core/list.fs
@@ -9,9 +9,6 @@ namespace Microsoft.FSharp.Collections
open Microsoft.FSharp.Collections
open Microsoft.FSharp.Core.CompilerServices
open System.Collections.Generic
-#if FX_RESHAPED_REFLECTION
- open System.Reflection
-#endif
[]
[]
@@ -71,11 +68,7 @@ namespace Microsoft.FSharp.Collections
[]
let countBy (projection:'T->'Key) (list:'T list) =
-#if FX_RESHAPED_REFLECTION
- if (typeof<'Key>).GetTypeInfo().IsValueType
-#else
if typeof<'Key>.IsValueType
-#endif
then countByValueType projection list
else countByRefType projection list
@@ -446,11 +439,7 @@ namespace Microsoft.FSharp.Collections
[]
let groupBy (projection:'T->'Key) (list:'T list) =
-#if FX_RESHAPED_REFLECTION
- if (typeof<'Key>).GetTypeInfo().IsValueType
-#else
if typeof<'Key>.IsValueType
-#endif
then groupByValueType projection list
else groupByRefType projection list
diff --git a/src/fsharp/FSharp.Core/map.fs b/src/fsharp/FSharp.Core/map.fs
index d701fb87cfa..d0fccda1fdb 100644
--- a/src/fsharp/FSharp.Core/map.fs
+++ b/src/fsharp/FSharp.Core/map.fs
@@ -446,21 +446,19 @@ module MapTree =
[]
type Map<[]'Key, []'Value when 'Key : comparison >(comparer: IComparer<'Key>, tree: MapTree<'Key, 'Value>) =
-#if !FX_NO_BINARY_SERIALIZATION
[]
- // This type is logically immutable. This field is only mutated during deserialization.
- let mutable comparer = comparer
+ // This type is logically immutable. This field is only mutated during deserialization.
+ let mutable comparer = comparer
[]
- // This type is logically immutable. This field is only mutated during deserialization.
- let mutable tree = tree
+ // This type is logically immutable. This field is only mutated during deserialization.
+ let mutable tree = tree
- // This type is logically immutable. This field is only mutated during serialization and deserialization.
+ // This type is logically immutable. This field is only mutated during serialization and deserialization.
//
- // WARNING: The compiled name of this field may never be changed because it is part of the logical
+ // WARNING: The compiled name of this field may never be changed because it is part of the logical
// WARNING: permanent serialization format for this type.
- let mutable serializedData = null
-#endif
+ let mutable serializedData = null
// We use .NET generics per-instantiation static fields to avoid allocating a new object for each empty
// set (it is just a lookup into a .NET table of type-instantiation-indexed static fields).
@@ -468,7 +466,6 @@ type Map<[]'Key, [
new Map<'Key, 'Value>(comparer, MapTree<_, _>.MapEmpty)
-#if !FX_NO_BINARY_SERIALIZATION
[]
member __.OnSerializing(context: System.Runtime.Serialization.StreamingContext) =
ignore context
@@ -483,9 +480,8 @@ type Map<[]'Key, [
- tree <- serializedData |> Array.map (fun (KeyValue(k, v)) -> (k, v)) |> MapTree.ofArray comparer
+ tree <- serializedData |> Array.map (fun (KeyValue(k, v)) -> (k, v)) |> MapTree.ofArray comparer
serializedData <- null
-#endif
static member Empty : Map<'Key, 'Value> =
empty
diff --git a/src/fsharp/FSharp.Core/prim-types.fs b/src/fsharp/FSharp.Core/prim-types.fs
index 5c053e8ba95..542852e5da9 100644
--- a/src/fsharp/FSharp.Core/prim-types.fs
+++ b/src/fsharp/FSharp.Core/prim-types.fs
@@ -374,29 +374,6 @@ namespace Microsoft.FSharp.Core
/// Represents a out-argument managed pointer in F# code. This type should only be used with F# 4.5+.
type outref<'T> = byref<'T, ByRefKinds.Out>
-#if FX_RESHAPED_REFLECTION
- module PrimReflectionAdapters =
-
- open System.Reflection
- open System.Linq
- // copied from BasicInlinedOperations
- let inline box (x:'T) = (# "box !0" type ('T) x : obj #)
- let inline unboxPrim<'T>(x:obj) = (# "unbox.any !0" type ('T) x : 'T #)
- type System.Type with
- member inline this.IsGenericType = this.GetTypeInfo().IsGenericType
- member inline this.IsValueType = this.GetTypeInfo().IsValueType
- member inline this.IsSealed = this.GetTypeInfo().IsSealed
- member inline this.IsAssignableFrom(otherType: Type) = this.GetTypeInfo().IsAssignableFrom(otherType.GetTypeInfo())
- member inline this.GetGenericArguments() = this.GetTypeInfo().GenericTypeArguments
- member inline this.GetProperty(name) = this.GetRuntimeProperty(name)
- member inline this.GetMethod(name, parameterTypes) = this.GetRuntimeMethod(name, parameterTypes)
- member inline this.GetCustomAttributes(attributeType: Type, inherits: bool) : obj[] =
- unboxPrim<_> (box (CustomAttributeExtensions.GetCustomAttributes(this.GetTypeInfo(), attributeType, inherits).ToArray()))
-
- open PrimReflectionAdapters
-
-#endif
-
module internal BasicInlinedOperations =
let inline unboxPrim<'T>(x:obj) = (# "unbox.any !0" type ('T) x : 'T #)
let inline box (x:'T) = (# "box !0" type ('T) x : obj #)
@@ -548,12 +525,8 @@ namespace Microsoft.FSharp.Core
ignore obj // pretend the variable is used
let e = new System.ArgumentException(ErrorStrings.AddressOpNotFirstClassString)
(# "throw" (e :> System.Exception) : nativeptr<'T> #)
-
-
+
open IntrinsicOperators
-#if FX_RESHAPED_REFLECTION
- open PrimReflectionAdapters
-#endif
[] // nested module OK
module IntrinsicFunctions =
@@ -881,78 +854,6 @@ namespace Microsoft.FSharp.Core
/// specialcase: Core implementation of structural comparison on arbitrary arrays.
and GenericComparisonArbArrayWithComparer (comp:GenericComparer) (x:System.Array) (y:System.Array) : int =
-#if FX_NO_ARRAY_LONG_LENGTH
- if x.Rank = 1 && y.Rank = 1 then
- let lenx = x.Length
- let leny = y.Length
- let c = intOrder lenx leny
- if c <> 0 then c else
- let basex = (x.GetLowerBound(0))
- let basey = (y.GetLowerBound(0))
- let c = intOrder basex basey
- if c <> 0 then c else
- let rec check i =
- if i >= lenx then 0 else
- let c = GenericCompare comp ((x.GetValue(i + basex)),(y.GetValue(i + basey)))
- if c <> 0 then c else check (i + 1)
- check 0
- elif x.Rank = 2 && y.Rank = 2 then
- let lenx0 = x.GetLength(0)
- let leny0 = y.GetLength(0)
- let c = intOrder lenx0 leny0
- if c <> 0 then c else
- let lenx1 = x.GetLength(1)
- let leny1 = y.GetLength(1)
- let c = intOrder lenx1 leny1
- if c <> 0 then c else
- let basex0 = (x.GetLowerBound(0))
- let basex1 = (x.GetLowerBound(1))
- let basey0 = (y.GetLowerBound(0))
- let basey1 = (y.GetLowerBound(1))
- let c = intOrder basex0 basey0
- if c <> 0 then c else
- let c = intOrder basex1 basey1
- if c <> 0 then c else
- let rec check0 i =
- let rec check1 j =
- if j >= lenx1 then 0 else
- let c = GenericCompare comp ((x.GetValue(i + basex0,j + basex1)), (y.GetValue(i + basey0,j + basey1)))
- if c <> 0 then c else check1 (j + 1)
- if i >= lenx0 then 0 else
- let c = check1 0
- if c <> 0 then c else
- check0 (i + 1)
- check0 0
- else
- let c = intOrder x.Rank y.Rank
- if c <> 0 then c else
- let ndims = x.Rank
- // check lengths
- let rec precheck k =
- if k >= ndims then 0 else
- let c = intOrder (x.GetLength(k)) (y.GetLength(k))
- if c <> 0 then c else
- let c = intOrder (x.GetLowerBound(k)) (y.GetLowerBound(k))
- if c <> 0 then c else
- precheck (k+1)
- let c = precheck 0
- if c <> 0 then c else
- let idxs : int[] = zeroCreate ndims
- let rec checkN k baseIdx i lim =
- if i >= lim then 0 else
- set idxs k (baseIdx + i)
- let c =
- if k = ndims - 1
- then GenericCompare comp ((x.GetValue(idxs)), (y.GetValue(idxs)))
- else check (k+1)
- if c <> 0 then c else
- checkN k baseIdx (i + 1) lim
- and check k =
- if k >= ndims then 0 else
- let baseIdx = x.GetLowerBound(k)
- checkN k baseIdx 0 (x.GetLength(k))
- check 0
-#else
if x.Rank = 1 && y.Rank = 1 then
let lenx = x.LongLength
let leny = y.LongLength
@@ -985,11 +886,11 @@ namespace Microsoft.FSharp.Core
let c = int64Order basex1 basey1
if c <> 0 then c else
let rec check0 i =
- let rec check1 j =
+ let rec check1 j =
if j >=. lenx1 then 0 else
let c = GenericCompare comp ((x.GetValue(i +. basex0,j +. basex1)), (y.GetValue(i +. basey0,j +. basey1)))
if c <> 0 then c else check1 (j +. 1L)
- if i >=. lenx0 then 0 else
+ if i >=. lenx0 then 0 else
let c = check1 0L
if c <> 0 then c else
check0 (i +. 1L)
@@ -998,8 +899,8 @@ namespace Microsoft.FSharp.Core
let c = intOrder x.Rank y.Rank
if c <> 0 then c else
let ndims = x.Rank
- // check lengths
- let rec precheck k =
+ // check lengths
+ let rec precheck k =
if k >= ndims then 0 else
let c = int64Order (x.GetLongLength(k)) (y.GetLongLength(k))
if c <> 0 then c else
@@ -1023,10 +924,9 @@ namespace Microsoft.FSharp.Core
let baseIdx = x.GetLowerBound(k)
checkN k (int64 baseIdx) 0L (x.GetLongLength(k))
check 0
-#endif
-
+
/// optimized case: Core implementation of structural comparison on object arrays.
- and GenericComparisonObjArrayWithComparer (comp:GenericComparer) (x:obj[]) (y:obj[]) : int =
+ and GenericComparisonObjArrayWithComparer (comp:GenericComparer) (x:obj[]) (y:obj[]) : int =
let lenx = x.Length
let leny = y.Length
let c = intOrder lenx leny
@@ -1035,8 +935,8 @@ namespace Microsoft.FSharp.Core
let mutable i = 0
let mutable res = 0
while i < lenx do
- let c = GenericCompare comp ((get x i), (get y i))
- if c <> 0 then (res <- c; i <- lenx)
+ let c = GenericCompare comp ((get x i), (get y i))
+ if c <> 0 then (res <- c; i <- lenx)
else i <- i + 1
res
@@ -1058,7 +958,7 @@ namespace Microsoft.FSharp.Core
type GenericComparer with
interface System.Collections.IComparer with
override c.Compare(x:obj,y:obj) = GenericCompare c (x,y)
-
+
/// The unique object for comparing values in PER mode (where local exceptions are thrown when NaNs are compared)
let fsComparerPER = GenericComparer(true)
@@ -1403,63 +1303,6 @@ namespace Microsoft.FSharp.Core
/// specialcase: Core implementation of structural equality on arbitrary arrays.
and GenericEqualityArbArray er (iec:System.Collections.IEqualityComparer) (x:System.Array) (y:System.Array) : bool =
-#if FX_NO_ARRAY_LONG_LENGTH
- if x.Rank = 1 && y.Rank = 1 then
- // check lengths
- let lenx = x.Length
- let leny = y.Length
- (int32Eq lenx leny) &&
- // check contents
- let basex = x.GetLowerBound(0)
- let basey = y.GetLowerBound(0)
- (int32Eq basex basey) &&
- let rec check i = (i >= lenx) || (GenericEqualityObj er iec ((x.GetValue(basex + i)),(y.GetValue(basey + i))) && check (i + 1))
- check 0
- elif x.Rank = 2 && y.Rank = 2 then
- // check lengths
- let lenx0 = x.GetLength(0)
- let leny0 = y.GetLength(0)
- (int32Eq lenx0 leny0) &&
- let lenx1 = x.GetLength(1)
- let leny1 = y.GetLength(1)
- (int32Eq lenx1 leny1) &&
- let basex0 = x.GetLowerBound(0)
- let basex1 = x.GetLowerBound(1)
- let basey0 = y.GetLowerBound(0)
- let basey1 = y.GetLowerBound(1)
- (int32Eq basex0 basey0) &&
- (int32Eq basex1 basey1) &&
- // check contents
- let rec check0 i =
- let rec check1 j = (j >= lenx1) || (GenericEqualityObj er iec ((x.GetValue(basex0 + i,basex1 + j)), (y.GetValue(basey0 + i,basey1 + j))) && check1 (j + 1))
- (i >= lenx0) || (check1 0 && check0 (i + 1))
- check0 0
- else
- (x.Rank = y.Rank) &&
- let ndims = x.Rank
- // check lengths
- let rec precheck k =
- (k >= ndims) ||
- (int32Eq (x.GetLength(k)) (y.GetLength(k)) &&
- int32Eq (x.GetLowerBound(k)) (y.GetLowerBound(k)) &&
- precheck (k+1))
- precheck 0 &&
- let idxs : int32[] = zeroCreate ndims
- // check contents
- let rec checkN k baseIdx i lim =
- (i >= lim) ||
- (set idxs k (baseIdx + i);
- (if k = ndims - 1
- then GenericEqualityObj er iec ((x.GetValue(idxs)),(y.GetValue(idxs)))
- else check (k+1)) &&
- checkN k baseIdx (i + 1) lim)
- and check k =
- (k >= ndims) ||
- (let baseIdx = x.GetLowerBound(k)
- checkN k baseIdx 0 (x.GetLength(k)))
-
- check 0
-#else
if x.Rank = 1 && y.Rank = 1 then
// check lengths
let lenx = x.LongLength
@@ -1468,9 +1311,9 @@ namespace Microsoft.FSharp.Core
// check contents
let basex = int64 (x.GetLowerBound(0))
let basey = int64 (y.GetLowerBound(0))
- (int64Eq basex basey) &&
+ (int64Eq basex basey) &&
let rec check i = (i >=. lenx) || (GenericEqualityObj er iec ((x.GetValue(basex +. i)),(y.GetValue(basey +. i))) && check (i +. 1L))
- check 0L
+ check 0L
elif x.Rank = 2 && y.Rank = 2 then
// check lengths
let lenx0 = x.GetLongLength(0)
@@ -1491,16 +1334,16 @@ namespace Microsoft.FSharp.Core
(i >=. lenx0) || (check1 0L && check0 (i +. 1L))
check0 0L
else
- (x.Rank = y.Rank) &&
+ (x.Rank = y.Rank) &&
let ndims = x.Rank
- // check lengths
- let rec precheck k =
- (k >= ndims) ||
- (int64Eq (x.GetLongLength(k)) (y.GetLongLength(k)) &&
- int32Eq (x.GetLowerBound(k)) (y.GetLowerBound(k)) &&
+ // check lengths
+ let rec precheck k =
+ (k >= ndims) ||
+ (int64Eq (x.GetLongLength(k)) (y.GetLongLength(k)) &&
+ int32Eq (x.GetLowerBound(k)) (y.GetLowerBound(k)) &&
precheck (k+1))
precheck 0 &&
- let idxs : int64[] = zeroCreate ndims
+ let idxs : int64[] = zeroCreate ndims
// check contents
let rec checkN k baseIdx i lim =
(i >=. lim) ||
@@ -1513,10 +1356,8 @@ namespace Microsoft.FSharp.Core
(k >= ndims) ||
(let baseIdx = x.GetLowerBound(k)
checkN k (int64 baseIdx) 0L (x.GetLongLength(k)))
-
check 0
-#endif
-
+
/// optimized case: Core implementation of structural equality on object arrays.
and GenericEqualityObjArray er iec (x:obj[]) (y:obj[]) : bool =
let lenx = x.Length
@@ -2958,7 +2799,6 @@ namespace Microsoft.FSharp.Core
[]
static member op_Implicit(func : ('T -> 'Res) ) = new System.Func<'T,'Res>(func)
-#if !FX_NO_CONVERTER
[]
static member op_Implicit(f : System.Converter<_,_>) : ('T -> 'Res) = (fun t -> f.Invoke(t))
@@ -2968,7 +2808,6 @@ namespace Microsoft.FSharp.Core
static member FromConverter (converter: System.Converter<_,_>) : ('T -> 'Res) = (fun t -> converter.Invoke(t))
static member ToConverter (func: ('T -> 'Res) ) = new System.Converter<'T,'Res>(func)
-#endif
static member InvokeFast (func:FSharpFunc<_,_>, arg1: 'T, arg2: 'Res) = OptimizedClosures.invokeFast2(func, arg1, arg2)
@@ -2984,9 +2823,7 @@ namespace Microsoft.FSharp.Core
static member inline ToFSharpFunc (action: Action<_>) = (fun t -> action.Invoke(t))
-#if !FX_NO_CONVERTER
static member inline ToFSharpFunc (converter : Converter<_,_>) = (fun t -> converter.Invoke(t))
-#endif
// Note: this is not made public in the signature, because of conflicts with the Converter overload.
// The method remains in case someone is calling it via reflection.
@@ -4266,26 +4103,12 @@ namespace Microsoft.FSharp.Core
module Attributes =
open System.Runtime.CompilerServices
-#if !FX_NO_DEFAULT_DEPENDENCY_TYPE
- []
-#endif
-
-#if !FX_NO_COMVISIBLE
[]
-#endif
[]
-
-#if BE_SECURITY_TRANSPARENT
[] // assembly is fully transparent
#if CROSS_PLATFORM_COMPILER
#else
[] // v4 transparency; soon to be the default, but not yet
-#endif
-#else
-#if !FX_NO_SECURITY_PERMISSIONS
- // REVIEW: Need to choose a specific permission for the action to be applied to
- []
-#endif
#endif
do ()
@@ -4317,6 +4140,9 @@ namespace Microsoft.FSharp.Core
[]
let inline typeof<'T> = BasicInlinedOperations.typeof<'T>
+ []
+ let inline nameof (_: 'T) : string = raise (Exception "may not call directly, should always be optimized away")
+
[]
let methodhandleof (_call: ('T -> 'TResult)) : System.RuntimeMethodHandle = raise (Exception "may not call directly, should always be optimized away")
@@ -4649,13 +4475,10 @@ namespace Microsoft.FSharp.Core
when ^T : unativeint = (# "conv.ovf.i.un" value : nativeint #)
when ^T : byte = (# "conv.ovf.i.un" value : nativeint #)
- module OperatorIntrinsics =
-
+ module OperatorIntrinsics =
+
open System.Collections
-#if FX_RESHAPED_REFLECTION
- open PrimReflectionAdapters
-#endif
-
+
let notStarted() = raise (new System.InvalidOperationException(SR.GetString(SR.enumerationNotStarted)))
let alreadyFinished() = raise (new System.InvalidOperationException(SR.GetString(SR.enumerationAlreadyFinished)))
diff --git a/src/fsharp/FSharp.Core/prim-types.fsi b/src/fsharp/FSharp.Core/prim-types.fsi
index 6d345a2cfda..7ba3b3ae4d4 100644
--- a/src/fsharp/FSharp.Core/prim-types.fsi
+++ b/src/fsharp/FSharp.Core/prim-types.fsi
@@ -1342,20 +1342,6 @@ namespace Microsoft.FSharp.Core
[]
val inline FastCompareTuple5 : comparer:System.Collections.IComparer -> tuple1:('T1 * 'T2 * 'T3 * 'T4 * 'T5) -> tuple2:('T1 * 'T2 * 'T3 * 'T4 * 'T5) -> int
-#if FX_RESHAPED_REFLECTION
- module internal PrimReflectionAdapters =
-
- open System.Reflection
-
- type System.Type with
- member inline IsGenericType : bool
- member inline IsValueType : bool
- member inline GetMethod : string * parameterTypes : Type[] -> MethodInfo
- member inline GetProperty : string -> PropertyInfo
- member inline IsAssignableFrom : otherType : Type -> bool
- member inline GetCustomAttributes : attributeType : Type * inherits: bool -> obj[]
-#endif
-
//-------------------------------------------------------------------------
// F# Choice Types
@@ -1503,8 +1489,6 @@ namespace Microsoft.FSharp.Core
/// 'U
abstract member Invoke : func:'T -> 'U
-#if !FX_NO_CONVERTER
-
/// Convert an F# first class function value to a value of type System.Converter
/// The input function.
/// A System.Converter of the function type.
@@ -1524,7 +1508,6 @@ namespace Microsoft.FSharp.Core
/// The input System.Converter.
/// An F# function of the same type.
static member FromConverter : converter:System.Converter<'T,'U> -> ('T -> 'U)
-#endif
/// Invoke an F# first class function value with five curried arguments. In some cases this
/// will result in a more efficient application than applying the arguments successively.
@@ -1575,12 +1558,10 @@ namespace Microsoft.FSharp.Core
/// The F# function.
static member inline ToFSharpFunc : action:Action<'T> -> ('T -> unit)
-#if !FX_NO_CONVERTER
/// Convert the given Converter delegate object to an F# function value
/// The input Converter delegate.
/// The F# function.
static member inline ToFSharpFunc : converter:Converter<'T,'U> -> ('T -> 'U)
-#endif
/// Convert the given Action delegate object to an F# function value
/// The input Action delegate.
@@ -2418,6 +2399,10 @@ namespace Microsoft.FSharp.Core
[]
val inline typeof<'T> : System.Type
+ /// Returns the name of the given symbol.
+ []
+ val inline nameof : 'T -> string
+
/// An internal, library-only compiler intrinsic for compile-time
/// generation of a RuntimeMethodHandle.
[]
diff --git a/src/fsharp/FSharp.Core/printf.fs b/src/fsharp/FSharp.Core/printf.fs
index 3913eeeba5a..26276c5fd63 100644
--- a/src/fsharp/FSharp.Core/printf.fs
+++ b/src/fsharp/FSharp.Core/printf.fs
@@ -47,11 +47,6 @@ module internal PrintfImpl =
open Microsoft.FSharp.Collections
open LanguagePrimitives.IntrinsicOperators
-#if FX_RESHAPED_REFLECTION
- open Microsoft.FSharp.Core.PrimReflectionAdapters
- open Microsoft.FSharp.Core.ReflectionAdapters
-#endif
-
open System.IO
[]
@@ -1070,12 +1065,8 @@ module internal PrintfImpl =
static member GenericToString<'T>(spec: FormatSpecifier) =
let bindingFlags =
-#if FX_RESHAPED_REFLECTION
- isPlusForPositives spec.Flags // true - show non-public
-#else
if isPlusForPositives spec.Flags then BindingFlags.Public ||| BindingFlags.NonPublic
else BindingFlags.Public
-#endif
let useZeroWidth = isPadWithZeros spec.Flags
let opts =
diff --git a/src/fsharp/FSharp.Core/quotations.fs b/src/fsharp/FSharp.Core/quotations.fs
index efd9763e1c5..974e32c7678 100644
--- a/src/fsharp/FSharp.Core/quotations.fs
+++ b/src/fsharp/FSharp.Core/quotations.fs
@@ -20,11 +20,6 @@ open Microsoft.FSharp.Text.StructuredPrintfImpl.TaggedTextOps
#nowarn "52" // The value has been copied to ensure the original is not mutated by this operation
-#if FX_RESHAPED_REFLECTION
-open PrimReflectionAdapters
-open ReflectionAdapters
-#endif
-
//--------------------------------------------------------------------------
// RAW quotations - basic data types
//--------------------------------------------------------------------------
@@ -56,11 +51,7 @@ module Helpers =
let staticBindingFlags = BindingFlags.Static ||| BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.DeclaredOnly
let staticOrInstanceBindingFlags = BindingFlags.Instance ||| BindingFlags.Static ||| BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.DeclaredOnly
let instanceBindingFlags = BindingFlags.Instance ||| BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.DeclaredOnly
-#if FX_RESHAPED_REFLECTION
- let publicOrPrivateBindingFlags = true
-#else
let publicOrPrivateBindingFlags = BindingFlags.Public ||| BindingFlags.NonPublic
-#endif
let isDelegateType (typ:Type) =
if typ.IsSubclassOf(typeof) then
@@ -989,11 +980,7 @@ module Patterns =
let resT = instFormal tyargTs rty
let methInfo =
try
-#if FX_RESHAPED_REFLECTION
- match parentT.GetMethod(nm, argTs) with
-#else
match parentT.GetMethod(nm, staticOrInstanceBindingFlags, null, argTs, null) with
-#endif
| null -> None
| res -> Some res
with :? AmbiguousMatchException -> None
@@ -1021,11 +1008,7 @@ module Patterns =
let tyArgs = List.toArray tyArgs
let methInfo =
try
-#if FX_RESHAPED_REFLECTION
- match ty.GetMethod(nm, argTypes) with
-#else
match ty.GetMethod(nm, staticOrInstanceBindingFlags, null, argTypes, null) with
-#endif
| null -> None
| res -> Some res
with :? AmbiguousMatchException -> None
@@ -1138,21 +1121,13 @@ module Patterns =
| _ -> null
| ctor -> ctor
-
let bindProp (tc, propName, retType, argTypes, tyargs) =
// We search in the instantiated type, rather than searching the generic type.
let typ = mkNamedType (tc, tyargs)
let argtyps : Type list = argTypes |> inst tyargs
let retType : Type = retType |> inst tyargs |> removeVoid
-#if FX_RESHAPED_REFLECTION
- try
- typ.GetProperty(propName, staticOrInstanceBindingFlags)
- with :? AmbiguousMatchException -> null // more than one property found with the specified name and matching binding constraints - return null to initiate manual search
- |> bindPropBySearchIfCandidateIsNull typ propName retType (Array.ofList argtyps)
- |> checkNonNullResult ("propName", String.Format(SR.GetString(SR.QfailedToBindProperty), propName)) // fxcop may not see "propName" as an arg
-#else
typ.GetProperty(propName, staticOrInstanceBindingFlags, null, retType, Array.ofList argtyps, null) |> checkNonNullResult ("propName", String.Format(SR.GetString(SR.QfailedToBindProperty), propName)) // fxcop may not see "propName" as an arg
-#endif
+
let bindField (tc, fldName, tyargs) =
let typ = mkNamedType (tc, tyargs)
typ.GetField(fldName, staticOrInstanceBindingFlags) |> checkNonNullResult ("fldName", String.Format(SR.GetString(SR.QfailedToBindField), fldName)) // fxcop may not see "fldName" as an arg
@@ -1163,26 +1138,12 @@ module Patterns =
let bindGenericCtor (tc:Type, argTypes:Instantiable) =
let argtyps = instFormal (getGenericArguments tc) argTypes
-#if FX_RESHAPED_REFLECTION
- let argTypes = Array.ofList argtyps
- tc.GetConstructor argTypes
- |> bindCtorBySearchIfCandidateIsNull tc argTypes
- |> checkNonNullResult ("tc", SR.GetString(SR.QfailedToBindConstructor))
-#else
tc.GetConstructor(instanceBindingFlags, null, Array.ofList argtyps, null) |> checkNonNullResult ("tc", SR.GetString(SR.QfailedToBindConstructor))
-#endif
let bindCtor (tc, argTypes:Instantiable, tyargs) =
let typ = mkNamedType (tc, tyargs)
let argtyps = argTypes |> inst tyargs
-#if FX_RESHAPED_REFLECTION
- let argTypes = Array.ofList argtyps
- typ.GetConstructor argTypes
- |> bindCtorBySearchIfCandidateIsNull typ argTypes
- |> checkNonNullResult ("tc", SR.GetString(SR.QfailedToBindConstructor))
-#else
typ.GetConstructor(instanceBindingFlags, null, Array.ofList argtyps, null) |> checkNonNullResult ("tc", SR.GetString(SR.QfailedToBindConstructor))
-#endif
let chop n xs =
if n < 0 then invalidArg "n" (SR.GetString(SR.inputMustBeNonNegative))
@@ -1358,11 +1319,7 @@ module Patterns =
if a = "" then mscorlib
elif a = "." then st.localAssembly
else
-#if FX_RESHAPED_REFLECTION
- match System.Reflection.Assembly.Load(AssemblyName a) with
-#else
match System.Reflection.Assembly.Load a with
-#endif
| null -> raise <| System.InvalidOperationException(String.Format(SR.GetString(SR.QfailedToBindAssembly), a.ToString()))
| assembly -> assembly
@@ -1684,14 +1641,6 @@ module Patterns =
let decodedTopResources = new Dictionary(10, HashIdentity.Structural)
-#if FX_NO_REFLECTION_MODULE_HANDLES // not available on Silverlight
- []
- type ModuleHandle = ModuleHandle of string * string
- type System.Reflection.Module with
- member x.ModuleHandle = ModuleHandle(x.Assembly.FullName, x.Name)
-#else
- type ModuleHandle = System.ModuleHandle
-#endif
[]
type ReflectedDefinitionTableKey =
@@ -1735,11 +1684,7 @@ module Patterns =
not (decodedTopResources.ContainsKey((assem, resourceName))) then
let cmaAttribForResource =
-#if FX_RESHAPED_REFLECTION
- CustomAttributeExtensions.GetCustomAttributes(assem, typeof) |> Seq.toArray
-#else
assem.GetCustomAttributes(typeof, false)
-#endif
|> (function null -> [| |] | x -> x)
|> Array.tryPick (fun ca ->
match ca with
diff --git a/src/fsharp/FSharp.Core/reflect.fs b/src/fsharp/FSharp.Core/reflect.fs
index 2024be205bf..f9e0a9daa8e 100644
--- a/src/fsharp/FSharp.Core/reflect.fs
+++ b/src/fsharp/FSharp.Core/reflect.fs
@@ -27,11 +27,6 @@ module internal ReflectionUtils =
[]
module internal Impl =
-#if FX_RESHAPED_REFLECTION
- open PrimReflectionAdapters
- open ReflectionAdapters
-#endif
-
let getBindingFlags allowAccess = ReflectionUtils.toBindingFlags (defaultArg allowAccess false)
let inline checkNonNull argName (v: 'T) =
@@ -56,31 +51,18 @@ module internal Impl =
//-----------------------------------------------------------------
// GENERAL UTILITIES
-#if FX_RESHAPED_REFLECTION
- let instanceFieldFlags = BindingFlags.Instance
- let instancePropertyFlags = BindingFlags.Instance
- let staticPropertyFlags = BindingFlags.Static
- let staticFieldFlags = BindingFlags.Static
- let staticMethodFlags = BindingFlags.Static
-#else
let instanceFieldFlags = BindingFlags.GetField ||| BindingFlags.Instance
let instancePropertyFlags = BindingFlags.GetProperty ||| BindingFlags.Instance
let staticPropertyFlags = BindingFlags.GetProperty ||| BindingFlags.Static
let staticFieldFlags = BindingFlags.GetField ||| BindingFlags.Static
let staticMethodFlags = BindingFlags.Static
-#endif
-
let getInstancePropertyInfo (typ: Type, propName, bindingFlags) = typ.GetProperty(propName, instancePropertyFlags ||| bindingFlags)
let getInstancePropertyInfos (typ, names, bindingFlags) = names |> Array.map (fun nm -> getInstancePropertyInfo (typ, nm, bindingFlags))
-
let getInstancePropertyReader (typ: Type, propName, bindingFlags) =
match getInstancePropertyInfo(typ, propName, bindingFlags) with
| null -> None
-#if FX_RESHAPED_REFLECTION
- | prop -> Some(fun (obj: obj) -> prop.GetValue (obj, null))
-#else
| prop -> Some(fun (obj: obj) -> prop.GetValue (obj, instancePropertyFlags ||| bindingFlags, null, null, null))
-#endif
+
//-----------------------------------------------------------------
// ATTRIBUTE DECOMPILATION
@@ -95,7 +77,6 @@ module internal Impl =
| None -> failwith "no compilation mapping attribute"
| Some a -> a
-#if !FX_NO_REFLECTION_ONLY
let cmaName = typeof.FullName
let assemblyName = typeof.Assembly.GetName().Name
let _ = assert (assemblyName = "FSharp.Core")
@@ -121,33 +102,26 @@ module internal Impl =
match tryFindCompilationMappingAttributeFromData attrs with
| None -> failwith "no compilation mapping attribute"
| Some a -> a
-#endif
let tryFindCompilationMappingAttributeFromType (typ: Type) =
-#if !FX_NO_REFLECTION_ONLY
let assem = typ.Assembly
if (not (isNull assem)) && assem.ReflectionOnly then
tryFindCompilationMappingAttributeFromData ( typ.GetCustomAttributesData())
else
-#endif
tryFindCompilationMappingAttribute ( typ.GetCustomAttributes (typeof, false))
let tryFindCompilationMappingAttributeFromMemberInfo (info: MemberInfo) =
-#if !FX_NO_REFLECTION_ONLY
let assem = info.DeclaringType.Assembly
if (not (isNull assem)) && assem.ReflectionOnly then
tryFindCompilationMappingAttributeFromData (info.GetCustomAttributesData())
else
-#endif
tryFindCompilationMappingAttribute (info.GetCustomAttributes (typeof, false))
let findCompilationMappingAttributeFromMemberInfo (info: MemberInfo) =
-#if !FX_NO_REFLECTION_ONLY
let assem = info.DeclaringType.Assembly
if (not (isNull assem)) && assem.ReflectionOnly then
findCompilationMappingAttributeFromData (info.GetCustomAttributesData())
else
-#endif
findCompilationMappingAttribute (info.GetCustomAttributes (typeof, false))
let sequenceNumberOfMember (x: MemberInfo) = let (_, n, _) = findCompilationMappingAttributeFromMemberInfo x in n
@@ -285,11 +259,8 @@ module internal Impl =
let getUnionCaseRecordReader (typ: Type, tag: int, bindingFlags) =
let props = fieldsPropsOfUnionCase (typ, tag, bindingFlags)
-#if FX_RESHAPED_REFLECTION
- (fun (obj: obj) -> props |> Array.map (fun prop -> prop.GetValue (obj, null)))
-#else
(fun (obj: obj) -> props |> Array.map (fun prop -> prop.GetValue (obj, bindingFlags, null, null, null)))
-#endif
+
let getUnionTagReader (typ: Type, bindingFlags) : (obj -> int) =
if isOptionType typ then
(fun (obj: obj) -> match obj with null -> 0 | _ -> 1)
@@ -302,20 +273,12 @@ module internal Impl =
| Some reader -> (fun (obj: obj) -> reader obj :?> int)
| None ->
(fun (obj: obj) ->
-#if FX_RESHAPED_REFLECTION
- let m2b = typ.GetMethod("GetTag", [| typ |])
-#else
let m2b = typ.GetMethod("GetTag", BindingFlags.Static ||| bindingFlags, null, [| typ |], null)
-#endif
m2b.Invoke(null, [|obj|]) :?> int)
let getUnionTagMemberInfo (typ: Type, bindingFlags) =
match getInstancePropertyInfo (typ, "Tag", bindingFlags) with
-#if FX_RESHAPED_REFLECTION
- | null -> (typ.GetMethod("GetTag") :> MemberInfo)
-#else
| null -> (typ.GetMethod("GetTag", BindingFlags.Static ||| bindingFlags) :> MemberInfo)
-#endif
| info -> (info :> MemberInfo)
let isUnionCaseNullary (typ: Type, tag: int, bindingFlags) =
@@ -335,11 +298,8 @@ module internal Impl =
let getUnionCaseConstructor (typ: Type, tag: int, bindingFlags) =
let meth = getUnionCaseConstructorMethod (typ, tag, bindingFlags)
(fun args ->
-#if FX_RESHAPED_REFLECTION
- meth.Invoke(null, args))
-#else
meth.Invoke(null, BindingFlags.Static ||| BindingFlags.InvokeMethod ||| bindingFlags, null, args, null))
-#endif
+
let checkUnionType (unionType, bindingFlags) =
checkNonNull "unionType" unionType
if not (isUnionType (unionType, bindingFlags)) then
@@ -513,18 +473,10 @@ module internal Impl =
let ctor =
if typ.IsValueType then
let fields = typ.GetFields (instanceFieldFlags ||| BindingFlags.Public) |> orderTupleFields
-#if FX_RESHAPED_REFLECTION
- typ.GetConstructor(fields |> Array.map (fun fi -> fi.FieldType))
-#else
typ.GetConstructor(BindingFlags.Public ||| BindingFlags.Instance, null, fields |> Array.map (fun fi -> fi.FieldType), null)
-#endif
else
let props = typ.GetProperties() |> orderTupleProperties
-#if FX_RESHAPED_REFLECTION
- typ.GetConstructor(props |> Array.map (fun p -> p.PropertyType))
-#else
typ.GetConstructor(BindingFlags.Public ||| BindingFlags.Instance, null, props |> Array.map (fun p -> p.PropertyType), null)
-#endif
match ctor with
| null -> raise (ArgumentException (String.Format (SR.GetString (SR.invalidTupleTypeConstructorNotDefined), typ.FullName)))
| _ -> ()
@@ -533,11 +485,7 @@ module internal Impl =
let getTupleCtor(typ: Type) =
let ctor = getTupleConstructorMethod typ
(fun (args: obj[]) ->
-#if FX_RESHAPED_REFLECTION
- ctor.Invoke args)
-#else
ctor.Invoke(BindingFlags.InvokeMethod ||| BindingFlags.Instance ||| BindingFlags.Public, null, args, null))
-#endif
let rec getTupleReader (typ: Type) =
let etys = typ.GetGenericArguments()
@@ -639,11 +587,7 @@ module internal Impl =
let getRecordConstructorMethod(typ: Type, bindingFlags) =
let props = fieldPropsOfRecordType(typ, bindingFlags)
-#if FX_RESHAPED_REFLECTION
- let ctor = typ.GetConstructor(props |> Array.map (fun p -> p.PropertyType))
-#else
let ctor = typ.GetConstructor(BindingFlags.Instance ||| bindingFlags, null, props |> Array.map (fun p -> p.PropertyType), null)
-#endif
match ctor with
| null -> raise <| ArgumentException (String.Format (SR.GetString (SR.invalidRecordTypeConstructorNotDefined), typ.FullName))
| _ -> ()
@@ -652,11 +596,7 @@ module internal Impl =
let getRecordConstructor(typ: Type, bindingFlags) =
let ctor = getRecordConstructorMethod(typ, bindingFlags)
(fun (args: obj[]) ->
-#if FX_RESHAPED_REFLECTION
- ctor.Invoke args)
-#else
ctor.Invoke(BindingFlags.InvokeMethod ||| BindingFlags.Instance ||| bindingFlags, null, args, null))
-#endif
/// EXCEPTION DECOMPILATION
// Check the base type - if it is also an F# type then
@@ -703,10 +643,6 @@ module internal Impl =
if not (isTupleType tupleType) then
invalidArg argName (String.Format (SR.GetString (SR.notATupleType), tupleType.FullName))
-#if FX_RESHAPED_REFLECTION
-open ReflectionAdapters
-#endif
-
[]
type UnionCaseInfo(typ: System.Type, tag: int) =
diff --git a/src/fsharp/FSharp.Core/seq.fs b/src/fsharp/FSharp.Core/seq.fs
index ab48146b631..97326e7315a 100644
--- a/src/fsharp/FSharp.Core/seq.fs
+++ b/src/fsharp/FSharp.Core/seq.fs
@@ -1071,11 +1071,7 @@ namespace Microsoft.FSharp.Collections
[]
let groupBy (projection:'T->'Key) (source:seq<'T>) =
-#if FX_RESHAPED_REFLECTION
- if (typeof<'Key>).GetTypeInfo().IsValueType
-#else
if typeof<'Key>.IsValueType
-#endif
then mkDelayedSeq (fun () -> groupByValueType projection source)
else mkDelayedSeq (fun () -> groupByRefType projection source)
@@ -1164,11 +1160,7 @@ namespace Microsoft.FSharp.Collections
let countBy (projection:'T->'Key) (source:seq<'T>) =
checkNonNull "source" source
-#if FX_RESHAPED_REFLECTION
- if (typeof<'Key>).GetTypeInfo().IsValueType
-#else
if typeof<'Key>.IsValueType
-#endif
then mkDelayedSeq (fun () -> countByValueType projection source)
else mkDelayedSeq (fun () -> countByRefType projection source)
diff --git a/src/fsharp/FSharp.Core/set.fs b/src/fsharp/FSharp.Core/set.fs
index f0c88dcf581..5da5152f296 100644
--- a/src/fsharp/FSharp.Core/set.fs
+++ b/src/fsharp/FSharp.Core/set.fs
@@ -512,23 +512,20 @@ module internal SetTree =
[>)>]
[]
[]
-type Set<[]'T when 'T: comparison >(comparer:IComparer<'T>, tree: SetTree<'T>) =
+type Set<[]'T when 'T: comparison >(comparer:IComparer<'T>, tree: SetTree<'T>) =
-#if !FX_NO_BINARY_SERIALIZATION
[]
- // NOTE: This type is logically immutable. This field is only mutated during deserialization.
- let mutable comparer = comparer
+ // NOTE: This type is logically immutable. This field is only mutated during deserialization.
+ let mutable comparer = comparer
[]
- // NOTE: This type is logically immutable. This field is only mutated during deserialization.
- let mutable tree = tree
+ // NOTE: This type is logically immutable. This field is only mutated during deserialization.
+ let mutable tree = tree
- // NOTE: This type is logically immutable. This field is only mutated during serialization and deserialization.
- //
- // WARNING: The compiled name of this field may never be changed because it is part of the logical
+ // NOTE: This type is logically immutable. This field is only mutated during serialization and deserialization.
+ // WARNING: The compiled name of this field may never be changed because it is part of the logical
// WARNING: permanent serialization format for this type.
- let mutable serializedData = null
-#endif
+ let mutable serializedData = null
// We use .NET generics per-instantiation static fields to avoid allocating a new object for each empty
// set (it is just a lookup into a .NET table of type-instantiation-indexed static fields).
@@ -537,7 +534,6 @@ type Set<[]'T when 'T: comparison >(comparer:IComparer<'T
let comparer = LanguagePrimitives.FastGenericComparer<'T>
Set<'T>(comparer, SetEmpty)
-#if !FX_NO_BINARY_SERIALIZATION
[]
member __.OnSerializing(context: System.Runtime.Serialization.StreamingContext) =
ignore context
@@ -554,7 +550,6 @@ type Set<[]'T when 'T: comparison >(comparer:IComparer<'T
comparer <- LanguagePrimitives.FastGenericComparer<'T>
tree <- SetTree.ofArray comparer serializedData
serializedData <- null
-#endif
[]
member internal set.Comparer = comparer
diff --git a/src/fsharp/FSharp.Core/xlf/FSCore.cs.xlf b/src/fsharp/FSharp.Core/xlf/FSCore.cs.xlf
index 7c8e97d6501..c1837555d36 100644
--- a/src/fsharp/FSharp.Core/xlf/FSCore.cs.xlf
+++ b/src/fsharp/FSharp.Core/xlf/FSCore.cs.xlf
@@ -707,6 +707,11 @@
Toto není platný výraz dotazu. V dotazu byla použita konstrukce {0}, která není rozpoznána překladačem dotazu z jazyka F# do jazyka LINQ. Prostudujte si specifikace povolených dotazů a zvažte přesunutí některých operací mimo výraz dotazu.
+
+
+ Hodnota maxDegreeOfParallelism musí být kladná, ale vyskytla se hodnota {0}.
+
+
\ No newline at end of file
diff --git a/src/fsharp/FSharp.Core/xlf/FSCore.de.xlf b/src/fsharp/FSharp.Core/xlf/FSCore.de.xlf
index cfcd71290fa..bb113a5dd44 100644
--- a/src/fsharp/FSharp.Core/xlf/FSCore.de.xlf
+++ b/src/fsharp/FSharp.Core/xlf/FSCore.de.xlf
@@ -707,6 +707,11 @@
Dies ist kein gültiger Abfrageausdruck. Das Konstrukt "{0}" wurde in einer Abfrage verwendet, wird jedoch vom F#-to-LINQ-Abfragekonvertierungsprogramm nicht erkannt. Überprüfen Sie die Spezifikation zulässiger Abfragen, und entfernen Sie unter Umständen einige Operationen aus dem Abfrageausdruck.
+
+
+ maxDegreeOfParallelism muss positiv sein, lautete jedoch "{0}".
+
+