diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs
index 7ada6090e9e..84ba70bb3f7 100644
--- a/src/fsharp/CompileOps.fs
+++ b/src/fsharp/CompileOps.fs
@@ -39,7 +39,7 @@ open Microsoft.FSharp.Compiler.Lexhelp
open Microsoft.FSharp.Compiler.Lib
open Microsoft.FSharp.Compiler.Infos
open Microsoft.FSharp.Compiler.ConstraintSolver
-open Microsoft.FSharp.Compiler.MSBuildResolver
+open Microsoft.FSharp.Compiler.ReferenceResolver
open Microsoft.FSharp.Compiler.TypeRelations
open Microsoft.FSharp.Compiler.SignatureConformance
open Microsoft.FSharp.Compiler.MethodOverrides
@@ -2007,7 +2007,7 @@ type TcConfigBuilder =
mutable implicitOpens: string list
mutable useFsiAuxLib: bool
mutable framework: bool
- mutable resolutionEnvironment : Microsoft.FSharp.Compiler.MSBuildResolver.ResolutionEnvironment
+ mutable resolutionEnvironment : ReferenceResolver.ResolutionEnvironment
mutable implicitlyResolveAssemblies: bool
mutable addVersionSpecificFrameworkReferences: bool
mutable light: bool option
@@ -2031,9 +2031,6 @@ type TcConfigBuilder =
mutable checkOverflow: bool
mutable showReferenceResolutions:bool
mutable outputFile : string option
- mutable resolutionFrameworkRegistryBase : string
- mutable resolutionAssemblyFoldersSuffix : string
- mutable resolutionAssemblyFoldersConditions : string
mutable platform : ILPlatform option
mutable prefer32Bit : bool
mutable useSimpleResolution : bool
@@ -2081,6 +2078,7 @@ type TcConfigBuilder =
mutable win32manifest : string
mutable includewin32manifest : bool
mutable linkResources : string list
+ mutable referenceResolver: ReferenceResolver.Resolver
mutable showFullPaths : bool
mutable errorStyle : ErrorStyle
@@ -2153,7 +2151,7 @@ type TcConfigBuilder =
#endif
}
- static member CreateNew (defaultFSharpBinariesDir,optimizeForMemory,implicitIncludeDir,isInteractive,isInvalidationSupported) =
+ static member CreateNew (referenceResolver,defaultFSharpBinariesDir,optimizeForMemory,implicitIncludeDir,isInteractive,isInvalidationSupported) =
System.Diagnostics.Debug.Assert(FileSystem.IsPathRootedShim(implicitIncludeDir), sprintf "implicitIncludeDir should be absolute: '%s'" implicitIncludeDir)
if (String.IsNullOrEmpty(defaultFSharpBinariesDir)) then
failwith "Expected a valid defaultFSharpBinariesDir"
@@ -2174,7 +2172,7 @@ type TcConfigBuilder =
useFsiAuxLib=false
implicitOpens=[]
includes=[]
- resolutionEnvironment=MSBuildResolver.CompileTimeLike
+ resolutionEnvironment=ReferenceResolver.CompileTimeLike
framework=true
implicitlyResolveAssemblies=true
addVersionSpecificFrameworkReferences=false
@@ -2197,9 +2195,6 @@ type TcConfigBuilder =
checkOverflow=false
showReferenceResolutions=false
outputFile=None
- resolutionFrameworkRegistryBase = "Software\Microsoft\.NetFramework"
- resolutionAssemblyFoldersSuffix = "AssemblyFoldersEx"
- resolutionAssemblyFoldersConditions = ""
platform = None
prefer32Bit = false
useSimpleResolution = runningOnMono
@@ -2251,6 +2246,7 @@ type TcConfigBuilder =
win32manifest = ""
includewin32manifest = true
linkResources = []
+ referenceResolver = referenceResolver
showFullPaths =false
errorStyle = ErrorStyle.DefaultErrors
@@ -2459,9 +2455,7 @@ let OpenILBinary(filename,optimizeForMemory,openBinariesInMemory,ilGlobalsOpt, p
type AssemblyResolution =
{ originalReference : AssemblyReference
resolvedPath : string
- resolvedFrom : ResolvedFrom
- fusionName : string
- redist : string
+ prepareToolTip : unit -> string
sysdir : bool
ilAssemblyRef : ILAssemblyRef option ref
}
@@ -2594,7 +2588,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
None, (0, ""), false
else
#endif
- None, MSBuildResolver.HighestInstalledNetFrameworkVersionMajorMinor(), false
+ None, (4, data.referenceResolver.HighestInstalledNetFrameworkVersion()), false
// Note: anycpu32bitpreferred can only be used with .Net version 4.5 and above
// but now there is no way to discriminate between 4.0 and 4.5,
@@ -2692,9 +2686,6 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
member x.checkOverflow = data.checkOverflow
member x.showReferenceResolutions = data.showReferenceResolutions
member x.outputFile = data.outputFile
- member x.resolutionFrameworkRegistryBase = data.resolutionFrameworkRegistryBase
- member x.resolutionAssemblyFoldersSuffix = data. resolutionAssemblyFoldersSuffix
- member x.resolutionAssemblyFoldersConditions = data. resolutionAssemblyFoldersConditions
member x.platform = data.platform
member x.prefer32Bit = data.prefer32Bit
member x.useSimpleResolution = data.useSimpleResolution
@@ -2708,7 +2699,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
member x.importAllReferencesOnly = data.importAllReferencesOnly
member x.simulateException = data.simulateException
member x.printAst = data.printAst
- member x.targetFrameworkVersionMajorMinor = targetFrameworkVersionValue
+ member x.targetFrameworkVersion = targetFrameworkVersionValue
member x.tokenizeOnly = data.tokenizeOnly
member x.testInteractionParser = data.testInteractionParser
member x.reportNumDecls = data.reportNumDecls
@@ -2787,6 +2778,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind (BuildPhase.Parameter)
TcConfig(builder,validate)
+ member x.referenceResolver = data.referenceResolver
member tcConfig.CloneOfOriginalBuilder =
{ data with conditionalCompilationDefines=data.conditionalCompilationDefines }
@@ -2811,12 +2803,12 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
try
match tcConfig.resolutionEnvironment with
#if FX_MSBUILDRESOLVER_RUNTIMELIKE
- | MSBuildResolver.RuntimeLike ->
+ | ReferenceResolver.RuntimeLike ->
[System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()]
#endif
| _ ->
- let frameworkRoot = MSBuildResolver.DotNetFrameworkReferenceAssembliesRootDirectoryOnWindows
- let frameworkRootVersion = Path.Combine(frameworkRoot,tcConfig.targetFrameworkVersionMajorMinor)
+ let frameworkRoot = tcConfig.referenceResolver.DotNetFrameworkReferenceAssembliesRootDirectory
+ let frameworkRootVersion = Path.Combine(frameworkRoot,tcConfig.targetFrameworkVersion)
[frameworkRootVersion]
with e ->
errorRecovery e range0; []
@@ -2877,18 +2869,19 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
let ext = System.IO.Path.GetExtension(nm)
let isNetModule = String.Compare(ext,".netmodule",StringComparison.OrdinalIgnoreCase)=0
+ let unknownToolTip (resolvedPath,resolved) =
+ let line(append:string) = append.Trim([|' '|])+"\n"
+ line(resolvedPath) + line(resolved)
+
// See if the language service has already produced the contents of the assembly for us, virtually
match r.ProjectReference with
| Some _ ->
let resolved = r.Text
let sysdir = tcConfig.IsSystemAssembly resolved
- let fusionName = resolved
Some
{ originalReference = r
resolvedPath = resolved
- resolvedFrom = Unknown
- fusionName = fusionName
- redist = null
+ prepareToolTip = (fun () -> resolved)
sysdir = sysdir
ilAssemblyRef = ref None }
| None ->
@@ -2924,9 +2917,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
Some
{ originalReference = r
resolvedPath = resolved
- resolvedFrom = Unknown
- fusionName = fusionName
- redist = null
+ prepareToolTip = (fun () -> unknownToolTip (resolved,fusionName))
sysdir = sysdir
ilAssemblyRef = ref None }
| None -> None
@@ -3009,7 +3000,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
if showMessages && mode = ReportErrors then
errorR(MSBuildReferenceResolutionError(code,message,errorAndWarningRange)))
- let targetFrameworkMajorMinor = tcConfig.targetFrameworkVersionMajorMinor
+ let targetFrameworkVersion = tcConfig.targetFrameworkVersion
let targetProcessorArchitecture =
match tcConfig.platform with
@@ -3023,10 +3014,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
| Some(outputFile) -> tcConfig.MakePathAbsolute outputFile
| None -> tcConfig.implicitIncludeDir
- let targetFrameworkDirectories =
- match tcConfig.clrRoot with
- | Some(clrRoot) -> [tcConfig.MakePathAbsolute clrRoot]
- | None -> []
+ let targetFrameworkDirectories = tcConfig.ClrRoot
// First, try to resolve everything as a file using simple resolution
let resolvedAsFile =
@@ -3040,22 +3028,19 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
// Whatever is left, pass to MSBuild.
let Resolve(references,showMessages) =
try
- MSBuildResolver.Resolve
+ tcConfig.referenceResolver.Resolve
(tcConfig.resolutionEnvironment,
references,
- targetFrameworkMajorMinor, // TargetFrameworkVersionMajorMinor
- targetFrameworkDirectories, // TargetFrameworkDirectories
- targetProcessorArchitecture, // TargetProcessorArchitecture
- Path.GetDirectoryName(outputDirectory), // Output directory
+ targetFrameworkVersion,
+ targetFrameworkDirectories,
+ targetProcessorArchitecture,
+ Path.GetDirectoryName(outputDirectory),
tcConfig.fsharpBinariesDir, // FSharp binaries directory
tcConfig.includes, // Explicit include directories
tcConfig.implicitIncludeDir, // Implicit include directory (likely the project directory)
- tcConfig.resolutionFrameworkRegistryBase,
- tcConfig.resolutionAssemblyFoldersSuffix,
- tcConfig.resolutionAssemblyFoldersConditions,
logmessage showMessages, logwarning showMessages, logerror showMessages)
with
- MSBuildResolver.ResolutionFailure -> error(Error(FSComp.SR.buildAssemblyResolutionFailed(),errorAndWarningRange))
+ ReferenceResolver.ResolutionFailure -> error(Error(FSComp.SR.buildAssemblyResolutionFailed(),errorAndWarningRange))
let toMsBuild = [|0..groupedReferences.Length-1|]
|> Array.map(fun i->(p13 groupedReferences.[i]),(p23 groupedReferences.[i]),i)
@@ -3066,7 +3051,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
// Map back to original assembly resolutions.
let resolvedByMsbuild =
- resolutions.resolvedFiles
+ resolutions
|> Array.map(fun resolvedFile ->
let i = int resolvedFile.baggage
let _,maxIndexOfReference,ms = groupedReferences.[i]
@@ -3076,9 +3061,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
let canonicalItemSpec = FileSystem.GetFullPathShim(resolvedFile.itemSpec)
{originalReference=originalReference
resolvedPath=canonicalItemSpec
- resolvedFrom=resolvedFile.resolvedFrom
- fusionName=resolvedFile.fusionName
- redist=resolvedFile.redist
+ prepareToolTip = (fun () -> resolvedFile.prepareToolTip (originalReference.Text, canonicalItemSpec))
sysdir= tcConfig.IsSystemAssembly canonicalItemSpec
ilAssemblyRef = ref None})
(maxIndexOfReference, assemblyResolutions))
@@ -3099,7 +3082,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
else
// MSBuild resolution may have unified the result of two duplicate references. Try to re-resolve now.
// If re-resolution worked then this was a removed duplicate.
- Resolve([|originalName,""|],(*showMessages*)false).resolvedFiles.Length<>0
+ Resolve([|originalName,""|],(*showMessages*)false).Length<>0
let unresolvedReferences =
groupedReferences
@@ -4394,7 +4377,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
try
Some(tcImports.RegisterAndPrepareToImportReferencedDll nm)
with e ->
- errorR(Error(FSComp.SR.buildProblemReadingAssembly(nm.fusionName, e.Message),nm.originalReference.Range))
+ errorR(Error(FSComp.SR.buildProblemReadingAssembly(nm.resolvedPath, e.Message),nm.originalReference.Range))
None)
|> List.unzip
let ccuinfos = (List.collect (fun phase2 -> phase2()) phase2s)
@@ -4874,12 +4857,12 @@ 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, useSimpleResolution, useFsiAuxLib, basicReferences, applyCommandLineArgs) =
+ let CreateScriptSourceTcConfig (referenceResolver, filename:string, codeContext, useSimpleResolution, useFsiAuxLib, basicReferences, applyCommandLineArgs) =
let projectDir = Path.GetDirectoryName(filename)
let isInteractive = (codeContext = CodeContext.Evaluation)
let isInvalidationSupported = (codeContext = CodeContext.Editing)
// always use primary assembly = mscorlib for scripts
- let tcConfigB = TcConfigBuilder.CreateNew(Internal.Utilities.FSharpEnvironment.BinFolderOfDefaultFSharpCompiler.Value, true (* optimize for memory *), projectDir, isInteractive, isInvalidationSupported)
+ let tcConfigB = TcConfigBuilder.CreateNew(referenceResolver, Internal.Utilities.FSharpEnvironment.BinFolderOfDefaultFSharpCompiler.Value, true (* optimize for memory *), projectDir, isInteractive, isInvalidationSupported)
applyCommandLineArgs tcConfigB
match basicReferences with
| None -> BasicReferencesForScriptLoadClosure(useSimpleResolution, useFsiAuxLib) |> List.iter(fun f->tcConfigB.AddReferencedAssemblyByPath(range0,f)) // Add script references
@@ -4887,11 +4870,11 @@ module private ScriptPreprocessClosure =
tcConfigB.resolutionEnvironment <-
match codeContext with
- | CodeContext.Editing -> MSBuildResolver.DesigntimeLike
+ | CodeContext.Editing -> ReferenceResolver.DesignTimeLike
#if FX_MSBUILDRESOLVER_RUNTIMELIKE
- | CodeContext.Compilation | CodeContext.Evaluation -> MSBuildResolver.RuntimeLike
+ | CodeContext.Compilation | CodeContext.Evaluation -> ReferenceResolver.RuntimeLike
#else
- | CodeContext.Compilation | CodeContext.Evaluation -> MSBuildResolver.CompileTimeLike
+ | CodeContext.Compilation | CodeContext.Evaluation -> ReferenceResolver.CompileTimeLike
#endif
tcConfigB.framework <- false
// Indicates that there are some references not in BasicReferencesForScriptLoadClosure which should
@@ -5049,18 +5032,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,useSimpleResolution,useFsiAuxLib,lexResourceManager:Lexhelp.LexResourceManager,applyCommmandLineArgs) =
+ let GetFullClosureOfScriptSource(referenceResolver,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,useSimpleResolution,useFsiAuxLib,None,applyCommmandLineArgs)
+ let tcConfig = CreateScriptSourceTcConfig(referenceResolver,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,useSimpleResolution,useFsiAuxLib,Some references0,applyCommmandLineArgs)
+ let tcConfig = CreateScriptSourceTcConfig(referenceResolver,filename,codeContext,useSimpleResolution,useFsiAuxLib,Some references0,applyCommmandLineArgs)
let closureSources = [ClosureSource(filename,range0,source,true)]
let closureFiles,tcConfig = FindClosureFiles(closureSources,tcConfig,codeContext,lexResourceManager)
@@ -5076,9 +5059,9 @@ module private ScriptPreprocessClosure =
type LoadClosure with
// Used from service.fs, when editing a script file
- static member ComputeClosureOfSourceText(filename:string, source:string, codeContext, useSimpleResolution:bool, useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, applyCommmandLineArgs) : LoadClosure =
+ static member ComputeClosureOfSourceText(referenceResolver,filename:string, source:string, codeContext, useSimpleResolution:bool, useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, applyCommmandLineArgs) : LoadClosure =
use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind (BuildPhase.Parse)
- ScriptPreprocessClosure.GetFullClosureOfScriptSource(filename,source,codeContext,useSimpleResolution,useFsiAuxLib, lexResourceManager, applyCommmandLineArgs)
+ ScriptPreprocessClosure.GetFullClosureOfScriptSource(referenceResolver,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 34a4f8bf763..cc3f9d415c2 100755
--- a/src/fsharp/CompileOps.fsi
+++ b/src/fsharp/CompileOps.fsi
@@ -18,7 +18,7 @@ open Microsoft.FSharp.Compiler.Tast
open Microsoft.FSharp.Compiler.Tastops
open Microsoft.FSharp.Compiler.Lib
open Microsoft.FSharp.Compiler.Infos
-open Microsoft.FSharp.Compiler.MSBuildResolver
+open Microsoft.FSharp.Compiler.ReferenceResolver
open Microsoft.FSharp.Compiler.TcGlobals
open Microsoft.FSharp.Core.CompilerServices
#if EXTENSIONTYPING
@@ -183,12 +183,8 @@ type AssemblyResolution =
originalReference : AssemblyReference
/// Path to the resolvedFile
resolvedPath : string
- /// Search path used to find this spot.
- resolvedFrom : ResolvedFrom
- /// The qualified name of the assembly
- fusionName : string
- /// Name of the redist, if any, that the assembly was found in.
- redist : string
+ /// Create the tooltip texxt for the assembly reference
+ prepareToolTip : unit -> string
/// Whether or not this is an installed system assembly (for example, System.dll)
sysdir : bool
// Lazily populated ilAssemblyRef for this reference.
@@ -241,7 +237,7 @@ type TcConfigBuilder =
mutable implicitOpens: string list
mutable useFsiAuxLib: bool
mutable framework: bool
- mutable resolutionEnvironment : Microsoft.FSharp.Compiler.MSBuildResolver.ResolutionEnvironment
+ mutable resolutionEnvironment : ReferenceResolver.ResolutionEnvironment
mutable implicitlyResolveAssemblies : bool
mutable addVersionSpecificFrameworkReferences : bool
/// Set if the user has explicitly turned indentation-aware syntax on/off
@@ -268,9 +264,6 @@ type TcConfigBuilder =
mutable checkOverflow:bool
mutable showReferenceResolutions:bool
mutable outputFile : string option
- mutable resolutionFrameworkRegistryBase : string
- mutable resolutionAssemblyFoldersSuffix : string
- mutable resolutionAssemblyFoldersConditions : string
mutable platform : ILPlatform option
mutable prefer32Bit : bool
mutable useSimpleResolution : bool
@@ -314,6 +307,7 @@ type TcConfigBuilder =
mutable win32manifest : string
mutable includewin32manifest : bool
mutable linkResources : string list
+ mutable referenceResolver: ReferenceResolver.Resolver
mutable showFullPaths : bool
mutable errorStyle : ErrorStyle
mutable utf8output : bool
@@ -365,6 +359,7 @@ type TcConfigBuilder =
}
static member CreateNew :
+ referenceResolver: ReferenceResolver.Resolver *
defaultFSharpBinariesDir: string *
optimizeForMemory: bool *
implicitIncludeDir: string *
@@ -422,9 +417,6 @@ type TcConfig =
member checkOverflow:bool
member showReferenceResolutions:bool
member outputFile : string option
- member resolutionFrameworkRegistryBase : string
- member resolutionAssemblyFoldersSuffix : string
- member resolutionAssemblyFoldersConditions : string
member platform : ILPlatform option
member prefer32Bit : bool
member useSimpleResolution : bool
@@ -776,7 +768,7 @@ type LoadClosure =
RootWarnings : PhasedError list }
// Used from service.fs, when editing a script file
- static member ComputeClosureOfSourceText : filename: string * source: string * implicitDefines:CodeContext * useSimpleResolution: bool * useFsiAuxLib: bool * lexResourceManager: Lexhelp.LexResourceManager * applyCompilerOptions: (TcConfigBuilder -> unit) -> LoadClosure
+ static member ComputeClosureOfSourceText : referenceResolver: ReferenceResolver.Resolver * 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 fb4ac15bcd8..0efae33e969 100644
--- a/src/fsharp/CompileOptions.fs
+++ b/src/fsharp/CompileOptions.fs
@@ -856,9 +856,9 @@ let internalFlags (tcConfigB:TcConfigBuilder) =
CompilerOption("implicitresolution", tagNone, OptionUnit (fun _ -> tcConfigB.implicitlyResolveAssemblies <- true), Some(InternalCommandLineOption("--implicitresolution", rangeCmdArgs)), None)
CompilerOption("resolutions", tagNone, OptionUnit (fun () -> tcConfigB.showReferenceResolutions <- true), Some(InternalCommandLineOption("", rangeCmdArgs)), None) // "Display assembly reference resolution information")
- 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("resolutionframeworkregistrybase", tagString, OptionString (fun _ -> ()), 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 _ -> ()), 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 _ -> ()), Some(InternalCommandLineOption("resolutionassemblyfoldersconditions", rangeCmdArgs)), None) // "Additional reference resolution conditions. For example \"OSVersion=5.1.2600.0,PlatformID=id")
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)
diff --git a/src/fsharp/FSharp.Compiler-proto/FSharp.Compiler-proto.fsproj b/src/fsharp/FSharp.Compiler-proto/FSharp.Compiler-proto.fsproj
index 8689c4d9dac..d92aea41891 100644
--- a/src/fsharp/FSharp.Compiler-proto/FSharp.Compiler-proto.fsproj
+++ b/src/fsharp/FSharp.Compiler-proto/FSharp.Compiler-proto.fsproj
@@ -140,11 +140,8 @@
bytes.fs
-
- ReferenceResolution.fsi
-
-
- ReferenceResolution.fs
+
+ ReferenceResolver.fs
il.fsi
@@ -449,6 +446,9 @@
fsc.fs
+
+ MSBuildReferenceResolver.fs
+
diff --git a/src/fsharp/FSharp.Compiler/FSharp.Compiler.fsproj b/src/fsharp/FSharp.Compiler/FSharp.Compiler.fsproj
index 4ae1551a54d..f69f0497d91 100644
--- a/src/fsharp/FSharp.Compiler/FSharp.Compiler.fsproj
+++ b/src/fsharp/FSharp.Compiler/FSharp.Compiler.fsproj
@@ -156,11 +156,8 @@
ErrorLogging\ErrorResolutionHints.fs
-
- ReferenceResolution\ReferenceResolution.fsi
-
-
- ReferenceResolution\ReferenceResolution.fs
+
+ ReferenceResolution\ReferenceResolver.fs
--lexlib Internal.Utilities.Text.Lexing
@@ -489,11 +486,8 @@
Driver\fsc.fs
-
- Driver\IncrementalBuild.fsi
-
-
- Driver\IncrementalBuild.fs
+
+ MSBuildReferenceResolver.fs
InternalsVisibleTo.fs
diff --git a/src/fsharp/FSharp.LanguageService.Compiler/FSharp.LanguageService.Compiler.fsproj b/src/fsharp/FSharp.LanguageService.Compiler/FSharp.LanguageService.Compiler.fsproj
index 0a58d2d9e6f..4ebc45999ce 100644
--- a/src/fsharp/FSharp.LanguageService.Compiler/FSharp.LanguageService.Compiler.fsproj
+++ b/src/fsharp/FSharp.LanguageService.Compiler/FSharp.LanguageService.Compiler.fsproj
@@ -160,11 +160,8 @@
ErrorLogging\ErrorResolutionHints.fs
-
- ReferenceResolution\ReferenceResolution.fsi
-
-
- ReferenceResolution\ReferenceResolution.fs
+
+ ReferenceResolution\ReferenceResolver.fs
--lexlib Internal.Utilities.Text.Lexing
@@ -544,6 +541,9 @@
Service/ServiceUntypedParse.fs
+
+ Service/MSBuildReferenceResolver.fs
+
Service/service.fsi
diff --git a/src/fsharp/ReferenceResolution.fs b/src/fsharp/MSBuildReferenceResolver.fs
similarity index 74%
rename from src/fsharp/ReferenceResolution.fs
rename to src/fsharp/MSBuildReferenceResolver.fs
index b2a275b8f28..f8fc2e2b0e0 100644
--- a/src/fsharp/ReferenceResolution.fs
+++ b/src/fsharp/MSBuildReferenceResolver.fs
@@ -2,7 +2,7 @@
namespace Microsoft.FSharp.Compiler
-module internal MSBuildResolver =
+module internal MSBuildReferenceResolver =
#if FX_RESHAPED_REFLECTION
open Microsoft.FSharp.Core.ReflectionAdapters
@@ -13,82 +13,15 @@ module internal MSBuildResolver =
#endif
open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library
-
- exception ResolutionFailure
-
- /// Describes the location where the reference was found.
- type ResolvedFrom =
- | AssemblyFolders
- | AssemblyFoldersEx
- | TargetFrameworkDirectory
- | RawFileName
- | GlobalAssemblyCache
- | Path of string
- | Unknown
-
-#if FX_MSBUILDRESOLVER_RUNTIMELIKE
- type ResolutionEnvironment = CompileTimeLike | RuntimeLike | DesigntimeLike
-#else
- type ResolutionEnvironment =
- | CompileTimeLike
- | RuntimeLike
- | DesigntimeLike
-
-#endif
+ open Microsoft.FSharp.Compiler.ReferenceResolver
open System
open Microsoft.Build.Tasks
open Microsoft.Build.Utilities
open Microsoft.Build.Framework
open System.IO
- type ResolvedFile =
- { /// Item specification.
- itemSpec:string
- /// Location that the assembly was resolved from.
- resolvedFrom:ResolvedFrom
- /// The long fusion name of the assembly.
- fusionName:string
- /// The version of the assembly (like 4.0.0.0).
- version:string
- /// The name of the redist the assembly was found in.
- redist:string
- /// Round-tripped baggage string.
- baggage:string
- }
-
- override this.ToString() = sprintf "ResolvedFile(%s)" this.itemSpec
-
- /// Reference resolution results. All paths are fully qualified.
- type ResolutionResults =
- { /// Paths to primary references.
- resolvedFiles:ResolvedFile[]
- /// Paths to dependencies.
- referenceDependencyPaths:string[]
- /// Paths to related files (like .xml and .pdb).
- relatedPaths:string[]
- /// Paths to satellite assemblies used for localization.
- referenceSatellitePaths:string[]
- /// Additional files required to support multi-file assemblies.
- referenceScatterPaths:string[]
- /// Paths to files that reference resolution recommend be copied to the local directory.
- referenceCopyLocalPaths:string[]
- /// Binding redirects that reference resolution recommends for the app.config file.
- suggestedBindingRedirects:string[]
- }
-
- static member Empty =
- { resolvedFiles = [| |]
- referenceDependencyPaths = [| |]
- relatedPaths = [| |]
- referenceSatellitePaths = [| |]
- referenceScatterPaths = [| |]
- referenceCopyLocalPaths = [| |]
- suggestedBindingRedirects = [| |]
- }
-
-
/// Get the Reference Assemblies directory for the .NET Framework on Window.
- let DotNetFrameworkReferenceAssembliesRootDirectoryOnWindows =
+ let DotNetFrameworkReferenceAssembliesRootDirectory =
// ProgramFilesX86 is correct for both x86 and x64 architectures
// (the reference assemblies are always in the 32-bit location, which is PF(x86) on an x64 machine)
let PF =
@@ -101,14 +34,14 @@ module internal MSBuildResolver =
/// When targeting .NET 2.0-3.5 on Windows, we expand the {WindowsFramework} and {ReferenceAssemblies} paths manually
let internal ReplaceVariablesForLegacyFxOnWindows(dirs: string list) =
let windowsFramework = Environment.GetEnvironmentVariable("windir")+ @"\Microsoft.NET\Framework"
- let referenceAssemblies = DotNetFrameworkReferenceAssembliesRootDirectoryOnWindows
+ let referenceAssemblies = DotNetFrameworkReferenceAssembliesRootDirectory
dirs |> List.map(fun d -> d.Replace("{WindowsFramework}",windowsFramework).Replace("{ReferenceAssemblies}",referenceAssemblies))
// ATTENTION!: the following code needs to be updated every time we are switching to the new MSBuild version because new .NET framework version was released
// 1. List of frameworks
// 2. DeriveTargetFrameworkDirectoriesFor45Plus
- // 3. HighestInstalledNetFrameworkVersionMajorMinor
+ // 3. HighestInstalledNetFrameworkVersion
// 4. GetPathToDotNetFrameworkImlpementationAssemblies
[]
let private Net10 = "v1.0"
@@ -185,14 +118,14 @@ module internal MSBuildResolver =
| None -> []
/// Use MSBuild to determine the version of the highest installed framework.
- let HighestInstalledNetFrameworkVersionMajorMinor() =
- if box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version461)) <> null then 4, Net461
- elif box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version46)) <> null then 4, Net46
+ let HighestInstalledNetFrameworkVersion() =
+ if box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version461)) <> null then Net461
+ elif box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version46)) <> null then Net46
// 4.5.2 enumeration is not available in Dev15 MSBuild version
- //elif box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version452)) <> null then 4, Net452
- elif box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version451)) <> null then 4, Net451
- elif box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version45)) <> null then 4, Net45
- else 4, Net40 // version is 4.0 assumed since this code is running.
+ //elif box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version452)) <> null then Net452
+ elif box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version451)) <> null then Net451
+ elif box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version45)) <> null then Net45
+ else Net40 // version is 4.0 assumed since this code is running.
/// Derive the target framework directories.
let DeriveTargetFrameworkDirectories (targetFrameworkVersion:string, logMessage) =
@@ -213,6 +146,16 @@ module internal MSBuildResolver =
logMessage (sprintf "Derived target framework directories for version %s are: %s" targetFrameworkVersion (String.Join(",", result)))
result
+ /// Describes the location where the reference was found, used only for debug and tooltip output
+ type ResolvedFrom =
+ | AssemblyFolders
+ | AssemblyFoldersEx
+ | TargetFrameworkDirectory
+ | RawFileName
+ | GlobalAssemblyCache
+ | Path of string
+ | Unknown
+
/// Decode the ResolvedFrom code from MSBuild.
let DecodeResolvedFrom(resolvedFrom:string) : ResolvedFrom =
match resolvedFrom with
@@ -223,6 +166,41 @@ module internal MSBuildResolver =
| r when r.Length >= 10 && "{Registry:" = r.Substring(0,10) -> AssemblyFoldersEx
| r -> ResolvedFrom.Path r
+ let TooltipForResolvedFrom(resolvedFrom, fusionName, redist) =
+ fun (originalReference,resolvedPath) ->
+ let originalReferenceName = originalReference
+ let resolvedPath = // Don't show the resolved path if it is identical to what was referenced.
+ if originalReferenceName = resolvedPath then String.Empty
+ else resolvedPath
+ let lineIfExists(append) =
+ if not(String.IsNullOrEmpty(append)) then append.Trim([|' '|])+"\n"
+ else ""
+ match resolvedFrom with
+ | AssemblyFolders ->
+ lineIfExists(resolvedPath)
+ + lineIfExists(fusionName)
+ + (FSComp.SR.assemblyResolutionFoundByAssemblyFoldersKey())
+ | AssemblyFoldersEx ->
+ lineIfExists(resolvedPath)
+ + lineIfExists(fusionName)
+ + (FSComp.SR.assemblyResolutionFoundByAssemblyFoldersExKey())
+ | TargetFrameworkDirectory ->
+ lineIfExists(resolvedPath)
+ + lineIfExists(fusionName)
+ + (FSComp.SR.assemblyResolutionNetFramework())
+ | Unknown ->
+ // Unknown when resolved by plain directory search without help from MSBuild resolver.
+ lineIfExists(resolvedPath)
+ + lineIfExists(fusionName)
+ | RawFileName ->
+ lineIfExists(fusionName)
+ | GlobalAssemblyCache ->
+ lineIfExists(fusionName)
+ + (FSComp.SR.assemblyResolutionGAC())+ "\n"
+ + lineIfExists(redist)
+ | Path _ ->
+ lineIfExists(resolvedPath)
+ + lineIfExists(fusionName)
/// Perform assembly resolution by instantiating the ResolveAssemblyReference task directly from the MSBuild SDK.
let ResolveCore(resolutionEnvironment: ResolutionEnvironment,
@@ -231,18 +209,17 @@ module internal MSBuildResolver =
targetFrameworkDirectories: string list,
targetProcessorArchitecture: string,
outputDirectory: string,
- fsharpCoreExplicitDirOrFSharpBinariesDir: string,
+ fsharpCoreDir: string,
explicitIncludeDirs: string list,
implicitIncludeDir: string,
- frameworkRegistryBase: string,
- assemblyFoldersSuffix: string,
- assemblyFoldersConditions: string,
allowRawFileName: bool,
logMessage: (string -> unit),
logWarning: (string -> string -> unit),
logError: (string -> string -> unit)) =
- if Array.isEmpty references then ResolutionResults.Empty else
+ let frameworkRegistryBase, assemblyFoldersSuffix, assemblyFoldersConditions =
+ "Software\Microsoft\.NetFramework", "AssemblyFoldersEx" , ""
+ if Array.isEmpty references then [| |] else
let backgroundException = ref false
@@ -289,13 +266,13 @@ module internal MSBuildResolver =
let registry = sprintf "{Registry:%s,%s,%s%s}" frameworkRegistryBase targetFrameworkVersion assemblyFoldersSuffix assemblyFoldersConditions
[| match resolutionEnvironment with
- | DesigntimeLike
+ | DesignTimeLike
| RuntimeLike ->
logMessage("Using scripting resolution precedence.")
// These are search paths for runtime-like or scripting resolution. GAC searching is present.
yield! rawFileNamePath // Quick-resolve straight to filename first
yield! explicitIncludeDirs // From -I, #I
- yield fsharpCoreExplicitDirOrFSharpBinariesDir // Location of explicit reference to FSharp.Core, otherwise location of fsc.exe
+ yield fsharpCoreDir // Location of explicit reference to FSharp.Core, otherwise location of fsc.exe
yield implicitIncludeDir // Usually the project directory
yield "{TargetFrameworkDirectory}"
yield registry
@@ -308,7 +285,7 @@ module internal MSBuildResolver =
yield "{TargetFrameworkDirectory}"
yield! rawFileNamePath // Quick-resolve straight to filename first
yield! explicitIncludeDirs // From -I, #I
- yield fsharpCoreExplicitDirOrFSharpBinariesDir // Location of explicit reference to FSharp.Core, otherwise location of fsc.exe
+ yield fsharpCoreDir // Location of explicit reference to FSharp.Core, otherwise location of fsc.exe
yield implicitIncludeDir // Usually the project directory
yield registry
yield "{AssemblyFolders}"
@@ -357,13 +334,13 @@ module internal MSBuildResolver =
let rawFileNamePath = if allowRawFileName then ["{RawFileName}"] else []
let searchPaths =
match resolutionEnvironment with
- | DesigntimeLike
+ | DesignTimeLike
| RuntimeLike ->
logMessage("Using scripting resolution precedence.")
// These are search paths for runtime-like or scripting resolution. GAC searching is present.
rawFileNamePath @ // Quick-resolve straight to filename first
explicitIncludeDirs @ // From -I, #I
- [fsharpCoreExplicitDirOrFSharpBinariesDir] @ // Location of explicit reference to FSharp.Core, otherwise location of fsc.exe
+ [fsharpCoreDir] @ // Location of explicit reference to FSharp.Core, otherwise location of fsc.exe
[implicitIncludeDir] @ // Usually the project directory
["{TargetFrameworkDirectory}"] @
[sprintf "{Registry:%s,%s,%s%s}" frameworkRegistryBase targetFrameworkVersion assemblyFoldersSuffix assemblyFoldersConditions] @
@@ -375,7 +352,7 @@ module internal MSBuildResolver =
["{TargetFrameworkDirectory}"] @
rawFileNamePath @ // Quick-resolve straight to filename first
explicitIncludeDirs @ // From -I, #I
- [fsharpCoreExplicitDirOrFSharpBinariesDir] @ // Location of explicit reference to FSharp.Core, otherwise location of fsc.exe
+ [fsharpCoreDir] @ // Location of explicit reference to FSharp.Core, otherwise location of fsc.exe
[implicitIncludeDir] @ // Usually the project directory
[sprintf "{Registry:%s,%s,%s%s}" frameworkRegistryBase targetFrameworkVersion assemblyFoldersSuffix assemblyFoldersConditions] @ // Like {Registry:Software\Microsoft\.NETFramework,v2.0,AssemblyFoldersEx}
["{AssemblyFolders}"] @
@@ -395,25 +372,18 @@ module internal MSBuildResolver =
let resolvedFiles =
[| for p in rar.ResolvedFiles ->
+ let resolvedFrom = DecodeResolvedFrom(p.GetMetadata("ResolvedFrom"))
+ let fusionName = p.GetMetadata("FusionName")
+ let redist = p.GetMetadata("Redist")
{ itemSpec = p.ItemSpec
- resolvedFrom = DecodeResolvedFrom(p.GetMetadata("ResolvedFrom"))
- fusionName = p.GetMetadata("FusionName")
- version = p.GetMetadata("Version")
- redist = p.GetMetadata("Redist")
+ prepareToolTip = TooltipForResolvedFrom(resolvedFrom, fusionName, redist)
baggage = p.GetMetadata("Baggage") } |]
- { resolvedFiles = resolvedFiles
- referenceDependencyPaths = [| for p in rar.ResolvedDependencyFiles -> p.ItemSpec |]
- relatedPaths = [| for p in rar.RelatedFiles -> p.ItemSpec |]
- referenceSatellitePaths = [| for p in rar.SatelliteFiles -> p.ItemSpec |]
- referenceScatterPaths = [| for p in rar.ScatterFiles -> p.ItemSpec |]
- referenceCopyLocalPaths = [| for p in rar.CopyLocalFiles -> p.ItemSpec |]
- suggestedBindingRedirects = [| for p in rar.SuggestedRedirects -> p.ItemSpec |] }
+ resolvedFiles
/// Perform the resolution on rooted and unrooted paths, and then combine the results.
let Resolve(resolutionEnvironment, references, targetFrameworkVersion, targetFrameworkDirectories, targetProcessorArchitecture,
- outputDirectory, fsharpCoreExplicitDirOrFSharpBinariesDir, explicitIncludeDirs, implicitIncludeDir, frameworkRegistryBase,
- assemblyFoldersSuffix, assemblyFoldersConditions, logMessage, logWarning, logError) =
+ outputDirectory, fsharpCoreDir, explicitIncludeDirs, implicitIncludeDir, logMessage, logWarning, logError) =
// The {RawFileName} target is 'dangerous', in the sense that is uses Directory.GetCurrentDirectory() to resolve unrooted file paths.
// It is unreliable to use this mutable global state inside Visual Studio. As a result, we partition all references into a "rooted" set
@@ -435,17 +405,20 @@ module internal MSBuildResolver =
let rooted, unrooted = references |> Array.partition (fst >> FileSystem.IsPathRootedShim)
- let rootedResults = ResolveCore(resolutionEnvironment, rooted, targetFrameworkVersion, targetFrameworkDirectories, targetProcessorArchitecture, outputDirectory, fsharpCoreExplicitDirOrFSharpBinariesDir, explicitIncludeDirs, implicitIncludeDir, frameworkRegistryBase, assemblyFoldersSuffix, assemblyFoldersConditions, true, logMessage, logWarning, logError)
+ let rootedResults = ResolveCore(resolutionEnvironment, rooted, targetFrameworkVersion, targetFrameworkDirectories, targetProcessorArchitecture, outputDirectory, fsharpCoreDir, explicitIncludeDirs, implicitIncludeDir, true, logMessage, logWarning, logError)
- let unrootedResults = ResolveCore(resolutionEnvironment, unrooted, targetFrameworkVersion, targetFrameworkDirectories, targetProcessorArchitecture, outputDirectory, fsharpCoreExplicitDirOrFSharpBinariesDir, explicitIncludeDirs, implicitIncludeDir, frameworkRegistryBase, assemblyFoldersSuffix, assemblyFoldersConditions, false, logMessage, logWarning, logError)
+ let unrootedResults = ResolveCore(resolutionEnvironment, unrooted, targetFrameworkVersion, targetFrameworkDirectories, targetProcessorArchitecture, outputDirectory, fsharpCoreDir, explicitIncludeDirs, implicitIncludeDir, false, logMessage, logWarning, logError)
// now unify the two sets of results
- {
- resolvedFiles = Array.concat [| rootedResults.resolvedFiles; unrootedResults.resolvedFiles |]
- referenceDependencyPaths = set rootedResults.referenceDependencyPaths |> Set.union (set unrootedResults.referenceDependencyPaths) |> Set.toArray
- relatedPaths = set rootedResults.relatedPaths |> Set.union (set unrootedResults.relatedPaths) |> Set.toArray
- referenceSatellitePaths = set rootedResults.referenceSatellitePaths |> Set.union (set unrootedResults.referenceSatellitePaths) |> Set.toArray
- referenceScatterPaths = set rootedResults.referenceScatterPaths |> Set.union (set unrootedResults.referenceScatterPaths) |> Set.toArray
- referenceCopyLocalPaths = set rootedResults.referenceCopyLocalPaths |> Set.union (set unrootedResults.referenceCopyLocalPaths) |> Set.toArray
- suggestedBindingRedirects = set rootedResults.suggestedBindingRedirects |> Set.union (set unrootedResults.suggestedBindingRedirects) |> Set.toArray
- }
\ No newline at end of file
+ Array.concat [| rootedResults; unrootedResults |]
+
+ let Resolver =
+ { new ReferenceResolver.Resolver with
+ member __.HighestInstalledNetFrameworkVersion() = HighestInstalledNetFrameworkVersion()
+ member __.DotNetFrameworkReferenceAssembliesRootDirectory = DotNetFrameworkReferenceAssembliesRootDirectory
+ member __.Resolve(resolutionEnvironment, references, targetFrameworkVersion, targetFrameworkDirectories, targetProcessorArchitecture,
+ outputDirectory, fsharpCoreDir, explicitIncludeDirs, implicitIncludeDir, logMessage, logWarning, logError) =
+
+ Resolve(resolutionEnvironment, references, targetFrameworkVersion, targetFrameworkDirectories, targetProcessorArchitecture,
+ outputDirectory, fsharpCoreDir, explicitIncludeDirs, implicitIncludeDir, logMessage, logWarning, logError)
+ }
diff --git a/src/fsharp/ReferenceResolution.fsi b/src/fsharp/ReferenceResolution.fsi
deleted file mode 100644
index 4c7b87cffbf..00000000000
--- a/src/fsharp/ReferenceResolution.fsi
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-
-namespace Microsoft.FSharp.Compiler
-
-module internal MSBuildResolver =
-
- exception ResolutionFailure
-
- val HighestInstalledNetFrameworkVersionMajorMinor : unit -> int * string
-
- /// Describes the location where the reference was found.
- type ResolvedFrom =
- | AssemblyFolders
- | AssemblyFoldersEx
- | TargetFrameworkDirectory
- | RawFileName
- | GlobalAssemblyCache
- | Path of string
- | Unknown
-
- /// Indicates whether the resolve should follow compile-time rules or runtime rules.
- type ResolutionEnvironment =
- | CompileTimeLike
- | RuntimeLike // Don't allow stubbed-out reference assemblies
- | DesigntimeLike
-
- /// Get the Reference Assemblies directory for the .NET Framework on Window
- val DotNetFrameworkReferenceAssembliesRootDirectoryOnWindows : string
-
- /// Information about a resolved file.
- type ResolvedFile =
- { /// Item specification.
- itemSpec:string
- /// Location that the assembly was resolved from.
- resolvedFrom:ResolvedFrom
- /// The long fusion name of the assembly.
- fusionName:string
- /// The version of the assembly (like 4.0.0.0).
- version:string
- /// The name of the redist the assembly was found in.
- redist:string
- /// Round-tripped baggage string.
- baggage:string
- }
-
- /// Reference resolution results. All paths are fully qualified.
- type ResolutionResults =
- { /// Paths to primary references.
- resolvedFiles:ResolvedFile[]
- /// Paths to dependencies.
- referenceDependencyPaths:string[]
- /// Paths to related files (like .xml and .pdb).
- relatedPaths:string[]
- /// Paths to satellite assemblies used for localization.
- referenceSatellitePaths:string[]
- /// Additional files required to support multi-file assemblies.
- referenceScatterPaths:string[]
- /// Paths to files that reference resolution recommend be copied to the local directory.
- referenceCopyLocalPaths:string[]
- /// Binding redirects that reference resolution recommends for the app.config file.
- suggestedBindingRedirects:string[] }
-
-
- /// Perform assembly resolution on the given references.
- val Resolve:
- resolutionEnvironment: ResolutionEnvironment *
- references:seq *
- targetFrameworkVersion:string *
- targetFrameworkDirectories:string list *
- targetProcessorArchitecture:string *
- outputDirectory:string *
- fsharpBinariesDir:string *
- explicitIncludeDirs:string list *
- implicitIncludeDir:string *
- frameworkRegistryBase:string *
- assemblyFoldersSuffix:string *
- assemblyFoldersConditions:string *
- logmessage:(string->unit) *
- logwarning:(string->string->unit) *
- logerror:(string->string->unit)
- -> ResolutionResults
diff --git a/src/fsharp/ReferenceResolver.fs b/src/fsharp/ReferenceResolver.fs
new file mode 100644
index 00000000000..d9e48bcd69d
--- /dev/null
+++ b/src/fsharp/ReferenceResolver.fs
@@ -0,0 +1,58 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+namespace Microsoft.FSharp.Compiler
+
+module internal ReferenceResolver =
+
+ exception ResolutionFailure
+
+ type ResolutionEnvironment =
+ /// Indicates a script or source being compiled
+ | CompileTimeLike
+ /// Indicates a script or source being interpreted
+ | RuntimeLike
+ /// Indicates a script or source being edited
+ | DesignTimeLike
+
+ type ResolvedFile =
+ { /// Item specification.
+ itemSpec:string
+ /// Prepare textual information about where the assembly was resolved from, used for tooltip output
+ prepareToolTip: string * string -> string
+ /// Round-tripped baggage
+ baggage:string
+ }
+
+ override this.ToString() = sprintf "ResolvedFile(%s)" this.itemSpec
+
+ type Resolver =
+ /// Get the "v4.5.1"-style moniker for the highest installed .NET Framework version.
+ /// This is the value passed back to Resolve if no explicit "mscorlib" has been given.
+ ///
+ /// Note: If an explicit "mscorlib" is given, then --noframework is being used, and the whole ReferenceResolver logic is essentially
+ /// unused. However in the future an option may be added to allow an expicit specification of
+ /// a .NET Framework version to use for scripts.
+ abstract HighestInstalledNetFrameworkVersion : unit -> string
+
+ /// Get the Reference Assemblies directory for the .NET Framework (on Windows)
+ /// This is added to the default resolution path for
+ /// design-time compilations.
+ abstract DotNetFrameworkReferenceAssembliesRootDirectory : string
+
+ /// Perform assembly resolution on the given references under the given conditions
+ abstract Resolve :
+ resolutionEnvironment: ResolutionEnvironment *
+ // The actual reference paths or assemby name text, plus baggage
+ references:(string (* baggage *) * string)[] *
+ // e.g. v4.5.1
+ targetFrameworkVersion:string *
+ targetFrameworkDirectories:string list *
+ targetProcessorArchitecture:string *
+ outputDirectory: string *
+ fsharpCoreDir:string *
+ explicitIncludeDirs:string list *
+ implicitIncludeDir:string *
+ logmessage:(string->unit) *
+ logwarning:(string->string->unit) *
+ logerror:(string->string->unit)
+ -> ResolvedFile[]
diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs
index 592bf86621a..e7ac600f92d 100644
--- a/src/fsharp/fsc.fs
+++ b/src/fsharp/fsc.fs
@@ -302,6 +302,7 @@ let ProcessCommandLineFlags (tcConfigB: TcConfigBuilder,setProcessThreadLocals,a
// A great deal of the logic of this function is repeated in fsi.fs, so maybe should refactor fsi.fs to call into this as well.
let GetTcImportsFromCommandLine
(argv : string[],
+ referenceResolver,
defaultFSharpBinariesDir : string,
directoryBuildingFrom : string,
#if FX_LCIDFROMCODEPAGE
@@ -314,7 +315,7 @@ let GetTcImportsFromCommandLine
errorLoggerProvider : ErrorLoggerProvider,
disposables : DisposablesTracker) =
- let tcConfigB = TcConfigBuilder.CreateNew(defaultFSharpBinariesDir, optimizeForMemory, directoryBuildingFrom, isInteractive=false, isInvalidationSupported=false)
+ let tcConfigB = TcConfigBuilder.CreateNew(referenceResolver, defaultFSharpBinariesDir, optimizeForMemory, directoryBuildingFrom, isInteractive=false, isInvalidationSupported=false)
// Preset: --optimize+ -g --tailcalls+ (see 4505)
SetOptimizeSwitch tcConfigB OptionSwitch.On
SetDebugSwitch tcConfigB None OptionSwitch.Off
@@ -1841,7 +1842,7 @@ let copyFSharpCore(outFile: string, referencedDlls: AssemblyReference list) =
[]
type Args<'T> = Args of 'T
-let main0(argv,bannerAlreadyPrinted,exiter:Exiter, errorLoggerProvider : ErrorLoggerProvider, disposables : DisposablesTracker) =
+let main0(argv,referenceResolver,bannerAlreadyPrinted,exiter:Exiter, errorLoggerProvider : ErrorLoggerProvider, disposables : DisposablesTracker) =
#if FX_LCIDFROMCODEPAGE
// See Bug 735819
@@ -1857,7 +1858,7 @@ let main0(argv,bannerAlreadyPrinted,exiter:Exiter, errorLoggerProvider : ErrorLo
let tcGlobals,tcImports,frameworkTcImports,generatedCcu,typedImplFiles,topAttrs,tcConfig,outfile,pdbfile,assemblyName,errorLogger =
GetTcImportsFromCommandLine(
- argv,defaultFSharpBinariesDir,Directory.GetCurrentDirectory(),
+ argv,referenceResolver,defaultFSharpBinariesDir,Directory.GetCurrentDirectory(),
#if FX_LCIDFROMCODEPAGE
lcidFromCodePage,
#endif
@@ -2052,26 +2053,27 @@ let main4 (Args (tcConfig, errorLogger: ErrorLogger, ilGlobals, ilxMainModule, o
ReportTime tcConfig "Exiting"
-let typecheckAndCompile(argv,bannerAlreadyPrinted,exiter:Exiter, errorLoggerProvider) =
+let typecheckAndCompile(argv,referenceResolver,bannerAlreadyPrinted,exiter:Exiter, errorLoggerProvider) =
use d = new DisposablesTracker()
use e = new SaveAndRestoreConsoleEncoding()
- main0(argv,bannerAlreadyPrinted,exiter, errorLoggerProvider, d)
+ main0(argv,referenceResolver,bannerAlreadyPrinted,exiter, errorLoggerProvider, d)
+
|> main1
|> main2
|> main2b
|> main3
|> main4
-let mainCompile (argv, bannerAlreadyPrinted, exiter:Exiter) =
- typecheckAndCompile(argv, bannerAlreadyPrinted, exiter, DefaultLoggerProvider())
+let mainCompile (argv, referenceResolver, bannerAlreadyPrinted, exiter:Exiter) =
+ typecheckAndCompile(argv, referenceResolver, bannerAlreadyPrinted, exiter, DefaultLoggerProvider())
[]
type CompilationOutput =
{ Errors : ErrorOrWarning[]
Warnings : ErrorOrWarning[] }
-type InProcCompiler() =
+type InProcCompiler(referenceResolver) =
member this.Compile(argv) =
let errors = ResizeArray()
@@ -2093,7 +2095,7 @@ type InProcCompiler() =
{ new Exiter with
member this.Exit n = exitCode := n; raise StopProcessing }
try
- typecheckAndCompile(argv, false, exiter, loggerProvider)
+ typecheckAndCompile(argv, referenceResolver, false, exiter, loggerProvider)
with
| StopProcessing -> ()
| ReportedError _ | WrappedError(ReportedError _,_) ->
diff --git a/src/fsharp/fsc.fsi b/src/fsharp/fsc.fsi
index 8e197976c48..a11696aeff9 100755
--- a/src/fsharp/fsc.fsi
+++ b/src/fsharp/fsc.fsi
@@ -39,7 +39,11 @@ val internal ProcessCommandLineFlags : TcConfigBuilder * setProcessThreadLocals:
//---------------------------------------------------------------------------
// The entry point used by fsc.exe
-val mainCompile : argv : string[] * bannerAlreadyPrinted : bool * exiter : Exiter -> unit
+val mainCompile :
+ argv : string[] *
+ referenceResolver: ReferenceResolver.Resolver *
+ bannerAlreadyPrinted : bool *
+ exiter : Exiter -> unit
//---------------------------------------------------------------------------
// The micro API into the compiler used by the visualfsharp test infrastructure
@@ -50,7 +54,7 @@ type CompilationOutput =
Warnings : ErrorOrWarning[] }
type InProcCompiler =
- new : unit -> InProcCompiler
+ new : ReferenceResolver.Resolver -> InProcCompiler
member Compile : args : string[] -> bool * CompilationOutput
diff --git a/src/fsharp/fscmain.fs b/src/fsharp/fscmain.fs
index 2c36d037085..733b7624135 100644
--- a/src/fsharp/fscmain.fs
+++ b/src/fsharp/fscmain.fs
@@ -83,7 +83,7 @@ module FSharpResidentCompiler =
let exitCode =
try
Environment.CurrentDirectory <- pwd
- mainCompile (argv, true, exiter);
+ mainCompile (argv, MSBuildReferenceResolver.Resolver, true, exiter);
if !progress then printfn "server: finished compilation request, argv = %A" argv
0
with e ->
@@ -290,7 +290,7 @@ module Driver =
match exitCodeOpt with
| Some exitCode -> exitCode
| None ->
- mainCompile (argv, true, quitProcessExiter)
+ mainCompile (argv, MSBuildReferenceResolver.Resolver, true, quitProcessExiter)
0
elif runningOnMono && argv |> Array.exists (fun x -> x = "/server" || x = "--server") then
@@ -300,10 +300,10 @@ module Driver =
0
else
- mainCompile (argv, false, quitProcessExiter)
+ mainCompile (argv, MSBuildReferenceResolver.Resolver, false, quitProcessExiter)
0
#else
- mainCompile (argv, false, quitProcessExiter)
+ mainCompile (argv, MSBuildReferenceResolver.Resolver, false, quitProcessExiter)
0
#endif
diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs
index 9af45e894ae..7bf1925331d 100644
--- a/src/fsharp/fsi/fsi.fs
+++ b/src/fsharp/fsi/fsi.fs
@@ -2209,16 +2209,18 @@ type internal FsiEvaluationSession (argv:string[], inReader:TextReader, outWrite
System.AppDomain.CurrentDomain.BaseDirectory
#endif
+ let referenceResolver = MSBuildReferenceResolver.Resolver
let tcConfigB =
- TcConfigBuilder.CreateNew(defaultFSharpBinariesDir,
- true, // long running: optimizeForMemory
- Directory.GetCurrentDirectory(),isInteractive=true,
- isInvalidationSupported=false)
+ TcConfigBuilder.CreateNew(referenceResolver,
+ defaultFSharpBinariesDir,
+ true, // long running: optimizeForMemory
+ Directory.GetCurrentDirectory(),isInteractive=true,
+ isInvalidationSupported=false)
let tcConfigP = TcConfigProvider.BasedOnMutableBuilder(tcConfigB)
#if FX_MSBUILDRESOLVER_RUNTIMELIKE
- do tcConfigB.resolutionEnvironment <- MSBuildResolver.RuntimeLike // See Bug 3608
+ do tcConfigB.resolutionEnvironment <- ReferenceResolver.RuntimeLike // See Bug 3608
#else
- do tcConfigB.resolutionEnvironment <- MSBuildResolver.DesigntimeLike
+ do tcConfigB.resolutionEnvironment <- ReferenceResolver.DesignTimeLike
#endif
do tcConfigB.useFsiAuxLib <- true
diff --git a/src/fsharp/vs/IncrementalBuild.fs b/src/fsharp/vs/IncrementalBuild.fs
index 0db1e3f6e5b..774c1aeecd7 100755
--- a/src/fsharp/vs/IncrementalBuild.fs
+++ b/src/fsharp/vs/IncrementalBuild.fs
@@ -1744,7 +1744,7 @@ type IncrementalBuilder(frameworkTcImportsCache: FrameworkImportsCache, tcConfig
/// CreateIncrementalBuilder (for background type checking). Note that fsc.fs also
/// creates an incremental builder used by the command line compiler.
- static member TryCreateBackgroundBuilderForProjectOptions (frameworkTcImportsCache, scriptClosureOptions:LoadClosure option, sourceFiles:string list, commandLineArgs:string list, projectReferences, projectDirectory, useScriptResolutionRules, isIncompleteTypeCheckEnvironment, keepAssemblyContents, keepAllBackgroundResolutions) =
+ static member TryCreateBackgroundBuilderForProjectOptions (referenceResolver, frameworkTcImportsCache, scriptClosureOptions:LoadClosure option, sourceFiles:string list, commandLineArgs:string list, projectReferences, projectDirectory, useScriptResolutionRules, isIncompleteTypeCheckEnvironment, keepAssemblyContents, keepAllBackgroundResolutions) =
// Trap and report warnings and errors from creation.
use errorScope = new ErrorScope()
@@ -1761,15 +1761,15 @@ type IncrementalBuilder(frameworkTcImportsCache: FrameworkImportsCache, tcConfig
// see also fsc.fs:runFromCommandLineToImportingAssemblies(), as there are many similarities to where the PS creates a tcConfigB
let tcConfigB =
- TcConfigBuilder.CreateNew(defaultFSharpBinariesDir, implicitIncludeDir=projectDirectory,
+ TcConfigBuilder.CreateNew(referenceResolver, defaultFSharpBinariesDir, implicitIncludeDir=projectDirectory,
optimizeForMemory=true, isInteractive=false, isInvalidationSupported=true)
// The following uses more memory but means we don'T take read-exclusions on the DLLs we reference
// Could detect well-known assemblies--ie System.dll--and open them with read-locks
tcConfigB.openBinariesInMemory <- true
tcConfigB.resolutionEnvironment
<- if useScriptResolutionRules
- then MSBuildResolver.DesigntimeLike
- else MSBuildResolver.CompileTimeLike
+ then ReferenceResolver.DesignTimeLike
+ else ReferenceResolver.CompileTimeLike
tcConfigB.conditionalCompilationDefines <-
let define = if useScriptResolutionRules then "INTERACTIVE" else "COMPILED"
@@ -1838,4 +1838,4 @@ type IncrementalBuilder(frameworkTcImportsCache: FrameworkImportsCache, tcConfig
| Some builder -> builder.IncrementUsageCount()
| None -> { new System.IDisposable with member __.Dispose() = () }
- member b.IsBeingKeptAliveApartFromCacheEntry = (referenceCount >= 2)
\ No newline at end of file
+ member b.IsBeingKeptAliveApartFromCacheEntry = (referenceCount >= 2)
diff --git a/src/fsharp/vs/IncrementalBuild.fsi b/src/fsharp/vs/IncrementalBuild.fsi
index 58f82cc3655..78f5f885dca 100755
--- a/src/fsharp/vs/IncrementalBuild.fsi
+++ b/src/fsharp/vs/IncrementalBuild.fsi
@@ -186,7 +186,7 @@ type internal IncrementalBuilder =
/// This may be a marginally long-running operation (parses are relatively quick, only one file needs to be parsed)
member GetParseResultsForFile : filename:string -> Ast.ParsedInput option * Range.range * string * (PhasedError * FSharpErrorSeverity) list
- static member TryCreateBackgroundBuilderForProjectOptions : FrameworkImportsCache * scriptClosureOptions:LoadClosure option * sourceFiles:string list * commandLineArgs:string list * projectReferences: IProjectReference list * projectDirectory:string * useScriptResolutionRules:bool * isIncompleteTypeCheckEnvironment : bool * keepAssemblyContents: bool * keepAllBackgroundResolutions: bool -> IncrementalBuilder option * FSharpErrorInfo list
+ static member TryCreateBackgroundBuilderForProjectOptions : ReferenceResolver.Resolver * FrameworkImportsCache * scriptClosureOptions:LoadClosure option * sourceFiles:string list * commandLineArgs:string list * projectReferences: IProjectReference list * projectDirectory:string * useScriptResolutionRules:bool * isIncompleteTypeCheckEnvironment : bool * keepAssemblyContents: bool * keepAllBackgroundResolutions: bool -> IncrementalBuilder option * FSharpErrorInfo list
static member KeepBuilderAlive : IncrementalBuilder option -> IDisposable
member IsBeingKeptAliveApartFromCacheEntry : bool
diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs
index 3b2a7ae0950..382ddf8dad4 100755
--- a/src/fsharp/vs/service.fs
+++ b/src/fsharp/vs/service.fs
@@ -25,7 +25,7 @@ open Microsoft.FSharp.Compiler.Ast
open Microsoft.FSharp.Compiler.CompileOps
open Microsoft.FSharp.Compiler.ErrorLogger
open Microsoft.FSharp.Compiler.Lib
-open Microsoft.FSharp.Compiler.MSBuildResolver
+open Microsoft.FSharp.Compiler.ReferenceResolver
open Microsoft.FSharp.Compiler.PrettyNaming
open Microsoft.FSharp.Compiler.Parser
open Microsoft.FSharp.Compiler.Range
@@ -1171,9 +1171,6 @@ type TypeCheckInfo
/// Get the "reference resolution" tooltip for at a location
member scope.GetReferenceResolutionToolTipText(line,col) =
let pos = mkPos line col
- let lineIfExists(append) =
- if not(String.IsNullOrEmpty(append)) then append.Trim([|' '|])+"\n"
- else ""
let isPosMatch(pos, ar:AssemblyReference) : bool =
let isRangeMatch = (Range.rangeContainsPos ar.Range pos)
let isNotSpecialRange = (ar.Range <> rangeStartup) && (ar.Range <> range0) && (ar.Range <> rangeCmdArgs)
@@ -1193,38 +1190,7 @@ type TypeCheckInfo
match matches with
| resolved::_ // Take the first seen
| [resolved] ->
- let originalReferenceName = resolved.originalReference.Text
- let resolvedPath = // Don't show the resolved path if it is identical to what was referenced.
- if originalReferenceName = resolved.resolvedPath then String.Empty
- else resolved.resolvedPath
- let tip =
- match resolved.resolvedFrom with
- | AssemblyFolders ->
- lineIfExists(resolvedPath)
- + lineIfExists(resolved.fusionName)
- + (FSComp.SR.assemblyResolutionFoundByAssemblyFoldersKey())
- | AssemblyFoldersEx ->
- lineIfExists(resolvedPath)
- + lineIfExists(resolved.fusionName)
- + (FSComp.SR.assemblyResolutionFoundByAssemblyFoldersExKey())
- | TargetFrameworkDirectory ->
- lineIfExists(resolvedPath)
- + lineIfExists(resolved.fusionName)
- + (FSComp.SR.assemblyResolutionNetFramework())
- | Unknown ->
- // Unknown when resolved by plain directory search without help from MSBuild resolver.
- lineIfExists(resolvedPath)
- + lineIfExists(resolved.fusionName)
- | RawFileName ->
- lineIfExists(resolved.fusionName)
- | GlobalAssemblyCache ->
- lineIfExists(resolved.fusionName)
- + (FSComp.SR.assemblyResolutionGAC())+ "\n"
- + lineIfExists(resolved.redist)
- | Path _ ->
- lineIfExists(resolvedPath)
- + lineIfExists(resolved.fusionName)
-
+ let tip = resolved.prepareToolTip ()
FSharpToolTipText [FSharpToolTipElement.Single(tip.TrimEnd([|'\n'|]) ,FSharpXmlDoc.None)]
| [] -> FSharpToolTipText []
@@ -2058,7 +2024,7 @@ module Helpers =
&& FSharpProjectOptions.AreSubsumable(o1,o2)
// There is only one instance of this type, held in FSharpChecker
-type BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions) as self =
+type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions) as self =
// STATIC ROOT: FSharpLanguageServiceTestable.FSharpChecker.backgroundCompiler.reactor: The one and only Reactor
let reactor = Reactor.Singleton
let beforeFileChecked = Event()
@@ -2097,7 +2063,7 @@ type BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroun
let builderOpt, errorsAndWarnings =
IncrementalBuilder.TryCreateBackgroundBuilderForProjectOptions
- (frameworkTcImportsCache, scriptClosureCache.TryGet options, Array.toList options.ProjectFileNames,
+ (referenceResolver, frameworkTcImportsCache, scriptClosureCache.TryGet options, Array.toList options.ProjectFileNames,
Array.toList options.OtherOptions, projectReferences, options.ProjectDirectory,
options.UseScriptResolutionRules, options.IsIncompleteTypeCheckEnvironment, keepAssemblyContents, keepAllBackgroundResolutions)
@@ -2472,7 +2438,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, useSimpleResolution, useFsiAuxLib, new Lexhelp.LexResourceManager(), applyCompilerOptions)
+ let fas = LoadClosure.ComputeClosureOfSourceText(referenceResolver,filename, source, CodeContext.Editing, useSimpleResolution, useFsiAuxLib, new Lexhelp.LexResourceManager(), applyCompilerOptions)
let otherFlags =
[| yield "--noframework"; yield "--warn:3";
yield! otherFlags
@@ -2574,9 +2540,9 @@ type BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroun
[]
[]
// There is typically only one instance of this type in a Visual Studio process.
-type FSharpChecker(projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions) =
+type FSharpChecker(referenceResolver, projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions) =
- let backgroundCompiler = BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions)
+ let backgroundCompiler = BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions)
static let globalInstance = FSharpChecker.Create()
@@ -2591,15 +2557,13 @@ type FSharpChecker(projectCacheSize, keepAssemblyContents, keepAllBackgroundReso
areSame=AreSameForParsing3,
areSameForSubsumption=AreSubsumable3)
- static member Create() =
- new FSharpChecker(projectCacheSizeDefault,false,true)
-
/// Instantiate an interactive checker.
static member Create(?projectCacheSize, ?keepAssemblyContents, ?keepAllBackgroundResolutions) =
+ let referenceResolver = MSBuildReferenceResolver.Resolver
let keepAssemblyContents = defaultArg keepAssemblyContents false
let keepAllBackgroundResolutions = defaultArg keepAllBackgroundResolutions true
let projectCacheSizeReal = defaultArg projectCacheSize projectCacheSizeDefault
- new FSharpChecker(projectCacheSizeReal,keepAssemblyContents, keepAllBackgroundResolutions)
+ new FSharpChecker(referenceResolver, projectCacheSizeReal,keepAssemblyContents, keepAllBackgroundResolutions)
member ic.MatchBracesAlternate(filename, source, options) =
async {
diff --git a/src/fsharp/vs/service.fsi b/src/fsharp/vs/service.fsi
index 45bd2fa2d51..13fdbc5dfc4 100755
--- a/src/fsharp/vs/service.fsi
+++ b/src/fsharp/vs/service.fsi
@@ -336,9 +336,6 @@ type internal FSharpChecker =
/// If false, do not keep full intermediate checking results from background checking suitable for returning from GetBackgroundCheckResultsForFileInProject. This reduces memory usage.
static member Create : ?projectCacheSize: int * ?keepAssemblyContents: bool * ?keepAllBackgroundResolutions: bool -> FSharpChecker
- /// Create an instance of an FSharpChecker.
- static member Create : unit -> FSharpChecker
-
///
/// Parse a source code file, returning information about brace matching in the file.
/// Return an enumeration of the matching parenthetical tokens in the file.
diff --git a/tests/fsharpqa/testenv/src/FSharp.Compiler.Hosted/Compiler.fs b/tests/fsharpqa/testenv/src/FSharp.Compiler.Hosted/Compiler.fs
index 3b0493f62ae..6860ab06ea5 100644
--- a/tests/fsharpqa/testenv/src/FSharp.Compiler.Hosted/Compiler.fs
+++ b/tests/fsharpqa/testenv/src/FSharp.Compiler.Hosted/Compiler.fs
@@ -37,7 +37,8 @@ type CompilationResult =
/// in-proc version of fsc.exe
type FscCompiler() =
- let compiler = Microsoft.FSharp.Compiler.Driver.InProcCompiler()
+ let referenceResolver = Microsoft.FSharp.Compiler.MSBuildReferenceResolver.Resolver
+ let compiler = Microsoft.FSharp.Compiler.Driver.InProcCompiler(referenceResolver)
let emptyLocation =
{
diff --git a/vsintegration/tests/unittests/Tests.LanguageService.Script.fs b/vsintegration/tests/unittests/Tests.LanguageService.Script.fs
index eea41cd6031..de6cb045247 100644
--- a/vsintegration/tests/unittests/Tests.LanguageService.Script.fs
+++ b/vsintegration/tests/unittests/Tests.LanguageService.Script.fs
@@ -964,7 +964,7 @@ type UsingMSBuild() as this =
let fileContent = "#r @\"" + fullyqualifiepathtoddll + "\""
let marker = "#r @\"" + fullyqualifiepathtoddll.Substring(0,fullyqualifiepathtoddll.Length/2) // somewhere in the middle of the string
this.AssertQuickInfoContainsAtEndOfMarkerInFsxFile fileContent marker expectedtooltip
- this.AssertQuickInfoNotContainsAtEndOfMarkerInFsxFile fileContent marker ".dll"
+ //this.AssertQuickInfoNotContainsAtEndOfMarkerInFsxFile fileContent marker ".dll"
[]
member public this.``Fsx.InvalidHashReference.ShouldBeASquiggle.Bug3012``() =
diff --git a/vsintegration/tests/unittests/Tests.Watson.fs b/vsintegration/tests/unittests/Tests.Watson.fs
index 00013946b78..e305f3d9814 100644
--- a/vsintegration/tests/unittests/Tests.Watson.fs
+++ b/vsintegration/tests/unittests/Tests.Watson.fs
@@ -23,7 +23,7 @@ type Check =
File.Delete("watson-test.fs")
File.WriteAllText("watson-test.fs", "// Hello watson" )
let argv = [| "--simulateException:"+simulationCode; "watson-test.fs"|]
- let _code = Microsoft.FSharp.Compiler.Driver.mainCompile (argv, false, Microsoft.FSharp.Compiler.ErrorLogger.QuitProcessExiter)
+ let _code = Microsoft.FSharp.Compiler.Driver.mainCompile (argv, Microsoft.FSharp.Compiler.MSBuildReferenceResolver.Resolver, false, Microsoft.FSharp.Compiler.ErrorLogger.QuitProcessExiter)
()
with
| :? 'TException as e ->