dotnet/roslyn

Move static members to another type does not use the correct visibility

Offen

#58.502 geöffnet am 27.12.2021

 (0 Kommentare) (0 Reaktionen) (1 zugewiesene Person)C# (4.257 Forks)batch import
Area-IDEBughelp wanted

Repository-Metriken

Stars
 (20.414 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

Related to https://github.com/dotnet/roslyn/issues/55127

Version Used: Version 17.1.0 Preview 1.1

Steps to Reproduce:

  1. Create a new class library, paste the following code in:
class Test
{
    private const string TestConstant = "";

    void M()
    {
        _ = TestConstant;
    }
}
  1. Ctrl+. on TestConstant, select "Move static members to another type..."
  2. Hit enter to accept the refactoring

Expected Behavior:

Generated code visibility allows for Test to see the constant.

Actual Behavior:

The following code is generated:

internal static class TestHelpers
{
    private const string TestConstant = "";
}

The constant is private, and compilation errors result as the original location cannot see the moved constant.

Contributor Guide