I would like to make some property of a class visisble (scope, access modifier) only by the XML serializer. I'm not sure about the best way to hide some properties from the consumers of a class without over engineering.
Let's see an exemple:
public class MyClass
{
[XmlIgnore]
public Version Version { get; set; }
/// <summary>
/// Do not used. This is a dummy property for XML serialization.
/// </summary>
[XmlAttribute(AttributeName = nameof(Version))]
public string XmlVersion
{
get => Version.ToString();
set => Version = new Version(value);
}
}
This kind of code allows me to use a class which is not designed to be serialized (System.Version isn't because its properties are readonly).
I would like that the consumers of my class see only Version but not the XmlVersion property.
Edit : If it's possible, I'd like those properties to be hidden even in the project where the class is so my co-worker won't use those dummy properties too. I know I can use ObsoleteAttribute to give information why they should be avoided but those properties will still be usable which isn't the behavior I'm looking for.