Open jkoritzinsky opened 1 year ago
Do you know if there are ways to solve this in the analyzer? The docs simply say that BaseType
is unavailable on such symbol - but doesn't say what to do about it :-(.
@agocke was suggesting to use the generic type definition (not sure if I'm using the right terminology for Roslyn) in places where we encounter unbound generic types instead.
The idea from @agocke would be to have something like the following:
// Might be worth using ConstructedFrom instead of OriginalDefinition, not sure.
type = type.IsUnboundGenericType ? type.OriginalDefinition : type;
Given the following code, the trimmer will issue a warning at trim time, but the Roslyn analyzer won't warn.
We traced this down to the behavior in Roslyn around "unbound constructed generic types", or more specifically
Bar<>
, as compared toBar<T>
.Bar<T>
is the original definition and has full fidelity in the Roslyn type system. However,Bar<>
is considered an "unbound constructed generic" and as a result has a few limitations in the Roslyn type system.These limitations cause this particular case to be missed by the analyzer built on top of the Roslyn type system, whereas the Cecil type system captures this case.