-
Notifications
You must be signed in to change notification settings - Fork 127
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
Mark forwarders for all TypeReferences #2276
Mark forwarders for all TypeReferences #2276
Conversation
4275362
to
3a60602
Compare
Leave the logic as before and mark them from MarkStep.
if (typeDefinition.HasProperties) { | ||
foreach (var p in typeDefinition.Properties) { | ||
WalkCustomAttributesTypesScopes (p); | ||
// p.PropertyType is not saved |
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.
For future reference - this feels dangerous - not because of saving, but because of custom steps. We update the type refs in sweep step - but we don't update this one (intentionally). Again - nothing to do with this change, just that I noticed this...
test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs
Outdated
Show resolved
Hide resolved
- Use ref assemblies for ReferenceAttribute - Avoid adding to common references unless needed by test dependencies
* Build testcases against reference assemblies * Reproduce issue in testcase * Add TypeReferenceMarker * Update one more testcase * Don't mark forwarders in TypeReferenceMarker Leave the logic as before and mark them from MarkStep. * PR feedback - Use ref assemblies for ReferenceAttribute - Avoid adding to common references unless needed by test dependencies
@sbomer - can you please prepare a backport to 6.0 RC2 for this? My understanding is that Xamarin will need this - @rolfbjarne can you please confirm? |
Correct, we need this. |
This went into the RC2 SDK with this change: dotnet/sdk#21118. |
Sorry - I didn't notice this PR was for the 6.0 branch. |
* Build testcases against reference assemblies * Reproduce issue in testcase * Add TypeReferenceMarker * Update one more testcase * Don't mark forwarders in TypeReferenceMarker Leave the logic as before and mark them from MarkStep. * PR feedback - Use ref assemblies for ReferenceAttribute - Avoid adding to common references unless needed by test dependencies
* Build testcases against reference assemblies * Reproduce issue in testcase * Add TypeReferenceMarker * Update one more testcase * Don't mark forwarders in TypeReferenceMarker Leave the logic as before and mark them from MarkStep. * PR feedback - Use ref assemblies for ReferenceAttribute - Avoid adding to common references unless needed by test dependencies
I can confirm this is in RC2, but it's not in the 6.0.1xx branch: https://github.com/dotnet/sdk/blob/7156781d4c687ddf6e0f24d244c0c239a92dd02e/eng/Version.Details.xml#L123-L131 |
@agocke - do you know what branch flows to the 6.0.1xx SDK? It might be that the answer is "none yet" and we would definitely need to fix that. |
Ah I thought there was automerge in sdk like there is in runtime. I'll insert the same build into both for now. |
…inker#2280) * Build testcases against reference assemblies * Reproduce issue in testcase * Add TypeReferenceMarker * Update one more testcase * Don't mark forwarders in TypeReferenceMarker Leave the logic as before and mark them from MarkStep. * PR feedback - Use ref assemblies for ReferenceAttribute - Avoid adding to common references unless needed by test dependencies Commit migrated from dotnet/linker@ff06442
Fixes #2267.
This fixes the issue by taking the first approach mentioned in #2267 (comment). We now mark type forwarders referenced from any
TypeReference
we discover for a copy assembly, includingTypeReference
s to built-in types which only exist as bytes in metadata rather than typeref rows.The walking logic in
TypeReferenceMarker
is copied fromAssemblyReferencesCorrector
inSweepStep
and adjusted so that instead of updating the scopes of typereferences, it just marks any type forwarders they point to. The walking logic was duplicated to avoid touchingSweepStep
to reduce the risk of this change.This includes a change to the test infrastructure to build tests against
System.Runtime
, which is necessary to reproduce the issue (since it has to do with references to builtin types forwarded fromSystem.Runtime
toSystem.Private.CoreLib
). That change caused the compiler to produce different code for event methods - before the change, there were unnecessary locals in the generated code. Either way the unreachablebodies optimization removes all locals for unreachable event methods, which is why I removed theExpectLocalsModified
from a few testcases.I plan to factor out the duplicated logic in a follow-up that we won't consider taking into .NET6.