Skip to content

Commit

Permalink
GH-7 getting methods printing a little better.
Browse files Browse the repository at this point in the history
  • Loading branch information
belav committed Mar 7, 2021
1 parent e272741 commit 72e0a6e
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 130 deletions.
13 changes: 7 additions & 6 deletions Src/CSharpier.Tests/EncodingTests/UTF8BOM.actual.cst
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@ namespace Insite.Admin
public class AdminContext
{
public static bool DisableAdminAccess
=> (ConfigurationManager.AppSettings["DisableAdminAccess"] ?? "false").EqualsIgnoreCase(
"true");
=> (ConfigurationManager.AppSettings["DisableAdminAccess"] ?? "false")
.EqualsIgnoreCase("true");

private static IPerRequestCacheManager perRequestCacheManager;
private static IPerRequestCacheManager PerRequestCacheManager
=> perRequestCacheManager ?? (perRequestCacheManager = DependencyLocator.Current.GetInstance<IPerRequestCacheManager>());
=> perRequestCacheManager ?? (perRequestCacheManager = DependencyLocator
.Current
.GetInstance<IPerRequestCacheManager>());

private static IAdminContext current;

public static IAdminContext Current
{
get
{
return current ?? PerRequestCacheManager.Get(
"AdminContext_Current",
LoadAdminContext);
return current ?? PerRequestCacheManager
.Get("AdminContext_Current", LoadAdminContext);
}
set { current = value; }
}
Expand Down
64 changes: 17 additions & 47 deletions Src/CSharpier.Tests/Samples/AllInOne.Formatted.cst
Original file line number Diff line number Diff line change
Expand Up @@ -297,19 +297,17 @@ namespace My
orderby g.Count() ascending
orderby g.Key descending
select new { Country = g.Key, CustCount = g.Count() };
query = from c in customers
select c into d
select d;
query = from c in customers select c into d select d;
}
~A() { }
private readonly int f1;
[Obsolete]
[NonExisting]
[Foo::NonExisting(var, 5)]
[CLSCompliant(false)]
[Obsolete, System.NonSerialized, NonSerialized, CLSCompliant(true ||
false &
true)]
[Obsolete, System.NonSerialized, NonSerialized, CLSCompliant(true
|| false
& true)]
private volatile int f2;
[return: Obsolete]
[method: Obsolete]
Expand Down Expand Up @@ -452,12 +450,14 @@ namespace My
}
void AsyncAnonymous() // C # 5 feature
{
var task = Task.Factory.StartNew(
async () =>
{
return await new WebClient().DownloadStringTaskAsync(
"http://example.com");
});
var task = Task
.Factory
.StartNew(
async () =>
{
return await new WebClient()
.DownloadStringTaskAsync("http://example.com");
});
}
}
}
Expand Down Expand Up @@ -624,8 +624,7 @@ namespace Comments.XmlComments.UndocumentedKeywords
/*s*/
int /*s*/
intValue = 0;
intValue = intValue /*s*/
+ 1;
intValue = intValue /*s*/ + 1;
string strValue = /*s*/ "hello";
/*s*/
MyClass c = new MyClass();
Expand Down Expand Up @@ -676,61 +675,33 @@ namespace Comments.XmlComments.UndocumentedKeywords
Foo<T> f = new Foo<int>(); /*<> ()*/

f.method(); /*().*/

i = i + i - i * i / i % i &
i |
i ^ i; /*+ - * / % & | ^*/

i = i + i - i * i / i % i & i | i ^ i; /*+ - * / % & | ^*/
bool b = true & false | true ^ false; /*& | ^*/

b = !b; /*!*/

i = ~i; /*~i*/

b = i < i &&
i > i; /*< && >*/

b = i < i && i > i; /*< && >*/
int? ii = 5; /*? bug*/
// NO ?
int f = true ? 1 : 0; /*? :*/
// YES :
i++; /*++*/

i--; /*--*/

b = true &&
false ||
true; /*&& ||*/

b = true && false || true; /*&& ||*/
i << 5; /*<<*/

i >> 5; /*>>*/

b = i == i &&
i != i &&
i <= i &&
i >= i; /*= == && != <= >=*/

b = i == i && i != i && i <= i && i >= i; /*= == && != <= >=*/
i += 5.0; /*+=*/

i -= i; /*-=*/

i *= i;
/**=*/
i /= i; /*/=*/

i %= i; /*%=*/

i &= i; /*&=*/

i |= i; /*|=*/

i ^= i; /*^=*/

i <<= i; /*<<=*/

i >>= i; /*>>=*/

object s = x => x + 1; /*=>*/

double d = .3;
Expand All @@ -740,7 +711,6 @@ namespace Comments.XmlComments.UndocumentedKeywords
Point* p = &point;
/** &*/
p->x = 10; /*->*/

}
IO::BinaryReader br = null;
x[i: 1] = 3;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class ClassName
{
public void MethodName()
{
this.Method(true);

this.NamedArguments(b: true, c: "false");
}
}
33 changes: 33 additions & 0 deletions Src/CSharpier.Tests/TestFiles/IfStatement/IfStatements.actual.cst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
public class ClassName
{
public void MethodName()
{
if (true) { }

if (true == false) { }

if (true && false) { }

if (
longStatementName
&& longerStatementName
&& evenLongeStatementName
&& superLongStatementName
) { }

if (true)
DoSoemthing();
else if (false)
DoSomething();
else
DoSomething;

if (!true) { }

if (true != false) { }

if (true || false) { }

if (true && (true || false)) { }
}
}
9 changes: 6 additions & 3 deletions Src/CSharpier.Tests/TestFiles/IfStatement/IfStatements.cst
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ public class ClassName
&& superLongStatementName
) { }

if (true) DoSoemthing();
else if (false) DoSomething();
else DoSomething;
if (true)
DoSoemthing();
else if (false)
DoSomething();
else
DoSomething;

if (!true) { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
.Method(
"ljkasdfkljasdlkjfklajsdfkjlasdfkjlasdkljfajklsdfkjasdf",
"kljasdfkljaslkjdfljaksdfkjlaksljfaksjldf");

var superLongMethodNameForceLine = someFactoryName
.SuperLongMethodNameForceLine();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,14 @@

namespace CSharpier.Tests.TestFiles
{
public class InterpolatedStringExpressionTests : BaseTest
public class InvocationExpressionTests : BaseTest
{
[Test]
public void BasicInterpolatedStringExpression()
public void InvocationExpressions()
{
this.RunTest(
"InterpolatedStringExpression",
"BasicInterpolatedStringExpression");
}
[Test]
public void Interpolation()
{
this.RunTest("InterpolatedStringExpression", "Interpolation");
}
[Test]
public void InterpolationShouldNotBreakLines()
{
this.RunTest(
"InterpolatedStringExpression",
"InterpolationShouldNotBreakLines");
}
[Test]
public void InterpolationWithAlignmentAndFormat()
{
this.RunTest(
"InterpolatedStringExpression",
"InterpolationWithAlignmentAndFormat");
"InvocationExpression",
"InvocationExpressions");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
where d != null
join c1 in customers on c1.GetHashCode() equals c.GetHashCode()
join c1 in customers on c1.GetHashCode() equals c.GetHashCode() into e
group c by c
.Country into g
group c by c.Country into g
orderby g.Count() ascending
orderby g
.Key descending
orderby g.Key descending
select new { Country = g.Key, CustCount = g.Count() };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,10 @@
{
var newState = (GetState(), action, hasKey) switch
{
(DoorState
.Closed, Action
.Open, _) => DoorState
.Opened,
(DoorState
.Opened, Action
.Close, _) => DoorState
.Closed,
(DoorState
.Closed, Action
.Lock, true) => DoorState
.Locked,
(DoorState
.Locked, Action
.Unlock, true) => DoorState
.Closed,
(DoorState.Closed, Action.Open, _) => DoorState.Opened,
(DoorState.Opened, Action.Close, _) => DoorState.Closed,
(DoorState.Closed, Action.Lock, true) => DoorState.Locked,
(DoorState.Locked, Action.Unlock, true) => DoorState.Closed,
(var state, _, _) => state
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
}

while (
directoryInfo
.Name != "Test"
&& directoryInfo
.Parent != null
directoryInfo.Name != "Test"
&& directoryInfo.Parent != null
&& someLongCondition == "test")
{
directoryInfo = directoryInfo.Parent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class ClassName
}

while (
directoryInfo.Name != "Test" &&
directoryInfo.Parent != null &&
someLongCondition == "test")
directoryInfo.Name != "Test"
&& directoryInfo.Parent != null
&& someLongCondition == "test")
{
directoryInfo = directoryInfo.Parent;
}
Expand Down
Loading

0 comments on commit 72e0a6e

Please sign in to comment.