Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
working
  • Loading branch information
KevinRansom committed Apr 19, 2019
commit 7d7effcbdad9e9b74fb2c3dfb18824be0a27c4e8
23 changes: 15 additions & 8 deletions src/fsharp/CompileOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2865,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)
Expand Down Expand Up @@ -4558,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 =
Expand All @@ -4574,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 |]
Expand Down
27 changes: 22 additions & 5 deletions src/fsharp/DotNetFrameworkDependencies.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,36 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
| _, -1 -> None
| pos, length -> Some ("netcoreapp" + file.Substring(pos, length))

let getFrameworkRefsPackDirectory =
//let netCoreRefDirectory = Path.Combine(Path.GetDirectoryName(getFSharpCompilerLocation), "../../../packs/Microsoft.NETCore.App.Ref/$(RefVersion)/ref/$(tfm)

let getFrameworkRefsPackDirectoryPath =
match executionTfm with
| Some tfm ->
| Some _ ->
let appRefDir = Path.Combine(getFSharpCompilerLocation, "../../../packs/Microsoft.NETCore.App.Ref")
if Directory.Exists(appRefDir) then
Some appRefDir
else
None
| _ -> None

let isInReferenceAssemblyPackDirectory filename =
match getFrameworkRefsPackDirectoryPath with
| Some appRefDir ->
let path = Path.GetDirectoryName(filename)
path.StartsWith(appRefDir, StringComparison.OrdinalIgnoreCase)
| _ -> false

let getFrameworkRefsPackDirectory =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it should be a function rather than a computation. Also have /// comments on all of these would be good please

match executionTfm, getFrameworkRefsPackDirectoryPath with
| Some tfm, Some appRefDir ->
try
let refDirs = Directory.GetDirectories(appRefDir)
let versionPath = refDirs |> Array.sortWith (versionCompare) |> Array.last
Some(Path.Combine(versionPath, "ref", tfm))
with | _ -> None
| _ -> None



let getDependenciesOf assemblyReferences =
let assemblies = new Dictionary<string, string>()

Expand Down Expand Up @@ -216,13 +234,12 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
yield getDefaultFSharpCoreReference
if useFsiAuxLib then yield getFsiLibraryName
]
with | _ -> printfn "None"; List.empty<string>
with | _ -> List.empty<string>
| None ->
getImplementationReferences ()
else
getImplementationReferences ()
dependencies
results |> Seq.iter(fun f-> printfn "%s" f)
results

let defaultReferencesForScriptsAndOutOfProjectSources assumeDotNetFramework useSdkRefs =
Expand Down