Skip to content

Commit d409041

Browse files
use modern extension
1 parent 5f51f25 commit d409041

File tree

1 file changed

+73
-70
lines changed

1 file changed

+73
-70
lines changed

src/Analyzers/CSharp/Tests/UseVarTestExtensions.cs

Lines changed: 73 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -22,83 +22,86 @@ internal static class UseVarTestExtensions
2222
private static readonly CodeStyleOption2<bool> offWithError = new(false, NotificationOption2.Error);
2323
private static readonly CodeStyleOption2<bool> onWithError = new(true, NotificationOption2.Error);
2424

25-
public static OptionsCollection PreferExplicitTypeWithError(this AbstractCodeActionOrUserDiagnosticTest_NoEditor<TestHostDocument, TestHostProject, TestHostSolution, TestWorkspace> test)
26-
=> new(test.GetLanguage())
27-
{
28-
{ CSharpCodeStyleOptions.VarElsewhere, offWithError },
29-
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, offWithError },
30-
{ CSharpCodeStyleOptions.VarForBuiltInTypes, offWithError },
31-
};
25+
extension(AbstractCodeActionOrUserDiagnosticTest_NoEditor<TestHostDocument, TestHostProject, TestHostSolution, TestWorkspace> test)
26+
{
27+
public OptionsCollection PreferExplicitTypeWithError()
28+
=> new(test.GetLanguage())
29+
{
30+
{ CSharpCodeStyleOptions.VarElsewhere, offWithError },
31+
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, offWithError },
32+
{ CSharpCodeStyleOptions.VarForBuiltInTypes, offWithError },
33+
};
3234

33-
public static OptionsCollection PreferImplicitTypeWithError(this AbstractCodeActionOrUserDiagnosticTest_NoEditor<TestHostDocument, TestHostProject, TestHostSolution, TestWorkspace> test)
34-
=> new(test.GetLanguage())
35-
{
36-
{ CSharpCodeStyleOptions.VarElsewhere, onWithError },
37-
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, onWithError },
38-
{ CSharpCodeStyleOptions.VarForBuiltInTypes, onWithError },
39-
};
35+
public OptionsCollection PreferImplicitTypeWithError()
36+
=> new(test.GetLanguage())
37+
{
38+
{ CSharpCodeStyleOptions.VarElsewhere, onWithError },
39+
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, onWithError },
40+
{ CSharpCodeStyleOptions.VarForBuiltInTypes, onWithError },
41+
};
4042

41-
public static OptionsCollection PreferExplicitTypeWithWarning(this AbstractCodeActionOrUserDiagnosticTest_NoEditor<TestHostDocument, TestHostProject, TestHostSolution, TestWorkspace> test)
42-
=> new(test.GetLanguage())
43-
{
44-
{ CSharpCodeStyleOptions.VarElsewhere, offWithWarning },
45-
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, offWithWarning },
46-
{ CSharpCodeStyleOptions.VarForBuiltInTypes, offWithWarning },
47-
};
43+
public OptionsCollection PreferExplicitTypeWithWarning()
44+
=> new(test.GetLanguage())
45+
{
46+
{ CSharpCodeStyleOptions.VarElsewhere, offWithWarning },
47+
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, offWithWarning },
48+
{ CSharpCodeStyleOptions.VarForBuiltInTypes, offWithWarning },
49+
};
4850

49-
public static OptionsCollection PreferImplicitTypeWithWarning(this AbstractCodeActionOrUserDiagnosticTest_NoEditor<TestHostDocument, TestHostProject, TestHostSolution, TestWorkspace> test)
50-
=> new(test.GetLanguage())
51-
{
52-
{ CSharpCodeStyleOptions.VarElsewhere, onWithWarning },
53-
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, onWithWarning },
54-
{ CSharpCodeStyleOptions.VarForBuiltInTypes, onWithWarning },
55-
};
51+
public OptionsCollection PreferImplicitTypeWithWarning()
52+
=> new(test.GetLanguage())
53+
{
54+
{ CSharpCodeStyleOptions.VarElsewhere, onWithWarning },
55+
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, onWithWarning },
56+
{ CSharpCodeStyleOptions.VarForBuiltInTypes, onWithWarning },
57+
};
5658

57-
public static OptionsCollection PreferExplicitTypeWithInfo(this AbstractCodeActionOrUserDiagnosticTest_NoEditor<TestHostDocument, TestHostProject, TestHostSolution, TestWorkspace> test)
58-
=> new(test.GetLanguage())
59-
{
60-
{ CSharpCodeStyleOptions.VarElsewhere, offWithInfo },
61-
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, offWithInfo },
62-
{ CSharpCodeStyleOptions.VarForBuiltInTypes, offWithInfo },
63-
};
59+
public OptionsCollection PreferExplicitTypeWithInfo()
60+
=> new(test.GetLanguage())
61+
{
62+
{ CSharpCodeStyleOptions.VarElsewhere, offWithInfo },
63+
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, offWithInfo },
64+
{ CSharpCodeStyleOptions.VarForBuiltInTypes, offWithInfo },
65+
};
6466

65-
public static OptionsCollection PreferImplicitTypeWithInfo(this AbstractCodeActionOrUserDiagnosticTest_NoEditor<TestHostDocument, TestHostProject, TestHostSolution, TestWorkspace> test)
66-
=> new(test.GetLanguage())
67-
{
68-
{ CSharpCodeStyleOptions.VarElsewhere, onWithInfo },
69-
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, onWithInfo },
70-
{ CSharpCodeStyleOptions.VarForBuiltInTypes, onWithInfo },
71-
};
67+
public OptionsCollection PreferImplicitTypeWithInfo()
68+
=> new(test.GetLanguage())
69+
{
70+
{ CSharpCodeStyleOptions.VarElsewhere, onWithInfo },
71+
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, onWithInfo },
72+
{ CSharpCodeStyleOptions.VarForBuiltInTypes, onWithInfo },
73+
};
7274

73-
public static OptionsCollection PreferExplicitTypeWithSilent(this AbstractCodeActionOrUserDiagnosticTest_NoEditor<TestHostDocument, TestHostProject, TestHostSolution, TestWorkspace> test)
74-
=> new(test.GetLanguage())
75-
{
76-
{ CSharpCodeStyleOptions.VarElsewhere, offWithSilent },
77-
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, offWithSilent },
78-
{ CSharpCodeStyleOptions.VarForBuiltInTypes, offWithSilent },
79-
};
75+
public OptionsCollection PreferExplicitTypeWithSilent()
76+
=> new(test.GetLanguage())
77+
{
78+
{ CSharpCodeStyleOptions.VarElsewhere, offWithSilent },
79+
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, offWithSilent },
80+
{ CSharpCodeStyleOptions.VarForBuiltInTypes, offWithSilent },
81+
};
8082

81-
public static OptionsCollection PreferImplicitTypeWithSilent(this AbstractCodeActionOrUserDiagnosticTest_NoEditor<TestHostDocument, TestHostProject, TestHostSolution, TestWorkspace> test)
82-
=> new(test.GetLanguage())
83-
{
84-
{ CSharpCodeStyleOptions.VarElsewhere, onWithSilent },
85-
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, onWithSilent },
86-
{ CSharpCodeStyleOptions.VarForBuiltInTypes, onWithSilent },
87-
};
83+
public OptionsCollection PreferImplicitTypeWithSilent()
84+
=> new(test.GetLanguage())
85+
{
86+
{ CSharpCodeStyleOptions.VarElsewhere, onWithSilent },
87+
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, onWithSilent },
88+
{ CSharpCodeStyleOptions.VarForBuiltInTypes, onWithSilent },
89+
};
8890

89-
public static OptionsCollection PreferExplicitTypeWithNone(this AbstractCodeActionOrUserDiagnosticTest_NoEditor<TestHostDocument, TestHostProject, TestHostSolution, TestWorkspace> test)
90-
=> new(test.GetLanguage())
91-
{
92-
{ CSharpCodeStyleOptions.VarElsewhere, offWithNone },
93-
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, offWithNone },
94-
{ CSharpCodeStyleOptions.VarForBuiltInTypes, offWithNone },
95-
};
91+
public OptionsCollection PreferExplicitTypeWithNone()
92+
=> new(test.GetLanguage())
93+
{
94+
{ CSharpCodeStyleOptions.VarElsewhere, offWithNone },
95+
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, offWithNone },
96+
{ CSharpCodeStyleOptions.VarForBuiltInTypes, offWithNone },
97+
};
9698

97-
public static OptionsCollection PreferImplicitTypeWithNone(this AbstractCodeActionOrUserDiagnosticTest_NoEditor<TestHostDocument, TestHostProject, TestHostSolution, TestWorkspace> test)
98-
=> new(test.GetLanguage())
99-
{
100-
{ CSharpCodeStyleOptions.VarElsewhere, onWithNone },
101-
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, onWithNone },
102-
{ CSharpCodeStyleOptions.VarForBuiltInTypes, onWithNone },
103-
};
99+
public OptionsCollection PreferImplicitTypeWithNone()
100+
=> new(test.GetLanguage())
101+
{
102+
{ CSharpCodeStyleOptions.VarElsewhere, onWithNone },
103+
{ CSharpCodeStyleOptions.VarWhenTypeIsApparent, onWithNone },
104+
{ CSharpCodeStyleOptions.VarForBuiltInTypes, onWithNone },
105+
};
106+
}
104107
}

0 commit comments

Comments
 (0)