-
Notifications
You must be signed in to change notification settings - Fork 832
Robustness of MVID for reference assemblies #15325
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
Conversation
tests/FSharp.Compiler.ComponentTests/Signatures/ImpliedSignatureHashTests.fs
Show resolved
Hide resolved
Thanks for spotting this, commiting it as a (failing) test case and will investigate. |
|
Fantastic to see progress on this. Re: private/internal functions, in principle shouldn't both private and internal functions be excluded? |
If the assembly does not have a single But if there is at least one project to which internals are made visible, all internals have to be counted for. |
tests/FSharp.Compiler.ComponentTests/Signatures/ImpliedSignatureHashTests.fs
Show resolved
Hide resolved
|
@T-Gro mvid calculation should take into account optimization data, otherwise inlining might work incorrectly (not rebuilding ref assembly, when inlined code is changed, but not type) when building against reference assemblies. |
|
I also wonder, will the signature files continue to contain the additional unnecessary private data? |
|
@KevinRansom ; @vzarytovskii : Please have a look one more time guys. However, the test suite now relies on the Therefore, I will raise a sibling PR with a new approach we discussed with Vlad: When building in DEBUG && when ref assemblies are present, I propose to build the project with WDYT? |
|
Take a look at the |
KevinRansom
left a comment
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.
A minor factoring quibble. Otherwise it looks okay.
F# compiler already knows how to produce reference assemblies.
One of the key elements for them is MVID, a deterministic hash identifier used for comparing 'before' and 'after' versions of an assembly.
If MVID of project 'x' is unchanged, projects depending on 'x' do not need to recompile and can just copy over the new 'x.dll' without being recompiled themselves. This significantly reduces costs in bigger nets of projects where a change is made in a low-level project, but the change does not alter the visible surface area - e.g. just implementation details are changed, or private members are added.
As of now, the MVID for F# reference assemblies has been calculated both as a hash of IL code, but also as hash of all the embedded resources. For F# that specifically means the Signature and Optimization data (byte streams compiled as resources) used for consumption by other F# projects, but also sections for byte arrays or constant strings for an assembly.
This PR changes the MVID calculation for reference assemblies by not including these resources, and instead replacing them with a custom hash number derived from what I call 'implied signature of a file'.
In a nutshell, it attempts to be equivalent to " auto-generate .fsi signature file and hash that", but without all the intermmediate string allocations and making things pretty - i.e. following the same TAST constructs, just hashing them instead of rendering to a string.