public static bool TryGetBackingFieldAndSpecifiedProperty(this CodeMemberProperty property, CodeTypeDeclaration codeType,
                                                              out CodeMemberField backingField, out CodeMemberProperty specifiedProperty)
    {
        if (property == null)
        {
            backingField      = null;
            specifiedProperty = null;
            return(false);
        }
        if ((backingField = property.GetBackingField(codeType)) == null)
        {
            specifiedProperty = null;
            return(false);
        }
        specifiedProperty = null;
        var specifiedName = property.Name + "Specified";

        foreach (var p in codeType.Members.OfType <CodeMemberProperty>())
        {
            if (p.Name == specifiedName)
            {
                // Make sure the property is marked as XmlIgnore (there might be a legitimate, serializable property
                // named xxxSpecified).
                if (!p.CustomAttributes.Cast <CodeAttributeDeclaration>().Any(a => a.AttributeType.BaseType == typeof(System.Xml.Serialization.XmlIgnoreAttribute).FullName))
                {
                    continue;
                }
                if (specifiedProperty == null)
                {
                    specifiedProperty = p;
                }
                else if (specifiedProperty != p)
                {
                    specifiedProperty = null;
                    break;
                }
            }
        }
        if (specifiedProperty == null)
        {
            return(false);
        }
        if (specifiedProperty.GetBackingField(codeType) == null)
        {
            return(false);
        }
        return(true);
    }
    public static bool TryGetBackingFieldAndSpecifiedProperty(this CodeMemberProperty property, CodeTypeDeclaration codeType,
                                                              out CodeMemberField backingField, out CodeMemberProperty specifiedProperty)
    {
        if (property == null)
        {
            backingField      = null;
            specifiedProperty = null;
            return(false);
        }
        if ((backingField = property.GetBackingField(codeType)) == null)
        {
            specifiedProperty = null;
            return(false);
        }
        specifiedProperty = null;
        var specifiedName = property.Name + "Specified";

        foreach (var p in codeType.Members.OfType <CodeMemberProperty>())
        {
            if (p.Name == specifiedName)
            {
                if (specifiedProperty == null)
                {
                    specifiedProperty = p;
                }
                else if (specifiedProperty != p)
                {
                    specifiedProperty = null;
                    break;
                }
            }
        }
        if (specifiedProperty == null)
        {
            return(false);
        }
        if (specifiedProperty.GetBackingField(codeType) == null)
        {
            return(false);
        }
        return(true);
    }