-
Notifications
You must be signed in to change notification settings - Fork 789
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
[WIP] Add Reference Assembly support #11521
Conversation
…ions and ones without
src/fsharp/IlxGen.fs
Outdated
// When emitting a reference assembly, do not emit methods that are private unless they are virtual/abstract or provide an explicit interface implementation. | ||
// Internal methods can be omitted only if the assembly does not contain a System.Runtime.CompilerServices.InternalsVisibleToAttribute. | ||
if cenv.opts.referenceAssemblyOnly && | ||
(v.Accessibility.IsPrivate || (v.Accessibility.IsInternal && not cenv.hasInternalsVisibleToAttr)) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Accessibility
thing on Val and Entity is not complete unfortunately and most code relying on it alone is probably buggy. See #11528
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll be using ILMemberAccess
here instead as it's the most accurate, so we don't have to do any extra work for accessibility.
The only downside is that the compiler will always emit Internal for everything and never private. I'm wondering if we could change that in the future. Logically speaking, there are things that really should be emit ILMemberAccess.Private
such as backing fields.
… the compiler understands Accessibility.
quick test to see if determinism CI breaks when deterministic flag is off, it should
Fixes #3066 |
…nto ref-assembly-output
Super excited for this to land! Do you think it'll make it into the .NET 6 release? |
…nto ref-assembly-output
@@ -2,8 +2,7 @@ | |||
|
|||
<PropertyGroup> | |||
<OutputType>Exe</OutputType> | |||
<TargetFrameworks Condition="'$(OS)' != 'Unix'">net472;net5.0</TargetFrameworks> | |||
<TargetFrameworks Condition="'$(OS)' == 'Unix'">net5.0</TargetFrameworks> | |||
<TargetFrameworks>net472;net5.0</TargetFrameworks> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, this would fail to build on Linux/macOS, since net472 is not supported there. Unintentional change (merge)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't have to be the case, if the .net framework reference assemblies nuget package was added as a dependency then these projects could at least build on non-windows.
@@ -1,7 +1,7 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFrameworks Condition="'$(OS)' != 'Unix'">net472;net5.0</TargetFrameworks> | |||
<TargetFrameworks>net472;net5.0</TargetFrameworks> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, unintentional change? This would fail to build on Linux/macOS, since net472 is not supported there.
I need to fix the test failures and merge conflicts. There is still a few more work items that need to be done here but for the most part I think this can be ready quickly if we scope out producing an assembly for design-time/IDE scenarios. |
Closing in favor of: #12334 |
This adds the ability for the compiler to emit reference assemblies. See here for more info about reference assemblies; it has the rules.
Adds the compiler options,
--refonly
and--refout:<file>
.For the F# compiler, there are some unique quirks about generating reference assemblies:
--refonly
and--refout
will do.The following are three parts of the reference assembly work, where the first part is the current PR:
Acceptance Criteria Part 1
--refonly
--refout
Acceptance Criteria Part 2
Acceptance Criteria Part 3