I have a class which communicates with an API and needs to do some transformations to any data it touches. This class is the equivalent too:
public class SerializeMe
{
public SerializeMe(string someString)
{
_someString = someString;
}
private string _someString;
public string TransformedValue
{
get { _someString = TransformToSomething();
return _someString; }
set { _someString = value; }
}
}
For my API callers I log every request and response by serializing these classes. They act as xml schemas almost.
Now everything works perfectly my only issue is that somebody could theoretically try and set and end up not getting their expected results back. Its mainly a design issue just trying to make my code responsible. I'd love to be able to use a private set on this but the XmlSerializer complains about it.
Is there a attribute or another technique to be able to make Transformed value as unsettable except by the serializer?
Also If there isn't an option, making the property as Obsolete is an option. Is there any other more appropriate attribute to use?