using System.Collections.Generic;
using System.Xml.Serialization;
using System.Diagnostics;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Text.RegularExpressions;
using System.Globalization;
using System.ComponentModel.DataAnnotations;
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Threading.Tasks;
public static class XElementExtensions
public static async Task WriteToAsync(this XContainer element, Stream stream, bool defAttr = true, bool indent = false)
var settings = new XmlWriterSettings
using (var writer = XmlWriter.Create(stream, settings))
using (var reader = element.CreateReader())
await writer.WriteNodeAsync(reader, defAttr);
public static async Task TestAsync(XContainer element, Stream stream)
await element.WriteToAsync(stream, false, true);
static void Test(XContainer element)
Console.WriteLine("\nTesting {0}", element.GetType());
using (var stream = new MemoryStream())
var task = TestAsync(element, stream);
Console.WriteLine(new StreamReader(stream).ReadToEnd());
public static void Test()
var document = XDocument.Parse(GetXml());
var xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<description>I, for one, was never strong.</description>
<pathToIcon>SomeIconPath</pathToIcon>
<!-- Fixed added missing Traits end element: -->
public class AssertionFailedException : System.Exception
public AssertionFailedException() : base() { }
public AssertionFailedException(string s) : base(s) { }
public static class Assert
public static void IsTrue(bool value)
public static void IsTrue(bool value, string message)
throw new AssertionFailedException(message ?? "failed");
public static void Main()
Console.WriteLine("Roslyn 2.0 Compiler; Environment version: " + Environment.Version);
Console.WriteLine("Uncaught exception: ");