Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Commit 6348822

Browse files
committed
Fix a couple of newline issues
The two HasNewLineBefore rules had a couple of small issues that needed to be addressed. 1. They were unconditionally using CRLF which could possibly lead to mixed line endings in files. The code was changed to prefer existing endings instead. 2. They were formatting around #if blocks which is suspect and needs to be disabled. 3. Produced new SyntaxNode values on trees that already had the correct formatting. This was potentially changing line endings and made it difficult to find noisy rules in the formatter. After looking at the logic of these rules they appear to really just be the same rule run against two different nodes. Hence I merged them into a single rule to make it easier to share code.
1 parent b08e58c commit 6348822

11 files changed

+434
-449
lines changed

src/Microsoft.DotNet.CodeFormatting.Tests/Microsoft.DotNet.CodeFormatting.Tests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@
123123
<Compile Include="Rules\CopyrightHeaderRuleTests.cs" />
124124
<Compile Include="Rules\ExplicitThisRuleTests.cs" />
125125
<Compile Include="Rules\ExplicitVisibilityRuleTests.cs" />
126-
<Compile Include="Rules\HasNewLineBeforeFirstNamespaceFormattingRuleTests.cs" />
127126
<Compile Include="Rules\HasNoIllegalHeadersFormattingRuleTests.cs" />
128-
<Compile Include="Rules\HasNewLineBeforeFirstUsingFormattingRuleTests.cs" />
127+
<Compile Include="Rules\NewLineAboveRuleTests.cs" />
129128
<Compile Include="Rules\PrivateFieldNamingRuleTests.cs" />
130129
<Compile Include="Rules\NonAsciiCharactersAreEscapedInLiteralsRuleTests.cs" />
131130
<Compile Include="Rules\UsingLocationRuleTests.cs" />

src/Microsoft.DotNet.CodeFormatting.Tests/Rules/HasNewLineBeforeFirstNamespaceFormattingRuleTests.cs

Lines changed: 0 additions & 96 deletions
This file was deleted.

src/Microsoft.DotNet.CodeFormatting.Tests/Rules/HasNewLineBeforeFirstUsingFormattingRuleTests.cs

Lines changed: 0 additions & 107 deletions
This file was deleted.

0 commit comments

Comments
 (0)