-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
GetDocumentation()
not working on members of generic classes
#52
Comments
@bert2 Thanks for the input. I was able to reproduce this issue. WorkaroundThere is a workaround you can use at the moment. Rather than supplying a placeholder type in the generics, you can just use empty generics: Assert.IsNotNull(typeof(MyGenericClass<>).GetMethod("Foo").GetDocumentation()); I removed the FixThere is probably a fix so that you do not need to remove the explicit generic types before calling |
The accepted answer on my StackOverflow question mentions using |
So For example, there could be something like this: class A<T>
{
void B(int a) {}
void B(T a) {}
} Those are two seperate methods, but if we are dealing with type There is a What is actually needed is a way to tell if a |
I am curious though. Did you run into a use case where you cannot use the generic definition (so that the workaround I mentioned is not possible)?
Cause what I should probably do is just force people to provide the |
Hi @ZacharyPatten, thanks for investigating this. I'm currently trying to fix a related bug in a tool to auto-generate markdown from an assembly having XML documentation. Through google I found your article/library and just wanted to inform you about this issue. In my case I might get away by using Your case, however, is more complicated as you explained. To me it seems that clients of your library have to be aware of this and use either the open generic type or |
I'm so dumb. I found a fix... and it was really easy... there is a I will have this fixed in the next release. Sorry this took so long. @bert2 |
No worries, @ZacharyPatten! ...and now I finally know what the |
GetDocumentation()
does not work (i.e. returnsnull
) when members reference generic type arguments of the enclosing type.Repro steps
GetDocumentation()
on it:Expected
GetDocumentation()
should return something like"<summary>foo method</summary>"
(plus some whitespace around it).Actual
GetDocumentation()
returnsnull
.Additional context
The root cause of this is that
Type.IsGenericParameter
is onlytrue
for parameters using type arguments of the method, but it isfalse
for parameters using type arguments of the class.You can verify that here: https://dotnetfiddle.net/belm44
Related question I just posted on StackOverflow: https://stackoverflow.com/questions/61542867/how-to-get-type-genericparameterposition-for-method-parameter-of-class-generic
The text was updated successfully, but these errors were encountered: