Exemplo n.º 1
0
        internal static IField GetBackingField(BaseRefactoringContext context, PropertyDeclaration propertyDeclaration)
        {
            // automatic properties always need getter & setter
            if (propertyDeclaration == null || propertyDeclaration.Getter.IsNull || propertyDeclaration.Setter.IsNull || propertyDeclaration.Getter.Body.IsNull || propertyDeclaration.Setter.Body.IsNull)
            {
                return(null);
            }
            if (!context.Supports(csharp3) || propertyDeclaration.HasModifier(ICSharpCode.NRefactory.Al.Modifiers.Abstract) || ((TypeDeclaration)propertyDeclaration.Parent).ClassType == ClassType.Interface)
            {
                return(null);
            }
            var getterField = ScanGetter(context, propertyDeclaration);

            if (getterField == null)
            {
                return(null);
            }
            var setterField = ScanSetter(context, propertyDeclaration);

            if (setterField == null)
            {
                return(null);
            }
            if (!getterField.Equals(setterField))
            {
                return(null);
            }
            return(getterField);
        }