using System.Collections.Generic;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO.Compression;
public static void Test()
XNamespace fooNs = "http://www.example.com/xmlns/foo-version1";
XNamespace defNs = "http://www.example.com/xmlns";
var root = new XElement(fooNs + "document"
, new XAttribute("xmlns", defNs.ToString())
, new XAttribute(XNamespace.Xmlns + "foo", fooNs.ToString())
, new XElement(fooNs + "bar", new XAttribute(fooNs + "baz", true)));
var xml = root.ToString();
Assert.IsTrue(XNode.DeepEquals(XElement.Parse(xml), XElement.Parse(GetRequiredXml())));
static string GetRequiredXml()
return @"<foo:document xmlns=""http://www.example.com/xmlns"" xmlns:foo=""http://www.example.com/xmlns/foo-version1"">
<foo:bar foo:baz=""true"" />
public static void Main()
Console.WriteLine("Environment version: {0} ({1})", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription , GetNetCoreVersion());
Console.WriteLine("Failed with unhandled exception: ");
public static string GetNetCoreVersion()
var assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly;
var assemblyPath = assembly.CodeBase.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2)
return assemblyPath[netCoreAppIndex + 1];