dotnet / docfx

Static site generator for .NET API documentation.
https://dotnet.github.io/docfx/
MIT License
4.06k stars 864 forks source link

Single-letter namespace aliases cause resolution failures #2620

Closed jskeet closed 11 months ago

jskeet commented 6 years ago

DocFX Version Used: 2.32.1

Template used: n/a

Steps to Reproduce:

Three files:

Aliases.csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net45</TargetFramework>
  </PropertyGroup>
</Project>

Class1.cs:

using x = System;
using xy = System;

namespace Aliases
{
    /// <summary>Fails: <see cref="x::ArgumentException" /></summary>
    /// <remarks>Works: <see cref="xy::ArgumentException" /></remarks>
    public class Class1
    {
    }
}

docfx.json:

{
  "metadata": [
    {
      "src": [ { "files": [ "Aliases.csproj" ] } ],
      "dest": "obj/api"
    }
  ]
}

Then just run docfx metadata -f

Expected Behavior:

No warnings or errors.

Actual Behavior:

Warning:[ExtractMetadata]Invalid cref value "x::ArgumentException" found in triple-slash-comments for Class1 defined in Class1.cs Line 7, ignored.

This appears to happen for any single-letter namespace alias. Notice how the alias of xy doesn't cause a problem.

jskeet commented 6 years ago

As noted on Twitter, single-letter-followed-by-colon has a meaning within the transformed XML, and it looks like VS treats it differently too, although I can't see anything in the language specification to indicate that it should do so. So this may not be a bug in docfx particularly, but just an unspecified oddity of the C# compiler :(

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

superyyrrzz commented 5 years ago

I am not sure of the root cause, but it should mistake it as some comment id like T:..., M:.... It is like a bug but not too harmful.

KalleOlaviNiemitalo commented 5 years ago

As Class1.cs does not declare extern alias x;, I'd expect it to use cref="x.ArgumentException" rather than cref="x::ArgumentException".

yufeih commented 11 months ago

Close as VS shares the same behavior.