Skip to content

[OpenApi] SourceGen error using xml docs for Static methods taking generic parameters. #61864

Closed
@jasonswearingen

Description

@jasonswearingen

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

it seems that a static class with Generic methods causes errors with the OpenApi sourcegen.

If I change the library's .csproj to include: <GenerateDocumentationFile>false</GenerateDocumentationFile> the error disappears.

a library referenced by my aspnetcore api has:

/// <summary>
///    helpers to allocate a WriteMem instance
/// </summary>
public static class Mem
{
   /// <summary>
   ///    Create a temporary (no-pooled) mem using your own backing data object
   /// </summary>
   public static Mem<T> CreateUsing<T>(T[] array)
   {
      return Mem<T>.CreateUsing(array);
   }
}

causes the following line to be generated in .Generated\Microsoft.AspNetCore.OpenApi.SourceGenerators\Microsoft.AspNetCore.OpenApi.SourceGenerators.XmlCommentGenerator\OpenApiXmlCommentSupport.generated.cs

_cache.Add(new MemberKey(typeof(global::NotNot.Mem), MemberType.Method, "CreateUsing", typeof(global::NotNot.Mem<>), [typeof(T[])]), new XmlComment(@"Create a temporary (no-pooled) mem using your own backing data object.", null, null, null, null, false, null, null, null));

which triggers the following error in build output:

1>V:\project\path\.Generated\Microsoft.AspNetCore.OpenApi.SourceGenerators\Microsoft.AspNetCore.OpenApi.SourceGenerators.XmlCommentGenerator\OpenApiXmlCommentSupport.generated.cs(599,138,599,139): error CS0246: The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)

Expected Behavior

see above

Steps To Reproduce

see above

Exceptions (if any)

see above

.NET Version

10.0.0-preview.3.25172.1

Anything else?

Microsoft.AspNetCore.OpenApi v10.0.0-preview.3.25172.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions