Description
Just FYI your "Type.GetDeclaration()" extension fails for nested generic types. Example:
class A
{
class B<D>
{
class C<E> { }
}
}
typeof(A.B<int>.C<string>).GetDeclaration();
It currently throws an InvalidOperationException.
I'm not sure what you would want to do in these cases since it is a nested type and the declaration requires the parent type as well. In my opinion it should probably return the declaration for only that nested class (and not the parents)... But that is up to you of course.
At a minimum you should probably throw a custom ArgumentException with a custom message.
If you remove types:
typeof(A.B<>.C<>).GetDeclaration()
It returns
And that is definitely incorrect.
Description
Just FYI your "Type.GetDeclaration()" extension fails for nested generic types. Example:
It currently throws an
InvalidOperationException.I'm not sure what you would want to do in these cases since it is a nested type and the declaration requires the parent type as well. In my opinion it should probably return the declaration for only that nested class (and not the parents)... But that is up to you of course.
At a minimum you should probably throw a custom
ArgumentExceptionwith a custom message.If you remove types:
It returns
"C<D, E>"And that is definitely incorrect.