Browse Source

Fix #603: Single element arrays should not span multiple lines

Fix #1079: CSharpFormattingOptions.AutoPropertyFormatting has no effect
pull/2276/head
Siegfried Pammer 5 years ago
parent
commit
cc19e9043e
  1. 32
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/FSharpLoops_Debug.cs
  2. 36
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/FSharpLoops_Release.cs
  3. 5
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1325.cs
  4. 13
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.cs
  5. 11
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.cs
  6. 41
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/AutoProperties.cs
  7. 4
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS72_PrivateProtected.cs
  8. 224
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs
  9. 5
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CheckedUnchecked.cs
  10. 230
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs
  11. 8
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CustomAttributes.cs
  12. 6
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CustomTaskType.cs
  13. 75
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/DeconstructionTests.cs
  14. 10
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs
  15. 254
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.cs
  16. 824
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs
  17. 15
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InlineAssignmentTest.cs
  18. 13
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InterfaceTests.cs
  19. 5
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs
  20. 5
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullPropagation.cs
  21. 10
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullableRefTypes.cs
  22. 5
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/OptionalArguments.cs
  23. 33
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs
  24. 44
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs
  25. 43
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Records.cs
  26. 19
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/RefLocalsAndReturns.cs
  27. 5
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs
  28. 82
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ThrowExpressions.cs
  29. 5
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/TupleTests.cs
  30. 39
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeMemberTests.cs
  31. 6
      ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Issue2192.cs
  32. 12
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpFormattingOptions.cs
  33. 165
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs
  34. 30
      ICSharpCode.Decompiler/CSharp/OutputVisitor/FormattingOptionsFactory.cs
  35. 2
      ICSharpCode.Decompiler/CSharp/OutputVisitor/ITokenWriter.cs
  36. 2
      ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs
  37. 3
      ICSharpCode.Decompiler/DecompilerSettings.cs
  38. 2
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

32
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/FSharpLoops_Debug.cs

@ -68,15 +68,15 @@ public static class Program
{ {
switch (pc) switch (pc)
{ {
default: default:
pc = 1; pc = 1;
current = 1; current = 1;
return 1; return 1;
case 1: case 1:
pc = 2; pc = 2;
break; break;
case 2: case 2:
break; break;
} }
current = 0; current = 0;
return 0; return 0;
@ -91,11 +91,11 @@ public static class Program
{ {
switch (pc) switch (pc)
{ {
default: default:
return false; return false;
case 0: case 0:
case 2: case 2:
return false; return false;
} }
} }
@ -131,9 +131,7 @@ public static class Program
public static int[] getArray() public static int[] getArray()
{ {
return new int[1] { return new int[1] { 1 };
1
};
} }
[EntryPoint] [EntryPoint]

36
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/FSharpLoops_Release.cs

@ -69,15 +69,15 @@ public static class Program
{ {
switch (pc) switch (pc)
{ {
default: default:
pc = 1; pc = 1;
current = 1; current = 1;
return 1; return 1;
case 1: case 1:
pc = 2; pc = 2;
break; break;
case 2: case 2:
break; break;
} }
current = 0; current = 0;
return 0; return 0;
@ -92,11 +92,11 @@ public static class Program
{ {
switch (pc) switch (pc)
{ {
default: default:
return false; return false;
case 0: case 0:
case 2: case 2:
return false; return false;
} }
} }
@ -132,9 +132,7 @@ public static class Program
public static int[] getArray() public static int[] getArray()
{ {
return new int[1] { return new int[1] { 1 };
1
};
} }
[EntryPoint] [EntryPoint]
@ -160,9 +158,7 @@ public static class Program
Console.WriteLine(headOrDefault); Console.WriteLine(headOrDefault);
fSharpList = tailOrNull; fSharpList = tailOrNull;
} }
int[] array = new int[1] { int[] array = new int[1] { 1 };
1
};
for (int headOrDefault = 0; headOrDefault < array.Length; headOrDefault++) for (int headOrDefault = 0; headOrDefault < array.Length; headOrDefault++)
{ {
Console.WriteLine(array[headOrDefault]); Console.WriteLine(array[headOrDefault]);

5
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1325.cs

@ -45,10 +45,7 @@ namespace Issue1325
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
public string Unparameterized { public string Unparameterized { get; set; }
get;
set;
}
} }
} }
namespace Microsoft.VisualBasic namespace Microsoft.VisualBasic

13
ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.cs

@ -24,8 +24,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
private void SimpleTypes() private void SimpleTypes()
{ {
var value = new { var value = new { };
};
var anon = new { var anon = new {
X = 5 X = 5
}; };
@ -82,19 +81,13 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
} }
}; };
#if ROSLYN && OPT #if ROSLYN && OPT
var obj = new[] { var obj = new[] { array, array };
array,
array
};
Console.WriteLine(array[0].X); Console.WriteLine(array[0].X);
Console.WriteLine(array[1].X); Console.WriteLine(array[1].X);
Console.WriteLine(obj.Length); Console.WriteLine(obj.Length);
#else #else
var array2 = new[] { var array2 = new[] { array, array };
array,
array
};
Console.WriteLine(array[0].X); Console.WriteLine(array[0].X);
Console.WriteLine(array[1].X); Console.WriteLine(array[1].X);

11
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.cs

@ -167,11 +167,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public static Func<Task<int>> AsyncLambda() public static Func<Task<int>> AsyncLambda()
{ {
return async () => await GetIntegerSumAsync(new int[3] { return async () => await GetIntegerSumAsync(new int[3] { 1, 2, 3 });
1,
2,
3
});
} }
public static Func<Task<int>> AsyncDelegate() public static Func<Task<int>> AsyncDelegate()
@ -252,10 +248,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public struct HopToThreadPoolAwaitable : INotifyCompletion public struct HopToThreadPoolAwaitable : INotifyCompletion
{ {
public bool IsCompleted { public bool IsCompleted { get; set; }
get;
set;
}
public HopToThreadPoolAwaitable GetAwaiter() public HopToThreadPoolAwaitable GetAwaiter()
{ {

41
ICSharpCode.Decompiler.Tests/TestCases/Pretty/AutoProperties.cs

@ -2,44 +2,25 @@
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
// TODO : maybe use single-line formatting in this case?
internal class AutoProperties internal class AutoProperties
{ {
public int A { public int A { get; } = 1;
get;
} = 1; public int B { get; set; } = 2;
public int B { public static int C { get; } = 3;
get;
set; public static int D { get; set; } = 4;
} = 2;
public string value { get; set; }
public static int C {
get;
} = 3;
public static int D {
get;
set;
} = 4;
public string value {
get;
set;
}
[Obsolete("Property")] [Obsolete("Property")]
#if CS70 #if CS70
[field: Obsolete("Field")] [field: Obsolete("Field")]
#endif #endif
public int PropertyWithAttributeOnBackingField { public int PropertyWithAttributeOnBackingField { get; set; }
get;
set;
}
public int issue1319 { public int issue1319 { get; }
get;
}
public AutoProperties(int issue1319) public AutoProperties(int issue1319)
{ {

4
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS72_PrivateProtected.cs

@ -20,9 +20,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
internal class CS72_PrivateProtected internal class CS72_PrivateProtected
{ {
private protected int Property { private protected int Property { get; }
get;
}
private protected void Method() private protected void Method()
{ {

224
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs

@ -1,4 +1,5 @@
// Copyright (c) 2018 Siegfried Pammer #pragma warning disable format
// Copyright (c) 2018 Siegfried Pammer
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy of this // Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software // software and associated documentation files (the "Software"), to deal in the Software
@ -56,33 +57,20 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocBool() public unsafe string SimpleStackAllocBool()
{ {
bool* ptr = stackalloc bool[4] { bool* ptr = stackalloc bool[4] { false, true, false, true };
false,
true,
false,
true
};
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
} }
public unsafe string DoNotInlineTest() public unsafe string DoNotInlineTest()
{ {
bool* ptr = stackalloc bool[4] { bool* ptr = stackalloc bool[4] { false, true, false, true };
false,
true,
false,
true
};
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
} }
public unsafe string SimpleStackAllocByte() public unsafe string SimpleStackAllocByte()
{ {
byte* ptr = stackalloc byte[2] { byte* ptr = stackalloc byte[2] { 0, 1 };
0,
1
};
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer(ptr); return UsePointer(ptr);
} }
@ -90,61 +78,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocPrimesAsBytes() public unsafe string SimpleStackAllocPrimesAsBytes()
{ {
byte* ptr = stackalloc byte[55] { byte* ptr = stackalloc byte[55] {
1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23,
2, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
3, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109,
5, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
7, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227,
11, 229, 233, 239, 241, 251
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,
61,
67,
71,
73,
79,
83,
89,
97,
101,
103,
107,
109,
113,
127,
131,
137,
139,
149,
151,
157,
163,
167,
173,
179,
181,
191,
193,
197,
199,
211,
223,
227,
229,
233,
239,
241,
251
}; };
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer(ptr); return UsePointer(ptr);
@ -152,12 +91,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocChar() public unsafe string SimpleStackAllocChar()
{ {
char* ptr = stackalloc char[4] { char* ptr = stackalloc char[4] { '1', '2', '3', '4' };
'1',
'2',
'3',
'4'
};
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
} }
@ -165,32 +99,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocCharAlphabet() public unsafe string SimpleStackAllocCharAlphabet()
{ {
char* ptr = stackalloc char[26] { char* ptr = stackalloc char[26] {
'A', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'B', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'C', 'U', 'V', 'W', 'X', 'Y', 'Z'
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z'
}; };
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
@ -198,58 +109,35 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocSByte() public unsafe string SimpleStackAllocSByte()
{ {
sbyte* ptr = stackalloc sbyte[3] { sbyte* ptr = stackalloc sbyte[3] { 1, 2, 3 };
1,
2,
3
};
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
} }
public unsafe string SimpleStackAllocInt16() public unsafe string SimpleStackAllocInt16()
{ {
short* ptr = stackalloc short[3] { short* ptr = stackalloc short[3] { 1, 2, 3 };
1,
2,
3
};
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
} }
public unsafe string SimpleStackAllocUInt16() public unsafe string SimpleStackAllocUInt16()
{ {
ushort* ptr = stackalloc ushort[3] { ushort* ptr = stackalloc ushort[3] { 1, 2, 3 };
1,
2,
3
};
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
} }
public unsafe string SimpleStackAllocInt32() public unsafe string SimpleStackAllocInt32()
{ {
int* ptr = stackalloc int[3] { int* ptr = stackalloc int[3] { 1, 2, 3 };
1,
2,
3
};
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
} }
public unsafe string SimpleStackAllocInt32(int a, int b, int c) public unsafe string SimpleStackAllocInt32(int a, int b, int c)
{ {
int* ptr = stackalloc int[6] { int* ptr = stackalloc int[6] { 1, a, 2, b, 3, c };
1,
a,
2,
b,
3,
c
};
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
} }
@ -257,23 +145,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocInt32Fibonacci() public unsafe string SimpleStackAllocInt32Fibonacci()
{ {
int* ptr = stackalloc int[17] { int* ptr = stackalloc int[17] {
1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55,
1, 89, 144, 233, 377, 610, 987, 1597
2,
3,
5,
8,
13,
21,
34,
55,
89,
144,
233,
377,
610,
987,
1597
}; };
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
@ -281,47 +154,28 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocUInt32() public unsafe string SimpleStackAllocUInt32()
{ {
uint* ptr = stackalloc uint[3] { uint* ptr = stackalloc uint[3] { 1u, 2u, 3u };
1u,
2u,
3u
};
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
} }
public unsafe string SimpleStackAllocInt64() public unsafe string SimpleStackAllocInt64()
{ {
long* ptr = stackalloc long[3] { long* ptr = stackalloc long[3] { 1L, 2L, 3L };
1L,
2L,
3L
};
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
} }
public unsafe string SimpleStackAllocUInt64() public unsafe string SimpleStackAllocUInt64()
{ {
ulong* ptr = stackalloc ulong[3] { ulong* ptr = stackalloc ulong[3] { 1uL, 2uL, 3uL };
1uL,
2uL,
3uL
};
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
} }
public unsafe string SimpleStackAllocInt32NonConstant(int a, int b, int c) public unsafe string SimpleStackAllocInt32NonConstant(int a, int b, int c)
{ {
int* ptr = stackalloc int[6] { int* ptr = stackalloc int[6] { 0, 1, 0, a, b, c };
0,
1,
0,
a,
b,
c
};
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
} }
@ -370,12 +224,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public string GetSpan2() public string GetSpan2()
{ {
Span<int> span = stackalloc int[4] { Span<int> span = stackalloc int[4] { 1, 2, 3, 4 };
1,
2,
3,
4
};
return UseSpan(span); return UseSpan(span);
} }
@ -387,22 +236,13 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public string GetSpan4() public string GetSpan4()
{ {
Span<decimal> span = stackalloc decimal[4] { Span<decimal> span = stackalloc decimal[4] { 1m, 2m, 3m, 4m };
1m,
2m,
3m,
4m
};
return UseSpan(span); return UseSpan(span);
} }
public void Issue2103a() public void Issue2103a()
{ {
Span<byte> span = stackalloc byte[3] { Span<byte> span = stackalloc byte[3] { 1, 2, 3 };
1,
2,
3
};
Console.WriteLine(span[2] + span[0]); Console.WriteLine(span[2] + span[0]);
} }
@ -414,11 +254,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public void Issue2103c() public void Issue2103c()
{ {
Console.WriteLine((stackalloc byte[3] { Console.WriteLine((stackalloc byte[3] { 1, 2, 3 })[2]);
1,
2,
3
})[2]);
} }
public void Issue2103d() public void Issue2103d()

5
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CheckedUnchecked.cs

@ -93,10 +93,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public void ArrayInitializerChecked() public void ArrayInitializerChecked()
{ {
TestHelp(new int[2] { TestHelp(new int[2] { 1, 2 }, (int[] n) => checked(new int[2] {
1,
2
}, (int[] n) => checked(new int[2] {
n[0] + 1, n[0] + 1,
n[1] + 1 n[1] + 1
})); }));

230
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs

@ -51,20 +51,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public int Field; public int Field;
public short ShortField; public short ShortField;
public int Property { public int Property { get; set; }
get;
set;
}
public byte ByteProperty { public byte ByteProperty { get; set; }
get;
set;
}
public bool BoolProperty { public bool BoolProperty { get; set; }
get;
set;
}
public uint this[string name] { public uint this[string name] {
get { get {
@ -93,51 +84,18 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public CustomClass CustomClassField; public CustomClass CustomClassField;
public CustomStruct CustomStructField; public CustomStruct CustomStructField;
public byte ByteProp { public byte ByteProp { get; set; }
get; public sbyte SbyteProp { get; set; }
set; public short ShortProp { get; set; }
} public ushort UshortProp { get; set; }
public sbyte SbyteProp { public int IntProp { get; set; }
get; public uint UintProp { get; set; }
set; public long LongProp { get; set; }
} public ulong UlongProp { get; set; }
public short ShortProp { public string StringProp { get; set; }
get;
set;
}
public ushort UshortProp {
get;
set;
}
public int IntProp {
get;
set;
}
public uint UintProp {
get;
set;
}
public long LongProp {
get;
set;
}
public ulong UlongProp {
get;
set;
}
public string StringProp {
get;
set;
}
public CustomClass CustomClassProp { public CustomClass CustomClassProp { get; set; }
get; public CustomStruct CustomStructProp { get; set; }
set;
}
public CustomStruct CustomStructProp {
get;
set;
}
public static CustomClass operator +(CustomClass lhs, CustomClass rhs) public static CustomClass operator +(CustomClass lhs, CustomClass rhs)
{ {
@ -205,42 +163,15 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public ulong UlongField; public ulong UlongField;
public CustomClass CustomClassField; public CustomClass CustomClassField;
public CustomClass CustomClassProp { public CustomClass CustomClassProp { get; set; }
get; public byte ByteProp { get; set; }
set; public sbyte SbyteProp { get; set; }
} public short ShortProp { get; set; }
public byte ByteProp { public ushort UshortProp { get; set; }
get; public int IntProp { get; set; }
set; public uint UintProp { get; set; }
} public long LongProp { get; set; }
public sbyte SbyteProp { public ulong UlongProp { get; set; }
get;
set;
}
public short ShortProp {
get;
set;
}
public ushort UshortProp {
get;
set;
}
public int IntProp {
get;
set;
}
public uint UintProp {
get;
set;
}
public long LongProp {
get;
set;
}
public ulong UlongProp {
get;
set;
}
public static CustomStruct operator +(CustomStruct lhs, CustomStruct rhs) public static CustomStruct operator +(CustomStruct lhs, CustomStruct rhs)
{ {
@ -306,46 +237,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public long LongField; public long LongField;
public ulong UlongField; public ulong UlongField;
public CustomClass CustomClassProp { public CustomClass CustomClassProp { get; set; }
get; public CustomStruct CustomStructProp { get; set; }
set; public byte ByteProp { get; set; }
} public sbyte SbyteProp { get; set; }
public CustomStruct CustomStructProp { public short ShortProp { get; set; }
get; public ushort UshortProp { get; set; }
set; public int IntProp { get; set; }
} public uint UintProp { get; set; }
public byte ByteProp { public long LongProp { get; set; }
get; public ulong UlongProp { get; set; }
set;
}
public sbyte SbyteProp {
get;
set;
}
public short ShortProp {
get;
set;
}
public ushort UshortProp {
get;
set;
}
public int IntProp {
get;
set;
}
public uint UintProp {
get;
set;
}
public long LongProp {
get;
set;
}
public ulong UlongProp {
get;
set;
}
} }
private int test1; private int test1;
@ -369,61 +270,22 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
private static long longField; private static long longField;
private static ulong ulongField; private static ulong ulongField;
private static CustomClass CustomClassProp { private static CustomClass CustomClassProp { get; set; }
get; private static CustomStruct CustomStructProp { get; set; }
set; private static byte ByteProp { get; set; }
} private static sbyte SbyteProp { get; set; }
private static CustomStruct CustomStructProp { private static short ShortProp { get; set; }
get; private static ushort UshortProp { get; set; }
set; private static int IntProp { get; set; }
} private static uint UintProp { get; set; }
private static byte ByteProp { private static long LongProp { get; set; }
get; private static ulong UlongProp { get; set; }
set;
}
private static sbyte SbyteProp {
get;
set;
}
private static short ShortProp {
get;
set;
}
private static ushort UshortProp {
get;
set;
}
private static int IntProp {
get;
set;
}
private static uint UintProp {
get;
set;
}
private static long LongProp {
get;
set;
}
private static ulong UlongProp {
get;
set;
}
public static int StaticProperty { public static int StaticProperty { get; set; }
get;
set;
}
public static ShortEnum StaticShortProperty { public static ShortEnum StaticShortProperty { get; set; }
get;
set;
}
public static string StaticStringProperty { public static string StaticStringProperty { get; set; }
get;
set;
}
private static CustomStruct2 GetStruct() private static CustomStruct2 GetStruct()
{ {

8
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CustomAttributes.cs

@ -139,12 +139,8 @@ namespace CustomAttributes
"text", "text",
null, null,
typeof(int), typeof(int),
new object[] { new object[] { 1 },
1 new int[] { 1 }
},
new int[] {
1
}
})] })]
public static void BoxedLiteralsArray() public static void BoxedLiteralsArray()
{ {

6
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CustomTaskType.cs

@ -114,11 +114,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public static Func<ValueTask<int>> AsyncLambda() public static Func<ValueTask<int>> AsyncLambda()
{ {
return async () => await GetIntegerSumAsync(new int[3] { return async () => await GetIntegerSumAsync(new int[3] { 1, 2, 3 });
1,
2,
3
});
} }
public static Func<ValueTask<int>> AsyncDelegate() public static Func<ValueTask<int>> AsyncDelegate()

75
ICSharpCode.Decompiler.Tests/TestCases/Pretty/DeconstructionTests.cs

@ -49,10 +49,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
private class DeconstructionSource<T, T2> private class DeconstructionSource<T, T2>
{ {
public int Dummy { public int Dummy { get; set; }
get;
set;
}
public void Deconstruct(out T a, out T2 b) public void Deconstruct(out T a, out T2 b)
{ {
@ -63,10 +60,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
private class DeconstructionSource<T, T2, T3> private class DeconstructionSource<T, T2, T3>
{ {
public int Dummy { public int Dummy { get; set; }
get;
set;
}
public void Deconstruct(out T a, out T2 b, out T3 c) public void Deconstruct(out T a, out T2 b, out T3 c)
{ {
@ -97,70 +91,31 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public MyInt? NullableMyIntField; public MyInt? NullableMyIntField;
public int Int { public int Int { get; set; }
get;
set;
}
public long Long { public long Long { get; set; }
get;
set;
}
public float Float { public float Float { get; set; }
get;
set;
}
public double Double { public double Double { get; set; }
get;
set;
}
public decimal Decimal { public decimal Decimal { get; set; }
get;
set;
}
public string String { public string String { get; set; }
get;
set;
}
public object Object { public object Object { get; set; }
get;
set;
}
public dynamic Dynamic { public dynamic Dynamic { get; set; }
get;
set;
}
public int? NInt { public int? NInt { get; set; }
get;
set;
}
public MyInt My { public MyInt My { get; set; }
get;
set;
}
public MyInt? NMy { public MyInt? NMy { get; set; }
get;
set;
}
public static MyInt StaticMy { public static MyInt StaticMy { get; set; }
get;
set;
}
public static MyInt? StaticNMy { public static MyInt? StaticNMy { get; set; }
get;
set;
}
} }
private DeconstructionSource<T, T2> GetSource<T, T2>() private DeconstructionSource<T, T2> GetSource<T, T2>()

10
ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs

@ -34,10 +34,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
} }
#endif #endif
public dynamic Property { public dynamic Property { get; set; }
get;
set;
}
public void Method(dynamic a) public void Method(dynamic a)
{ {
@ -47,10 +44,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
private static dynamic field; private static dynamic field;
private static object objectField; private static object objectField;
public dynamic Property { public dynamic Property { get; set; }
get;
set;
}
public DynamicTests() public DynamicTests()
{ {

254
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.cs

@ -35,15 +35,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public static X StaticField; public static X StaticField;
public X InstanceField; public X InstanceField;
public static X StaticProperty { public static X StaticProperty { get; set; }
get;
set;
}
public X InstanceProperty { public X InstanceProperty { get; set; }
get;
set;
}
public static bool GenericMethod<Y>() public static bool GenericMethod<Y>()
{ {
@ -98,142 +92,67 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public class Administrator public class Administrator
{ {
public int ID { public int ID { get; set; }
get;
set;
}
public string TrueName { public string TrueName { get; set; }
get;
set;
}
public string Phone { public string Phone { get; set; }
get;
set;
}
} }
public class Contract public class Contract
{ {
public int ID { public int ID { get; set; }
get;
set;
}
public string ContractNo { public string ContractNo { get; set; }
get;
set;
}
public string HouseAddress { public string HouseAddress { get; set; }
get;
set;
}
public DateTime SigningTime { public DateTime SigningTime { get; set; }
get;
set;
}
public string BuyerName { public string BuyerName { get; set; }
get;
set;
}
public string BuyerTelephone { public string BuyerTelephone { get; set; }
get;
set;
}
public string Customer { public string Customer { get; set; }
get;
set;
}
public string CustTelephone { public string CustTelephone { get; set; }
get;
set;
}
public int AdminID { public int AdminID { get; set; }
get;
set;
}
public int StoreID { public int StoreID { get; set; }
get;
set;
}
} }
public class Database public class Database
{ {
public IQueryable<Contract> Contracts { public IQueryable<Contract> Contracts { get; set; }
get;
set;
}
public IQueryable<Loan> Loan { public IQueryable<Loan> Loan { get; set; }
get;
set;
}
public IQueryable<Administrator> Administrator { public IQueryable<Administrator> Administrator { get; set; }
get;
set;
}
public IQueryable<Store> Store { public IQueryable<Store> Store { get; set; }
get;
set;
}
} }
public class Loan public class Loan
{ {
public string ContractNo { public string ContractNo { get; set; }
get;
set;
}
public DateTime? ShenDate { public DateTime? ShenDate { get; set; }
get;
set;
}
public DateTime? LoanDate { public DateTime? LoanDate { get; set; }
get;
set;
}
public string Credit { public string Credit { get; set; }
get;
set;
}
public string LoanBank { public string LoanBank { get; set; }
get;
set;
}
public string Remarks { public string Remarks { get; set; }
get;
set;
}
} }
public class Store public class Store
{ {
public int ID { public int ID { get; set; }
get;
set;
}
public string Name { public string Name { get; set; }
get;
set;
}
} }
internal class MyClass internal class MyClass
@ -266,10 +185,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
} }
#endif #endif
public static int StaticProperty { public static int StaticProperty { get; set; }
get;
set;
}
#if CS60 #if CS60
public int ReadonlyProperty => 0; public int ReadonlyProperty => 0;
@ -281,10 +197,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
} }
#endif #endif
public int Property { public int Property { get; set; }
get;
set;
}
} }
internal class SimpleTypeWithCtor internal class SimpleTypeWithCtor
@ -435,23 +348,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public void ArrayIndex() public void ArrayIndex()
{ {
ToCode(X(), () => (new int[3] { ToCode(X(), () => (new int[3] { 3, 4, 5 })[0 + (int)(DateTime.Now.Ticks % 3)]);
3,
4,
5
})[0 + (int)(DateTime.Now.Ticks % 3)]);
} }
public void ArrayLengthAndDoubles() public void ArrayLengthAndDoubles()
{ {
ToCode(X(), () => new double[3] { ToCode(X(), () => new double[3] { 1.0, 2.01, 3.5 }.Concat(new double[2] { 1.0, 2.0 }).ToArray().Length);
1.0,
2.01,
3.5
}.Concat(new double[2] {
1.0,
2.0
}).ToArray().Length);
} }
public void AsOperator() public void AsOperator()
@ -488,37 +390,20 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public void ListInitializer() public void ListInitializer()
{ {
ToCode(X(), () => new Dictionary<int, int> { ToCode(X(), () => new Dictionary<int, int> {
{ { 1, 1 },
1, { 2, 2 },
1 { 3, 4 }
}, }.Count == 3);
{
2,
2
},
{
3,
4
}
}.Count == 3);
} }
public void ListInitializer2() public void ListInitializer2()
{ {
ToCode(X(), () => new List<int>(50) { ToCode(X(), () => new List<int>(50) { 1, 2, 3 }.Count == 3);
1,
2,
3
}.Count == 3);
} }
public void ListInitializer3() public void ListInitializer3()
{ {
ToCode(X(), () => new List<int> { ToCode(X(), () => new List<int> { 1, 2, 3 }.Count == 3);
1,
2,
3
}.Count == 3);
} }
public void LiteralCharAndProperty() public void LiteralCharAndProperty()
@ -582,30 +467,15 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public void MethodGroupAsExtensionMethod() public void MethodGroupAsExtensionMethod()
{ {
ToCode(X(), (Expression<Func<Func<bool>>>)(() => ((IEnumerable<int>)new int[4] { ToCode(X(), (Expression<Func<Func<bool>>>)(() => ((IEnumerable<int>)new int[4] { 2000, 2004, 2008, 2012 }).Any));
2000,
2004,
2008,
2012
}).Any));
} }
public void MethodGroupConstant() public void MethodGroupConstant()
{ {
ToCode(X(), () => Array.TrueForAll(new int[4] { ToCode(X(), () => Array.TrueForAll(new int[4] { 2000, 2004, 2008, 2012 }, DateTime.IsLeapYear));
2000,
2004,
2008,
2012
}, DateTime.IsLeapYear));
HashSet<int> set = new HashSet<int>(); HashSet<int> set = new HashSet<int>();
ToCode(X(), () => new int[4] { ToCode(X(), () => new int[4] { 2000, 2004, 2008, 2012 }.All(set.Add));
2000,
2004,
2008,
2012
}.All(set.Add));
Func<Func<object, object, bool>, bool> sink = (Func<object, object, bool> f) => f(null, null); Func<Func<object, object, bool>, bool> sink = (Func<object, object, bool> f) => f(null, null);
ToCode(X(), () => sink(object.Equals)); ToCode(X(), () => sink(object.Equals));
@ -627,15 +497,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
//no params //no params
ToCode(X(), () => call(() => 42)); ToCode(X(), () => call(() => 42));
//one param //one param
ToCode(X(), () => new int[2] { ToCode(X(), () => new int[2] { 37, 42 }.Select((int x) => x * 2));
37,
42
}.Select((int x) => x * 2));
//two params //two params
ToCode(X(), () => new int[2] { ToCode(X(), () => new int[2] { 37, 42 }.Select((int x, int i) => x * 2));
37,
42
}.Select((int x, int i) => x * 2));
} }
public void CurriedLambda() public void CurriedLambda()
@ -677,15 +541,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public void NewArrayAndExtensionMethod() public void NewArrayAndExtensionMethod()
{ {
ToCode(X(), () => new double[3] { ToCode(X(), () => new double[3] { 1.0, 2.01, 3.5 }.SequenceEqual(new double[3] { 1.0, 2.01, 3.5 }));
1.0,
2.01,
3.5
}.SequenceEqual(new double[3] {
1.0,
2.01,
3.5
}));
} }
public void NewMultiDimArray() public void NewMultiDimArray()
@ -982,31 +838,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public static void ArrayInitializer() public static void ArrayInitializer()
{ {
Test<Func<int[]>>(() => new int[3] { Test<Func<int[]>>(() => new int[3] { 1, 2, 3 }, () => new int[3] { 1, 2, 3 });
1,
2,
3
}, () => new int[3] {
1,
2,
3
});
Test<Func<int[]>>(() => new int[3], () => new int[3]); Test<Func<int[]>>(() => new int[3], () => new int[3]);
Test<Func<int[,]>>(() => new int[3, 5], () => new int[3, 5]); Test<Func<int[,]>>(() => new int[3, 5], () => new int[3, 5]);
Test<Func<int[][]>>(() => new int[3][], () => new int[3][]); Test<Func<int[][]>>(() => new int[3][], () => new int[3][]);
Test<Func<int[][]>>(() => new int[1][] { Test<Func<int[][]>>(() => new int[1][] { new int[3] { 1, 2, 3 } }, () => new int[1][] { new int[3] { 1, 2, 3 } });
new int[3] {
1,
2,
3
}
}, () => new int[1][] {
new int[3] {
1,
2,
3
}
});
} }
public static void AnonymousTypes() public static void AnonymousTypes()

824
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs

File diff suppressed because it is too large Load Diff

15
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InlineAssignmentTest.cs

@ -28,20 +28,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
private int[] field3; private int[] field3;
private short field4; private short field4;
public int InstanceProperty { public int InstanceProperty { get; set; }
get;
set;
}
public static int StaticProperty { public static int StaticProperty { get; set; }
get;
set;
}
public bool BoolProperty { public bool BoolProperty { get; set; }
get;
set;
}
public void SimpleInlineWithLocals() public void SimpleInlineWithLocals()
{ {

13
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InterfaceTests.cs

@ -24,16 +24,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
public interface IA public interface IA
{ {
int Property1 { int Property1 { get; }
get; int Property2 { set; }
} int Property3 { get; set; }
int Property2 {
set;
}
int Property3 {
get;
set;
}
event EventHandler MyEvent; event EventHandler MyEvent;
void Method(); void Method();

5
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs

@ -257,10 +257,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
#endif #endif
public struct DataItem public struct DataItem
{ {
public int Property { public int Property { get; set; }
get;
set;
}
public void TestCall() public void TestCall()
{ {

5
ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullPropagation.cs

@ -32,10 +32,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public readonly MyStruct ReadonlyStructField; public readonly MyStruct ReadonlyStructField;
public string Text; public string Text;
public MyClass Field; public MyClass Field;
public MyClass Property { public MyClass Property { get; set; }
get;
set;
}
public MyClass this[int index] => null; public MyClass this[int index] => null;
public MyClass Method(int arg) public MyClass Method(int arg)
{ {

10
ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullableRefTypes.cs

@ -75,10 +75,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
private int field3; private int field3;
private int? field4; private int? field4;
public string? Property { public string? Property { get; set; }
get;
set;
}
public event EventHandler? Event; public event EventHandler? Event;
public static int? NullConditionalOperator(T02_EverythingIsNullableInHere? x) public static int? NullConditionalOperator(T02_EverythingIsNullableInHere? x)
@ -98,10 +95,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
private int field3; private int field3;
private int? field4; private int? field4;
public string Property { public string Property { get; set; }
get;
set;
}
public event EventHandler Event; public event EventHandler Event;
} }

5
ICSharpCode.Decompiler.Tests/TestCases/Pretty/OptionalArguments.cs

@ -95,10 +95,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
a = new OptionalArguments("Hallo"); a = new OptionalArguments("Hallo");
b = new OptionalArguments(10); b = new OptionalArguments(10);
c = new OptionalArguments(10) { c = new OptionalArguments(10) {
{ { "Test", 10 },
"Test",
10
},
"Test2" "Test2"
}; };
} }

33
ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs

@ -25,18 +25,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
private interface IBase private interface IBase
{ {
int GetterOnly { int GetterOnly { get; }
get;
}
int SetterOnly { int SetterOnly { set; }
set;
}
int Test { int Test { get; set; }
get;
set;
}
event Action Event; event Action Event;
} }
@ -109,10 +102,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
private interface IChange private interface IChange
{ {
int Property { int Property { get; set; }
get;
set;
}
event EventHandler Changed; event EventHandler Changed;
} }
@ -121,10 +111,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
private EventHandler Changed; private EventHandler Changed;
int IChange.Property { int IChange.Property { get; set; }
get;
set;
}
event EventHandler IChange.Changed { event EventHandler IChange.Changed {
add { add {
@ -141,15 +128,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
private object issue1221; private object issue1221;
public int Value { public int Value { get; private set; }
get;
private set;
}
public int AutomaticProperty { public int AutomaticProperty { get; set; }
get;
set;
}
public int CustomProperty { public int CustomProperty {
get { get {

44
ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs

@ -46,14 +46,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
public class HbmParam public class HbmParam
{ {
public string Name { public string Name { get; set; }
get; public string[] Text { get; set; }
set;
}
public string[] Text {
get;
set;
}
} }
public class Customer public class Customer
@ -96,11 +90,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
return from c in customers return from c in customers
from o in c.Orders from o in c.Orders
select new { select new { c.Name, o.OrderID, o.Total };
c.Name,
o.OrderID,
o.Total
};
} }
public object SelectManyFollowedByOrderBy() public object SelectManyFollowedByOrderBy()
@ -108,11 +98,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
return from c in customers return from c in customers
from o in c.Orders from o in c.Orders
orderby o.Total descending orderby o.Total descending
select new { select new { c.Name, o.OrderID, o.Total };
c.Name,
o.OrderID,
o.Total
};
} }
public object MultipleSelectManyFollowedBySelect() public object MultipleSelectManyFollowedBySelect()
@ -120,11 +106,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
return from c in customers return from c in customers
from o in c.Orders from o in c.Orders
from d in o.Details from d in o.Details
select new { select new { c.Name, o.OrderID, d.Quantity };
c.Name,
o.OrderID,
d.Quantity
};
} }
public object MultipleSelectManyFollowedByLet() public object MultipleSelectManyFollowedByLet()
@ -133,11 +115,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
from o in c.Orders from o in c.Orders
from d in o.Details from d in o.Details
let x = (decimal)d.Quantity * d.UnitPrice let x = (decimal)d.Quantity * d.UnitPrice
select new { select new { c.Name, o.OrderID, x };
c.Name,
o.OrderID,
x
};
} }
public object FromLetWhereSelect() public object FromLetWhereSelect()
@ -166,9 +144,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
let pvalue = pi.GetValue(customers, null) let pvalue = pi.GetValue(customers, null)
select new HbmParam { select new HbmParam {
Name = pname, Name = pname,
Text = new string[1] { Text = new string[1] { (pvalue == null) ? "null" : pvalue.ToString() }
(pvalue == null) ? "null" : pvalue.ToString()
}
}).ToArray(); }).ToArray();
} }
@ -176,11 +152,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
return from c in customers return from c in customers
join o in orders on c.CustomerID equals o.CustomerID join o in orders on c.CustomerID equals o.CustomerID
select new { select new { c.Name, o.OrderDate, o.Total };
c.Name,
o.OrderDate,
o.Total
};
} }
public object JoinInto() public object JoinInto()

43
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Records.cs

@ -15,38 +15,18 @@
public record Pair<A, B> public record Pair<A, B>
{ {
public A First { public A First { get; init; }
get; public B Second { get; init; }
init;
}
public B Second {
get;
init;
}
} }
public record Properties public record Properties
{ {
public int A { public int A { get; set; }
get; public int B { get; }
set;
}
public int B {
get;
}
public int C => 43; public int C => 43;
public object O { public object O { get; set; }
get; public string S { get; set; }
set; public dynamic D { get; set; }
}
public string S {
get;
set;
}
public dynamic D {
get;
set;
}
public Properties() public Properties()
{ {
@ -87,10 +67,7 @@
{ {
public override string AbstractProp => "B"; public override string AbstractProp => "B";
public int? Value { public int? Value { get; set; }
get;
set;
}
} }
public record DerivedGeneric<T> : Pair<T, T?> where T : struct public record DerivedGeneric<T> : Pair<T, T?> where T : struct
@ -98,9 +75,7 @@
public bool Flag; public bool Flag;
} }
public abstract string AbstractProp { public abstract string AbstractProp { get; }
get;
}
} }
} }
namespace System.Runtime.CompilerServices namespace System.Runtime.CompilerServices

19
ICSharpCode.Decompiler.Tests/TestCases/Pretty/RefLocalsAndReturns.cs

@ -139,23 +139,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
} }
} }
private static int[] numbers = new int[10] { private static int[] numbers = new int[10] { 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023 };
1, private static string[] strings = new string[2] { "Hello", "World" };
3,
7,
15,
31,
63,
127,
255,
511,
1023
};
private static string[] strings = new string[2] {
"Hello",
"World"
};
private static string NullString = ""; private static string NullString = "";

5
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs

@ -29,10 +29,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
public readonly PropertyInfo Property; public readonly PropertyInfo Property;
public int Set { public int Set { get; set; }
get;
set;
}
public SetProperty(PropertyInfo property) public SetProperty(PropertyInfo property)
{ {

82
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ThrowExpressions.cs

@ -67,20 +67,10 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public int? NullableIntField; public int? NullableIntField;
public Data DataField; public Data DataField;
public Data? NullableDataField; public Data? NullableDataField;
public int IntProperty { public int IntProperty { get; set; }
get; public int? NullableIntProperty { get; set; }
set; public Data DataProperty { get; }
} public Data? NullableDataProperty { get; }
public int? NullableIntProperty {
get;
set;
}
public Data DataProperty {
get;
}
public Data? NullableDataProperty {
get;
}
} }
public struct Data public struct Data
@ -89,34 +79,18 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public int? NullableIntField; public int? NullableIntField;
public MoreData DataField; public MoreData DataField;
public MoreData? NullableDataField; public MoreData? NullableDataField;
public int IntProperty { public int IntProperty { get; set; }
get; public int? NullableIntProperty { get; set; }
set; public MoreData DataProperty { get; }
} public MoreData? NullableDataProperty { get; }
public int? NullableIntProperty {
get;
set;
}
public MoreData DataProperty {
get;
}
public MoreData? NullableDataProperty {
get;
}
} }
public struct MoreData public struct MoreData
{ {
public int IntField; public int IntField;
public int? NullableIntField; public int? NullableIntField;
public int IntProperty { public int IntProperty { get; set; }
get; public int? NullableIntProperty { get; set; }
set;
}
public int? NullableIntProperty {
get;
set;
}
} }
public static int IntField; public static int IntField;
@ -129,33 +103,15 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public Data? NullableDataField; public Data? NullableDataField;
public DataObject DataObjectField; public DataObject DataObjectField;
public static int IntProperty { public static int IntProperty { get; }
get; public static int? NullableIntProperty { get; }
} public static object ObjProperty { get; }
public static int? NullableIntProperty { public int InstIntProperty { get; }
get; public int? InstNullableIntProperty { get; }
} public object InstObjProperty { get; }
public static object ObjProperty { public Data DataProperty { get; }
get; public Data? NullableDataProperty { get; }
} public DataObject DataObjectProperty { get; }
public int InstIntProperty {
get;
}
public int? InstNullableIntProperty {
get;
}
public object InstObjProperty {
get;
}
public Data DataProperty {
get;
}
public Data? NullableDataProperty {
get;
}
public DataObject DataObjectProperty {
get;
}
public static int ReturnIntField() public static int ReturnIntField()
{ {

5
ICSharpCode.Decompiler.Tests/TestCases/Pretty/TupleTests.cs

@ -41,10 +41,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public struct GenericStruct<T> public struct GenericStruct<T>
{ {
public T Field; public T Field;
public T Property { public T Property { get; set; }
get;
set;
}
} }
public ValueTuple VT0; public ValueTuple VT0;

39
ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeMemberTests.cs

@ -87,15 +87,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
} }
public interface T06_IIndexerInInterface public interface T06_IIndexerInInterface
{ {
int this[string s, string s2] { int this[string s, string s2] { set; }
set;
}
} }
public interface T07_IMyInterface_IndexerInterfaceExplicitImplementation public interface T07_IMyInterface_IndexerInterfaceExplicitImplementation
{ {
int this[string s] { int this[string s] { get; }
get;
}
} }
public class T07_MyClass_IndexerInterfaceExplicitImplementation : T07_IMyInterface_IndexerInterfaceExplicitImplementation public class T07_MyClass_IndexerInterfaceExplicitImplementation : T07_IMyInterface_IndexerInterfaceExplicitImplementation
{ {
@ -111,9 +107,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
} }
public interface T08_IMyInterface_IndexerInterfaceImplementation public interface T08_IMyInterface_IndexerInterfaceImplementation
{ {
int this[string s] { int this[string s] { get; }
get;
}
} }
public class T08_MyClass_IndexerInterfaceImplementation : T08_IMyInterface_IndexerInterfaceImplementation public class T08_MyClass_IndexerInterfaceImplementation : T08_IMyInterface_IndexerInterfaceImplementation
{ {
@ -134,12 +128,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
} }
public abstract class T09_MyClass_IndexerAbstract public abstract class T09_MyClass_IndexerAbstract
{ {
public abstract int this[string s, string s2] { public abstract int this[string s, string s2] { set; }
set; protected abstract string this[int index] { get; }
}
protected abstract string this[int index] {
get;
}
} }
public class T09_MyClass_MethodExplicit : T09_IMyInterface_MethodExplicit public class T09_MyClass_MethodExplicit : T09_IMyInterface_MethodExplicit
{ {
@ -178,17 +168,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
} }
public interface T13_IMyInterface_PropertyInterface public interface T13_IMyInterface_PropertyInterface
{ {
int MyProperty { int MyProperty { get; set; }
get;
set;
}
} }
public interface T14_IMyInterface_PropertyInterfaceExplicitImplementation public interface T14_IMyInterface_PropertyInterfaceExplicitImplementation
{ {
int MyProperty { int MyProperty { get; set; }
get;
set;
}
} }
public class T14_MyClass_PropertyInterfaceExplicitImplementation : T14_IMyInterface_PropertyInterfaceExplicitImplementation public class T14_MyClass_PropertyInterfaceExplicitImplementation : T14_IMyInterface_PropertyInterfaceExplicitImplementation
{ {
@ -202,10 +186,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
} }
public interface T15_IMyInterface_PropertyInterfaceImplementation public interface T15_IMyInterface_PropertyInterfaceImplementation
{ {
int MyProperty { int MyProperty { get; set; }
get;
set;
}
} }
public class T15_MyClass_PropertyInterfaceImplementation : T15_IMyInterface_PropertyInterfaceImplementation public class T15_MyClass_PropertyInterfaceImplementation : T15_IMyInterface_PropertyInterfaceImplementation
{ {
@ -504,9 +485,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
} }
public interface T24_IA_HideMembers2a public interface T24_IA_HideMembers2a
{ {
int this[int i] { int this[int i] { get; }
get;
}
} }
public class T25_G_HideMembers3<T> public class T25_G_HideMembers3<T>

6
ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Issue2192.cs

@ -5,11 +5,7 @@ public class Issue2192
{ {
public static void M() public static void M()
{ {
string[] source = new string[3] { string[] source = new string[3] { "abc", "defgh", "ijklm" };
"abc",
"defgh",
"ijklm"
};
string text = "test"; string text = "test";
Console.WriteLine(source.Count((string w) => w.Length > text.Length)); Console.WriteLine(source.Count((string w) => w.Length > text.Length));
} }

12
ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpFormattingOptions.cs

@ -30,7 +30,6 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
{ {
public enum BraceStyle public enum BraceStyle
{ {
DoNotChange,
EndOfLine, EndOfLine,
EndOfLineWithoutSpace, EndOfLineWithoutSpace,
NextLine, NextLine,
@ -41,14 +40,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public enum PropertyFormatting public enum PropertyFormatting
{ {
AllowOneLine, SingleLine,
ForceOneLine, MultipleLines
ForceNewLine
} }
public enum Wrapping public enum Wrapping
{ {
DoNotChange,
DoNotWrap, DoNotWrap,
WrapAlways, WrapAlways,
WrapIfTooLong WrapIfTooLong
@ -167,10 +164,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public PropertyFormatting AutoPropertyFormatting { // tested public PropertyFormatting AutoPropertyFormatting { get; set; }
get;
set;
}
public PropertyFormatting SimplePropertyFormatting { // tested public PropertyFormatting SimplePropertyFormatting { // tested
get; get;

165
ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs

@ -248,12 +248,33 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
/// </summary> /// </summary>
protected virtual void Semicolon() protected virtual void Semicolon()
{ {
Role role = containerStack.Peek().Role;
// get the role of the current node // get the role of the current node
if (!(role == ForStatement.InitializerRole || role == ForStatement.IteratorRole || role == UsingStatement.ResourceAcquisitionRole)) Role role = containerStack.Peek().Role;
if (!SkipToken())
{ {
WriteToken(Roles.Semicolon); WriteToken(Roles.Semicolon);
NewLine(); if (!SkipNewLine())
NewLine();
else
Space();
}
bool SkipToken()
{
return role == ForStatement.InitializerRole
|| role == ForStatement.IteratorRole
|| role == UsingStatement.ResourceAcquisitionRole;
}
bool SkipNewLine()
{
if (containerStack.Peek() is not Accessor accessor)
return false;
if (!(role == PropertyDeclaration.GetterRole || role == PropertyDeclaration.SetterRole))
return false;
bool isAutoProperty = accessor.Body.IsNull
&& policy.AutoPropertyFormatting == PropertyFormatting.SingleLine;
return isAutoProperty;
} }
} }
@ -305,66 +326,68 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
return true; return true;
} }
protected virtual void OpenBrace(BraceStyle style) protected virtual void OpenBrace(BraceStyle style, bool newLine = true)
{ {
switch (style) switch (style)
{ {
case BraceStyle.DoNotChange:
case BraceStyle.EndOfLine: case BraceStyle.EndOfLine:
case BraceStyle.BannerStyle: case BraceStyle.BannerStyle:
if (!isAtStartOfLine) if (!isAtStartOfLine)
Space(); Space();
writer.WriteToken(Roles.LBrace, "{"); WriteToken("{", Roles.LBrace);
break; break;
case BraceStyle.EndOfLineWithoutSpace: case BraceStyle.EndOfLineWithoutSpace:
writer.WriteToken(Roles.LBrace, "{"); WriteToken("{", Roles.LBrace);
break; break;
case BraceStyle.NextLine: case BraceStyle.NextLine:
if (!isAtStartOfLine) if (!isAtStartOfLine)
NewLine(); NewLine();
writer.WriteToken(Roles.LBrace, "{"); WriteToken("{", Roles.LBrace);
break; break;
case BraceStyle.NextLineShifted: case BraceStyle.NextLineShifted:
NewLine(); NewLine();
writer.Indent(); writer.Indent();
writer.WriteToken(Roles.LBrace, "{"); WriteToken("{", Roles.LBrace);
NewLine(); NewLine();
return; return;
case BraceStyle.NextLineShifted2: case BraceStyle.NextLineShifted2:
NewLine(); NewLine();
writer.Indent(); writer.Indent();
writer.WriteToken(Roles.LBrace, "{"); WriteToken("{", Roles.LBrace);
break; break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
writer.Indent(); if (newLine)
NewLine(); {
writer.Indent();
NewLine();
}
} }
protected virtual void CloseBrace(BraceStyle style) protected virtual void CloseBrace(BraceStyle style, bool unindent = true)
{ {
switch (style) switch (style)
{ {
case BraceStyle.DoNotChange:
case BraceStyle.EndOfLine: case BraceStyle.EndOfLine:
case BraceStyle.EndOfLineWithoutSpace: case BraceStyle.EndOfLineWithoutSpace:
case BraceStyle.NextLine: case BraceStyle.NextLine:
writer.Unindent(); if (unindent)
writer.WriteToken(Roles.RBrace, "}"); writer.Unindent();
isAtStartOfLine = false; WriteToken("}", Roles.RBrace);
break; break;
case BraceStyle.BannerStyle: case BraceStyle.BannerStyle:
case BraceStyle.NextLineShifted: case BraceStyle.NextLineShifted:
writer.WriteToken(Roles.RBrace, "}"); WriteToken("}", Roles.RBrace);
isAtStartOfLine = false; if (unindent)
writer.Unindent(); writer.Unindent();
break; break;
case BraceStyle.NextLineShifted2: case BraceStyle.NextLineShifted2:
writer.Unindent(); if (unindent)
writer.WriteToken(Roles.RBrace, "}"); writer.Unindent();
isAtStartOfLine = false; WriteToken("}", Roles.RBrace);
writer.Unindent(); if (unindent)
writer.Unindent();
break; break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
@ -519,7 +542,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
} }
} }
protected virtual void WriteMethodBody(BlockStatement body, BraceStyle style) protected virtual void WriteMethodBody(BlockStatement body, BraceStyle style, bool newLine = true)
{ {
if (body.IsNull) if (body.IsNull)
{ {
@ -663,36 +686,70 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
protected virtual void PrintInitializerElements(AstNodeCollection<Expression> elements) protected virtual void PrintInitializerElements(AstNodeCollection<Expression> elements)
{ {
BraceStyle style; bool wrapAlways = policy.ArrayInitializerWrapping == Wrapping.WrapAlways
if (policy.ArrayInitializerWrapping == Wrapping.WrapAlways) || (elements.Count > 1 && elements.Any(e => !IsSimpleExpression(e)))
{ || elements.Any(IsComplexExpression);
style = BraceStyle.NextLine; bool wrap = wrapAlways
} || elements.Count > 10;
else OpenBrace(wrap ? policy.ArrayInitializerBraceStyle : BraceStyle.EndOfLine, newLine: wrap);
{ if (!wrap)
style = BraceStyle.EndOfLine; Space();
}
OpenBrace(style);
bool isFirst = true;
AstNode last = null; AstNode last = null;
foreach (AstNode node in elements) foreach (var (idx, node) in elements.WithIndex())
{ {
if (isFirst) if (idx > 0)
{
isFirst = false;
}
else
{ {
Comma(node, noSpaceAfterComma: true); Comma(node, noSpaceAfterComma: true);
NewLine(); if (wrapAlways || idx % 10 == 0)
NewLine();
else
Space();
} }
last = node; last = node;
node.AcceptVisitor(this); node.AcceptVisitor(this);
} }
if (last != null) if (last != null)
OptionalComma(last.NextSibling); OptionalComma(last.NextSibling);
NewLine(); if (wrap)
CloseBrace(style); NewLine();
else
Space();
CloseBrace(wrap ? policy.ArrayInitializerBraceStyle : BraceStyle.EndOfLine, unindent: wrap);
bool IsSimpleExpression(Expression ex)
{
switch (ex)
{
case NullReferenceExpression _:
case ThisReferenceExpression _:
case PrimitiveExpression _:
case IdentifierExpression _:
case MemberReferenceExpression
{
Target: ThisReferenceExpression
or IdentifierExpression
or BaseReferenceExpression
} _:
return true;
default:
return false;
}
}
bool IsComplexExpression(Expression ex)
{
switch (ex)
{
case AnonymousMethodExpression _:
case LambdaExpression _:
case AnonymousTypeCreateExpression _:
case ObjectCreateExpression _:
case NamedExpression _:
return true;
default:
return false;
}
}
} }
public virtual void VisitAsExpression(AsExpression asExpression) public virtual void VisitAsExpression(AsExpression asExpression)
@ -2362,7 +2419,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
if (indexerDeclaration.ExpressionBody.IsNull) if (indexerDeclaration.ExpressionBody.IsNull)
{ {
OpenBrace(policy.PropertyBraceStyle); bool isSingleLine =
(indexerDeclaration.Getter.IsNull || indexerDeclaration.Getter.Body.IsNull)
&& (indexerDeclaration.Setter.IsNull || indexerDeclaration.Setter.Body.IsNull);
OpenBrace(isSingleLine ? BraceStyle.EndOfLine : policy.PropertyBraceStyle, newLine: !isSingleLine);
if (isSingleLine)
Space();
// output get/set in their original order // output get/set in their original order
foreach (AstNode node in indexerDeclaration.Children) foreach (AstNode node in indexerDeclaration.Children)
{ {
@ -2371,7 +2433,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
node.AcceptVisitor(this); node.AcceptVisitor(this);
} }
} }
CloseBrace(policy.PropertyBraceStyle); CloseBrace(isSingleLine ? BraceStyle.EndOfLine : policy.PropertyBraceStyle, unindent: !isSingleLine);
NewLine(); NewLine();
} }
else else
@ -2497,7 +2559,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
WriteIdentifier(propertyDeclaration.NameToken); WriteIdentifier(propertyDeclaration.NameToken);
if (propertyDeclaration.ExpressionBody.IsNull) if (propertyDeclaration.ExpressionBody.IsNull)
{ {
OpenBrace(policy.PropertyBraceStyle); bool isSingleLine =
(propertyDeclaration.Getter.IsNull || propertyDeclaration.Getter.Body.IsNull)
&& (propertyDeclaration.Setter.IsNull || propertyDeclaration.Setter.Body.IsNull);
OpenBrace(isSingleLine ? BraceStyle.EndOfLine : policy.PropertyBraceStyle, newLine: !isSingleLine);
if (isSingleLine)
Space();
// output get/set in their original order // output get/set in their original order
foreach (AstNode node in propertyDeclaration.Children) foreach (AstNode node in propertyDeclaration.Children)
{ {
@ -2506,7 +2573,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
node.AcceptVisitor(this); node.AcceptVisitor(this);
} }
} }
CloseBrace(policy.PropertyBraceStyle); CloseBrace(isSingleLine ? BraceStyle.EndOfLine : policy.PropertyBraceStyle, unindent: !isSingleLine);
if (!propertyDeclaration.Initializer.IsNull) if (!propertyDeclaration.Initializer.IsNull)
{ {
Space(policy.SpaceAroundAssignment); Space(policy.SpaceAroundAssignment);

30
ICSharpCode.Decompiler/CSharp/OutputVisitor/FormattingOptionsFactory.cs

@ -72,8 +72,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
PropertyBraceStyle = BraceStyle.EndOfLine, PropertyBraceStyle = BraceStyle.EndOfLine,
PropertyGetBraceStyle = BraceStyle.EndOfLine, PropertyGetBraceStyle = BraceStyle.EndOfLine,
PropertySetBraceStyle = BraceStyle.EndOfLine, PropertySetBraceStyle = BraceStyle.EndOfLine,
SimpleGetBlockFormatting = PropertyFormatting.AllowOneLine, SimpleGetBlockFormatting = PropertyFormatting.SingleLine,
SimpleSetBlockFormatting = PropertyFormatting.AllowOneLine, SimpleSetBlockFormatting = PropertyFormatting.SingleLine,
EventBraceStyle = BraceStyle.EndOfLine, EventBraceStyle = BraceStyle.EndOfLine,
EventAddBraceStyle = BraceStyle.EndOfLine, EventAddBraceStyle = BraceStyle.EndOfLine,
@ -151,8 +151,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
SpaceAfterTypecast = false, SpaceAfterTypecast = false,
AlignEmbeddedStatements = true, AlignEmbeddedStatements = true,
SimplePropertyFormatting = PropertyFormatting.AllowOneLine, SimplePropertyFormatting = PropertyFormatting.SingleLine,
AutoPropertyFormatting = PropertyFormatting.AllowOneLine, AutoPropertyFormatting = PropertyFormatting.SingleLine,
EmptyLineFormatting = EmptyLineFormatting.DoNotIndent, EmptyLineFormatting = EmptyLineFormatting.DoNotIndent,
SpaceBeforeMethodDeclarationParameterComma = false, SpaceBeforeMethodDeclarationParameterComma = false,
SpaceAfterMethodDeclarationParameterComma = true, SpaceAfterMethodDeclarationParameterComma = true,
@ -186,12 +186,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
AlignToFirstMethodCallArgument = false, AlignToFirstMethodCallArgument = false,
AlignToFirstMethodDeclarationParameter = true, AlignToFirstMethodDeclarationParameter = true,
KeepCommentsAtFirstColumn = true, KeepCommentsAtFirstColumn = true,
ChainedMethodCallWrapping = Wrapping.DoNotChange, ChainedMethodCallWrapping = Wrapping.DoNotWrap,
MethodCallArgumentWrapping = Wrapping.DoNotChange, MethodCallArgumentWrapping = Wrapping.DoNotWrap,
NewLineAferMethodCallOpenParentheses = NewLinePlacement.DoNotCare, NewLineAferMethodCallOpenParentheses = NewLinePlacement.DoNotCare,
MethodCallClosingParenthesesOnNewLine = NewLinePlacement.DoNotCare, MethodCallClosingParenthesesOnNewLine = NewLinePlacement.DoNotCare,
IndexerArgumentWrapping = Wrapping.DoNotChange, IndexerArgumentWrapping = Wrapping.DoNotWrap,
NewLineAferIndexerOpenBracket = NewLinePlacement.DoNotCare, NewLineAferIndexerOpenBracket = NewLinePlacement.DoNotCare,
IndexerClosingBracketOnNewLine = NewLinePlacement.DoNotCare, IndexerClosingBracketOnNewLine = NewLinePlacement.DoNotCare,
@ -240,8 +240,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
PropertyBraceStyle = BraceStyle.EndOfLine, PropertyBraceStyle = BraceStyle.EndOfLine,
PropertyGetBraceStyle = BraceStyle.EndOfLine, PropertyGetBraceStyle = BraceStyle.EndOfLine,
PropertySetBraceStyle = BraceStyle.EndOfLine, PropertySetBraceStyle = BraceStyle.EndOfLine,
SimpleGetBlockFormatting = PropertyFormatting.AllowOneLine, SimpleGetBlockFormatting = PropertyFormatting.SingleLine,
SimpleSetBlockFormatting = PropertyFormatting.AllowOneLine, SimpleSetBlockFormatting = PropertyFormatting.SingleLine,
EventBraceStyle = BraceStyle.EndOfLine, EventBraceStyle = BraceStyle.EndOfLine,
EventAddBraceStyle = BraceStyle.EndOfLine, EventAddBraceStyle = BraceStyle.EndOfLine,
@ -323,8 +323,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
SpaceAfterTypecast = false, SpaceAfterTypecast = false,
AlignEmbeddedStatements = true, AlignEmbeddedStatements = true,
SimplePropertyFormatting = PropertyFormatting.AllowOneLine, SimplePropertyFormatting = PropertyFormatting.SingleLine,
AutoPropertyFormatting = PropertyFormatting.AllowOneLine, AutoPropertyFormatting = PropertyFormatting.SingleLine,
EmptyLineFormatting = EmptyLineFormatting.DoNotIndent, EmptyLineFormatting = EmptyLineFormatting.DoNotIndent,
SpaceBeforeMethodDeclarationParameterComma = false, SpaceBeforeMethodDeclarationParameterComma = false,
SpaceAfterMethodDeclarationParameterComma = true, SpaceAfterMethodDeclarationParameterComma = true,
@ -353,12 +353,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
MinimumBlankLinesInsideRegion = 1, MinimumBlankLinesInsideRegion = 1,
KeepCommentsAtFirstColumn = true, KeepCommentsAtFirstColumn = true,
ChainedMethodCallWrapping = Wrapping.DoNotChange, ChainedMethodCallWrapping = Wrapping.DoNotWrap,
MethodCallArgumentWrapping = Wrapping.DoNotChange, MethodCallArgumentWrapping = Wrapping.DoNotWrap,
NewLineAferMethodCallOpenParentheses = NewLinePlacement.DoNotCare, NewLineAferMethodCallOpenParentheses = NewLinePlacement.DoNotCare,
MethodCallClosingParenthesesOnNewLine = NewLinePlacement.DoNotCare, MethodCallClosingParenthesesOnNewLine = NewLinePlacement.DoNotCare,
IndexerArgumentWrapping = Wrapping.DoNotChange, IndexerArgumentWrapping = Wrapping.DoNotWrap,
NewLineAferIndexerOpenBracket = NewLinePlacement.DoNotCare, NewLineAferIndexerOpenBracket = NewLinePlacement.DoNotCare,
IndexerClosingBracketOnNewLine = NewLinePlacement.DoNotCare, IndexerClosingBracketOnNewLine = NewLinePlacement.DoNotCare,
@ -389,7 +389,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
baseOptions.FinallyNewLinePlacement = NewLinePlacement.NewLine; baseOptions.FinallyNewLinePlacement = NewLinePlacement.NewLine;
baseOptions.WhileNewLinePlacement = NewLinePlacement.DoNotCare; baseOptions.WhileNewLinePlacement = NewLinePlacement.DoNotCare;
baseOptions.ArrayInitializerWrapping = Wrapping.DoNotChange; baseOptions.ArrayInitializerWrapping = Wrapping.DoNotWrap;
baseOptions.IndentBlocksInsideExpressions = true; baseOptions.IndentBlocksInsideExpressions = true;
return baseOptions; return baseOptions;

2
ICSharpCode.Decompiler/CSharp/OutputVisitor/ITokenWriter.cs

@ -95,7 +95,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public abstract class DecoratingTokenWriter : TokenWriter public abstract class DecoratingTokenWriter : TokenWriter
{ {
TokenWriter decoratedWriter; readonly TokenWriter decoratedWriter;
protected DecoratingTokenWriter(TokenWriter decoratedWriter) protected DecoratingTokenWriter(TokenWriter decoratedWriter)
{ {

2
ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs

@ -29,7 +29,7 @@ using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
/// <summary> /// <summary>
/// get/set/add/remove /// get/set/init/add/remove
/// </summary> /// </summary>
public class Accessor : EntityDeclaration public class Accessor : EntityDeclaration
{ {

3
ICSharpCode.Decompiler/DecompilerSettings.cs

@ -1736,7 +1736,8 @@ namespace ICSharpCode.Decompiler
{ {
csharpFormattingOptions = FormattingOptionsFactory.CreateAllman(); csharpFormattingOptions = FormattingOptionsFactory.CreateAllman();
csharpFormattingOptions.IndentSwitchBody = false; csharpFormattingOptions.IndentSwitchBody = false;
csharpFormattingOptions.ArrayInitializerWrapping = Wrapping.WrapAlways; csharpFormattingOptions.ArrayInitializerWrapping = Wrapping.WrapIfTooLong;
csharpFormattingOptions.AutoPropertyFormatting = PropertyFormatting.SingleLine;
} }
return csharpFormattingOptions; return csharpFormattingOptions;
} }

2
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -14,7 +14,7 @@
<GenerateAssemblyInformationalVersionAttribute>False</GenerateAssemblyInformationalVersionAttribute> <GenerateAssemblyInformationalVersionAttribute>False</GenerateAssemblyInformationalVersionAttribute>
<EnableDefaultItems>false</EnableDefaultItems> <EnableDefaultItems>false</EnableDefaultItems>
<LangVersion>8.0</LangVersion> <LangVersion>9.0</LangVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<SignAssembly>True</SignAssembly> <SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>ICSharpCode.Decompiler.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>ICSharpCode.Decompiler.snk</AssemblyOriginatorKeyFile>

Loading…
Cancel
Save