Skip to content
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

Merge master to feature/string-interp #9648

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 16 additions & 3 deletions src/fsharp/DotNetFrameworkDependencies.fs
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,23 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
if not (assemblies.ContainsKey(referenceName)) then
try
if File.Exists(path) then
// System.Private.CoreLib doesn't load with reflection
if referenceName = "System.Private.CoreLib" then
match referenceName with
| "System.Runtime.WindowsRuntime"
| "System.Runtime.WindowsRuntime.UI.Xaml" ->
// The Windows compatibility pack included in the runtime contains a reference to
// System.Runtime.WindowsRuntime, but to properly use that type the runtime also needs a
// reference to the Windows.md meta-package, which isn't referenced by default. To avoid
// a bug where types from `Windows, Version=255.255.255.255` can't be found we're going to
// not default include this assembly. It can still be manually referenced if it's needed
// via the System.Runtime.WindowsRuntime NuGet package.
//
// In the future this branch can be removed because WinRT support is being removed from the
// .NET 5 SDK (https://github.com/dotnet/runtime/pull/36715)
()
| "System.Private.CoreLib" ->
// System.Private.CoreLib doesn't load with reflection
assemblies.Add(referenceName, path)
else
| _ ->
try
let asm = System.Reflection.Assembly.LoadFrom(path)
assemblies.Add(referenceName, path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ type CompletionTests() =
Assert.AreEqual(1, matchingCompletions.Length)
} |> Async.StartAsTask :> Task

[<Test>]
member _.``Completions from types that try to pull in Windows runtime extensions``() =
async {
use script = new FSharpScript()
script.Eval("open System") |> ignoreValue
script.Eval("let t = TimeSpan.FromHours(1.0)") |> ignoreValue
let! completions = script.GetCompletionItems("t.", 1, 2)
let matchingCompletions = completions |> Array.filter (fun d -> d.Name = "TotalHours")
Assert.AreEqual(1, matchingCompletions.Length)
} |> Async.StartAsTask :> Task

[<Test>]
member _.``Static member completions``() =
async {
Expand Down