Closed stakx closed 6 years ago
class Outer { public class Inner<T> { } } typeof(Outer.Inner<int>).GetFormattedName(); // *boom*
The problem lies here:
https://github.com/stakx/TypeNameFormatter/blob/4d3f70a706477d929888490a6fe4abc55a1034f9/src/TypeNameFormatter/TypeNameFormatter.cs#L134-L139
This only checks whether the innermost type (typeWithGenericTypeArgs) is generic, but if we're formatting a non-generic enclosing type, type.GetGenericTypeDefinition will bomb.
typeWithGenericTypeArgs
type.GetGenericTypeDefinition
The problem lies here:
https://github.com/stakx/TypeNameFormatter/blob/4d3f70a706477d929888490a6fe4abc55a1034f9/src/TypeNameFormatter/TypeNameFormatter.cs#L134-L139
This only checks whether the innermost type (
typeWithGenericTypeArgs
) is generic, but if we're formatting a non-generic enclosing type,type.GetGenericTypeDefinition
will bomb.