[generator] Only skip generic "overloads" of bound types #178
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.
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=57828
The #runtime team is attempting to update xamarin-android to use the
mono/2017-06 and mono/2017-08 (and...) branches, and when
doing so they are seeing a unit test fail in
Xamarin.Android.Build.Tests.BuildTest.GeneratorValidateMultiMethodEventName()
:no
BG850*
warnings are expected but they are produced.After much analysis, the cause of ght
BG850*
warnings is thatthe mono/2017-06 branch introduces a non-generic "overload" of
System.Collections.Generic.KeyValuePair
:Specifically, the above "
KeyValuePair
overload" type runs into aFIXME within
CodeGenerator.cs
:The intent of the check that is that, given a type
AdapterView<T>
,we only check to see if
AdapterView
exists as well. If it does exist,then we ignore the
AdapterView<T>
type, and only use theAdapterView
type for code generation.In the case of
KeyValuePair
, the same "check" is done, which causeus to skip type registration for
KeyValuePair<TKey, TValue>
, whichin turn causes us to invalidate e.g.
IDictionary<TKey, TValue>
-- asit implements
ICollection<KeyValuePair<TKey, TValue>>
-- andeverything promply falls apart from there:
I still don't fully understand the scenario that the check was
attempting to solve, so in lieu of actually fixing the FIXME, make the
check stricter so that we only ignore "generically overloaded" types
if they bind the same Java type. Since
KeyValuePair<TKey, TValue>
binds no Java type, it will no longer be skipped, thus removing the
BG8502 and related warnings.
Additionally, a bit of code cleanup for consistency: some parts of the
code use
HAVE_CECIL
, and others useUSE_CECIL
. Standardize onHAVE_CECIL
for consistency and sanity.