From 6c1ffbbd443eb21c8bd1564ba9e277edbe40fbc9 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Wed, 6 Jul 2016 14:07:24 +0100 Subject: [PATCH] cleanup --- src/absil/il.fsi | 2 -- src/absil/ilread.fs | 2 -- src/fsharp/CompileOps.fs | 38 ++++++++++++++++++------------------ src/fsharp/CompileOps.fsi | 6 +++--- src/fsharp/CompileOptions.fs | 4 ++-- src/fsharp/fsc.fs | 6 +----- src/fsharp/fsi/fsi.fs | 6 +----- src/fsharp/vs/service.fs | 4 ++-- 8 files changed, 28 insertions(+), 40 deletions(-) diff --git a/src/absil/il.fsi b/src/absil/il.fsi index 147f5baf987..d61e3c24f5a 100644 --- a/src/absil/il.fsi +++ b/src/absil/il.fsi @@ -2092,9 +2092,7 @@ type ILPropertyRef = member Name: string interface System.IComparable -#if ENABLE_MONO_SUPPORT val runningOnMono: bool -#endif type ILReferences = { AssemblyReferences: ILAssemblyRef list; diff --git a/src/absil/ilread.fs b/src/absil/ilread.fs index c02b35def8e..353b3b114d2 100644 --- a/src/absil/ilread.fs +++ b/src/absil/ilread.fs @@ -3807,11 +3807,9 @@ let rec genOpenBinaryReader infile is opts = let pdb = None #else let pdb = -#if ENABLE_MONO_SUPPORT if runningOnMono then None else -#endif getPdbReader opts infile #endif diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 37b459d817d..6d3d6242dfe 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -1579,9 +1579,9 @@ let OutputErrorOrWarningContext prefix fileLineFn os err = let GetFSharpCoreLibraryName () = "FSharp.Core" type internal TypeInThisAssembly = class end -let GetFSharpCoreReferenceUsedByCompiler(useMonoResolution) = +let GetFSharpCoreReferenceUsedByCompiler(useSimpleResolution) = // On Mono, there is no good reference resolution - if useMonoResolution then + if useSimpleResolution then GetFSharpCoreLibraryName()+".dll" else let fsCoreName = GetFSharpCoreLibraryName() @@ -1698,8 +1698,8 @@ let SystemAssemblies primaryAssemblyName = // // REVIEW: it isn't clear if there is any negative effect // of leaving an assembly off this list. -let BasicReferencesForScriptLoadClosure(useMonoResolution, useFsiAuxLib) = - ["mscorlib"; GetFSharpCoreReferenceUsedByCompiler(useMonoResolution) ] @ // Need to resolve these explicitly so they will be found in the reference assemblies directory which is where the .xml files are. +let BasicReferencesForScriptLoadClosure(useSimpleResolution, useFsiAuxLib) = + ["mscorlib"; GetFSharpCoreReferenceUsedByCompiler(useSimpleResolution) ] @ // Need to resolve these explicitly so they will be found in the reference assemblies directory which is where the .xml files are. DefaultBasicReferencesForOutOfProjectSources @ [ if useFsiAuxLib then yield GetFsiLibraryName () ] @@ -2011,7 +2011,7 @@ type TcConfigBuilder = mutable resolutionAssemblyFoldersConditions : string; mutable platform : ILPlatform option; mutable prefer32Bit : bool; - mutable useMonoResolution : bool + mutable useSimpleResolution : bool mutable target : CompilerTarget mutable debuginfo : bool mutable testFlagEmitFeeFeeAs100001 : bool; @@ -2177,9 +2177,9 @@ type TcConfigBuilder = platform = None; prefer32Bit = false; #if ENABLE_MONO_SUPPORT - useMonoResolution = runningOnMono + useSimpleResolution = runningOnMono #else - useMonoResolution = false + useSimpleResolution = false #endif target = ConsoleExe debuginfo = false @@ -2531,7 +2531,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = match fileNameOpt with | None -> // if FSharp.Core was not provided explicitly - use version that was referenced by compiler - AssemblyReference(range0, GetFSharpCoreReferenceUsedByCompiler(data.useMonoResolution), None), None + AssemblyReference(range0, GetFSharpCoreReferenceUsedByCompiler(data.useSimpleResolution), None), None | _ -> res let primaryAssemblyCcuInitializer = getSystemRuntimeInitializer data.primaryAssembly (computeKnownDllReference >> fst) @@ -2667,7 +2667,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = member x.resolutionAssemblyFoldersConditions = data. resolutionAssemblyFoldersConditions member x.platform = data.platform member x.prefer32Bit = data.prefer32Bit - member x.useMonoResolution = data.useMonoResolution + member x.useSimpleResolution = data.useSimpleResolution member x.target = data.target member x.debuginfo = data.debuginfo member x.testFlagEmitFeeFeeAs100001 = data.testFlagEmitFeeFeeAs100001 @@ -2942,7 +2942,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = // NOTE!! if mode=ReportErrors then this method must not raise exceptions. It must just report the errors and recover static member TryResolveLibsUsingMSBuildRules (tcConfig:TcConfig,originalReferences:AssemblyReference list, errorAndWarningRange:range, mode:ResolveAssemblyReferenceMode) : AssemblyResolution list * UnresolvedAssemblyReference list = use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind (BuildPhase.Parameter) - if tcConfig.useMonoResolution then + if tcConfig.useSimpleResolution then failwith "MSBuild resolution is not supported." if originalReferences=[] then [],[] else @@ -3450,7 +3450,7 @@ type TcAssemblyResolutions(results : AssemblyResolution list, unresolved : Unres static member Resolve (tcConfig:TcConfig,assemblyList:AssemblyReference list, knownUnresolved:UnresolvedAssemblyReference list) : TcAssemblyResolutions = let resolved,unresolved = - if tcConfig.useMonoResolution then + if tcConfig.useSimpleResolution then let resolutions = assemblyList |> List.map (fun assemblyReference -> @@ -4449,7 +4449,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti | Some assemblyResolution -> ResultD [assemblyResolution] | None -> - if tcConfigP.Get().useMonoResolution then + if tcConfigP.Get().useSimpleResolution then let action = match mode with | ResolveAssemblyReferenceMode.ReportErrors -> CcuLoadFailureAction.RaiseError @@ -4857,7 +4857,7 @@ module private ScriptPreprocessClosure = ParseOneInputLexbuf (tcConfig,lexResourceManager,defines,lexbuf,filename,isLastCompiland,errorLogger) /// Create a TcConfig for load closure starting from a single .fsx file - let CreateScriptSourceTcConfig (filename:string, codeContext, useMonoResolution, useFsiAuxLib, basicReferences, applyCommandLineArgs) = + let CreateScriptSourceTcConfig (filename:string, codeContext, useSimpleResolution, useFsiAuxLib, basicReferences, applyCommandLineArgs) = let projectDir = Path.GetDirectoryName(filename) let isInteractive = (codeContext = CodeContext.Evaluation) let isInvalidationSupported = (codeContext = CodeContext.Editing) @@ -4865,7 +4865,7 @@ module private ScriptPreprocessClosure = let tcConfigB = TcConfigBuilder.CreateNew(Internal.Utilities.FSharpEnvironment.BinFolderOfDefaultFSharpCompiler.Value, true (* optimize for memory *), projectDir, isInteractive, isInvalidationSupported) applyCommandLineArgs tcConfigB match basicReferences with - | None -> BasicReferencesForScriptLoadClosure(useMonoResolution, useFsiAuxLib) |> List.iter(fun f->tcConfigB.AddReferencedAssemblyByPath(range0,f)) // Add script references + | None -> BasicReferencesForScriptLoadClosure(useSimpleResolution, useFsiAuxLib) |> List.iter(fun f->tcConfigB.AddReferencedAssemblyByPath(range0,f)) // Add script references | Some rs -> for m,r in rs do tcConfigB.AddReferencedAssemblyByPath(m,r) tcConfigB.resolutionEnvironment <- @@ -5026,18 +5026,18 @@ module private ScriptPreprocessClosure = result /// Given source text, find the full load closure. Used from service.fs, when editing a script file - let GetFullClosureOfScriptSource(filename,source,codeContext,useMonoResolution,useFsiAuxLib,lexResourceManager:Lexhelp.LexResourceManager,applyCommmandLineArgs) = + let GetFullClosureOfScriptSource(filename,source,codeContext,useSimpleResolution,useFsiAuxLib,lexResourceManager:Lexhelp.LexResourceManager,applyCommmandLineArgs) = // Resolve the basic references such as FSharp.Core.dll first, before processing any #I directives in the script // // This is tries to mimic the action of running the script in F# Interactive - the initial context for scripting is created // first, then #I and other directives are processed. let references0 = - let tcConfig = CreateScriptSourceTcConfig(filename,codeContext,useMonoResolution,useFsiAuxLib,None,applyCommmandLineArgs) + let tcConfig = CreateScriptSourceTcConfig(filename,codeContext,useSimpleResolution,useFsiAuxLib,None,applyCommmandLineArgs) let resolutions0,_unresolvedReferences = GetAssemblyResolutionInformation(tcConfig) let references0 = resolutions0 |> List.map (fun r->r.originalReference.Range,r.resolvedPath) |> Seq.distinct |> List.ofSeq references0 - let tcConfig = CreateScriptSourceTcConfig(filename,codeContext,useMonoResolution,useFsiAuxLib,Some references0,applyCommmandLineArgs) + let tcConfig = CreateScriptSourceTcConfig(filename,codeContext,useSimpleResolution,useFsiAuxLib,Some references0,applyCommmandLineArgs) let protoClosure = [SourceFile(filename,range0,source)] let finalClosure,tcConfig = FindClosureDirectives(protoClosure,tcConfig,codeContext,lexResourceManager) @@ -5053,9 +5053,9 @@ module private ScriptPreprocessClosure = type LoadClosure with // Used from service.fs, when editing a script file - static member ComputeClosureOfSourceText(filename:string, source:string, codeContext, useMonoResolution:bool, useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, applyCommmandLineArgs) : LoadClosure = + static member ComputeClosureOfSourceText(filename:string, source:string, codeContext, useSimpleResolution:bool, useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, applyCommmandLineArgs) : LoadClosure = use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind (BuildPhase.Parse) - ScriptPreprocessClosure.GetFullClosureOfScriptSource(filename,source,codeContext,useMonoResolution,useFsiAuxLib, lexResourceManager, applyCommmandLineArgs) + ScriptPreprocessClosure.GetFullClosureOfScriptSource(filename,source,codeContext,useSimpleResolution,useFsiAuxLib, lexResourceManager, applyCommmandLineArgs) /// Used from fsi.fs and fsc.fs, for #load and command line. /// The resulting references are then added to a TcConfig. diff --git a/src/fsharp/CompileOps.fsi b/src/fsharp/CompileOps.fsi index b80b4dfc236..9ff4d4adafe 100755 --- a/src/fsharp/CompileOps.fsi +++ b/src/fsharp/CompileOps.fsi @@ -273,7 +273,7 @@ type TcConfigBuilder = mutable resolutionAssemblyFoldersConditions : string mutable platform : ILPlatform option mutable prefer32Bit : bool - mutable useMonoResolution : bool + mutable useSimpleResolution : bool mutable target : CompilerTarget mutable debuginfo : bool mutable testFlagEmitFeeFeeAs100001 : bool @@ -425,7 +425,7 @@ type TcConfig = member resolutionAssemblyFoldersConditions : string member platform : ILPlatform option member prefer32Bit : bool - member useMonoResolution : bool + member useSimpleResolution : bool member target : CompilerTarget member debuginfo : bool member testFlagEmitFeeFeeAs100001 : bool @@ -775,7 +775,7 @@ type LoadClosure = RootWarnings : PhasedError list } // Used from service.fs, when editing a script file - static member ComputeClosureOfSourceText : filename: string * source: string * implicitDefines:CodeContext * useMonoResolution: bool * useFsiAuxLib: bool * lexResourceManager: Lexhelp.LexResourceManager * applyCompilerOptions: (TcConfigBuilder -> unit) -> LoadClosure + static member ComputeClosureOfSourceText : filename: string * source: string * implicitDefines:CodeContext * useSimpleResolution: bool * useFsiAuxLib: bool * lexResourceManager: Lexhelp.LexResourceManager * applyCompilerOptions: (TcConfigBuilder -> unit) -> LoadClosure /// Used from fsi.fs and fsc.fs, for #load and command line. The resulting references are then added to a TcConfig. static member ComputeClosureOfSourceFiles : tcConfig:TcConfig * (string * range) list * implicitDefines:CodeContext * useDefaultScriptingReferences : bool * lexResourceManager : Lexhelp.LexResourceManager -> LoadClosure diff --git a/src/fsharp/CompileOptions.fs b/src/fsharp/CompileOptions.fs index 11a178d9cea..a0558eab336 100644 --- a/src/fsharp/CompileOptions.fs +++ b/src/fsharp/CompileOptions.fs @@ -780,7 +780,7 @@ let advancedFlagsFsc tcConfigB = #endif yield CompilerOption("pdb", tagString, OptionString (fun s -> tcConfigB.debugSymbolFile <- Some s), None, Some (FSComp.SR.optsPdb())); - yield CompilerOption("simpleresolution", tagNone, OptionUnit (fun () -> tcConfigB.useMonoResolution<-true), None, + yield CompilerOption("simpleresolution", tagNone, OptionUnit (fun () -> tcConfigB.useSimpleResolution<-true), None, Some (FSComp.SR.optsSimpleresolution())); yield CompilerOption("highentropyva", tagNone, OptionSwitch (useHighEntropyVASwitch tcConfigB), None, Some (FSComp.SR.optsUseHighEntropyVA())) yield CompilerOption("subsystemversion", tagString, OptionString (subSystemVersionSwitch tcConfigB), None, Some (FSComp.SR.optsSubSystemVersion())) @@ -859,7 +859,7 @@ let internalFlags (tcConfigB:TcConfigBuilder) = CompilerOption("resolutionframeworkregistrybase", tagString, OptionString (fun s -> tcConfigB.resolutionFrameworkRegistryBase<-s), Some(InternalCommandLineOption("", rangeCmdArgs)), None); // "The base registry key to use for assembly resolution. This part in brackets here: HKEY_LOCAL_MACHINE\[SOFTWARE\Microsoft\.NETFramework]\v2.0.50727\AssemblyFoldersEx"); CompilerOption("resolutionassemblyfoldersuffix", tagString, OptionString (fun s -> tcConfigB.resolutionAssemblyFoldersSuffix<-s), Some(InternalCommandLineOption("resolutionassemblyfoldersuffix", rangeCmdArgs)), None); // "The base registry key to use for assembly resolution. This part in brackets here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\[AssemblyFoldersEx]"); CompilerOption("resolutionassemblyfoldersconditions", tagString, OptionString (fun s -> tcConfigB.resolutionAssemblyFoldersConditions <- ","^s), Some(InternalCommandLineOption("resolutionassemblyfoldersconditions", rangeCmdArgs)), None); // "Additional reference resolution conditions. For example \"OSVersion=5.1.2600.0,PlatformID=id"); - CompilerOption("msbuildresolution", tagNone, OptionUnit (fun () -> tcConfigB.useMonoResolution<-false), Some(InternalCommandLineOption("msbuildresolution", rangeCmdArgs)), None); // "Resolve assembly references using MSBuild resolution rules rather than directory based (Default=true except when running fsc.exe under mono)"); + CompilerOption("msbuildresolution", tagNone, OptionUnit (fun () -> tcConfigB.useSimpleResolution<-false), Some(InternalCommandLineOption("msbuildresolution", rangeCmdArgs)), None); // "Resolve assembly references using MSBuild resolution rules rather than directory based (Default=true except when running fsc.exe under mono)"); CompilerOption("alwayscallvirt",tagNone,OptionSwitch(callVirtSwitch tcConfigB),Some(InternalCommandLineOption("alwayscallvirt",rangeCmdArgs)), None); CompilerOption("nodebugdata",tagNone, OptionUnit (fun () -> tcConfigB.noDebugData<-true),Some(InternalCommandLineOption("--nodebugdata",rangeCmdArgs)), None); testFlag tcConfigB ] @ diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs index 344fc582482..97895c5a14b 100755 --- a/src/fsharp/fsc.fs +++ b/src/fsharp/fsc.fs @@ -1234,11 +1234,7 @@ module MainModuleBuilder = yield Lazy<_>.CreateFromValue av if not(tcConfig.win32res = "") then yield Lazy<_>.CreateFromValue (FileSystem.ReadAllBytesShim tcConfig.win32res) -#if ENABLE_MONO_SUPPORT - if tcConfig.includewin32manifest && not(win32Manifest = "") && not(runningOnMono) then -#else - if tcConfig.includewin32manifest && not(win32Manifest = "") then -#endif + if tcConfig.includewin32manifest && not(win32Manifest = "") && not runningOnMono then yield Lazy<_>.CreateFromValue [| yield! ResFileFormat.ResFileHeader() yield! (ManifestResourceFormat.VS_MANIFEST_RESOURCE((FileSystem.ReadAllBytesShim win32Manifest), tcConfig.target = Dll)) |]] diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index 0e5ded12cc6..54ff244a89e 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -835,11 +835,7 @@ type internal FsiDynamicCompiler errorLogger.AbortOnError(); let fragName = textOfLid prefixPath -#if ENABLE_MONO_SUPPORT let codegenResults = GenerateIlxCode (IlReflectBackend, isInteractiveItExpr, runningOnMono, tcConfig, topCustomAttrs, optimizedImpls, fragName, true, ilxGenerator) -#else - let codegenResults = GenerateIlxCode (IlReflectBackend, isInteractiveItExpr, false, tcConfig, topCustomAttrs, optimizedImpls, fragName, true, ilxGenerator) -#endif errorLogger.AbortOnError(); // Each input is like a small separately compiled extension to a single source file. @@ -2229,7 +2225,7 @@ type internal FsiEvaluationSession (argv:string[], inReader:TextReader, outWrite do tcConfigB.useFsiAuxLib <- true #if TODO_REWORK_ASSEMBLY_LOAD - do tcConfigB.useMonoResolution<-true + do tcConfigB.useSimpleResolution<-true #else #endif diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs index 91c10f9a8be..00951b3e5f1 100755 --- a/src/fsharp/vs/service.fs +++ b/src/fsharp/vs/service.fs @@ -2463,7 +2463,7 @@ type BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroun let useFsiAuxLib = defaultArg useFsiAuxLib true // Do we use a "FSharp.Core, 4.3.0.0" reference by default? let otherFlags = defaultArg otherFlags [| |] - let useMonoResolution = + let useSimpleResolution = #if ENABLE_MONO_SUPPORT runningOnMono || otherFlags |> Array.exists (fun x -> x = "--simpleresolution") #else @@ -2474,7 +2474,7 @@ type BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroun let collect _name = () let fsiCompilerOptions = CompileOptions.GetCoreFsiCompilerOptions tcConfigB CompileOptions.ParseCompilerOptions (collect, fsiCompilerOptions, Array.toList otherFlags) - let fas = LoadClosure.ComputeClosureOfSourceText(filename, source, CodeContext.Editing, useMonoResolution, useFsiAuxLib, new Lexhelp.LexResourceManager(), applyCompilerOptions) + let fas = LoadClosure.ComputeClosureOfSourceText(filename, source, CodeContext.Editing, useSimpleResolution, useFsiAuxLib, new Lexhelp.LexResourceManager(), applyCompilerOptions) let otherFlags = [| yield "--noframework"; yield "--warn:3"; yield! otherFlags