Description
If tags precede methods it is not possible to disable re-formatting.
[someTag]
public void MyMethod()
{
// how to keep formatting untouched here
}
Steps to Reproduce
// csharpier-ignore is applied to code:
internal class CSharpierTest
{
public void WillBeFormatted()
{
var x = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30;
var y = x + 100;
}
// csharpier-ignore
public void IsNotFormatted()
{
var x = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30;
var y = x + 100;
}
[AttributeUsage(AttributeTargets.Method)]
public class TagAttribute : Attribute { }
[Tag]
// csharpier-ignore
public void ShallNotBeFormatted_ButRemovesSpaceLines()
{
var x = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30;
var y = x + 100;
}
// csharpier-ignore
[Tag]
public void ShallNotBeFormatted_ButFormats()
{
var x = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30;
var y = x + 100;
}
}
Expected Behavior
Only the first method should be re-formatted:
internal class CSharpierTest
{
public void WillBeFormatted()
{
var x =
1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30;
var y = x + 100;
}
// csharpier-ignore
public void IsNotFormatted()
{
var x = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30;
var y = x + 100;
}
[AttributeUsage(AttributeTargets.Method)]
public class TagAttribute : Attribute { }
[Tag]
// csharpier-ignore
public void ShallNotBeFormatted_ButRemovesSpaceLines()
{
var x = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30;
var y = x + 100;
}
// csharpier-ignore
[Tag]
public void ShallNotBeFormatted_ButFormats()
{
var x = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30;
var y = x + 100;
}
}
Actual Behavior
As shown in ShallNotBeFormatted_ButRemovesSpaceLines(), although re-formatting is suppressed as expected, empty lines are removed. Without [Tag], it works as expected (see IsNotFormatted()).
It is not possible to suppress re-formatting with // csharpier-ignore before the tag (see ShallNotBeFormatted_ButFormats()):
internal class CSharpierTest
{
public void WillBeFormatted()
{
var x =
1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30;
var y = x + 100;
}
// csharpier-ignore
public void IsNotFormatted()
{
var x = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30;
var y = x + 100;
}
[AttributeUsage(AttributeTargets.Method)]
public class TagAttribute : Attribute { }
[Tag]
// csharpier-ignore
public void ShallNotBeFormatted_ButRemovesSpaceLines()
{
var x = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30;
var y = x + 100;
}
// csharpier-ignore
[Tag]
public void ShallNotBeFormatted_ButFormats()
{
var x =
1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30;
var y = x + 100;
}
}
Description
If tags precede methods it is not possible to disable re-formatting.
Steps to Reproduce
// csharpier-ignoreis applied to code:Expected Behavior
Only the first method should be re-formatted:
Actual Behavior
As shown in
ShallNotBeFormatted_ButRemovesSpaceLines(), although re-formatting is suppressed as expected, empty lines are removed. Without[Tag], it works as expected (seeIsNotFormatted()).It is not possible to suppress re-formatting with
// csharpier-ignorebefore the tag (seeShallNotBeFormatted_ButFormats()):