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

How to get Extension Methods to display when using assembly references #10117

Open
UmaHarano opened this issue Jul 17, 2024 Discussed in #10063 · 4 comments
Open

How to get Extension Methods to display when using assembly references #10117

UmaHarano opened this issue Jul 17, 2024 Discussed in #10063 · 4 comments

Comments

@UmaHarano
Copy link

Discussed in #10063

Originally posted by UmaHarano July 3, 2024
I am having issues with extension methods to be listed in the base class.
I have two csproj files in my solution:

  • Project A with a "Map" class.
  • Project B in the same sln has a "MappingExtensions" class that defines extension methods for the Map class that is defined in Project A.

Issue

  • If Project B has a "project reference" to Project A:
    Project A's Map class apiPage yml I generate using DocFX lists the extension methods defined in Project B.
  • If Project B has a assembly reference to Project A:
    Project A's Map class apiPage yml I generate using DocFX does not list the extension methods defined in Project B. This is the issue.

The problem is my code base only uses "Assembly reference". So I am missing all the extension methods. Is there a solution or work around you can recommend? I cannot use project references.

@filzrev
Copy link
Contributor

filzrev commented Jul 17, 2024

It seems be filtered out by following line.

.Select(m => m.ReduceExtensionMethod(type))


Is there a solution or work around you can recommend? I cannot use project references.

As a temporary workaround.
Is is able to use conditional compilation for docfx metadata command?

docfx.json

"metadata": [
    {
      "properties": {
        "DocfxMetadataBuild": "true"
      }
  ],

ProjectB.csproj

  <ItemGroup Condition="'$(DocfxMetadataBuild)' == 'true'">
    <ProjectReference Include="..\ClassLibrary1\ProjectA.csproj" />
  </ItemGroup>
  
  <ItemGroup Condition="'$(DocfxMetadataBuild)' != 'true'">
    <Reference Include="ProjectA">
      <HintPath>..\ClassLibrary1\bin\Release\net8.0\ProjectA.dll</HintPath>
    </Reference>
  </ItemGroup>

@UmaHarano
Copy link
Author

@filzrev
Thanks for the work around. The main reason this won't work is because I am building a documentation site for 17+ dlls. It would be a maintenance issue to evaluate the extensions in them in order to add these compilation conditions.

Any chance this can be fixed in the next round of DocFX updates?

image

@filzrev
Copy link
Contributor

filzrev commented Jul 22, 2024

When using Assembly Reference.
It seems ReduceExtensionMethod returns null at following lines.

.Select(m => m.ReduceExtensionMethod(type))

Any chance this can be fixed in the next round of DocFX updates?

ReduceExtensionMethod is implemented by Roslyn API.
So It would be difficult to fix on the docfx side.

I've found similar issue at Roslyn repository. But it seems not be resolved.
https://github.com/dotnet/roslyn/issues/11950

@UmaHarano
Copy link
Author

Thank you @filzrev for this info.

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

No branches or pull requests

2 participants