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

Add use refassemblies switch to fsi #6585

Merged
merged 4 commits into from
Apr 23, 2019

Conversation

KevinRansom
Copy link
Member

With DotNet Core 3.0, we will be shipping a set of reference assemblies that matches the default target framework for the shipped dotnet cli. The NetSdk team are updating the compile time build to make use of these.

This PR adds an additional switch to FSI, that will have fsi compile against this set of reference assemblies by default rather than the implementation assemblies.

This is important because with versions of the cli revving frequently and supporting multiple platforms, we want to ensure that scripts run against a consistent platform. Implementation assemblies may have a bigger public surface, and one that is not consistent across platforms or between versions.

E.g ..

Internal.Runtime.InteropServices.WindowsRuntime.ExceptionSupport is a public internal implementation type, that would be risky to rely on.

> let t=typeof<Internal.Runtime.InteropServices.WindowsRuntime.ExceptionSupport>;;
val t : System.Type =
  Internal.Runtime.InteropServices.WindowsRuntime.ExceptionSupport

With this feature:

> let t = typeof<Internal.Resources.WindowsRuntimeResourceManagerBase.WindowsRuntimeResourceManagerBase>;;

  let t = typeof<Internal.Resources.WindowsRuntimeResourceManagerBase.WindowsRuntimeResourceManagerBase>;;
  ---------------^^^^^^^^

stdin(1,16): error FS0039: The namespace or module 'Internal' is not defined.

The dotnet framework contracts are defined by the framework definitions: DotNetStandard1.6 and up, and DotNetCoreApp1.0 and up and similar net461, net472 etc … not by the contents of any assemblies in the coreclr runtime directory.

  1. Enabled by default use refs on DotNet Core 3.0 runtime
  2. Always run scripts, against the netcoreapp version that matches the executing fsi.
  3. It does not provide a downgrade switch. We can consider a downgrade switch for a future feature when the deployment story for these packages has stabilized.
  4. To disable use --usesdkrefs-
  5. If refs not supported, I.e. netcoreapp2.1 or 2.2 then falls back to implementation assemblies.
  6. Desktop / Mono implementaions of fsi, do what they did before … use implementation assemblies, there is no switch.

Kevin

@KevinRansom KevinRansom requested review from dsyme and brettfo April 19, 2019 19:48
filename: string, sourceText:ISourceText, codeContext, useSimpleResolution: bool,
useFsiAuxLib, lexResourceManager: Lexhelp.LexResourceManager,
applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage): LoadClosure =
(ctok, legacyReferenceResolver, defaultFSharpBinariesDir,
Copy link
Member

Choose a reason for hiding this comment

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

lots of trailing whitespace

else
struct (Int32.Parse(elements.[0]), Int32.Parse(elements.[1]), Int32.Parse(elements.[2]), getSuffix)

let versionCompare c1 c2 =
Copy link
Member

Choose a reason for hiding this comment

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

Unit test this, because it could get nasty.

@KevinRansom KevinRansom merged commit d58159c into dotnet:master Apr 23, 2019
let executionTfm =
let file =
try
let depsJsonPath = Path.ChangeExtension(Assembly.GetEntryAssembly().Location, "deps.json")
Copy link
Contributor

Choose a reason for hiding this comment

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

This is raising-then-catching exceptions on startup of desktop F# Interactive. SHould this code be executed for desktop fsi.exe at all?

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

String.CompareOrdinal(suffix2, suffix1)
with _ -> 0

let executionTfm =
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a /// comment please, and avoid use of abbreviations like tfm (TargetFrameworkMoniker for those wondering)

@@ -34,6 +34,98 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
None
with _ -> None

// Compare nuget version strings
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a /// comment please

@@ -3209,10 +3209,10 @@ type FSharpChecker(legacyReferenceResolver, projectCacheSize, keepAssemblyConten
backgroundCompiler.KeepProjectAlive(options, userOpName)

/// For a given script file, get the ProjectOptions implied by the #load closure
member ic.GetProjectOptionsFromScript(filename, sourceText, ?loadedTimeStamp, ?otherFlags, ?useFsiAuxLib, ?assumeDotNetFramework, ?extraProjectInfo: obj, ?optionsStamp: int64, ?userOpName: string) =
member ic.GetProjectOptionsFromScript(filename, source, ?loadedTimeStamp, ?otherFlags, ?useFsiAuxLib, ?useSdkRefs, ?assumeDotNetFramework, ?extraProjectInfo: obj, ?optionsStamp: int64, ?userOpName: string) =
Copy link
Contributor

Choose a reason for hiding this comment

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

This is still showing as source in the diff - were you going to change it back to sourceText?

@@ -1458,3 +1458,4 @@ notAFunctionButMaybeDeclaration,"This value is not a function and cannot be appl
3245,tcCopyAndUpdateNeedsRecordType,"The input to a copy-and-update expression that creates an anonymous record must be either an anonymous record or a record"
3300,chkInvalidFunctionParameterType,"The parameter '%s' has an invalid type '%s'. This is not permitted by the rules of Common IL."
3301,chkInvalidFunctionReturnType,"The function or method has an invalid return type '%s'. This is not permitted by the rules of Common IL."
useSdkRefs,"Use reference assemblies for DotNET framework references when available (Enabled by default))."
Copy link
Contributor

Choose a reason for hiding this comment

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

This is still showing DotNET on github though you said you'd change it to .NET in code review - was that done separately?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

@KevinRansom KevinRansom Apr 24, 2019

Choose a reason for hiding this comment

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

Oh I fixed it, it must have got lost somehow. As did the )) on the end of the line.

@KevinRansom KevinRansom deleted the userefassemblies branch July 2, 2019 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants