[generator] Fix issue where generic types couldn't be found in SymbolTable (#543) #552
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: #543
In #450 we began stripping the arity from Cecil imported types so that we wouldn't write invalid types like
System.Collections.Generic.IList'1<string>, resulting in the correctly formedSystem.Collections.Generic.IList<string>.However when we try to resolve these types in the SymbolTable we only look at the type name, ignoring the generic types. In this case we are looking for
System.Collections.Generic.IListbut the type is stored in the symbol table with the arity to disambiguate types likeAction'1andAction'2. Therefore our lookup fails because the table key isSystem.Collections.Generic.IList'1.With this PR, if the type is not found in the table and there are generic type parameters, calculate the arity from the generic type parameters and look in the table again.
That is,
System.Collections.Generic.IList<string>is rechecked asSystem.Collections.Generic.IList'1, which allows the type to be found.This is a relatively rare case because it comes from reference assemblies read in via Cecil, and there aren't many generics used in binding libraries. The only case in
Mono.Android.dllis: