diff --git a/XmlSchemaClassGenerator.Tests/XmlTests.cs b/XmlSchemaClassGenerator.Tests/XmlTests.cs index 1b66de13..7c865b14 100644 --- a/XmlSchemaClassGenerator.Tests/XmlTests.cs +++ b/XmlSchemaClassGenerator.Tests/XmlTests.cs @@ -522,7 +522,7 @@ private bool HandleValidationError(string[] xmlLines, ValidationEventArgs e) && !e.Message.Contains("The Pattern constraint failed")); // generator doesn't generate valid values where pattern restrictions exist, e.g. email } - private static readonly XmlQualifiedName AnyType = new XmlQualifiedName("anyType", XmlSchema.Namespace); + private static readonly XmlQualifiedName AnyType = new("anyType", XmlSchema.Namespace); private void DeserializeSampleXml(string pattern, Assembly assembly) { @@ -691,7 +691,7 @@ public void TestCustomNamespaces() string dcXsd = "DC.xsd"; string diXsd = "DI.xsd"; - Dictionary xsdToCsharpNsMap = new Dictionary + Dictionary xsdToCsharpNsMap = new() { { bpmnXsd, "Namespace1" }, { semantXsd, "Namespace1" }, @@ -700,7 +700,7 @@ public void TestCustomNamespaces() { diXsd, "Namespace4" } }; - Dictionary xsdToCsharpTypeMap = new Dictionary + Dictionary xsdToCsharpTypeMap = new() { { bpmnXsd, "TDefinitions" }, { semantXsd, "TActivity" }, @@ -709,7 +709,7 @@ public void TestCustomNamespaces() { diXsd, "DiagramElement" } }; - List customNamespaceConfig = new List(); + List customNamespaceConfig = new(); foreach (var ns in xsdToCsharpNsMap) customNamespaceConfig.Add(string.Format(customNsPattern, ns.Key, ns.Value)); @@ -804,7 +804,7 @@ void UnknownAttributeHandler(object sender, XmlAttributeEventArgs e) private static IDictionary GetNamespacesFromSource(string source) { - XPathDocument doc = new XPathDocument(new StringReader(source)); + XPathDocument doc = new(new StringReader(source)); XPathNavigator namespaceNavigator = doc.CreateNavigator(); namespaceNavigator.MoveToFollowing(XPathNodeType.Element); return namespaceNavigator.GetNamespacesInScope(XmlNamespaceScope.All); @@ -2442,7 +2442,7 @@ namespace Test [System.Xml.Serialization.XmlRootAttribute(""document"", Namespace=""http://local.none"")] public partial class Elem {{ - + [System.Xml.Serialization.XmlAttributeAttribute(""Text"")] public string Text {{ get; set; }} }} diff --git a/XmlSchemaClassGenerator/ModelBuilder.cs b/XmlSchemaClassGenerator/ModelBuilder.cs index 41d73525..38ddf6eb 100644 --- a/XmlSchemaClassGenerator/ModelBuilder.cs +++ b/XmlSchemaClassGenerator/ModelBuilder.cs @@ -14,11 +14,11 @@ internal class ModelBuilder private readonly XmlSchemaSet _set; private readonly Dictionary AttributeGroups; private readonly Dictionary Groups; - private readonly Dictionary Namespaces = new Dictionary(); - private readonly Dictionary Types = new Dictionary(); - private readonly Dictionary> SubstitutionGroups = new Dictionary>(); + private readonly Dictionary Namespaces = new(); + private readonly Dictionary Types = new(); + private readonly Dictionary> SubstitutionGroups = new(); - private static readonly XmlQualifiedName AnyType = new XmlQualifiedName("anyType", XmlSchema.Namespace); + private static readonly XmlQualifiedName AnyType = new("anyType", XmlSchema.Namespace); private string BuildKey(XmlSchemaAnnotated annotated, XmlQualifiedName name) => $"{annotated.GetType()}:{annotated.SourceUri}:{annotated.LineNumber}:{annotated.LinePosition}:{name}"; @@ -557,7 +557,7 @@ private TypeModel CreateTypeModel(Uri source, XmlSchemaComplexType complexType, private TypeModel CreateTypeModel(XmlSchemaSimpleType simpleType, NamespaceModel namespaceModel, XmlQualifiedName qualifiedName, List docs) { var restrictions = new List(); - List facets = new List(); + List facets = new(); if (simpleType.Content is XmlSchemaSimpleTypeRestriction typeRestriction) facets = typeRestriction.Facets.Cast().ToList();