Skip to content

Missing cases in base/override method comparisons #5974

@sbomer

Description

@sbomer

I'm filing this issue to track concerns that came up in #5748 (comment). See that discussion for more context. The basic issue is that some base/override method comparisons don't account for the .override directive or variance of parameters.

PreserveRegistrations calls the helper TryGetBaseOrInterfaceRegisterMember to look for matching base methods:

https://github.com/xamarin/xamarin-android/blob/da536fcf1b663fd71adee40c06466547a04cc6ed/src/Microsoft.Android.Sdk.ILLink/PreserveRegistrations.cs#L87

It is also called from MonoDroidMarkStep, but I haven't looked into this usage.

There are a few potential issues along the lines that @jonpryor mentioned in #5748 (comment), but I don't have the full context to understand how concerning these are:

Compare this with FixAbstractMethodsStep:
https://github.com/xamarin/xamarin-android/blob/da536fcf1b663fd71adee40c06466547a04cc6ed/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixAbstractMethodsStep.cs#L228-L232
which does check for overrides
https://github.com/xamarin/xamarin-android/blob/da536fcf1b663fd71adee40c06466547a04cc6ed/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixAbstractMethodsStep.cs#L172-L175

https://github.com/xamarin/xamarin-android/blob/da536fcf1b663fd71adee40c06466547a04cc6ed/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixAbstractMethodsStep.cs#L160-L169

though I don't think it does anything to handle variance.

Long-term I think the ideal approach would be to build these kinds of comparisons into the linker and make the APIs available to custom steps. There may be more cases that need to be considered, such as default interface methods, and static virtual interface methods.

Metadata

Metadata

Assignees

Labels

Area: LinkerIssues when linking assemblies.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions