Can you somehow fine-tune the rule "Simplify member access (IDE0002)" in Visual Studio 2022? It's mostly useful, until it's not :)
internal class Good_God_Please_Help_Why_Is_This_Class_Name_So_Looooooooooooooooooooooooooooooooooong {
internal class SomeConstants {
public const string A = "A";
public const string B = "B";
}
}
internal class Salvation : Good_God_Please_Help_Why_Is_This_Class_Name_So_Looooooooooooooooooooooooooooooooooong { }
internal class Test {
void SomeMethod() {
var a = Salvation.SomeConstants.A;
}
}
Code above produces following simplification:
CodePudding user response:
Use SuppressMessage
:
using System.Diagnostics.CodeAnalysis;
internal class Test
{
[SuppressMessage("Style", "IDE0002")]
private void SomeMethod()
{
var a = Salvation.SomeConstants.A;
}
}
Before:
After:
Alternatively, import static member:
using static Good_God_Please_Help_Why_Is_This_Class_Name_So_Looooooooooooooooooooooooooooooooooong;
internal class Test
{
private void SomeMethod()
{
var a = SomeConstants.A;
}
}