Skip to content

Commit

Permalink
Use new()
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Jul 26, 2021
1 parent c88b0d9 commit 5d31527
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions XmlSchemaClassGenerator.Tests/XmlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -691,7 +691,7 @@ public void TestCustomNamespaces()
string dcXsd = "DC.xsd";
string diXsd = "DI.xsd";

Dictionary<string, string> xsdToCsharpNsMap = new Dictionary<string, string>
Dictionary<string, string> xsdToCsharpNsMap = new()
{
{ bpmnXsd, "Namespace1" },
{ semantXsd, "Namespace1" },
Expand All @@ -700,7 +700,7 @@ public void TestCustomNamespaces()
{ diXsd, "Namespace4" }
};

Dictionary<string, string> xsdToCsharpTypeMap = new Dictionary<string, string>
Dictionary<string, string> xsdToCsharpTypeMap = new()
{
{ bpmnXsd, "TDefinitions" },
{ semantXsd, "TActivity" },
Expand All @@ -709,7 +709,7 @@ public void TestCustomNamespaces()
{ diXsd, "DiagramElement" }
};

List<string> customNamespaceConfig = new List<string>();
List<string> customNamespaceConfig = new();

foreach (var ns in xsdToCsharpNsMap)
customNamespaceConfig.Add(string.Format(customNsPattern, ns.Key, ns.Value));
Expand Down Expand Up @@ -804,7 +804,7 @@ void UnknownAttributeHandler(object sender, XmlAttributeEventArgs e)

private static IDictionary<string, string> 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);
Expand Down Expand Up @@ -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; }}
}}
Expand Down
10 changes: 5 additions & 5 deletions XmlSchemaClassGenerator/ModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ internal class ModelBuilder
private readonly XmlSchemaSet _set;
private readonly Dictionary<XmlQualifiedName, XmlSchemaAttributeGroup> AttributeGroups;
private readonly Dictionary<XmlQualifiedName, XmlSchemaGroup> Groups;
private readonly Dictionary<NamespaceKey, NamespaceModel> Namespaces = new Dictionary<NamespaceKey, NamespaceModel>();
private readonly Dictionary<string, TypeModel> Types = new Dictionary<string, TypeModel>();
private readonly Dictionary<XmlQualifiedName, HashSet<Substitute>> SubstitutionGroups = new Dictionary<XmlQualifiedName, HashSet<Substitute>>();
private readonly Dictionary<NamespaceKey, NamespaceModel> Namespaces = new();
private readonly Dictionary<string, TypeModel> Types = new();
private readonly Dictionary<XmlQualifiedName, HashSet<Substitute>> 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}";
Expand Down Expand Up @@ -557,7 +557,7 @@ private TypeModel CreateTypeModel(Uri source, XmlSchemaComplexType complexType,
private TypeModel CreateTypeModel(XmlSchemaSimpleType simpleType, NamespaceModel namespaceModel, XmlQualifiedName qualifiedName, List<DocumentationModel> docs)
{
var restrictions = new List<RestrictionModel>();
List<XmlSchemaFacet> facets = new List<XmlSchemaFacet>();
List<XmlSchemaFacet> facets = new();

if (simpleType.Content is XmlSchemaSimpleTypeRestriction typeRestriction)
facets = typeRestriction.Facets.Cast<XmlSchemaFacet>().ToList();
Expand Down

0 comments on commit 5d31527

Please sign in to comment.