Browse Source

Fix initialization of FakeProperty with setter

Seems like a typo - the setter method was assigned to the Getter property

The test GuessAccessors needed adjustments in the generated code.
ILSpy is more eager to merge property assignments
pull/2792/head
Standa Lukeš 3 years ago
parent
commit
18481efc44
No known key found for this signature in database
GPG Key ID: DEDDF275FAB0910F
  1. 30
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/GuessAccessors.cs
  2. 2
      ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs

30
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/GuessAccessors.cs

@ -15,9 +15,8 @@ namespace ClassLibrary1 @@ -15,9 +15,8 @@ namespace ClassLibrary1
//IL_0007: Expected O, but got Unknown
UnknownClass val = new UnknownClass();
int? unknownProperty = val.UnknownProperty;
int? num = unknownProperty.GetValueOrDefault();
val.UnknownProperty = num;
int? num2 = num;
int? num2 = (val.UnknownProperty = unknownProperty.GetValueOrDefault());
int? num3 = num2;
List<object> list = new List<object> {
val[unknownProperty.Value] ?? "",
val.NotProperty,
@ -51,10 +50,9 @@ namespace ClassLibrary1 @@ -51,10 +50,9 @@ namespace ClassLibrary1
//IL_00e1: Expected O, but got Unknown
//IL_00e1: Expected O, but got Unknown
UnknownGenericClass<UnknownEventArgs> val = new UnknownGenericClass<UnknownEventArgs>();
UnknownEventArgs unknownProperty = val.UnknownProperty;
val.UnknownProperty = unknownProperty;
UnknownEventArgs val2 = (val.UnknownProperty = val.UnknownProperty);
List<object> list = new List<object> {
val[((object)unknownProperty).GetHashCode()] ?? "",
val[((object)val2).GetHashCode()] ?? "",
val.NotProperty,
val.get_NotPropertyWithGeneric<string>(42),
val[42],
@ -63,18 +61,17 @@ namespace ClassLibrary1 @@ -63,18 +61,17 @@ namespace ClassLibrary1
};
val.OnEvent += Instance_OnEvent;
val.OnEvent -= Instance_OnEvent;
UnknownEventArgs val2 = val[(UnknownEventArgs)null];
val[new UnknownEventArgs()] = val2;
UnknownEventArgs val3 = val[new UnknownEventArgs(), new UnknownEventArgs()];
val[new UnknownEventArgs(), new UnknownEventArgs()] = val3;
UnknownEventArgs val3 = val[(UnknownEventArgs)null];
val[new UnknownEventArgs()] = val3;
UnknownEventArgs val4 = val[new UnknownEventArgs(), new UnknownEventArgs()];
val[new UnknownEventArgs(), new UnknownEventArgs()] = val4;
}
public void MethodUnknownStatic()
{
int? unknownProperty = UnknownStaticClass.UnknownProperty;
UnknownStaticClass.UnknownProperty = unknownProperty;
int? num = (UnknownStaticClass.UnknownProperty = UnknownStaticClass.UnknownProperty);
List<object> list = new List<object> {
UnknownStaticClass[unknownProperty.Value] ?? "",
UnknownStaticClass[num.Value] ?? "",
UnknownStaticClass.NotProperty,
UnknownStaticClass.get_NotPropertyWithGeneric<string>(42),
UnknownStaticClass[42],
@ -87,10 +84,9 @@ namespace ClassLibrary1 @@ -87,10 +84,9 @@ namespace ClassLibrary1
public void MethodUnknownStaticGeneric()
{
string unknownProperty = UnknownStaticGenericClass<string>.UnknownProperty;
UnknownStaticGenericClass<string>.UnknownProperty = unknownProperty;
string text = (UnknownStaticGenericClass<string>.UnknownProperty = UnknownStaticGenericClass<string>.UnknownProperty);
List<object> list = new List<object> {
UnknownStaticGenericClass<string>[unknownProperty.Length] ?? "",
UnknownStaticGenericClass<string>[text.Length] ?? "",
UnknownStaticGenericClass<string>.NotProperty,
UnknownStaticGenericClass<string>.get_NotPropertyWithGeneric<string>(42),
UnknownStaticGenericClass<string>[42],
@ -121,4 +117,4 @@ namespace ClassLibrary1 @@ -121,4 +117,4 @@ namespace ClassLibrary1
throw new NotImplementedException();
}
}
}
}

2
ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs

@ -670,7 +670,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -670,7 +670,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
m.AccessorKind = MethodSemanticsAttributes.Setter;
m.AccessorOwner = fakeProperty;
fakeProperty.Getter = m;
fakeProperty.Setter = m;
fakeProperty.ReturnType = parameters.Last().Type;
fakeProperty.IsIndexer = parameters.Count > 1;
fakeProperty.Parameters = parameters.SkipLast(1).ToArray();

Loading…
Cancel
Save