-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 reference assembly for System.Private.CoreLib.dll #72143
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries Issue DetailsWe now compile against the reference assembly in all places where we were compiling against the mono/coreclr System.Private.CoreLib.dll implementation assembly before. The new reference assembly consumes sources from the existing contracts to avoid checking in a generated version of SPC.dll (this would add ~20k lines of .cs which is mostly duplicated with System.Runtime.cs) The reference .cs file of contracts where all types are actually living in SPC like System.Runtime.cs or System.Numerics.Vectors.cs were moved into Since a few contracts have only partially moved types to SPC we wrap contract types with Note that this means that the types which live in CoreLib are moved to the end of the ref .cs file which causes a GitHub diff to show up, but it is actually a no-op. Fixes #67660 /cc @stephentoub @tannergooding @jkotas @vitek-karas @ericstj @ViktorHofer
|
Thoughts:
|
+1 |
As an alternative to manually creating the reference assembly and maintaining it, could we add a switch to Roslyn to not emit private fields into the reference assembly produced via RefOut, in order to get a stable MVID? We would only want to use such a switch for unshipping "private" reference assemblies like System.Private.CoreLib anyway. Asking as I could imagine that would need to do this for other private assemblies like System.Private.Uri or System.Private.Xml as well in case they would become arch/platform specific in the future. cc @jaredpar |
…te.* assemblies They access a lot of internals of SPC, not worth it right now.
...clr/nativeaot/System.Private.DisabledReflection/src/System.Private.DisabledReflection.csproj
Outdated
Show resolved
Hide resolved
Co-authored-by: Viktor Hofer <[email protected]>
Are we still going to get a validation that the public surface matches with this? The extra methods in NativeAOT CoreLib should be in several types. It may be better to add |
@jkotas I'm looking at it, this was mostly to get something building so I could get test coverage, I'll continue looking at how best to handle NativeAOT |
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.
GenAPI changes and usage look ok to me. I’d like folks working in this codebase to provide their sign off.
The `System.IO.Enumeration.FileSystemEntry.<_fileNameBuffer>e__FixedBuffer` only happens on non-Windows platforms.
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 didn't review in depth, but I don't see any changes that impact anything. It's just reordering where various entries are, so provided GenAPI changes are checked in it won't impact anyone needing to make subsequent changes to the ref assemblies.
@akoeplinger is there any plan to backport this to .NET 6? We're hitting this issue in MAUI + .NET 7 when you change the the |
@sbomer - another instance of using 7.0 linker for 6.0 apps - completely different problem though. |
@vitek-karas How realistic is making a change to use the 6.0 linker for 6.0 apps? We're either going to have to do something like that or backport this change. Using the 6.0 linker seems like the least impactful from my perspective. Thoughts? |
@sbomer has been looking into that, but it's relatively complicated and thus risky. |
As @vitek-karas said - it will be difficult and risky to make that change in time for the release. We would need to start publishing a package for the linker and add SDK logic to download the right version, probably using the runtime pack mechanism that we use for ILCompiler. There are a lot of details to get right, with changes across multiple repos. Often for this kind of change we only catch errors when dependencies flow into upstream repos. I'll work on this in case we decide to go that route, but we should also consider:
|
@sbomer so the result when building a Release-mode Android app, we end up with an assembly per architecture: Where if you use a I will get an app size comparison, but the duplicates cause another issue we need to solve first: dotnet/android#7302 I suspect the app might be near 4x larger? |
I don't believe it's super risky backporting this change. @akoeplinger are there any concerns that you know of / have? |
I think we ran out of time for any solution beyond the backport. Can we get that rolling ASAP? |
We now compile against the reference assembly in all places where we were compiling against the mono/coreclr System.Private.CoreLib.dll implementation assembly before.
The new reference assembly consumes sources from the existing contracts to avoid checking in a generated version of SPC.dll (this would add ~20k lines of .cs which is mostly duplicated with System.Runtime.cs)
The reference .cs file of contracts where all types are actually living in SPC like System.Runtime.cs or System.Numerics.Vectors.cs were moved into.src\libraries\System.Private.CoreLib\ref\contracts\
to keep them co-located (@ericstj suggested this in a discussion we had, but happy to change it back if most people don't like it)Since a few contracts have only partially moved types to SPC we wrap contract types with
#if !BUILDING_CORELIB_REFERENCE
so we can hide them when compiling the SPC reference assembly. This needed a few GenAPI changes which are implemented here: dotnet/arcade#10003.Note that this means that the types which live in CoreLib are moved to the end of the ref .cs file which causes a GitHub diff to show up, but it is actually a no-op.
Regenerating the ref .cs files works the same way as before, by running the
GenerateReferenceAssemblySource
target in the contract's src\ folder.Fixes #67660
/cc @stephentoub @tannergooding @jkotas @vitek-karas @ericstj @ViktorHofer