Skip to content

Commit 83be495

Browse files
authored
factor out reference resolution (#1593)
* factor out reference resolution * adjut test for quickinfo change
1 parent 98e8c9a commit 83be495

File tree

20 files changed

+258
-370
lines changed

20 files changed

+258
-370
lines changed

src/fsharp/CompileOps.fs

Lines changed: 41 additions & 58 deletions
Large diffs are not rendered by default.

src/fsharp/CompileOps.fsi

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ open Microsoft.FSharp.Compiler.Tast
1818
open Microsoft.FSharp.Compiler.Tastops
1919
open Microsoft.FSharp.Compiler.Lib
2020
open Microsoft.FSharp.Compiler.Infos
21-
open Microsoft.FSharp.Compiler.MSBuildResolver
21+
open Microsoft.FSharp.Compiler.ReferenceResolver
2222
open Microsoft.FSharp.Compiler.TcGlobals
2323
open Microsoft.FSharp.Core.CompilerServices
2424
#if EXTENSIONTYPING
@@ -183,12 +183,8 @@ type AssemblyResolution =
183183
originalReference : AssemblyReference
184184
/// Path to the resolvedFile
185185
resolvedPath : string
186-
/// Search path used to find this spot.
187-
resolvedFrom : ResolvedFrom
188-
/// The qualified name of the assembly
189-
fusionName : string
190-
/// Name of the redist, if any, that the assembly was found in.
191-
redist : string
186+
/// Create the tooltip texxt for the assembly reference
187+
prepareToolTip : unit -> string
192188
/// Whether or not this is an installed system assembly (for example, System.dll)
193189
sysdir : bool
194190
// Lazily populated ilAssemblyRef for this reference.
@@ -241,7 +237,7 @@ type TcConfigBuilder =
241237
mutable implicitOpens: string list
242238
mutable useFsiAuxLib: bool
243239
mutable framework: bool
244-
mutable resolutionEnvironment : Microsoft.FSharp.Compiler.MSBuildResolver.ResolutionEnvironment
240+
mutable resolutionEnvironment : ReferenceResolver.ResolutionEnvironment
245241
mutable implicitlyResolveAssemblies : bool
246242
mutable addVersionSpecificFrameworkReferences : bool
247243
/// Set if the user has explicitly turned indentation-aware syntax on/off
@@ -268,9 +264,6 @@ type TcConfigBuilder =
268264
mutable checkOverflow:bool
269265
mutable showReferenceResolutions:bool
270266
mutable outputFile : string option
271-
mutable resolutionFrameworkRegistryBase : string
272-
mutable resolutionAssemblyFoldersSuffix : string
273-
mutable resolutionAssemblyFoldersConditions : string
274267
mutable platform : ILPlatform option
275268
mutable prefer32Bit : bool
276269
mutable useSimpleResolution : bool
@@ -314,6 +307,7 @@ type TcConfigBuilder =
314307
mutable win32manifest : string
315308
mutable includewin32manifest : bool
316309
mutable linkResources : string list
310+
mutable referenceResolver: ReferenceResolver.Resolver
317311
mutable showFullPaths : bool
318312
mutable errorStyle : ErrorStyle
319313
mutable utf8output : bool
@@ -365,6 +359,7 @@ type TcConfigBuilder =
365359
}
366360

367361
static member CreateNew :
362+
referenceResolver: ReferenceResolver.Resolver *
368363
defaultFSharpBinariesDir: string *
369364
optimizeForMemory: bool *
370365
implicitIncludeDir: string *
@@ -422,9 +417,6 @@ type TcConfig =
422417
member checkOverflow:bool
423418
member showReferenceResolutions:bool
424419
member outputFile : string option
425-
member resolutionFrameworkRegistryBase : string
426-
member resolutionAssemblyFoldersSuffix : string
427-
member resolutionAssemblyFoldersConditions : string
428420
member platform : ILPlatform option
429421
member prefer32Bit : bool
430422
member useSimpleResolution : bool
@@ -776,7 +768,7 @@ type LoadClosure =
776768
RootWarnings : PhasedError list }
777769

778770
// Used from service.fs, when editing a script file
779-
static member ComputeClosureOfSourceText : filename: string * source: string * implicitDefines:CodeContext * useSimpleResolution: bool * useFsiAuxLib: bool * lexResourceManager: Lexhelp.LexResourceManager * applyCompilerOptions: (TcConfigBuilder -> unit) -> LoadClosure
771+
static member ComputeClosureOfSourceText : referenceResolver: ReferenceResolver.Resolver * filename: string * source: string * implicitDefines:CodeContext * useSimpleResolution: bool * useFsiAuxLib: bool * lexResourceManager: Lexhelp.LexResourceManager * applyCompilerOptions: (TcConfigBuilder -> unit) -> LoadClosure
780772

781773
/// Used from fsi.fs and fsc.fs, for #load and command line. The resulting references are then added to a TcConfig.
782774
static member ComputeClosureOfSourceFiles : tcConfig:TcConfig * (string * range) list * implicitDefines:CodeContext * useDefaultScriptingReferences : bool * lexResourceManager : Lexhelp.LexResourceManager -> LoadClosure

src/fsharp/CompileOptions.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,9 +856,9 @@ let internalFlags (tcConfigB:TcConfigBuilder) =
856856
CompilerOption("implicitresolution", tagNone, OptionUnit (fun _ -> tcConfigB.implicitlyResolveAssemblies <- true), Some(InternalCommandLineOption("--implicitresolution", rangeCmdArgs)), None)
857857

858858
CompilerOption("resolutions", tagNone, OptionUnit (fun () -> tcConfigB.showReferenceResolutions <- true), Some(InternalCommandLineOption("", rangeCmdArgs)), None) // "Display assembly reference resolution information")
859-
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")
860-
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]")
861-
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")
859+
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")
860+
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]")
861+
CompilerOption("resolutionassemblyfoldersconditions", tagString, OptionString (fun _ -> ()), Some(InternalCommandLineOption("resolutionassemblyfoldersconditions", rangeCmdArgs)), None) // "Additional reference resolution conditions. For example \"OSVersion=5.1.2600.0,PlatformID=id")
862862
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)")
863863
CompilerOption("alwayscallvirt",tagNone,OptionSwitch(callVirtSwitch tcConfigB),Some(InternalCommandLineOption("alwayscallvirt",rangeCmdArgs)), None)
864864
CompilerOption("nodebugdata",tagNone, OptionUnit (fun () -> tcConfigB.noDebugData<-true),Some(InternalCommandLineOption("--nodebugdata",rangeCmdArgs)), None)

src/fsharp/FSharp.Compiler-proto/FSharp.Compiler-proto.fsproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,8 @@
140140
<Compile Include="..\..\absil\bytes.fs">
141141
<Link>bytes.fs</Link>
142142
</Compile>
143-
<Compile Include="..\ReferenceResolution.fsi">
144-
<Link>ReferenceResolution.fsi</Link>
145-
</Compile>
146-
<Compile Include="..\ReferenceResolution.fs">
147-
<Link>ReferenceResolution.fs</Link>
143+
<Compile Include="..\ReferenceResolver.fs">
144+
<Link>ReferenceResolver.fs</Link>
148145
</Compile>
149146
<Compile Include="..\..\absil\il.fsi">
150147
<Link>il.fsi</Link>
@@ -449,6 +446,9 @@
449446
<Compile Include="..\fsc.fs">
450447
<Link>fsc.fs</Link>
451448
</Compile>
449+
<Compile Include="..\MSBuildReferenceResolver.fs">
450+
<Link>MSBuildReferenceResolver.fs</Link>
451+
</Compile>
452452
</ItemGroup>
453453
<ItemGroup>
454454
<Reference Include="mscorlib" />

src/fsharp/FSharp.Compiler/FSharp.Compiler.fsproj

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,8 @@
156156
<Compile Include="..\ErrorResolutionHints.fs">
157157
<Link>ErrorLogging\ErrorResolutionHints.fs</Link>
158158
</Compile>
159-
<Compile Include="..\ReferenceResolution.fsi">
160-
<Link>ReferenceResolution\ReferenceResolution.fsi</Link>
161-
</Compile>
162-
<Compile Include="..\ReferenceResolution.fs">
163-
<Link>ReferenceResolution\ReferenceResolution.fs</Link>
159+
<Compile Include="..\ReferenceResolver.fs">
160+
<Link>ReferenceResolution\ReferenceResolver.fs</Link>
164161
</Compile>
165162
<FsLex Include="..\..\absil\illex.fsl">
166163
<OtherFlags>--lexlib Internal.Utilities.Text.Lexing</OtherFlags>
@@ -489,11 +486,8 @@
489486
<Compile Include="..\fsc.fs">
490487
<Link>Driver\fsc.fs</Link>
491488
</Compile>
492-
<Compile Include="..\vs\IncrementalBuild.fsi">
493-
<Link>Driver\IncrementalBuild.fsi</Link>
494-
</Compile>
495-
<Compile Include="..\vs\IncrementalBuild.fs">
496-
<Link>Driver\IncrementalBuild.fs</Link>
489+
<Compile Include="..\MSBuildReferenceResolver.fs">
490+
<Link>MSBuildReferenceResolver.fs</Link>
497491
</Compile>
498492
<Compile Include="InternalsVisibleTo.fs" Condition="'$(TargetFramework)' != 'coreclr'">
499493
<Link>InternalsVisibleTo.fs</Link>

src/fsharp/FSharp.LanguageService.Compiler/FSharp.LanguageService.Compiler.fsproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,8 @@
160160
<Compile Include="..\ErrorResolutionHints.fs">
161161
<Link>ErrorLogging\ErrorResolutionHints.fs</Link>
162162
</Compile>
163-
<Compile Include="..\ReferenceResolution.fsi">
164-
<Link>ReferenceResolution\ReferenceResolution.fsi</Link>
165-
</Compile>
166-
<Compile Include="..\ReferenceResolution.fs">
167-
<Link>ReferenceResolution\ReferenceResolution.fs</Link>
163+
<Compile Include="..\ReferenceResolver.fs">
164+
<Link>ReferenceResolution\ReferenceResolver.fs</Link>
168165
</Compile>
169166
<FsLex Include="..\..\absil\illex.fsl">
170167
<OtherFlags>--lexlib Internal.Utilities.Text.Lexing</OtherFlags>
@@ -544,6 +541,9 @@
544541
<Compile Include="..\vs\ServiceUntypedParse.fs">
545542
<Link>Service/ServiceUntypedParse.fs</Link>
546543
</Compile>
544+
<Compile Include="..\MSBuildReferenceResolver.fs">
545+
<Link>Service/MSBuildReferenceResolver.fs</Link>
546+
</Compile>
547547
<Compile Include="..\vs\service.fsi">
548548
<Link>Service/service.fsi</Link>
549549
</Compile>

0 commit comments

Comments
 (0)