From e613e7a49f3729138ef03080b6737140eea4972a Mon Sep 17 00:00:00 2001 From: Andreas Weizel Date: Sat, 15 Jun 2013 12:35:08 +0200 Subject: [PATCH] Now detecting auto-implemented properties correctly. --- .../Src/Refactoring/RefactoringExtensions.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/RefactoringExtensions.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/RefactoringExtensions.cs index 0fba0bf336..9b4462a1ea 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/RefactoringExtensions.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/RefactoringExtensions.cs @@ -2,6 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Linq; using ICSharpCode.Core; using ICSharpCode.NRefactory.CSharp; using ICSharpCode.NRefactory.TypeSystem; @@ -28,7 +29,17 @@ namespace CSharpBinding.Refactoring if (property.IsAbstract) return false; - return property.CanGet && !property.Getter.HasBody && property.CanSet && !property.Setter.HasBody; + CSharpFullParseInformation parseInformation; + PropertyDeclaration propDeclaration = property.GetDeclaration(out parseInformation) as PropertyDeclaration; + if ((propDeclaration != null) && (propDeclaration.Getter != null) && (propDeclaration.Setter != null)) { + bool containsGetterBlock = propDeclaration.Getter.Children.Any(node => node is BlockStatement); + bool containsSetterBlock = propDeclaration.Setter.Children.Any(node => node is BlockStatement); + + // This property is only auto-generated, if it contains get; and set; without block statements! + return !containsGetterBlock && !containsSetterBlock; + } + + return false; } ///