Browse Source

Fix #2100: 'value'-named auto property could not be recognized correctly.

pull/2113/head
Siegfried Pammer 5 years ago
parent
commit
36a432940b
  1. 5
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/AutoProperties.cs
  2. 5
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

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

@ -23,6 +23,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -23,6 +23,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
set;
} = 4;
public string value {
get;
set;
}
[Obsolete("Property")]
[field: Obsolete("Field")]
public int PropertyWithAttributeOnBackingField {

5
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -244,7 +244,10 @@ namespace ICSharpCode.Decompiler.CSharp @@ -244,7 +244,10 @@ namespace ICSharpCode.Decompiler.CSharp
// in PatternStatementTransform, then we have to do the "requires qualifier"-check based on the property instead of the field.
// It is easier to solve this special case here than in PatternStatementTransform, because here we perform all resolver checks.
// It feels a bit hacky, though.
if (settings.AutomaticProperties && PatternStatementTransform.IsBackingFieldOfAutomaticProperty(field, out var property)) {
if (settings.AutomaticProperties
&& PatternStatementTransform.IsBackingFieldOfAutomaticProperty(field, out var property)
&& !(this.decompilationContext.CurrentMember == property))
{
requireTarget = RequiresQualifier(property, target);
} else {
requireTarget = RequiresQualifier(field, target);

Loading…
Cancel
Save