Skip to content

Commit 3506fca

Browse files
Merge pull request #19426 from CyrusNajmabadi/blockSimplification
Respect user settings around 'Blocks' when adding parameter null checks.
2 parents 9c6b618 + 125ac47 commit 3506fca

File tree

7 files changed

+514
-29
lines changed

7 files changed

+514
-29
lines changed

src/EditorFeatures/CSharpTest/InitializeParameter/AddParameterCheckTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,5 +755,34 @@ static void Main(String bar)
755755
CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess,
756756
CodeStyleOptions.FalseWithSuggestionEnforcement)));
757757
}
758+
759+
[WorkItem(19172, "https://github.com/dotnet/roslyn/issues/19172")]
760+
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInitializeParameter)]
761+
public async Task TestPreferNoBlock()
762+
{
763+
await TestInRegularAndScript1Async(
764+
@"
765+
using System;
766+
767+
class C
768+
{
769+
public C([||]string s)
770+
{
771+
}
772+
}",
773+
@"
774+
using System;
775+
776+
class C
777+
{
778+
public C(string s)
779+
{
780+
if (s == null)
781+
throw new ArgumentNullException(nameof(s));
782+
}
783+
}", ignoreTrivia: false,
784+
parameters: new TestParameters(options:
785+
Option(CSharpCodeStyleOptions.PreferBraces, CodeStyleOptions.FalseWithNoneEnforcement)));
786+
}
758787
}
759788
}

src/EditorFeatures/Test2/EditorServicesTest2.vbproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
<Compile Include="IntelliSense\CompletionRulesTests.vb" />
250250
<Compile Include="LanguageServices\SyntaxFactsServiceTests.vb" />
251251
<Compile Include="NamingStyles\NamingStylesTests.vb" />
252+
<Compile Include="Simplification\BlockSimplificationTests.vb" />
252253
<Compile Include="Simplification\SimplifierAPITests.vb" />
253254
<Compile Include="CodeFixes\CodeFixServiceTests.vb" />
254255
<Compile Include="Compilation\CompilationTests.vb" />

0 commit comments

Comments
 (0)