Skip to content

FSI integration is broken #465

@baronfel

Description

@baronfel

Right now FSI fails in Ionide because we're computing the .Net Framework reference set for parsing script files instead of the proper reference set for .Net Core.

We should fix this, and the route we've chosen for now is to investigate the use of the BackgroundCompiler.GetProjectOptionsFromScript method in FCS, specifically using the useSdkRefs and assumeDotNetFramework parameters.

This works, mostly. Results are summarized in the following table:

TFM assumeDotNetFramework useSdkRefs Ref Set Ok?
net462 true false Yes
net462 false true No (no netstandard.dll
netcoreapp2.1 true false No (netfx references are no bueno)
netcoreapp2.1 false true Sorta (missing mscorlib reference then ok)
netcoreapp3.0 true false No (same as netcoreapp2.1)
netcoreapp3.0 false true Yes (all refs from pack directory, which includes mscorlib)

On .net core, at least 2.1. The code paths all converge onto this function. This function seems to work for netfx and netcoreapp > 3.0 TFMs, because either desktop refs are ok or all necessary refs are in the 'pack' directories starting with 3.0.

For 2.x, once an mscorlib is added to the project options, then typechecking works. The problem seems to be that some deps are not available that the user might expect, ie System.Diagnostics.Process. I did some work to find the set of assemblies found in dotnet fsi:

dotnet fsi reference set
 [("/usr/local/share/dotnet/shared/Microsoft.NETCore.App/3.0.0",
    ["System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e";
     "System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Runtime.Extensions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Console, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Threading, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Text.Encoding.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51";
     "System.Collections, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "Microsoft.Win32.Primitives, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Diagnostics.Process, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.ComponentModel.Primitives, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.IO.FileSystem, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Collections.Concurrent, Version=4.0.14.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Resources.ResourceManager, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Threading.Thread, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Memory, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51";
     "System.Threading.Tasks, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Threading.ThreadPool, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Linq, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Buffers, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51";
     "System.Diagnostics.TraceSource, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Runtime.InteropServices, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Reflection.Emit, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Reflection.Emit.ILGeneration, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Reflection.Primitives, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Reflection, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Runtime.Numerics, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Diagnostics.Debug, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Linq.Expressions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Net.Requests, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Net.WebClient, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51";
     "System.ComponentModel.EventBasedAsync, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Diagnostics.Tracing, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Text.RegularExpressions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Reflection.Metadata, Version=1.4.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Collections.Immutable, Version=1.2.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Collections.NonGeneric, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Collections.Specialized, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.ComponentModel, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.Diagnostics.StackTrace, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.IO.MemoryMappedFiles, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "System.IO.Compression, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"]);
   ("/usr/local/share/dotnet/sdk/3.0.100/FSharp",
    ["fsi, Version=10.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "FSharp.Core, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "FSharp.Compiler.Private, Version=10.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
     "FSharp.Compiler.Interactive.Settings, Version=10.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"]);

and the ones discovered in netcoreapp2.1 _that aren't in dotnet fsi`:

netcoreapp2.1 - dotnet fsi assemblies
System.ComponentModel.TypeConverter
System.Data.Common
System.Diagnostics.Contracts
System.Diagnostics.DiagnosticSource
System.Diagnostics.FileVersionInfo
System.Diagnostics.TextWriterTraceListener
System.Diagnostics.Tools
System.Drawing.Primitives
System.IO.Compression.Brotli
System.IO.Compression.ZipFile
System.IO.FileSystem.DriveInfo
System.IO.FileSystem.Watcher
System.IO.IsolatedStorage
System.IO.Pipes
System.Linq.Parallel
System.Linq.Queryable
System.Net.Http
System.Net.HttpListener
System.Net.Mail
System.Net.NameResolution
System.Net.NetworkInformation
System.Net.Ping
System.Net.Primitives
System.Net.Security
System.Net.ServicePoint
System.Net.Sockets
System.Net.WebHeaderCollection
System.Net.WebProxy
System.Net.WebSockets
System.Net.WebSockets.Client
System.Numerics.Vectors
System.ObjectModel
System.Private.DataContractSerialization
System.Private.Uri
System.Private.Xml
System.Private.Xml.Linq
System.Reflection.DispatchProxy
System.Reflection.Emit.Lightweight
System.Resources.Writer
System.Runtime.CompilerServices.Unsafe
System.Runtime.CompilerServices.VisualC
System.Runtime.InteropServices.RuntimeInformation
System.Runtime.Serialization.Formatters
System.Runtime.Serialization.Json
System.Runtime.Serialization.Primitives
System.Runtime.Serialization.Xml
System.Security.Claims
System.Security.Cryptography.Algorithms
System.Security.Cryptography.Csp
System.Security.Cryptography.Encoding
System.Security.Cryptography.Primitives
System.Security.Cryptography.X509Certificates
System.Security.Principal
System.Security.Principal.Windows
System.Threading.Overlapped
System.Threading.Tasks.Parallel
System.Threading.Timer
System.Transactions.Local
System.Web.HttpUtility
System.Xml.ReaderWriter
System.Xml.XDocument
System.Xml.XPath
System.Xml.XPath.XDocument
System.Xml.XmlSerializer

And that's where we are right now. We have a working proof of concept, but we'd like to
a) PR adding mscorlib to the default reference set, and
b) figure out which assemblies need to be added to the netcoreapp2.x reference set.

Solving this in a way that includes FSharp.Compiler.Interactive.Settings in the references set all the time would also fix #227.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions