On Aug 6, 4:38*pm, "Andrus" <kobrule...@hot.eewrote:
FxCop orders to use properties instead of Getter methods. Probably ToFont()
method will be
flagged as issue by FxCop.
FXCop is just plain wrong there. Have a look at the BCL classes - how
many GetXxx() methods can you find. They are usually there for a
reason. One prominent example is IEnumerable.GetEnumerator() - it is a
method, and not a property, because on every call it creates a new
enumerator. The fundamental contract of a property is that, if the
state of the system does not change, calling the property gettor twice
should return the same value (i.e., foo.Bar == foo.Bar).
And no, it will not flag ToXxx() methods - would it flag, say,
ToString()? I've no idea, to be honest, since I've last used FXCop
several years ago - but if it did that, it's just not worth using. Or
maybe you should turn off that specific rule for it...
Maybe it is reasonable to use TypeConverter and avoid creating wrapper
object ?
If you do not need to serialize individual font properties to XML in
such a way that they are clearly separated in that XML (so that they
could be described by XML Schema, and easily retrieved using XPath),
then sure, using TypeConverter to convert to/from string, and storing
that string within an XML attribute or element, is a perfectly valid
solution.