This is a heavy PR, but these changes do make sense, solving most of our generics related problems.
Essentially, this PR removes old code related to CecilHelpers.TransformGeneric and CecilHelpers.Equals.
And adds copy-pasted internal implementations from the Cecil itself (that never have been made public).
It now includes:
GenericParameterResolver
GenericTypeResolver
MethodReferenceEqualityComparer
TypeReferenceEqualityComparer
Where GenericTypeResolver always works in a context. In a context of "owner" generic type and "owner" generic method (one of them or both, or none if no generics). Which would require passing GenericTypeResolver down from the root types to nested methods. Instead of that, partially moves responsibility to create IXamlType from CecilTypeSystem to CecilTypeResolver, which internally abstracts on top of both CecilTypeSystem and GenericTypeResolver with GenericParameterResolver.
Every IXamlType instance now goes through generics transformation, except cases where it's explicitly disable (IXamlType.GenericTypeDefinition).
This and also multiple type caching layers were reduced to one in CecilTypeResolver. Which is greatly simplified using TypeReferenceEqualityComparer.
cc @kekekeks @MrJul
This is a heavy PR, but these changes do make sense, solving most of our generics related problems.
Essentially, this PR removes old code related to CecilHelpers.TransformGeneric and CecilHelpers.Equals. And adds copy-pasted internal implementations from the Cecil itself (that never have been made public). It now includes:
Where GenericTypeResolver always works in a context. In a context of "owner" generic type and "owner" generic method (one of them or both, or none if no generics). Which would require passing GenericTypeResolver down from the root types to nested methods. Instead of that, partially moves responsibility to create IXamlType from CecilTypeSystem to CecilTypeResolver, which internally abstracts on top of both CecilTypeSystem and GenericTypeResolver with GenericParameterResolver. Every IXamlType instance now goes through generics transformation, except cases where it's explicitly disable (IXamlType.GenericTypeDefinition).
This and also multiple type caching layers were reduced to one in CecilTypeResolver. Which is greatly simplified using TypeReferenceEqualityComparer.
Fixes https://github.com/AvaloniaUI/Avalonia/issues/10485 Fixes https://github.com/AvaloniaUI/Avalonia/issues/9090 Probably https://github.com/AvaloniaUI/Avalonia/issues/8684 (didn't test) Probably https://github.com/AvaloniaUI/Avalonia/issues/3395 (didn't test)