dotnet/roslyn

Rename symbol misses symbol used in invalid assignment

Open

#67,665 创建于 2023年4月6日

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

仓库指标

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

描述

Version Used: Version 17.7.0 Preview 1.0 [33604.490.main]

Steps to Reproduce:

class C
{
    private static readonly object _f;

    public C()
    {
        _f = new();
    }
}

Attempting to rename _f fails to rename the occurrence in the constructor. Admitted that occurrence is invalid (cannot assign to readonly static) but Go to definition and Find all references both resolve the usage, so rename should too.

My larger use case here was converting a field from local to static. I added static then had a diagnostic to update the name due to naming convention. It renamed the field to s_f but not the usage. Further investigation revealed the issue applies to manual renames too.

贡献者指南