Skip to content

Commit

Permalink
GH-22 directives WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
belav committed Mar 1, 2021
1 parent 7894443 commit 1a23d08
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,20 @@
#undef foo
#line 6
class ClassName { }

public class ClassName
{
void MethodName()
{
#if DEBUG
Console.WriteLine("Rosyln does not parse this because DEBUG is not defined");
#endif
}
}

namespace Namespace
{

#pragma
class ExtraLineChecker { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,19 @@
#undef foo
#line 6
class ClassName { }

public class ClassName
{
void MethodName()
{
#if DEBUG
Console.WriteLine("Rosyln does not parse this because DEBUG is not defined");
#endif
}
}

namespace Namespace
{
#pragma
class ExtraLineChecker { }
}

This file was deleted.

This file was deleted.

9 changes: 2 additions & 7 deletions Src/CSharpier.Tests/TestFiles/Directives/_DirectivesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ namespace CSharpier.Tests.TestFiles
public class DirectivesTests : BaseTest
{
[Test]
public void BasicDirectives()
public void Directives()
{
this.RunTest("Directives", "BasicDirectives");
}
[Test]
public void IfDirectiveEmptyBlock()
{
this.RunTest("Directives", "IfDirectiveEmptyBlock");
this.RunTest("Directives", "Directives");
}
[Test]
public void Regions()
Expand Down
2 changes: 2 additions & 0 deletions Src/CSharpier/PrinterHelpers/SyntaxTrivia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ private Doc PrintLeadingTrivia(SyntaxTriviaList leadingTrivia)
)
{
hadDirective = true;
// GH-22 the problem is that we have a hardline followed by a literalline. What we really mean by literalLine is, add a line and dedent if this isn't preceded by a hardline.... I think
// we should probably figure out better new lines for directives, because that could affect this.
parts.Push(LiteralLine, trivia.ToString());
}
else if (
Expand Down

0 comments on commit 1a23d08

Please sign in to comment.