Skip to content

GetDocumentation() not working on members of generic classes #52

@bert2

Description

@bert2

GetDocumentation() does not work (i.e. returns null) when members reference generic type arguments of the enclosing type.

Repro steps

  1. Create a generic type e.g:
public class MyGenericClass<T> {
    /// <summary>foo method</summary>
    public void Foo(T x) {}
}
  1. Call GetDocumentation() on it:
Assert.IsNotNull(typeof(MyGenericClass<T>).GetMethod("Foo").GetDocumentation());

Expected

GetDocumentation() should return something like "<summary>foo method</summary>" (plus some whitespace around it).

Actual

GetDocumentation() returns null.

Additional context

The root cause of this is that Type.IsGenericParameter is only true for parameters using type arguments of the method, but it is false 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

Metadata

Metadata

Assignees

Labels

Bugissues that suggest a flaw with existing code

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions