using System.Collections.Generic;
using System.Collections;
using System.Xml.Serialization;
public static void Test()
var xsdString = GetXsd();
XmlSchemaSet schemaSet = new XmlSchemaSet();
using (var reader = new StringReader(xsdString))
schemaSet.Add(XmlSchema.Read(reader, null));
foreach (XmlSchema schema in schemaSet.Schemas())
foreach (XmlSchemaElement element in schema.Elements.Values)
var complexType = element.ElementSchemaType as XmlSchemaComplexType;
Console.WriteLine("Complex element: {0}", element.Name);
if (complexType.AttributeUses.Count > 0)
var enumerator = complexType.AttributeUses.GetEnumerator();
while (enumerator.MoveNext())
var attribute = (XmlSchemaAttribute)enumerator.Value;
var name = attribute.Name;
var type = attribute.AttributeSchemaType.TypeCode;
Console.WriteLine(" Attribute {0}: {1}", name, type);
var sequence = complexType.ContentTypeParticle as XmlSchemaSequence;
foreach (XmlSchemaElement childElement in sequence.Items)
var name = childElement.Name;
var type = childElement.ElementSchemaType.TypeCode;
Console.WriteLine(" Element {0}: {1}", name, type);
return @"<?xml version=""1.0""?>
<xs:schema xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
<xs:element name=""Student"">
<xs:element name=""Id"" type=""xs:integer""/>
<xs:element name=""Name"" type=""xs:string""/>
<xs:element name=""City"" type=""xs:string""/>
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];