dotnet/roslyn

Misleading completion for cref in inheritdoc

Open

#76,579 创建于 2024年12月29日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)C# (4,257 fork)batch import
Area-IDEBughelp wanted

仓库指标

Star
 (20,414 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

Version Used: VS 17.13 Preview 1

Steps to Reproduce:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net9.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <GenerateDocumentationFile>true</GenerateDocumentationFile> <!-- important for repro -->
  </PropertyGroup>

</Project>

Console.WriteLine();

public class C
{
    /// <summary>Whatever</summary>
    public static void M1<T>(T? expected)
    {
    }

    /// <inheritdoc cref="M1$$" />
    public static void M2()
    {
    }
}

Trigger completion in place of $$, it completes to M1{T}(T?) which produces:

CS1574 XML comment has cref attribute 'M1{T}(T?)' that could not be resolved

It should have completed to M1{T}(T) (unless the completion is correct and this is a compiler bug?)

NOTE: Some scenarios that are working currently correctly but need to be taken with care to not regress them

If you have:

/// <summary>Whatever</summary>
public static void M1<T>(T? expected) where T : struct
{
}

/// <summary>Whatever 2</summary>
public static void M1<T>(T expected) where T : struct
{
}

Then completion for both T and T? should be offered (and is currently the case that should not be regressed).

Similarly, even if only this overload exists:

/// <summary>Whatever</summary>
public static void M1<T>(T? expected) where T : struct
{
}

The completion should use T?

贡献者指南