@@ -1282,7 +1282,7 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) =
12821282#if DEBUG
12831283 Printf.bprintf os" \n Stack Trace\n %s \n " ( exn.ToString())
12841284if ! showAssertForUnexpectedExceptionthen
1285- System.Diagnostics.Debug.Assert( false , sprintf" Bug seen in compiler:%s " ( exn.ToString()))
1285+ System.Diagnostics.Debug.Assert( false , sprintf" Unexpected exception seen in compiler:%s \n %s " s ( exn.ToString()))
12861286#endif
12871287| FullAbstraction( s,_) -> os.Append( FullAbstractionE() .Format s) |> ignore
12881288| WrappedError( exn,_) -> OutputExceptionR os exn
@@ -1413,7 +1413,7 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) =
14131413#if DEBUG
14141414 Printf.bprintf os" \n Stack Trace\n %s \n " ( e.ToString())
14151415if ! showAssertForUnexpectedExceptionthen
1416- System.Diagnostics.Debug.Assert( false , sprintf" Bug seen in compiler:%s " ( e.ToString()))
1416+ System.Diagnostics.Debug.Assert( false , sprintf" Unknown exception seen in compiler:%s " ( e.ToString()))
14171417#endif
14181418 OutputExceptionR os( err.Exception)
14191419
@@ -1627,8 +1627,8 @@ let GetFSharpCoreReferenceUsedByCompiler(useSimpleResolution) =
16271627if useSimpleResolutionthen
16281628 GetFSharpCoreLibraryName()+ " .dll"
16291629else
1630- let fsCoreName = GetFSharpCoreLibraryName()
16311630#if FX_ RESHAPED_ REFLECTION
1631+ let fsCoreName = GetFSharpCoreLibraryName()
16321632// RESHAPED_REFLECTION does not have Assembly.GetReferencedAssemblies()
16331633// So use the FSharp.Core.dll from alongside the fsc compiler.
16341634// This can also be used for the out of gac work on DEV15
@@ -1643,6 +1643,7 @@ let GetFSharpCoreReferenceUsedByCompiler(useSimpleResolution) =
16431643// FSharp.Compiler.Service.dll
16441644// assumes for the version of FSharp.Core running in the hosting environment when processing
16451645// scripts and out-of-project files.
1646+ let fsCoreName = GetFSharpCoreLibraryName()
16461647let foundReference =
16471648match System.Reflection.Assembly.GetEntryAssembly() with
16481649| null -> None
@@ -1663,23 +1664,8 @@ let GetFSharpCoreReferenceUsedByCompiler(useSimpleResolution) =
16631664// FSharp.Compiler.Tools nuget package fsc.exe
16641665// Mono /usr/lib/mono/fsharp/fsc.exe
16651666//
1666- // assume a reference to the latest .NET Framework FSharp.Core with which those tools are built, e.g.
1667- // "FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
1668- // This is always known to ship as part of an installation of any delivery of the F# Compiler.
1669- // This reference gets resolved either using the compiler tools directory itself, or using the
1670- // AssemblyFoldersEx key on Windows, or the /usr/lib/mono/4.5/FSharp.Core.dll on Mono
1671- // It doesn't get resolved to the GAC.
1672- //
1673- // In pretty much all these cases we could probably look directly in the folder where the relevant tool is located.
1674- // Even in the case of FSharp.LanguageService.Compiler.dll this component is installed into
1675- // ...Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\FSharp
1676- // However that DLL can also be in the GAC
1677- //
1678- typeof< TypeInThisAssembly>. Assembly.GetReferencedAssemblies()
1679- |> Array.pick( fun name ->
1680- if name.Name= fsCoreNamethen Some( name.ToString())
1681- else None
1682- )
1667+ // assume a reference to the latest .NET Framework FSharp.Core with which those tools are built.
1668+ typeof< list< int>>. Assembly.Location
16831669#endif
16841670let GetFsiLibraryName () = " FSharp.Compiler.Interactive.Settings"
16851671
@@ -4961,12 +4947,11 @@ module private ScriptPreprocessClosure =
49614947 ParseOneInputLexbuf( tcConfig, lexResourceManager, defines, lexbuf, filename, isLastCompiland, errorLogger)
49624948
49634949/// Create a TcConfig for load closure starting from a single .fsx file
4964- let CreateScriptSourceTcConfig ( referenceResolver , filename : string , codeContext , useSimpleResolution , useFsiAuxLib , basicReferences , applyCommandLineArgs , assumeDotNetFramework ) =
4950+ let CreateScriptSourceTcConfig ( referenceResolver , defaultFSharpBinariesDir , filename : string , codeContext , useSimpleResolution , useFsiAuxLib , basicReferences , applyCommandLineArgs , assumeDotNetFramework ) =
49654951let projectDir = Path.GetDirectoryName( filename)
49664952let isInteractive = ( codeContext= CodeContext.Evaluation)
49674953let isInvalidationSupported = ( codeContext= CodeContext.Editing)
4968- // always use primary assembly = mscorlib for scripts
4969- let tcConfigB = TcConfigBuilder.CreateNew( referenceResolver, Internal.Utilities.FSharpEnvironment.BinFolderOfDefaultFSharpCompiler( None) .Value, true (* optimize for memory*) , projectDir, isInteractive, isInvalidationSupported)
4954+ let tcConfigB = TcConfigBuilder.CreateNew( referenceResolver, defaultFSharpBinariesDir, true (* optimize for memory*) , projectDir, isInteractive, isInvalidationSupported)
49704955 applyCommandLineArgs tcConfigB
49714956match basicReferenceswith
49724957| None-> BasicReferencesForScriptLoadClosure( useSimpleResolution, useFsiAuxLib, assumeDotNetFramework) |> List.iter( fun f -> tcConfigB.AddReferencedAssemblyByPath( range0, f)) // Add script references
@@ -5133,18 +5118,18 @@ module private ScriptPreprocessClosure =
51335118 result
51345119
51355120/// Given source text, find the full load closure. Used from service.fs, when editing a script file
5136- let GetFullClosureOfScriptSource ( ctok , referenceResolver , filename , source , codeContext , useSimpleResolution , useFsiAuxLib , lexResourceManager : Lexhelp.LexResourceManager , applyCommmandLineArgs , assumeDotNetFramework ) =
5121+ let GetFullClosureOfScriptSource ( ctok , referenceResolver , defaultFSharpBinariesDir , filename , source , codeContext , useSimpleResolution , useFsiAuxLib , lexResourceManager : Lexhelp.LexResourceManager , applyCommmandLineArgs , assumeDotNetFramework ) =
51375122// Resolve the basic references such as FSharp.Core.dll first, before processing any #I directives in the script
51385123//
51395124// This is tries to mimic the action of running the script in F# Interactive - the initial context for scripting is created
51405125// first, then #I and other directives are processed.
51415126let references0 =
5142- let tcConfig = CreateScriptSourceTcConfig( referenceResolver, filename, codeContext, useSimpleResolution, useFsiAuxLib, None, applyCommmandLineArgs, assumeDotNetFramework)
5127+ let tcConfig = CreateScriptSourceTcConfig( referenceResolver, defaultFSharpBinariesDir , filename, codeContext, useSimpleResolution, useFsiAuxLib, None, applyCommmandLineArgs, assumeDotNetFramework)
51435128let resolutions0 , _unresolvedReferences = GetAssemblyResolutionInformation( ctok, tcConfig)
51445129let references0 = resolutions0|> List.map( fun r -> r.originalReference.Range, r.resolvedPath) |> Seq.distinct|> List.ofSeq
51455130 references0
51465131
5147- let tcConfig = CreateScriptSourceTcConfig( referenceResolver, filename, codeContext, useSimpleResolution, useFsiAuxLib, Some references0, applyCommmandLineArgs, assumeDotNetFramework)
5132+ let tcConfig = CreateScriptSourceTcConfig( referenceResolver, defaultFSharpBinariesDir , filename, codeContext, useSimpleResolution, useFsiAuxLib, Some references0, applyCommmandLineArgs, assumeDotNetFramework)
51485133
51495134let closureSources = [ ClosureSource( filename, range0, source, true )]
51505135let closureFiles , tcConfig = FindClosureFiles( closureSources, tcConfig, codeContext, lexResourceManager)
@@ -5160,9 +5145,9 @@ module private ScriptPreprocessClosure =
51605145
51615146type LoadClosure with
51625147// Used from service.fs, when editing a script file
5163- static member ComputeClosureOfSourceText ( ctok , referenceResolver , filename : string , source : string , codeContext , useSimpleResolution : bool , useFsiAuxLib , lexResourceManager : Lexhelp.LexResourceManager , applyCommmandLineArgs , assumeDotNetFramework ) : LoadClosure =
5148+ static member ComputeClosureOfSourceText ( ctok , referenceResolver , defaultFSharpBinariesDir , filename : string , source : string , codeContext , useSimpleResolution : bool , useFsiAuxLib , lexResourceManager : Lexhelp.LexResourceManager , applyCommmandLineArgs , assumeDotNetFramework ) : LoadClosure =
51645149use unwindBuildPhase= PushThreadBuildPhaseUntilUnwind BuildPhase.Parse
5165- ScriptPreprocessClosure.GetFullClosureOfScriptSource( ctok, referenceResolver, filename, source, codeContext, useSimpleResolution, useFsiAuxLib, lexResourceManager, applyCommmandLineArgs, assumeDotNetFramework)
5150+ ScriptPreprocessClosure.GetFullClosureOfScriptSource( ctok, referenceResolver, defaultFSharpBinariesDir , filename, source, codeContext, useSimpleResolution, useFsiAuxLib, lexResourceManager, applyCommmandLineArgs, assumeDotNetFramework)
51665151
51675152/// Used from fsi.fs and fsc.fs, for #load and command line.
51685153/// The resulting references are then added to a TcConfig.