Skip to content

Commit 38a33f8

Browse files
committed
Merge pull request #1605 from vweijsters/fix-1583
2 parents 6be2d79 + d81705d commit 38a33f8

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1513UnitTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,17 @@ public object[] ExpressionBodiedMethod() =>
393393
3
394394
}
395395
.Contains(3);
396+
397+
// This is a regression test for https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1583
398+
public void TestTernaryConstruction()
399+
{
400+
var target = contained
401+
? new Dictionary<string, string>
402+
{
403+
{ ""target"", ""_parent"" }
404+
}
405+
: new Dictionary<string, string>();
406+
}
396407
}
397408
";
398409

StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1513ClosingCurlyBracketMustBeFollowedByBlankLine.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ private void AnalyzeCloseBrace(SyntaxToken token)
249249
return;
250250
}
251251

252+
if (nextToken.IsKind(SyntaxKind.ColonToken))
253+
{
254+
// the close brace is in the first part of a conditional expression.
255+
return;
256+
}
257+
252258
if (nextToken.IsKind(SyntaxKind.AddKeyword)
253259
|| nextToken.IsKind(SyntaxKind.RemoveKeyword)
254260
|| nextToken.IsKind(SyntaxKind.GetKeyword)

0 commit comments

Comments
 (0)