Obsolete attribute causes property to be ignored by XmlSerialization

前端 未结 6 1092
臣服心动
臣服心动 2020-12-05 12:54

I\'m refactoring some objects that are serialized to XML but need to keep a few properties for backwards compatibility, I\'ve got a method that converts the old object into

6条回答
  •  不知归路
    2020-12-05 13:06

    Yes I agree with marking things with the name "Obsolete" we do this with Enum values

    /// 
    /// Determines the swap file location for a cluster.
    /// 
    /// This enum contains the original text based values for backwards compatibility with versions previous to "8.1".
    public enum VMwareClusterSwapFileLocation
    {
    
        /// 
        /// The swap file location is unknown.
        /// 
        Unknown = 0,
    
        /// 
        /// The swap file is stored in the virtual machine directory.
        /// 
        VmDirectory = 1,
    
        /// 
        /// The swap file is stored in the datastore specified by the host.
        /// 
        HostLocal = 2,
    
        /// 
        /// The swap file is stored in the virtual machine directory. This value is obsolete and used for backwards compatibility.
        /// 
        [XmlElement("vmDirectory")]
        ObseleteVmDirectory = 3,
    
        /// 
        /// The swap file is stored in the datastore specified by the host. This value is obsolete and used for backwards compatibility.
        /// 
        [XmlElement("hostLocal")]
        ObseleteHostLocal = 4,
    
    
    
    
    }
    

提交回复
热议问题