How can I force .NET\'s XmlSerializer to add an xsi:type=\"FooClass\" to a member/node of type FooClass?
The scenario
XmlSerializer can be pretty dumb and straightforward at times, which works to your advantage in this case. Just put it there manually:
public class FooClass
{
public int FooPropertyA { get; set; }
public string FooPropertyB { get; set; }
[XmlAttribute("type", Namespace="http://www.w3.org/2001/XMLSchema-instance")]
public string XsiType
{
get { return "Foo"; }
set { }
}
}