Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistently indent by 4 spaces (or by tabs) #623

Merged
merged 14 commits into from
May 9, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class TestClass

var conditionalIndentation = someBoolean
? someLongValue____________________________________
+ someLongValue____________________________________
+ someLongValue____________________________________
: someLongValue____________________________________
+ someLongValue____________________________________;
+ someLongValue____________________________________;

var someValue =
value1__________________ == value2_________________
Expand Down
24 changes: 12 additions & 12 deletions Src/CSharpier.Tests/FormattingTests/TestFiles/ClassDeclarations.cst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class WithReallyLongNameInterface

public class ThisIsSomeLongNameAndItShouldFormatWell1
: AnotherLongClassName,
AndYetAnotherLongClassName,
AndStillOneMore { }
AndYetAnotherLongClassName,
AndStillOneMore { }

public class SimpleGeneric<T> where T : new() { }

Expand All @@ -36,22 +36,22 @@ public class SimpleGeneric<T> : BaseClass<T> where T : new() { }

public class ThisIsSomeLongNameAndItShouldFormatWell2<T, T2, T3>
: AnotherLongClassName<T>,
AnotherClassName
AnotherClassName
where T : new(), AnotherTypeConstraint
where T2 : new()
where T3 : new() { }

public class IdentityDbContext<TUser, TRole, TKey>
: IdentityDbContext<
TUser,
TRole,
TKey,
IdentityUserClaim<TKey>,
IdentityUserRole<TKey>,
IdentityUserLogin<TKey>,
IdentityRoleClaim<TKey>,
IdentityUserToken<TKey>
>
TUser,
TRole,
TKey,
IdentityUserClaim<TKey>,
IdentityUserRole<TKey>,
IdentityUserLogin<TKey>,
IdentityRoleClaim<TKey>,
IdentityUserToken<TKey>
>
where TUser : IdentityUser<TKey>
where TRole : IdentityRole<TKey>
where TKey : IEquatable<TKey> { }
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class WithReallyLongNameInterface

public class ThisIsSomeLongNameAndItShouldFormatWell1
: AnotherLongClassName,
AndYetAnotherLongClassName,
AndStillOneMore { }
AndYetAnotherLongClassName,
AndStillOneMore { }

public class SimpleGeneric<T> where T : new() { }

Expand All @@ -36,22 +36,22 @@ public class SimpleGeneric<T> : BaseClass<T> where T : new() { }

public class ThisIsSomeLongNameAndItShouldFormatWell2<T, T2, T3>
: AnotherLongClassName<T>,
AnotherClassName
AnotherClassName
where T : new(), AnotherTypeConstraint
where T2 : new()
where T3 : new() { }

public class IdentityDbContext<TUser, TRole, TKey>
: IdentityDbContext<
TUser,
TRole,
TKey,
IdentityUserClaim<TKey>,
IdentityUserRole<TKey>,
IdentityUserLogin<TKey>,
IdentityRoleClaim<TKey>,
IdentityUserToken<TKey>
>
TUser,
TRole,
TKey,
IdentityUserClaim<TKey>,
IdentityUserRole<TKey>,
IdentityUserLogin<TKey>,
IdentityRoleClaim<TKey>,
IdentityUserToken<TKey>
>
where TUser : IdentityUser<TKey>
where TRole : IdentityRole<TKey>
where TKey : IEquatable<TKey> { }
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ public class ClassName

public bool CloseParenIndents = someCondition
? this.SomeMethodCallThatIsLonger____________________(
someLongValue,
someLongValue,
someLongValue
)
someLongValue,
someLongValue,
someLongValue
)
: this.SomeMethodCallThatIsLonger____________________(
someLongValue,
someLongValue,
someLongValue
);
someLongValue,
someLongValue,
someLongValue
);

void Method()
{
Expand All @@ -37,12 +37,12 @@ public class ClassName
CallMethod(
someValue,
someCondition
? trueValue________________________________
: falseValue_______________________________,
? trueValue________________________________
: falseValue_______________________________,
someCondition_____________________________________
&& someOtherCondition__________________________________
? trueValue________________________________
: falseValue_______________________________,
&& someOtherCondition__________________________________
? trueValue________________________________
: falseValue_______________________________,
someCondition_____________________________________
&& someOtherCondition__________________________________
);
Expand All @@ -51,8 +51,8 @@ public class ClassName
file,
// leading here should break parameters and GetEncoding should still group
encoding
? File.GetEncoding________________________________(1252)
: encoding_____________________,
? File.GetEncoding________________________________(1252)
: encoding_____________________,
cancellationToken
);

Expand All @@ -64,80 +64,80 @@ public class ClassName
);

return someLongCondition___________________________
? trueValue________________________________
: falseValue________________________________;
? trueValue________________________________
: falseValue________________________________;

return
someLongCondition____________________________________
&& someOtherLongCondition____________________________________
? trueValue________________________________
: falseValue_______________________________;
? trueValue________________________________
: falseValue_______________________________;

return
someLongCondition____________________________________
is SomeLongType___________________________
? trueValue________________________________
: falseValue_______________________________;
? trueValue________________________________
: falseValue_______________________________;

return (
someLongCondition____________________________________
&& someOtherLongCondition____________________________________
)
? trueValue________________________________
: falseValue_______________________________;
? trueValue________________________________
: falseValue_______________________________;

return
someLongCondition____________________________________
== someThingElse______________________
&& someOtherLongCondition____________________________________
? trueValue________________________________
: falseValue_______________________________;
? trueValue________________________________
: falseValue_______________________________;

return CallSomeMethod(
someLongCondition____________________________________,
someOtherLongCondition____________________________________
)
? trueValue________________________________
: falseValue_______________________________;
? trueValue________________________________
: falseValue_______________________________;

return firstCondition
? firstValue
: secondCondition
? secondValue
: thirdCondition
? thirdValue
: fourthValue;
? firstValue
: secondCondition
? secondValue
: thirdCondition
? thirdValue
: fourthValue;

return firstCondition
? secondCondition
? firstValue
: secondValue
: thirdCondition
? thirdValue
: fourthValue;
? secondCondition
? firstValue
: secondValue
: thirdCondition
? thirdValue
: fourthValue;

return a ? b : c;

return a
? b
: c
? d
: e;
? b
: c
? d
: e;

var invocationIndent = someCondition
? SomeObject
.CallLongMethod__________________________________________()
.CallLongMethod__________________________________________()
.CallLongMethod__________________________________________()
.CallLongMethod__________________________________________()
: SomeObject
.CallLongMethod__________________________________________()
.CallLongMethod__________________________________________();
.CallLongMethod__________________________________________()
.CallLongMethod__________________________________________();

CallMethod(
someCondition
? SomeValue
: SomeObject
.CallMethod__________________________________()
.CallMethod__________________________________()
? SomeValue
: SomeObject
.CallMethod__________________________________()
.CallMethod__________________________________()
);
}
}
Loading