JetBrains Rider 2024.3 Help

Code inspection: Member hides static member from outer class

There is not much wrong with the code example below, at least in its current state where you can observe all declarations at once. However, as the FooNested class would grow and DoSomething() would be not so close to the both declarations of the Bar, someone who reads the code could mistakenly think that DoSomething() uses Foo.Bar and not FooNested.Bar. Furthermore, if someone removes the Foo declaration from FooNested later, they may not notice that the remaining usages of Foo will be returning the value of the Foo.Bar.

Therefore, JetBrains Rider issues a warning to draw your attention to potential problems with this code. There are no quick-fixes because this declaration of the Bar is indeed intended. But if it's not and if you want to safely rename it, press Shift+F6 on it to invoke the Rename refactoring.

public class Foo { private static string Bar { get; set; } // some other members private class FooNested { private static string Bar { get; set; } static void DoSomething() { Console.WriteLine(Bar); } } }
Last modified: 11 February 2024