@@ -2213,7 +2213,7 @@ type TcConfigBuilder =
22132213 useFsiAuxLib= false
22142214 implicitOpens=[]
22152215 includes=[]
2216- resolutionEnvironment= ReferenceResolver.CompileTimeLike
2216+ resolutionEnvironment= ResolutionEnvironment.EditingAndCompilation false
22172217 framework= true
22182218 implicitlyResolveAssemblies= true
22192219 referencedDLLs= []
@@ -2801,55 +2801,61 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
28012801// This call can fail if no CLR is found (this is the path to mscorlib)
28022802member tcConfig.GetTargetFrameworkDirectories () =
28032803use unwindBuildPhase= PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
2804- match tcConfig.clrRootwith
2805- | Some x->
2806- [ tcConfig.MakePathAbsolute x]
2807- | None->
2808- #if ENABLE_ MONO_ SUPPORT
2809- if runningOnMonothen
2810- [ let runtimeRoot = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
2811- let runtimeRootWithoutSlash = runtimeRoot.TrimEnd( '/' , '\\' )
2812- let api = runtimeRootWithoutSlash+ " -api"
2813- let rootFacades = Path.Combine( runtimeRootWithoutSlash, " Facades" )
2814- let apiFacades = Path.Combine( api, " Facades" )
2815- match tcConfig.resolutionEnvironmentwith
2816- #if ! FSI_ TODO_ NETCORE
2817- // For F# Interactive code we must inly reference impementation assemblies
2818- | ReferenceResolver.RuntimeLike->
2819- yield runtimeRoot
2820- if Directory.Exists( rootFacades) then
2821- yield rootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2822- #endif
2823- | _ ->
2824- // The default FSharp.Core is found in lib/mono/4.5
2825- yield runtimeRoot
2826- if Directory.Exists( rootFacades) then
2827- yield rootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2828- // It's not clear why we would need to reference the 4.5-api directory.
2829- if Directory.Exists( api) then
2830- yield api
2831- if Directory.Exists( apiFacades) then
2832- yield apiFacades
2833- ]
2834- else
2835- #endif
2836- try
2837- [
2838- match tcConfig.resolutionEnvironmentwith
2839- #if ! FSI_ TODO_ NETCORE
2840- | ReferenceResolver.RuntimeLike->
2841- yield System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
2842- #endif
2843- | _ ->
2804+ try
2805+ [
2806+ // Check if we are given an explicit framework root - if so, use that
2807+ match tcConfig.clrRootwith
2808+ | Some x->
2809+ yield tcConfig.MakePathAbsolute x
2810+
2811+ | None->
2812+ let runtimeRoot = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
2813+ let runtimeRootWithoutSlash = runtimeRoot.TrimEnd( '/' , '\\' )
2814+ let runtimeRootFacades = Path.Combine( runtimeRootWithoutSlash, " Facades" )
2815+ let runtimeRootWPF = Path.Combine( runtimeRootWithoutSlash, " WPF" )
2816+
2817+ match tcConfig.resolutionEnvironmentwith
2818+ | ResolutionEnvironment.CompilationAndEvaluation->
2819+ // Default compilation-and-execution-time references on .NET Framework and Mono, e.g. for F# Interactive
2820+ //
2821+ // In the current way of doing things, F# Interactive refers to implementation assemblies.
2822+ yield runtimeRoot
2823+ if Directory.Exists( runtimeRootFacades) then
2824+ yield runtimeRootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2825+ if Directory.Exists( runtimeRootWPF) then
2826+ yield runtimeRootWPF// PresentationCore.dll is in C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF
2827+
2828+ | ResolutionEnvironment.EditingAndCompilation_ ->
2829+ if runningOnMonothen
2830+ // Default compilation-time references on Mono
2831+ //
2832+ // On Mono, the default references come from the implementation assemblies.
2833+ // This is because we have had trouble reliably using MSBuild APIs to compute DotNetFrameworkReferenceAssembliesRootDirectory on Mono.
2834+ yield runtimeRoot
2835+ if Directory.Exists( runtimeRootFacades) then
2836+ yield runtimeRootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2837+ if Directory.Exists( runtimeRootWPF) then
2838+ yield runtimeRootWPF// PresentationCore.dll is in C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF
2839+ // On Mono we also add a default reference to the 4.5-api and 4.5-api/Facades directories.
2840+ let runtimeRootApi = runtimeRootWithoutSlash+ " -api"
2841+ let runtimeRootApiFacades = Path.Combine( runtimeRootApi, " Facades" )
2842+ if Directory.Exists( runtimeRootApi) then
2843+ yield runtimeRootApi
2844+ if Directory.Exists( runtimeRootApiFacades) then
2845+ yield runtimeRootApiFacades
2846+ else
2847+ // Default compilation-time references on .NET Framework
2848+ //
2849+ // This is the normal case for "fsc.exe a.fs". We refer to the reference assemblies folder.
28442850let frameworkRoot = tcConfig.legacyReferenceResolver.DotNetFrameworkReferenceAssembliesRootDirectory
28452851let frameworkRootVersion = Path.Combine( frameworkRoot, tcConfig.targetFrameworkVersion)
28462852yield frameworkRootVersion
28472853let facades = Path.Combine( frameworkRootVersion, " Facades" )
28482854if Directory.Exists( facades) then
28492855yield facades
28502856]
2851- with e->
2852- errorRecovery e range0; []
2857+ with e->
2858+ errorRecovery e range0; []
28532859
28542860member tcConfig.ComputeLightSyntaxInitialStatus ( filename ) =
28552861use unwindBuildPhase= PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
@@ -4854,7 +4860,7 @@ type LoadClosure =
48544860
48554861[<RequireQualifiedAccess>]
48564862type CodeContext =
4857- | Evaluation // in fsi.exe
4863+ | CompilationAndEvaluation // in fsi.exe
48584864| Compilation// in fsc.exe
48594865| Editing// in VS
48604866
@@ -4887,7 +4893,7 @@ module private ScriptPreprocessClosure =
48874893// .fsx -- EDITING + !COMPILED\INTERACTIVE
48884894let defines =
48894895match codeContextwith
4890- | CodeContext.Evaluation -> [ " INTERACTIVE" ]
4896+ | CodeContext.CompilationAndEvaluation -> [ " INTERACTIVE" ]
48914897| CodeContext.Compilation-> [ " COMPILED" ]
48924898| CodeContext.Editing-> " EDITING" :: ( if IsScript filenamethen [ " INTERACTIVE" ] else [ " COMPILED" ])
48934899let lexbuf = UnicodeLexing.StringAsLexbuf source
@@ -4898,7 +4904,7 @@ module private ScriptPreprocessClosure =
48984904/// Create a TcConfig for load closure starting from a single .fsx file
48994905let CreateScriptSourceTcConfig ( legacyReferenceResolver , defaultFSharpBinariesDir , filename : string , codeContext , useSimpleResolution , useFsiAuxLib , basicReferences , applyCommandLineArgs , assumeDotNetFramework ) =
49004906let projectDir = Path.GetDirectoryName( filename)
4901- let isInteractive = ( codeContext= CodeContext.Evaluation )
4907+ let isInteractive = ( codeContext= CodeContext.CompilationAndEvaluation )
49024908let isInvalidationSupported = ( codeContext= CodeContext.Editing)
49034909let tcConfigB = TcConfigBuilder.CreateNew( legacyReferenceResolver, defaultFSharpBinariesDir, true (* optimize for memory*) , projectDir, isInteractive, isInvalidationSupported, defaultCopyFSharpCore= false )
49044910 applyCommandLineArgs tcConfigB
@@ -4908,12 +4914,14 @@ module private ScriptPreprocessClosure =
49084914
49094915 tcConfigB.resolutionEnvironment<-
49104916match codeContextwith
4911- | CodeContext.Editing-> ReferenceResolver.DesignTimeLike
4917+ | CodeContext.Editing-> ResolutionEnvironment.EditingAndCompilationtrue
4918+ | CodeContext.Compilation-> ResolutionEnvironment.EditingAndCompilationfalse
4919+ | CodeContext.CompilationAndEvaluation->
49124920#if FSI_ TODO_ NETCORE
4913- // "RuntimeLike " assembly resolution for F# Interactive is not yet properly figured out on .NET Core
4914- | CodeContext.Compilation | CodeContext.Evaluation -> ReferenceResolver.CompileTimeLike
4921+ // "CompilationAndEvaluation " assembly resolution for F# Interactive is not yet properly figured out on .NET Core
4922+ ResolutionEnvironment.EditingAndCompilation false
49154923#else
4916- | CodeContext.Compilation | CodeContext.Evaluation -> ReferenceResolver.RuntimeLike
4924+ ResolutionEnvironment.CompilationAndEvaluation
49174925#endif
49184926 tcConfigB.framework<- false
49194927 tcConfigB.useSimpleResolution<- useSimpleResolution