Browse Source

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

Fix #1079: CSharpFormattingOptions.AutoPropertyFormatting has no effect
pull/2276/head
Siegfried Pammer 4 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 @@ -68,15 +68,15 @@ public static class Program
{
switch (pc)
{
default:
pc = 1;
current = 1;
return 1;
case 1:
pc = 2;
break;
case 2:
break;
default:
pc = 1;
current = 1;
return 1;
case 1:
pc = 2;
break;
case 2:
break;
}
current = 0;
return 0;
@ -91,11 +91,11 @@ public static class Program @@ -91,11 +91,11 @@ public static class Program
{
switch (pc)
{
default:
return false;
case 0:
case 2:
return false;
default:
return false;
case 0:
case 2:
return false;
}
}
@ -131,9 +131,7 @@ public static class Program @@ -131,9 +131,7 @@ public static class Program
public static int[] getArray()
{
return new int[1] {
1
};
return new int[1] { 1 };
}
[EntryPoint]

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,4 +1,5 @@ @@ -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
// software and associated documentation files (the "Software"), to deal in the Software
@ -56,33 +57,20 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -56,33 +57,20 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocBool()
{
bool* ptr = stackalloc bool[4] {
false,
true,
false,
true
};
bool* ptr = stackalloc bool[4] { false, true, false, true };
Console.WriteLine(*ptr);
return UsePointer((byte*)ptr);
}
public unsafe string DoNotInlineTest()
{
bool* ptr = stackalloc bool[4] {
false,
true,
false,
true
};
bool* ptr = stackalloc bool[4] { false, true, false, true };
return UsePointer((byte*)ptr);
}
public unsafe string SimpleStackAllocByte()
{
byte* ptr = stackalloc byte[2] {
0,
1
};
byte* ptr = stackalloc byte[2] { 0, 1 };
Console.WriteLine(*ptr);
return UsePointer(ptr);
}
@ -90,61 +78,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -90,61 +78,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocPrimesAsBytes()
{
byte* ptr = stackalloc byte[55] {
1,
2,
3,
5,
7,
11,
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
1, 2, 3, 5, 7, 11, 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);
return UsePointer(ptr);
@ -152,12 +91,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -152,12 +91,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocChar()
{
char* ptr = stackalloc char[4] {
'1',
'2',
'3',
'4'
};
char* ptr = stackalloc char[4] { '1', '2', '3', '4' };
Console.WriteLine(*ptr);
return UsePointer((byte*)ptr);
}
@ -165,32 +99,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -165,32 +99,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocCharAlphabet()
{
char* ptr = stackalloc char[26] {
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z'
'A', 'B', 'C', '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);
return UsePointer((byte*)ptr);
@ -198,58 +109,35 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -198,58 +109,35 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocSByte()
{
sbyte* ptr = stackalloc sbyte[3] {
1,
2,
3
};
sbyte* ptr = stackalloc sbyte[3] { 1, 2, 3 };
Console.WriteLine(*ptr);
return UsePointer((byte*)ptr);
}
public unsafe string SimpleStackAllocInt16()
{
short* ptr = stackalloc short[3] {
1,
2,
3
};
short* ptr = stackalloc short[3] { 1, 2, 3 };
Console.WriteLine(*ptr);
return UsePointer((byte*)ptr);
}
public unsafe string SimpleStackAllocUInt16()
{
ushort* ptr = stackalloc ushort[3] {
1,
2,
3
};
ushort* ptr = stackalloc ushort[3] { 1, 2, 3 };
Console.WriteLine(*ptr);
return UsePointer((byte*)ptr);
}
public unsafe string SimpleStackAllocInt32()
{
int* ptr = stackalloc int[3] {
1,
2,
3
};
int* ptr = stackalloc int[3] { 1, 2, 3 };
Console.WriteLine(*ptr);
return UsePointer((byte*)ptr);
}
public unsafe string SimpleStackAllocInt32(int a, int b, int c)
{
int* ptr = stackalloc int[6] {
1,
a,
2,
b,
3,
c
};
int* ptr = stackalloc int[6] { 1, a, 2, b, 3, c };
Console.WriteLine(*ptr);
return UsePointer((byte*)ptr);
}
@ -257,23 +145,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -257,23 +145,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocInt32Fibonacci()
{
int* ptr = stackalloc int[17] {
1,
1,
2,
3,
5,
8,
13,
21,
34,
55,
89,
144,
233,
377,
610,
987,
1597
1, 1, 2, 3, 5, 8, 13, 21, 34, 55,
89, 144, 233, 377, 610, 987, 1597
};
Console.WriteLine(*ptr);
return UsePointer((byte*)ptr);
@ -281,47 +154,28 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -281,47 +154,28 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string SimpleStackAllocUInt32()
{
uint* ptr = stackalloc uint[3] {
1u,
2u,
3u
};
uint* ptr = stackalloc uint[3] { 1u, 2u, 3u };
Console.WriteLine(*ptr);
return UsePointer((byte*)ptr);
}
public unsafe string SimpleStackAllocInt64()
{
long* ptr = stackalloc long[3] {
1L,
2L,
3L
};
long* ptr = stackalloc long[3] { 1L, 2L, 3L };
Console.WriteLine(*ptr);
return UsePointer((byte*)ptr);
}
public unsafe string SimpleStackAllocUInt64()
{
ulong* ptr = stackalloc ulong[3] {
1uL,
2uL,
3uL
};
ulong* ptr = stackalloc ulong[3] { 1uL, 2uL, 3uL };
Console.WriteLine(*ptr);
return UsePointer((byte*)ptr);
}
public unsafe string SimpleStackAllocInt32NonConstant(int a, int b, int c)
{
int* ptr = stackalloc int[6] {
0,
1,
0,
a,
b,
c
};
int* ptr = stackalloc int[6] { 0, 1, 0, a, b, c };
Console.WriteLine(*ptr);
return UsePointer((byte*)ptr);
}
@ -370,12 +224,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -370,12 +224,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public string GetSpan2()
{
Span<int> span = stackalloc int[4] {
1,
2,
3,
4
};
Span<int> span = stackalloc int[4] { 1, 2, 3, 4 };
return UseSpan(span);
}
@ -387,22 +236,13 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -387,22 +236,13 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public string GetSpan4()
{
Span<decimal> span = stackalloc decimal[4] {
1m,
2m,
3m,
4m
};
Span<decimal> span = stackalloc decimal[4] { 1m, 2m, 3m, 4m };
return UseSpan(span);
}
public void Issue2103a()
{
Span<byte> span = stackalloc byte[3] {
1,
2,
3
};
Span<byte> span = stackalloc byte[3] { 1, 2, 3 };
Console.WriteLine(span[2] + span[0]);
}
@ -414,11 +254,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -414,11 +254,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public void Issue2103c()
{
Console.WriteLine((stackalloc byte[3] {
1,
2,
3
})[2]);
Console.WriteLine((stackalloc byte[3] { 1, 2, 3 })[2]);
}
public void Issue2103d()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -5,11 +5,7 @@ public class Issue2192 @@ -5,11 +5,7 @@ public class Issue2192
{
public static void M()
{
string[] source = new string[3] {
"abc",
"defgh",
"ijklm"
};
string[] source = new string[3] { "abc", "defgh", "ijklm" };
string text = "test";
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 @@ -30,7 +30,6 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
{
public enum BraceStyle
{
DoNotChange,
EndOfLine,
EndOfLineWithoutSpace,
NextLine,
@ -41,14 +40,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -41,14 +40,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public enum PropertyFormatting
{
AllowOneLine,
ForceOneLine,
ForceNewLine
SingleLine,
MultipleLines
}
public enum Wrapping
{
DoNotChange,
DoNotWrap,
WrapAlways,
WrapIfTooLong
@ -167,10 +164,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -167,10 +164,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public PropertyFormatting AutoPropertyFormatting { // tested
get;
set;
}
public PropertyFormatting AutoPropertyFormatting { get; set; }
public PropertyFormatting SimplePropertyFormatting { // tested
get;

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

@ -248,12 +248,33 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -248,12 +248,33 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
/// </summary>
protected virtual void Semicolon()
{
Role role = containerStack.Peek().Role;
// 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);
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 @@ -305,66 +326,68 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
return true;
}
protected virtual void OpenBrace(BraceStyle style)
protected virtual void OpenBrace(BraceStyle style, bool newLine = true)
{
switch (style)
{
case BraceStyle.DoNotChange:
case BraceStyle.EndOfLine:
case BraceStyle.BannerStyle:
if (!isAtStartOfLine)
Space();
writer.WriteToken(Roles.LBrace, "{");
WriteToken("{", Roles.LBrace);
break;
case BraceStyle.EndOfLineWithoutSpace:
writer.WriteToken(Roles.LBrace, "{");
WriteToken("{", Roles.LBrace);
break;
case BraceStyle.NextLine:
if (!isAtStartOfLine)
NewLine();
writer.WriteToken(Roles.LBrace, "{");
WriteToken("{", Roles.LBrace);
break;
case BraceStyle.NextLineShifted:
NewLine();
writer.Indent();
writer.WriteToken(Roles.LBrace, "{");
WriteToken("{", Roles.LBrace);
NewLine();
return;
case BraceStyle.NextLineShifted2:
NewLine();
writer.Indent();
writer.WriteToken(Roles.LBrace, "{");
WriteToken("{", Roles.LBrace);
break;
default:
throw new ArgumentOutOfRangeException();
}
writer.Indent();
NewLine();
if (newLine)
{
writer.Indent();
NewLine();
}
}
protected virtual void CloseBrace(BraceStyle style)
protected virtual void CloseBrace(BraceStyle style, bool unindent = true)
{
switch (style)
{
case BraceStyle.DoNotChange:
case BraceStyle.EndOfLine:
case BraceStyle.EndOfLineWithoutSpace:
case BraceStyle.NextLine:
writer.Unindent();
writer.WriteToken(Roles.RBrace, "}");
isAtStartOfLine = false;
if (unindent)
writer.Unindent();
WriteToken("}", Roles.RBrace);
break;
case BraceStyle.BannerStyle:
case BraceStyle.NextLineShifted:
writer.WriteToken(Roles.RBrace, "}");
isAtStartOfLine = false;
writer.Unindent();
WriteToken("}", Roles.RBrace);
if (unindent)
writer.Unindent();
break;
case BraceStyle.NextLineShifted2:
writer.Unindent();
writer.WriteToken(Roles.RBrace, "}");
isAtStartOfLine = false;
writer.Unindent();
if (unindent)
writer.Unindent();
WriteToken("}", Roles.RBrace);
if (unindent)
writer.Unindent();
break;
default:
throw new ArgumentOutOfRangeException();
@ -519,7 +542,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -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)
{
@ -663,36 +686,70 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -663,36 +686,70 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
protected virtual void PrintInitializerElements(AstNodeCollection<Expression> elements)
{
BraceStyle style;
if (policy.ArrayInitializerWrapping == Wrapping.WrapAlways)
{
style = BraceStyle.NextLine;
}
else
{
style = BraceStyle.EndOfLine;
}
OpenBrace(style);
bool isFirst = true;
bool wrapAlways = policy.ArrayInitializerWrapping == Wrapping.WrapAlways
|| (elements.Count > 1 && elements.Any(e => !IsSimpleExpression(e)))
|| elements.Any(IsComplexExpression);
bool wrap = wrapAlways
|| elements.Count > 10;
OpenBrace(wrap ? policy.ArrayInitializerBraceStyle : BraceStyle.EndOfLine, newLine: wrap);
if (!wrap)
Space();
AstNode last = null;
foreach (AstNode node in elements)
foreach (var (idx, node) in elements.WithIndex())
{
if (isFirst)
{
isFirst = false;
}
else
if (idx > 0)
{
Comma(node, noSpaceAfterComma: true);
NewLine();
if (wrapAlways || idx % 10 == 0)
NewLine();
else
Space();
}
last = node;
node.AcceptVisitor(this);
}
if (last != null)
OptionalComma(last.NextSibling);
NewLine();
CloseBrace(style);
if (wrap)
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)
@ -2362,7 +2419,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -2362,7 +2419,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
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
foreach (AstNode node in indexerDeclaration.Children)
{
@ -2371,7 +2433,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -2371,7 +2433,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
node.AcceptVisitor(this);
}
}
CloseBrace(policy.PropertyBraceStyle);
CloseBrace(isSingleLine ? BraceStyle.EndOfLine : policy.PropertyBraceStyle, unindent: !isSingleLine);
NewLine();
}
else
@ -2497,7 +2559,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -2497,7 +2559,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
WriteIdentifier(propertyDeclaration.NameToken);
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
foreach (AstNode node in propertyDeclaration.Children)
{
@ -2506,7 +2573,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -2506,7 +2573,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
node.AcceptVisitor(this);
}
}
CloseBrace(policy.PropertyBraceStyle);
CloseBrace(isSingleLine ? BraceStyle.EndOfLine : policy.PropertyBraceStyle, unindent: !isSingleLine);
if (!propertyDeclaration.Initializer.IsNull)
{
Space(policy.SpaceAroundAssignment);

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

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

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

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

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

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

3
ICSharpCode.Decompiler/DecompilerSettings.cs

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

2
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

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

Loading…
Cancel
Save