Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetDeclaration fails on nested generic types #29

Open
ZacharyPatten opened this issue Jan 7, 2020 · 0 comments
Open

GetDeclaration fails on nested generic types #29

ZacharyPatten opened this issue Jan 7, 2020 · 0 comments

Comments

@ZacharyPatten
Copy link

ZacharyPatten commented Jan 7, 2020

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

"C<D, E>"

And that is definitely incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant