Skip to content

AddOpenApi does not find the XML documentation file when called from an extension library #1175

@abc-rpg

Description

@abc-rpg

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

If I have a web application, that uses a custom library, and that library makes the call to IApiVersioningBuilder.AddOpenApi(), then the XML documentation file of the web application is not read.

The bug is in the Asp.Versioning.OpenApi project: IApiVrsioningBuilderExtensions.GetAssemblies:

private static Assembly[] GetAssemblies( Assembly callingAssembly )
{
    var assemblies = new List<Assembly>( capacity: 2 ) { callingAssembly };

    if ( Assembly.GetEntryAssembly() is { } entryAssembly && assemblies[0] != callingAssembly ) // callingAssembly should be entryAssembly
    {
        assemblies.Add( entryAssembly );
    }

    return [.. assemblies];
}

That 2nd boolean will always resolve to false because it's comparing the element to itself. It should be comparing it to the entryAssembly.

Expected Behavior

The XML documentation file of the Entry Assembly is read.

Steps To Reproduce

Web App

builder.Services.AddOpenApiWithVersioning();

Custom Library

public IServiceCollection AddOpenApiWithVersioning(this IServiceCollection services)
{
    services.AddApiVersioning().AddOpenApi();
}

Exceptions (if any)

No response

.NET Version

10.0.104

Anything else?

Asp.Verisoning.OpenApi v10.0.0-preview.2

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions