Skip to content

Commit

Permalink
arrow expression methods
Browse files Browse the repository at this point in the history
closes #58
  • Loading branch information
belav committed Apr 11, 2021
1 parent 5de9d10 commit 180542a
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ public class LongConstructorClass
{
public LongConstructorClass(
string oneoneoneoneoneoneone,
string twotwotwotwotwotwo) { }
string twotwotwotwotwotwo
) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ class ClassName
int,
NativeMethods.REQUEST_NOTIFICATION_STATUS> asyncCallback,
delegate* unmanaged<IntPtr, void> requestsDrainedHandler,
IntPtr pvRequestContext)
{
IntPtr pvRequestContext
) {
return;
}

public static extern unsafe int InvokeCallbackFuncPtr_Inline_NoGCTransition(
delegate* unmanaged[Cdecl]<int, int> cb,
int* n);
int* n
);
}

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions Src/CSharpier.Tests/TestFiles/MethodDeclaration/MethodComments.cst

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
public class ClassName
{
public void DoStuff() { }

public void LongMethodNameForceLineBreak(
string oneoneoneoneoneoneoneoneone,
string twotwotwotwotwotwotwotwo,
string threethreethreethreethreethree
) {
return;
}

public void LongMethodNameForceLineBreakasdfasdfasfasdf(
string one,
string two,
string three
) { }

public void DoStuff(
// leading
string one, // trailing
string two,
string three
) {
var x = 0;
}

public void DoStuff(string one, string two) { }

public void DoStuff()
{
DoStuff();
DoStuff();
}

private Doc MethodWithParameters(
SomeClass one,
SomeClass two,
SomeClass three
) => CallSomethingElseWithALongNameThatForcesABreak(one, two, three);

private Doc ShortMethod() => Method();

private Doc ShortishMethod(SomeClass one) =>
CallSomeOtherLongMethodSoThatItBreaks(one);

private Doc MethodWithParameters(
SomeClass one,
SomeClass two,
SomeClass three
) => CallSomething(one, two, three);
}

class ExplicitInterfaceSpecifier : IDisposable
{
void IDisposable.Dispose() { }
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,9 @@ namespace CSharpier.Tests.TestFiles
public class MethodDeclarationTests : BaseTest
{
[Test]
public void BasicMethod()
public void MethodDeclarations()
{
this.RunTest("MethodDeclaration", "BasicMethod");
}
[Test]
public void ExplicitlyInterfaceSpecifierMethod()
{
this.RunTest(
"MethodDeclaration",
"ExplicitlyInterfaceSpecifierMethod"
);
}
[Test]
public void LongMethodWithParameters()
{
this.RunTest("MethodDeclaration", "LongMethodWithParameters");
}
[Test]
public void MethodComments()
{
this.RunTest("MethodDeclaration", "MethodComments");
}
[Test]
public void MethodWithParameters()
{
this.RunTest("MethodDeclaration", "MethodWithParameters");
}
[Test]
public void MethodWithStatements()
{
this.RunTest("MethodDeclaration", "MethodWithStatements");
this.RunTest("MethodDeclaration", "MethodDeclarations");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ record MostlyWeeklyTemperature(
double monday,
double thursday,
double friday,
double sunday)
{
double sunday
) {
public double Mean => (monday + monday + thursday + friday + sunday) / 5.0;
}

Expand Down
6 changes: 3 additions & 3 deletions Src/CSharpier/Printer/ArrowExpressionClauseSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public partial class Printer
private Doc PrintArrowExpressionClauseSyntax(
ArrowExpressionClauseSyntax node)
{
return Group(
Indent(
return Docs.Group(
Docs.Indent(
" ",
this.PrintSyntaxToken(node.ArrowToken, Line),
this.PrintSyntaxToken(node.ArrowToken, Docs.Line),
this.Print(node.Expression)
)
);
Expand Down
17 changes: 10 additions & 7 deletions Src/CSharpier/Printer/ParameterListSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ private Doc PrintParameterListSyntax(ParameterListSyntax node)
return Group(
this.PrintSyntaxToken(node.OpenParenToken),
node.Parameters.Count > 0
? Indent(
SoftLine,
this.PrintSeparatedSyntaxList(
node.Parameters,
this.PrintParameterSyntax,
Line
)
? Docs.Concat(
Docs.Indent(
Docs.SoftLine,
this.PrintSeparatedSyntaxList(
node.Parameters,
this.PrintParameterSyntax,
Line
)
),
Docs.SoftLine
)
: Doc.Null,
this.PrintSyntaxToken(node.CloseParenToken)
Expand Down

0 comments on commit 180542a

Please sign in to comment.