-
Notifications
You must be signed in to change notification settings - Fork 840
Add use refassemblies switch to fsi #6585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2141,6 +2141,7 @@ type TcConfigBuilder = | |
|
|
||
| /// When false FSI will lock referenced assemblies requiring process restart, false = disable Shadow Copy false (*default*) | ||
| mutable shadowCopyReferences: bool | ||
| mutable useSdkRefs: bool | ||
|
|
||
| /// A function to call to try to get an object that acts as a snapshot of the metadata section of a .NET binary, | ||
| /// and from which we can read the metadata. Only used when metadataOnly=true. | ||
|
|
@@ -2280,6 +2281,7 @@ type TcConfigBuilder = | |
| exename = None | ||
| copyFSharpCore = CopyFSharpCoreFlag.No | ||
| shadowCopyReferences = false | ||
| useSdkRefs = true | ||
| tryGetMetadataSnapshot = (fun _ -> None) | ||
| internalTestSpanStackReferring = false | ||
| noConditionalErasure = false | ||
|
|
@@ -2747,6 +2749,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = | |
| member x.emitDebugInfoInQuotations = data.emitDebugInfoInQuotations | ||
| member x.copyFSharpCore = data.copyFSharpCore | ||
| member x.shadowCopyReferences = data.shadowCopyReferences | ||
| member x.useSdkRefs = data.useSdkRefs | ||
| member x.tryGetMetadataSnapshot = data.tryGetMetadataSnapshot | ||
| member x.internalTestSpanStackReferring = data.internalTestSpanStackReferring | ||
| member x.noConditionalErasure = data.noConditionalErasure | ||
|
|
@@ -2795,6 +2798,11 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = | |
| if Directory.Exists runtimeRootWPF then | ||
| yield runtimeRootWPF // PresentationCore.dll is in C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF | ||
|
|
||
| match getFrameworkRefsPackDirectory with | ||
| | Some path when Directory.Exists(path) -> | ||
| yield path | ||
| | _ -> () | ||
|
|
||
| | ResolutionEnvironment.EditingOrCompilation _ -> | ||
| #if ENABLE_MONO_SUPPORT | ||
| if runningOnMono then | ||
|
|
@@ -2857,13 +2865,14 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = | |
| /// | ||
| /// Returning true may mean that the file is locked and/or placed into the | ||
| /// 'framework' reference set that is potentially shared across multiple compilations. | ||
| member tcConfig.IsSystemAssembly (filename: string) = | ||
| try | ||
| FileSystem.SafeExists filename && | ||
| member tcConfig.IsSystemAssembly (filename: string) = | ||
| try | ||
| FileSystem.SafeExists filename && | ||
| ((tcConfig.GetTargetFrameworkDirectories() |> List.exists (fun clrRoot -> clrRoot = Path.GetDirectoryName filename)) || | ||
| (systemAssemblies.Contains(fileNameWithoutExtension filename))) | ||
| (systemAssemblies.Contains (fileNameWithoutExtension filename)) || | ||
| isInReferenceAssemblyPackDirectory filename) | ||
| with _ -> | ||
| false | ||
| false | ||
|
|
||
| // This is not the complete set of search paths, it is just the set | ||
| // that is special to F# (as compared to MSBuild resolution) | ||
|
|
@@ -3506,18 +3515,16 @@ type TcAssemblyResolutions(tcConfig: TcConfig, results: AssemblyResolution list, | |
| TcConfig.TryResolveLibsUsingMSBuildRules (tcConfig, assemblyList, rangeStartup, ResolveAssemblyReferenceMode.ReportErrors) | ||
| TcAssemblyResolutions(tcConfig, resolved, unresolved @ knownUnresolved) | ||
|
|
||
|
|
||
| static member GetAllDllReferences (tcConfig: TcConfig) = | ||
| [ | ||
| static member GetAllDllReferences (tcConfig: TcConfig) = [ | ||
| let primaryReference = tcConfig.PrimaryAssemblyDllReference() | ||
| yield primaryReference | ||
| //yield primaryReference | ||
|
|
||
| if not tcConfig.compilingFslib then | ||
| yield tcConfig.CoreLibraryDllReference() | ||
|
|
||
| let assumeDotNetFramework = primaryReference.SimpleAssemblyNameIs("mscorlib") | ||
| if tcConfig.framework then | ||
| for s in defaultReferencesForScriptsAndOutOfProjectSources assumeDotNetFramework do | ||
| if tcConfig.framework then | ||
| for s in defaultReferencesForScriptsAndOutOfProjectSources assumeDotNetFramework tcConfig.useSdkRefs do | ||
| yield AssemblyReference(rangeStartup, (if s.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) then s else s+".dll"), None) | ||
|
|
||
| if tcConfig.useFsiAuxLib then | ||
|
|
@@ -4552,8 +4559,14 @@ type TcImports(tcConfigP: TcConfigProvider, initialResolutions: TcAssemblyResolu | |
|
|
||
| // Note: TcImports are disposable - the caller owns this object and must dispose | ||
| let frameworkTcImports = new TcImports(tcConfigP, tcResolutions, None, None) | ||
|
|
||
| let primaryAssemblyReference = tcConfig.PrimaryAssemblyDllReference() | ||
|
|
||
| // Fetch the primaryAssembly from the referenced assemblies otherwise | ||
| let primaryAssemblyReference = | ||
| let path = frameworkDLLs |> List.tryFind(fun dll -> String.Compare(Path.GetFileNameWithoutExtension(dll.resolvedPath), tcConfig.primaryAssembly.Name, StringComparison.OrdinalIgnoreCase) = 0) | ||
| match path with | ||
| | Some p -> AssemblyReference(range0, p.resolvedPath, None) | ||
| | None -> tcConfig.PrimaryAssemblyDllReference() | ||
|
|
||
| let primaryAssemblyResolution = frameworkTcImports.ResolveAssemblyReference(ctok, primaryAssemblyReference, ResolveAssemblyReferenceMode.ReportErrors) | ||
| let! primaryAssem = frameworkTcImports.RegisterAndImportReferencedAssemblies(ctok, primaryAssemblyResolution) | ||
| let primaryScopeRef = | ||
|
|
@@ -4568,7 +4581,7 @@ type TcImports(tcConfigP: TcConfigProvider, initialResolutions: TcAssemblyResolu | |
| let! _assemblies = frameworkTcImports.RegisterAndImportReferencedAssemblies (ctok, tcResolutions.GetAssemblyResolutions()) | ||
|
|
||
| // These are the DLLs we can search for well-known types | ||
| let sysCcus = | ||
| let sysCcus = | ||
| [| for ccu in frameworkTcImports.GetCcusInDeclOrder() do | ||
| //printfn "found sys ccu %s" ccu.AssemblyName | ||
| yield ccu |] | ||
|
|
@@ -4913,8 +4926,8 @@ module private ScriptPreprocessClosure = | |
| filename: string, codeContext, | ||
| useSimpleResolution, useFsiAuxLib, | ||
| basicReferences, applyCommandLineArgs, | ||
| assumeDotNetFramework, tryGetMetadataSnapshot, | ||
| reduceMemoryUsage) = | ||
| assumeDotNetFramework, useSdkRefs, | ||
| tryGetMetadataSnapshot, reduceMemoryUsage) = | ||
|
|
||
| let projectDir = Path.GetDirectoryName filename | ||
| let isInteractive = (codeContext = CodeContext.CompilationAndEvaluation) | ||
|
|
@@ -4929,7 +4942,7 @@ module private ScriptPreprocessClosure = | |
| applyCommandLineArgs tcConfigB | ||
|
|
||
| match basicReferences with | ||
| | None -> (basicReferencesForScriptLoadClosure useFsiAuxLib assumeDotNetFramework) |> List.iter(fun f->tcConfigB.AddReferencedAssemblyByPath(range0, f)) // Add script references | ||
| | None -> (basicReferencesForScriptLoadClosure useFsiAuxLib useSdkRefs assumeDotNetFramework) |> 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 <- | ||
|
|
@@ -4942,8 +4955,10 @@ module private ScriptPreprocessClosure = | |
| // Indicates that there are some references not in basicReferencesForScriptLoadClosure which should | ||
| // be added conditionally once the relevant version of mscorlib.dll has been detected. | ||
| tcConfigB.implicitlyResolveAssemblies <- false | ||
| tcConfigB.useSdkRefs <- useSdkRefs | ||
|
|
||
| TcConfig.Create(tcConfigB, validate=true) | ||
|
|
||
| let ClosureSourceOfFilename(filename, m, inputCodePage, parseRequired) = | ||
| try | ||
| let filename = FileSystem.GetFullPathShim filename | ||
|
|
@@ -5111,12 +5126,13 @@ module private ScriptPreprocessClosure = | |
|
|
||
| /// Given source text, find the full load closure. Used from service.fs, when editing a script file | ||
| let GetFullClosureOfScriptText | ||
| (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, | ||
| filename, sourceText, | ||
| codeContext, useSimpleResolution, useFsiAuxLib, | ||
| lexResourceManager: Lexhelp.LexResourceManager, | ||
| (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, | ||
KevinRansom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| filename, sourceText, codeContext, | ||
| useSimpleResolution, useFsiAuxLib, useSdkRefs, | ||
| lexResourceManager: Lexhelp.LexResourceManager, | ||
KevinRansom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| applyCommmandLineArgs, assumeDotNetFramework, | ||
| tryGetMetadataSnapshot, reduceMemoryUsage) = | ||
| tryGetMetadataSnapshot, reduceMemoryUsage) = | ||
|
|
||
| // 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 | ||
|
|
@@ -5126,7 +5142,7 @@ module private ScriptPreprocessClosure = | |
| CreateScriptTextTcConfig(legacyReferenceResolver, defaultFSharpBinariesDir, | ||
| filename, codeContext, useSimpleResolution, | ||
| useFsiAuxLib, None, applyCommmandLineArgs, assumeDotNetFramework, | ||
| tryGetMetadataSnapshot, reduceMemoryUsage) | ||
| useSdkRefs, tryGetMetadataSnapshot, reduceMemoryUsage) | ||
|
|
||
| let resolutions0, _unresolvedReferences = GetAssemblyResolutionInformation(ctok, tcConfig) | ||
| let references0 = resolutions0 |> List.map (fun r->r.originalReference.Range, r.resolvedPath) |> Seq.distinct |> List.ofSeq | ||
|
|
@@ -5135,7 +5151,8 @@ module private ScriptPreprocessClosure = | |
| let tcConfig = | ||
| CreateScriptTextTcConfig(legacyReferenceResolver, defaultFSharpBinariesDir, filename, | ||
| codeContext, useSimpleResolution, useFsiAuxLib, Some references0, | ||
| applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) | ||
| applyCommmandLineArgs, assumeDotNetFramework, useSdkRefs, | ||
| tryGetMetadataSnapshot, reduceMemoryUsage) | ||
|
|
||
| let closureSources = [ClosureSource(filename, range0, sourceText, true)] | ||
| let closureFiles, tcConfig = FindClosureFiles(closureSources, tcConfig, codeContext, lexResourceManager) | ||
|
|
@@ -5161,15 +5178,15 @@ type LoadClosure with | |
| /// A temporary TcConfig is created along the way, is why this routine takes so many arguments. We want to be sure to use exactly the | ||
| /// same arguments as the rest of the application. | ||
| static member ComputeClosureOfScriptText | ||
| (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, | ||
| filename: string, sourceText:ISourceText, codeContext, useSimpleResolution: bool, | ||
| useFsiAuxLib, lexResourceManager: Lexhelp.LexResourceManager, | ||
| applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage): LoadClosure = | ||
| (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lots of trailing whitespace |
||
| filename: string, sourceText: ISourceText, codeContext, useSimpleResolution: bool, | ||
| useFsiAuxLib, useSdkRefs, lexResourceManager: Lexhelp.LexResourceManager, | ||
| applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) = | ||
|
|
||
| use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parse | ||
| ScriptPreprocessClosure.GetFullClosureOfScriptText | ||
| (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename, sourceText, | ||
| codeContext, useSimpleResolution, useFsiAuxLib, lexResourceManager, | ||
| (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename, sourceText, | ||
| codeContext, useSimpleResolution, useFsiAuxLib, useSdkRefs, lexResourceManager, | ||
| applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) | ||
|
|
||
| /// Analyze a set of script files and find the closure of their references. | ||
|
|
@@ -5479,4 +5496,4 @@ let TypeCheckClosedInputSet (ctok, checkForErrors, tcConfig, tcImports, tcGlobal | |
|
|
||
| // Existing public APIs delegate to newer implementations | ||
| let GetFSharpCoreLibraryName () = getFSharpCoreLibraryName | ||
| let DefaultReferencesForScriptsAndOutOfProjectSources assumeDotNetFramework = defaultReferencesForScriptsAndOutOfProjectSources assumeDotNetFramework | ||
| let DefaultReferencesForScriptsAndOutOfProjectSources assumeDotNetFramework = defaultReferencesForScriptsAndOutOfProjectSources assumeDotNetFramework false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.