Browse Source

Fix #1082: Add support for compound assignment with string.Concat().

Currently only supports the binary overloads of string.Concat().
pull/1213/head
Daniel Grunwald 7 years ago
parent
commit
33ef82f75c
  1. 34
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs
  2. 122
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.il
  3. 107
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.opt.il
  4. 135
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.opt.roslyn.il
  5. 150
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.roslyn.il
  6. 8
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  7. 9
      ICSharpCode.Decompiler/IL/Instructions/CompoundAssignmentInstruction.cs
  8. 12
      ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs

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

@ -120,6 +120,10 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -120,6 +120,10 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
get;
set;
}
public string StringProp {
get;
set;
}
public CustomClass CustomClassProp {
get;
@ -411,6 +415,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -411,6 +415,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
set;
}
public static string StaticStringProperty {
get;
set;
}
#if CS70
private static ref CustomStruct2 GetStruct()
{
@ -4540,5 +4549,30 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -4540,5 +4549,30 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
items[num++] = item;
items[num++] = item;
}
#if !LEGACY_CSC
// Legacy csc generates a slightly different pattern for string compound assignment
// as for all other compound assignments. We'll ignore that edge case.
private static void Issue1082(string[] strings, List<char> chars, bool flag, int i)
{
// The 'chars[i]' result is stored in a temporary, and both branches use the
// same temporary. In order to inline the generated value-type temporary, we
// need to split it, even though it has the address taken for the ToString() call.
if (flag) {
strings[1] += chars[i].ToString();
} else {
strings[0] += chars[i].ToString();
}
}
#endif
private static void StringPropertyCompoundAssign()
{
StaticStringProperty += "a";
StaticStringProperty += 1;
new CustomClass().StringProp += "a";
new CustomClass().StringProp += 1;
}
}
}

122
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.il

@ -163,8 +163,8 @@ @@ -163,8 +163,8 @@
.property instance int32 Property()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
.get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_Property()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
} // end of property MutableClass::Property
.property instance uint8 ByteProperty()
{
@ -224,6 +224,8 @@ @@ -224,6 +224,8 @@
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private uint64 '<UlongProp>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<StringProp>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass '<CustomClassProp>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct '<CustomStructProp>k__BackingField'
@ -452,6 +454,34 @@ @@ -452,6 +454,34 @@
IL_0007: ret
} // end of method CustomClass::set_UlongProp
.method public hidebysig specialname
instance string get_StringProp() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (string V_0)
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::'<StringProp>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method CustomClass::get_StringProp
.method public hidebysig specialname
instance void set_StringProp(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::'<StringProp>k__BackingField'
IL_0007: ret
} // end of method CustomClass::set_StringProp
.method public hidebysig specialname
instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
get_CustomClassProp() cil managed
@ -676,8 +706,8 @@ @@ -676,8 +706,8 @@
.property instance uint8 ByteProp()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_ByteProp(uint8)
.get instance uint8 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_ByteProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_ByteProp(uint8)
} // end of property CustomClass::ByteProp
.property instance int8 SbyteProp()
{
@ -711,14 +741,19 @@ @@ -711,14 +741,19 @@
} // end of property CustomClass::LongProp
.property instance uint64 UlongProp()
{
.get instance uint64 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_UlongProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_UlongProp(uint64)
.get instance uint64 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_UlongProp()
} // end of property CustomClass::UlongProp
.property instance string StringProp()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_StringProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_StringProp(string)
} // end of property CustomClass::StringProp
.property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
CustomClassProp()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_CustomClassProp(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass)
.get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_CustomClassProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_CustomClassProp(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass)
} // end of property CustomClass::CustomClassProp
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct
CustomStructProp()
@ -1161,8 +1196,8 @@ @@ -1161,8 +1196,8 @@
} // end of property CustomStruct::CustomClassProp
.property instance uint8 ByteProp()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct::set_ByteProp(uint8)
.get instance uint8 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct::get_ByteProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct::set_ByteProp(uint8)
} // end of property CustomStruct::ByteProp
.property instance int8 SbyteProp()
{
@ -1191,8 +1226,8 @@ @@ -1191,8 +1226,8 @@
} // end of property CustomStruct::UintProp
.property instance int64 LongProp()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct::set_LongProp(int64)
.get instance int64 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct::get_LongProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct::set_LongProp(int64)
} // end of property CustomStruct::LongProp
.property instance uint64 UlongProp()
{
@ -1613,6 +1648,8 @@ @@ -1613,6 +1648,8 @@
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum '<StaticShortProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private static string '<StaticStringProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method private hidebysig specialname static
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
get_CustomClassProp() cil managed
@ -1928,6 +1965,32 @@ @@ -1928,6 +1965,32 @@
IL_0006: ret
} // end of method CompoundAssignmentTest::set_StaticShortProperty
.method public hidebysig specialname static
string get_StaticStringProperty() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 10 (0xa)
.maxstack 1
.locals init (string V_0)
IL_0000: ldsfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::'<StaticStringProperty>k__BackingField'
IL_0005: stloc.0
IL_0006: br.s IL_0008
IL_0008: ldloc.0
IL_0009: ret
} // end of method CompoundAssignmentTest::get_StaticStringProperty
.method public hidebysig specialname static
void set_StaticStringProperty(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: stsfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::'<StaticStringProperty>k__BackingField'
IL_0006: ret
} // end of method CompoundAssignmentTest::set_StaticStringProperty
.method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
GetClass() cil managed
{
@ -21495,6 +21558,44 @@ @@ -21495,6 +21558,44 @@
IL_0025: ret
} // end of method CompoundAssignmentTest::Issue1007
.method private hidebysig static void StringPropertyCompoundAssign() cil managed
{
// Code size 100 (0x64)
.maxstack 3
IL_0000: nop
IL_0001: call string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticStringProperty()
IL_0006: ldstr "a"
IL_000b: call string [mscorlib]System.String::Concat(string,
string)
IL_0010: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticStringProperty(string)
IL_0015: nop
IL_0016: call string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticStringProperty()
IL_001b: ldc.i4.1
IL_001c: box [mscorlib]System.Int32
IL_0021: call string [mscorlib]System.String::Concat(object,
object)
IL_0026: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticStringProperty(string)
IL_002b: nop
IL_002c: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::.ctor()
IL_0031: dup
IL_0032: call instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_StringProp()
IL_0037: ldstr "a"
IL_003c: call string [mscorlib]System.String::Concat(string,
string)
IL_0041: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_StringProp(string)
IL_0046: nop
IL_0047: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::.ctor()
IL_004c: dup
IL_004d: call instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_StringProp()
IL_0052: ldc.i4.1
IL_0053: box [mscorlib]System.Int32
IL_0058: call string [mscorlib]System.String::Concat(object,
object)
IL_005d: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_StringProp(string)
IL_0062: nop
IL_0063: ret
} // end of method CompoundAssignmentTest::StringPropertyCompoundAssign
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -21563,15 +21664,20 @@ @@ -21563,15 +21664,20 @@
} // end of property CompoundAssignmentTest::UlongProp
.property int32 StaticProperty()
{
.get int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticProperty(int32)
.get int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
} // end of property CompoundAssignmentTest::StaticProperty
.property valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum
StaticShortProperty()
{
.get valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticShortProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticShortProperty(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum)
.get valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticShortProperty()
} // end of property CompoundAssignmentTest::StaticShortProperty
.property string StaticStringProperty()
{
.get string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticStringProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticStringProperty(string)
} // end of property CompoundAssignmentTest::StaticStringProperty
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest

107
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.opt.il

@ -146,8 +146,8 @@ @@ -146,8 +146,8 @@
.property instance int32 Property()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
.get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_Property()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
} // end of property MutableClass::Property
.property instance uint8 ByteProperty()
{
@ -207,6 +207,8 @@ @@ -207,6 +207,8 @@
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private uint64 '<UlongProp>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<StringProp>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass '<CustomClassProp>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct '<CustomStructProp>k__BackingField'
@ -395,6 +397,29 @@ @@ -395,6 +397,29 @@
IL_0007: ret
} // end of method CustomClass::set_UlongProp
.method public hidebysig specialname
instance string get_StringProp() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::'<StringProp>k__BackingField'
IL_0006: ret
} // end of method CustomClass::get_StringProp
.method public hidebysig specialname
instance void set_StringProp(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::'<StringProp>k__BackingField'
IL_0007: ret
} // end of method CustomClass::set_StringProp
.method public hidebysig specialname
instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
get_CustomClassProp() cil managed
@ -596,8 +621,8 @@ @@ -596,8 +621,8 @@
.property instance uint8 ByteProp()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_ByteProp(uint8)
.get instance uint8 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_ByteProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_ByteProp(uint8)
} // end of property CustomClass::ByteProp
.property instance int8 SbyteProp()
{
@ -631,14 +656,19 @@ @@ -631,14 +656,19 @@
} // end of property CustomClass::LongProp
.property instance uint64 UlongProp()
{
.get instance uint64 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_UlongProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_UlongProp(uint64)
.get instance uint64 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_UlongProp()
} // end of property CustomClass::UlongProp
.property instance string StringProp()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_StringProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_StringProp(string)
} // end of property CustomClass::StringProp
.property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
CustomClassProp()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_CustomClassProp(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass)
.get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_CustomClassProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_CustomClassProp(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass)
} // end of property CustomClass::CustomClassProp
.property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct
CustomStructProp()
@ -1024,8 +1054,8 @@ @@ -1024,8 +1054,8 @@
} // end of property CustomStruct::CustomClassProp
.property instance uint8 ByteProp()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct::set_ByteProp(uint8)
.get instance uint8 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct::get_ByteProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct::set_ByteProp(uint8)
} // end of property CustomStruct::ByteProp
.property instance int8 SbyteProp()
{
@ -1054,8 +1084,8 @@ @@ -1054,8 +1084,8 @@
} // end of property CustomStruct::UintProp
.property instance int64 LongProp()
{
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct::set_LongProp(int64)
.get instance int64 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct::get_LongProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct::set_LongProp(int64)
} // end of property CustomStruct::LongProp
.property instance uint64 UlongProp()
{
@ -1426,6 +1456,8 @@ @@ -1426,6 +1456,8 @@
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum '<StaticShortProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private static string '<StaticStringProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method private hidebysig specialname static
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
get_CustomClassProp() cil managed
@ -1681,6 +1713,27 @@ @@ -1681,6 +1713,27 @@
IL_0006: ret
} // end of method CompoundAssignmentTest::set_StaticShortProperty
.method public hidebysig specialname static
string get_StaticStringProperty() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::'<StaticStringProperty>k__BackingField'
IL_0005: ret
} // end of method CompoundAssignmentTest::get_StaticStringProperty
.method public hidebysig specialname static
void set_StaticStringProperty(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: stsfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::'<StaticStringProperty>k__BackingField'
IL_0006: ret
} // end of method CompoundAssignmentTest::set_StaticStringProperty
.method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
GetClass() cil managed
{
@ -19787,6 +19840,39 @@ @@ -19787,6 +19840,39 @@
IL_0024: ret
} // end of method CompoundAssignmentTest::Issue1007
.method private hidebysig static void StringPropertyCompoundAssign() cil managed
{
// Code size 95 (0x5f)
.maxstack 3
IL_0000: call string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticStringProperty()
IL_0005: ldstr "a"
IL_000a: call string [mscorlib]System.String::Concat(string,
string)
IL_000f: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticStringProperty(string)
IL_0014: call string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticStringProperty()
IL_0019: ldc.i4.1
IL_001a: box [mscorlib]System.Int32
IL_001f: call string [mscorlib]System.String::Concat(object,
object)
IL_0024: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticStringProperty(string)
IL_0029: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::.ctor()
IL_002e: dup
IL_002f: call instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_StringProp()
IL_0034: ldstr "a"
IL_0039: call string [mscorlib]System.String::Concat(string,
string)
IL_003e: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_StringProp(string)
IL_0043: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::.ctor()
IL_0048: dup
IL_0049: call instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_StringProp()
IL_004e: ldc.i4.1
IL_004f: box [mscorlib]System.Int32
IL_0054: call string [mscorlib]System.String::Concat(object,
object)
IL_0059: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_StringProp(string)
IL_005e: ret
} // end of method CompoundAssignmentTest::StringPropertyCompoundAssign
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -19854,15 +19940,20 @@ @@ -19854,15 +19940,20 @@
} // end of property CompoundAssignmentTest::UlongProp
.property int32 StaticProperty()
{
.get int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticProperty(int32)
.get int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
} // end of property CompoundAssignmentTest::StaticProperty
.property valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum
StaticShortProperty()
{
.get valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticShortProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticShortProperty(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum)
.get valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticShortProperty()
} // end of property CompoundAssignmentTest::StaticShortProperty
.property string StaticStringProperty()
{
.get string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticStringProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticStringProperty(string)
} // end of property CompoundAssignmentTest::StaticStringProperty
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest

135
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.opt.roslyn.il

@ -211,6 +211,8 @@ @@ -211,6 +211,8 @@
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private uint64 '<UlongProp>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private string '<StringProp>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass '<CustomClassProp>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct '<CustomStructProp>k__BackingField'
@ -399,6 +401,29 @@ @@ -399,6 +401,29 @@
IL_0007: ret
} // end of method CustomClass::set_UlongProp
.method public hidebysig specialname
instance string get_StringProp() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::'<StringProp>k__BackingField'
IL_0006: ret
} // end of method CustomClass::get_StringProp
.method public hidebysig specialname
instance void set_StringProp(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::'<StringProp>k__BackingField'
IL_0007: ret
} // end of method CustomClass::set_StringProp
.method public hidebysig specialname
instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
get_CustomClassProp() cil managed
@ -638,6 +663,11 @@ @@ -638,6 +663,11 @@
.get instance uint64 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_UlongProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_UlongProp(uint64)
} // end of property CustomClass::UlongProp
.property instance string StringProp()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_StringProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_StringProp(string)
} // end of property CustomClass::StringProp
.property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
CustomClassProp()
{
@ -1430,6 +1460,8 @@ @@ -1430,6 +1460,8 @@
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum '<StaticShortProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private static string '<StaticStringProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method private hidebysig specialname static
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
get_CustomClassProp() cil managed
@ -1685,6 +1717,27 @@ @@ -1685,6 +1717,27 @@
IL_0006: ret
} // end of method CompoundAssignmentTest::set_StaticShortProperty
.method public hidebysig specialname static
string get_StaticStringProperty() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::'<StaticStringProperty>k__BackingField'
IL_0005: ret
} // end of method CompoundAssignmentTest::get_StaticStringProperty
.method public hidebysig specialname static
void set_StaticStringProperty(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: stsfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::'<StaticStringProperty>k__BackingField'
IL_0006: ret
} // end of method CompoundAssignmentTest::set_StaticStringProperty
.method private hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct2&
GetStruct() cil managed
{
@ -23089,6 +23142,83 @@ @@ -23089,6 +23142,83 @@
IL_001a: ret
} // end of method CompoundAssignmentTest::Issue1007
.method private hidebysig static void Issue1082(string[] strings,
class [mscorlib]System.Collections.Generic.List`1<char> chars,
bool flag,
int32 i) cil managed
{
// Code size 65 (0x41)
.maxstack 4
.locals init (char V_0)
IL_0000: ldarg.2
IL_0001: brfalse.s IL_0022
IL_0003: ldarg.0
IL_0004: ldc.i4.1
IL_0005: ldelema [mscorlib]System.String
IL_000a: dup
IL_000b: ldind.ref
IL_000c: ldarg.1
IL_000d: ldarg.3
IL_000e: callvirt instance !0 class [mscorlib]System.Collections.Generic.List`1<char>::get_Item(int32)
IL_0013: stloc.0
IL_0014: ldloca.s V_0
IL_0016: call instance string [mscorlib]System.Char::ToString()
IL_001b: call string [mscorlib]System.String::Concat(string,
string)
IL_0020: stind.ref
IL_0021: ret
IL_0022: ldarg.0
IL_0023: ldc.i4.0
IL_0024: ldelema [mscorlib]System.String
IL_0029: dup
IL_002a: ldind.ref
IL_002b: ldarg.1
IL_002c: ldarg.3
IL_002d: callvirt instance !0 class [mscorlib]System.Collections.Generic.List`1<char>::get_Item(int32)
IL_0032: stloc.0
IL_0033: ldloca.s V_0
IL_0035: call instance string [mscorlib]System.Char::ToString()
IL_003a: call string [mscorlib]System.String::Concat(string,
string)
IL_003f: stind.ref
IL_0040: ret
} // end of method CompoundAssignmentTest::Issue1082
.method private hidebysig static void StringPropertyCompoundAssign() cil managed
{
// Code size 95 (0x5f)
.maxstack 3
IL_0000: call string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticStringProperty()
IL_0005: ldstr "a"
IL_000a: call string [mscorlib]System.String::Concat(string,
string)
IL_000f: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticStringProperty(string)
IL_0014: call string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticStringProperty()
IL_0019: ldc.i4.1
IL_001a: box [mscorlib]System.Int32
IL_001f: call string [mscorlib]System.String::Concat(object,
object)
IL_0024: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticStringProperty(string)
IL_0029: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::.ctor()
IL_002e: dup
IL_002f: callvirt instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_StringProp()
IL_0034: ldstr "a"
IL_0039: call string [mscorlib]System.String::Concat(string,
string)
IL_003e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_StringProp(string)
IL_0043: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::.ctor()
IL_0048: dup
IL_0049: callvirt instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_StringProp()
IL_004e: ldc.i4.1
IL_004f: box [mscorlib]System.Int32
IL_0054: call string [mscorlib]System.String::Concat(object,
object)
IL_0059: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_StringProp(string)
IL_005e: ret
} // end of method CompoundAssignmentTest::StringPropertyCompoundAssign
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -23165,6 +23295,11 @@ @@ -23165,6 +23295,11 @@
.get valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticShortProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticShortProperty(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum)
} // end of property CompoundAssignmentTest::StaticShortProperty
.property string StaticStringProperty()
{
.get string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticStringProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticStringProperty(string)
} // end of property CompoundAssignmentTest::StaticStringProperty
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest

150
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.roslyn.il

@ -230,6 +230,9 @@ @@ -230,6 +230,9 @@
.field private uint64 '<UlongProp>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private string '<StringProp>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass '<CustomClassProp>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
@ -420,6 +423,29 @@ @@ -420,6 +423,29 @@
IL_0007: ret
} // end of method CustomClass::set_UlongProp
.method public hidebysig specialname
instance string get_StringProp() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::'<StringProp>k__BackingField'
IL_0006: ret
} // end of method CustomClass::get_StringProp
.method public hidebysig specialname
instance void set_StringProp(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::'<StringProp>k__BackingField'
IL_0007: ret
} // end of method CustomClass::set_StringProp
.method public hidebysig specialname
instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
get_CustomClassProp() cil managed
@ -673,6 +699,11 @@ @@ -673,6 +699,11 @@
.get instance uint64 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_UlongProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_UlongProp(uint64)
} // end of property CustomClass::UlongProp
.property instance string StringProp()
{
.get instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_StringProp()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_StringProp(string)
} // end of property CustomClass::StringProp
.property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
CustomClassProp()
{
@ -1508,6 +1539,9 @@ @@ -1508,6 +1539,9 @@
.field private static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum '<StaticShortProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private static string '<StaticStringProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.method private hidebysig specialname static
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass
get_CustomClassProp() cil managed
@ -1763,6 +1797,27 @@ @@ -1763,6 +1797,27 @@
IL_0006: ret
} // end of method CompoundAssignmentTest::set_StaticShortProperty
.method public hidebysig specialname static
string get_StaticStringProperty() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::'<StaticStringProperty>k__BackingField'
IL_0005: ret
} // end of method CompoundAssignmentTest::get_StaticStringProperty
.method public hidebysig specialname static
void set_StaticStringProperty(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: stsfld string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::'<StaticStringProperty>k__BackingField'
IL_0006: ret
} // end of method CompoundAssignmentTest::set_StaticStringProperty
.method private hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomStruct2&
GetStruct() cil managed
{
@ -25447,6 +25502,96 @@ @@ -25447,6 +25502,96 @@
IL_001b: ret
} // end of method CompoundAssignmentTest::Issue1007
.method private hidebysig static void Issue1082(string[] strings,
class [mscorlib]System.Collections.Generic.List`1<char> chars,
bool flag,
int32 i) cil managed
{
// Code size 73 (0x49)
.maxstack 4
.locals init (bool V_0,
char V_1)
IL_0000: nop
IL_0001: ldarg.2
IL_0002: stloc.0
IL_0003: ldloc.0
IL_0004: brfalse.s IL_0028
IL_0006: nop
IL_0007: ldarg.0
IL_0008: ldc.i4.1
IL_0009: ldelema [mscorlib]System.String
IL_000e: dup
IL_000f: ldind.ref
IL_0010: ldarg.1
IL_0011: ldarg.3
IL_0012: callvirt instance !0 class [mscorlib]System.Collections.Generic.List`1<char>::get_Item(int32)
IL_0017: stloc.1
IL_0018: ldloca.s V_1
IL_001a: call instance string [mscorlib]System.Char::ToString()
IL_001f: call string [mscorlib]System.String::Concat(string,
string)
IL_0024: stind.ref
IL_0025: nop
IL_0026: br.s IL_0048
IL_0028: nop
IL_0029: ldarg.0
IL_002a: ldc.i4.0
IL_002b: ldelema [mscorlib]System.String
IL_0030: dup
IL_0031: ldind.ref
IL_0032: ldarg.1
IL_0033: ldarg.3
IL_0034: callvirt instance !0 class [mscorlib]System.Collections.Generic.List`1<char>::get_Item(int32)
IL_0039: stloc.1
IL_003a: ldloca.s V_1
IL_003c: call instance string [mscorlib]System.Char::ToString()
IL_0041: call string [mscorlib]System.String::Concat(string,
string)
IL_0046: stind.ref
IL_0047: nop
IL_0048: ret
} // end of method CompoundAssignmentTest::Issue1082
.method private hidebysig static void StringPropertyCompoundAssign() cil managed
{
// Code size 100 (0x64)
.maxstack 3
IL_0000: nop
IL_0001: call string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticStringProperty()
IL_0006: ldstr "a"
IL_000b: call string [mscorlib]System.String::Concat(string,
string)
IL_0010: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticStringProperty(string)
IL_0015: nop
IL_0016: call string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticStringProperty()
IL_001b: ldc.i4.1
IL_001c: box [mscorlib]System.Int32
IL_0021: call string [mscorlib]System.String::Concat(object,
object)
IL_0026: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticStringProperty(string)
IL_002b: nop
IL_002c: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::.ctor()
IL_0031: dup
IL_0032: callvirt instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_StringProp()
IL_0037: ldstr "a"
IL_003c: call string [mscorlib]System.String::Concat(string,
string)
IL_0041: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_StringProp(string)
IL_0046: nop
IL_0047: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::.ctor()
IL_004c: dup
IL_004d: callvirt instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::get_StringProp()
IL_0052: ldc.i4.1
IL_0053: box [mscorlib]System.Int32
IL_0058: call string [mscorlib]System.String::Concat(object,
object)
IL_005d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/CustomClass::set_StringProp(string)
IL_0062: nop
IL_0063: ret
} // end of method CompoundAssignmentTest::StringPropertyCompoundAssign
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -25524,6 +25669,11 @@ @@ -25524,6 +25669,11 @@
.get valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticShortProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticShortProperty(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum)
} // end of property CompoundAssignmentTest::StaticShortProperty
.property string StaticStringProperty()
{
.get string ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticStringProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticStringProperty(string)
} // end of property CompoundAssignmentTest::StaticStringProperty
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest

8
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -1111,7 +1111,13 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1111,7 +1111,13 @@ namespace ICSharpCode.Decompiler.CSharp
protected internal override TranslatedExpression VisitUserDefinedCompoundAssign(UserDefinedCompoundAssign inst, TranslationContext context)
{
var target = Translate(inst.Target);
if (inst.Method.Parameters.Count == 2) {
if (UserDefinedCompoundAssign.IsStringConcat(inst.Method)) {
Debug.Assert(inst.Method.Parameters.Count == 2);
var value = Translate(inst.Value).ConvertTo(inst.Method.Parameters[1].Type, this, allowImplicitConversion: true);
return new AssignmentExpression(target, AssignmentOperatorType.Add, value)
.WithILInstruction(inst)
.WithRR(new OperatorResolveResult(inst.Method.ReturnType, ExpressionType.AddAssign, inst.Method, inst.IsLifted, new[] { target.ResolveResult, value.ResolveResult }));
} else if (inst.Method.Parameters.Count == 2) {
var value = Translate(inst.Value).ConvertTo(inst.Method.Parameters[1].Type, this);
AssignmentOperatorType? op = GetAssignmentOperatorTypeFromMetadataName(inst.Method.Name);
Debug.Assert(op != null);

9
ICSharpCode.Decompiler/IL/Instructions/CompoundAssignmentInstruction.cs

@ -196,17 +196,22 @@ namespace ICSharpCode.Decompiler.IL @@ -196,17 +196,22 @@ namespace ICSharpCode.Decompiler.IL
public partial class UserDefinedCompoundAssign : CompoundAssignmentInstruction
{
public readonly IMethod Method;
public bool IsLifted => false; // TODO: implement ILi
public bool IsLifted => false; // TODO: implement lifted user-defined compound assignments
public UserDefinedCompoundAssign(IMethod method, CompoundAssignmentType compoundAssignmentType, ILInstruction target, ILInstruction value)
: base(OpCode.UserDefinedCompoundAssign, compoundAssignmentType, target, value)
{
this.Method = method;
Debug.Assert(Method.IsOperator);
Debug.Assert(Method.IsOperator || IsStringConcat(method));
Debug.Assert(compoundAssignmentType == CompoundAssignmentType.EvaluatesToNewValue || (Method.Name == "op_Increment" || Method.Name == "op_Decrement"));
Debug.Assert(IsValidCompoundAssignmentTarget(Target));
}
public static bool IsStringConcat(IMethod method)
{
return method.Name == "Concat" && method.IsStatic && method.DeclaringType.IsKnownType(KnownTypeCode.String);
}
public override StackType ResultType => Method.ReturnType.GetStackType();
public override void WriteTo(ITextOutput output, ILAstWritingOptions options)

12
ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs

@ -298,9 +298,21 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -298,9 +298,21 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false;
context.Step($"Compound assignment (dynamic binary)", compoundStore);
newInst = new DynamicCompoundAssign(dynamicBinaryOp.Operation, dynamicBinaryOp.BinderFlags, dynamicBinaryOp.Left, dynamicBinaryOp.LeftArgumentInfo, dynamicBinaryOp.Right, dynamicBinaryOp.RightArgumentInfo);
} else if (setterValue is Call concatCall && UserDefinedCompoundAssign.IsStringConcat(concatCall.Method)) {
// setterValue is a string.Concat() invocation
if (concatCall.Arguments.Count != 2)
return false; // for now we only support binary compound assignments
if (!targetType.IsKnownType(KnownTypeCode.String))
return false;
if (!IsMatchingCompoundLoad(concatCall.Arguments[0], compoundStore, forbiddenVariable: storeInSetter?.Variable))
return false;
context.Step($"Compound assignment (string concatenation)", compoundStore);
newInst = new UserDefinedCompoundAssign(concatCall.Method, CompoundAssignmentType.EvaluatesToNewValue,
concatCall.Arguments[0], concatCall.Arguments[1]);
} else {
return false;
}
newInst.AddILRange(setterValue.ILRange);
if (storeInSetter != null) {
storeInSetter.Value = newInst;
newInst = storeInSetter;

Loading…
Cancel
Save