[generator] Remove buggy annotation loose match. #886
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context: #885
When updating to the latest
annotations.zipfile, someMono.Android.dllmembers are getting multiple[RequiresPermission]attributes applied. This is because the.zipcontains the following entries:Which correspond to these overloads:
However, the overload that takes
Android.OS.VibrationEffectwasn't added until API-26, so when binding API-21 only the overload takinglongexists.Our method finding code first does a "loose" match where it sees if there is only 1 bound method that has the same number of parameters as the annotation. If so, it uses that overload without checking if the parameter types match.
In this case, both annotations "match" the only overload with a single parameter, so both annotations get applied to it, causing the duplicate. The fix is to remove the "loose" match and require all matches to be "strict".
A test XA PR was run to ensure this does not cause a regression. It only changed a few attributes, and seems to have made them more accurate: https://github.com/xamarin/xamarin-android/pull/6344/files.