C# with an epic fail
using System.Xml.Serialization;
[XmlRoot]
public class P
{
public P X { get { return new P(); } set { } }
static void Main()
{
new XmlSerializer(typeof(P)).Serialize(System.Console.Out, new P());
}
}
The way it fails is epic, it blew my mind completely:
It is just one frame of a seemingly infinite tripping series of strange images.
This has got to be the weirdest thing ever. Can anybody explain? Apparently, the ever increasing amount of spaces used for indentation cause those white blocks to appear. It happens on a Win7 Enterprise x64 with .NET 4.5.
I haven't actually seen the end of it yet. If you replace System.Console.Out
with System.IO.Stream.Null
, it dies pretty fast.
The explanation is pretty simple. I make a class which has a single property, and it always returns a new instance of its containing type. So it's an infinitely deep object hierarchy. Now we need something which tries to read through that. That's where I use the XmlSerializer
, which does just that. And apparently, it uses recursion.