diff --git a/XmlSchemaClassGenerator.Tests/Compiler.cs b/XmlSchemaClassGenerator.Tests/Compiler.cs index ff6789ff..4db9c633 100644 --- a/XmlSchemaClassGenerator.Tests/Compiler.cs +++ b/XmlSchemaClassGenerator.Tests/Compiler.cs @@ -33,7 +33,7 @@ public static CompilationResult GenerateAssembly(Compilation compilation) }; } - private static readonly ConcurrentDictionary Assemblies = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary Assemblies = new(); private static readonly string[] DependencyAssemblies = new[] { diff --git a/XmlSchemaClassGenerator.Tests/IntegerTypeTests.cs b/XmlSchemaClassGenerator.Tests/IntegerTypeTests.cs index 8cf71e5e..85fb9391 100644 --- a/XmlSchemaClassGenerator.Tests/IntegerTypeTests.cs +++ b/XmlSchemaClassGenerator.Tests/IntegerTypeTests.cs @@ -9,7 +9,7 @@ namespace XmlSchemaClassGenerator.Tests { public class IntegerTypeTests { - private IEnumerable ConvertXml(string name, string xsd, Generator generatorPrototype = null) + private static IEnumerable ConvertXml(string name, string xsd, Generator generatorPrototype = null) { if (name is null) { diff --git a/XmlSchemaClassGenerator.Tests/MemoryOutputWriter.cs b/XmlSchemaClassGenerator.Tests/MemoryOutputWriter.cs index f830884a..b9566417 100644 --- a/XmlSchemaClassGenerator.Tests/MemoryOutputWriter.cs +++ b/XmlSchemaClassGenerator.Tests/MemoryOutputWriter.cs @@ -6,7 +6,7 @@ namespace XmlSchemaClassGenerator.Tests { internal class MemoryOutputWriter : OutputWriter { - private readonly List _contents = new List(); + private readonly List _contents = new(); public IEnumerable Content => _contents; diff --git a/XmlSchemaClassGenerator.Tests/VisitorTests.cs b/XmlSchemaClassGenerator.Tests/VisitorTests.cs index c252f24e..3be53817 100644 --- a/XmlSchemaClassGenerator.Tests/VisitorTests.cs +++ b/XmlSchemaClassGenerator.Tests/VisitorTests.cs @@ -9,7 +9,7 @@ namespace XmlSchemaClassGenerator.Tests { public class VisitorTests { - private IEnumerable ConvertXml(string name, string xsd, Generator generatorPrototype = null) + private static IEnumerable ConvertXml(string name, string xsd, Generator generatorPrototype = null) { if (name is null) { diff --git a/XmlSchemaClassGenerator/CodeUtilities.cs b/XmlSchemaClassGenerator/CodeUtilities.cs index edd33d8c..e88a597f 100644 --- a/XmlSchemaClassGenerator/CodeUtilities.cs +++ b/XmlSchemaClassGenerator/CodeUtilities.cs @@ -11,7 +11,7 @@ namespace XmlSchemaClassGenerator public static class CodeUtilities { // Match non-letter followed by letter - static readonly Regex PascalCaseRegex = new Regex(@"[^\p{L}]\p{L}", RegexOptions.Compiled); + static readonly Regex PascalCaseRegex = new(@"[^\p{L}]\p{L}", RegexOptions.Compiled); // Uppercases first letter and all letters following non-letters. // Examples: testcase -> Testcase, html5element -> Html5Element, test_case -> Test_Case @@ -312,14 +312,14 @@ public static string GetUniquePropertyName(this TypeModel tm, string name) return name; } - static readonly Regex NormalizeNewlinesRegex = new Regex(@"(^|[^\r])\n", RegexOptions.Compiled); + static readonly Regex NormalizeNewlinesRegex = new (@"(^|[^\r])\n", RegexOptions.Compiled); internal static string NormalizeNewlines(string text) { return NormalizeNewlinesRegex.Replace(text, "$1\r\n"); } - static readonly List CSharpKeywords = new List + static readonly List CSharpKeywords = new() { "abstract", "as", "base", "bool", "break", "byte", "case", "catch", @@ -365,7 +365,7 @@ public static KeyValuePair ParseNamespace(string nsArg, st return new KeyValuePair(new NamespaceKey(source, xmlNs), netNs); } - public static readonly List<(string Namespace, Func Condition)> UsingNamespaces = new List<(string, Func)> { + public static readonly List<(string Namespace, Func Condition)> UsingNamespaces = new() { ("System", c => c.CompactTypeNames), ("System.CodeDom.Compiler", c => c.CompactTypeNames), ("System.Collections.Generic", c => c.CompactTypeNames), diff --git a/XmlSchemaClassGenerator/FileOutputWriter.cs b/XmlSchemaClassGenerator/FileOutputWriter.cs index a5256a1d..81699983 100644 --- a/XmlSchemaClassGenerator/FileOutputWriter.cs +++ b/XmlSchemaClassGenerator/FileOutputWriter.cs @@ -88,7 +88,7 @@ private void WriteSeparateFiles(CodeNamespace cn) } } - static readonly Regex InvalidCharacters = new Regex($"[{string.Join("", Path.GetInvalidFileNameChars())}]", RegexOptions.Compiled); + static readonly Regex InvalidCharacters = new($"[{string.Join("", Path.GetInvalidFileNameChars())}]", RegexOptions.Compiled); private string ValidateName(string name) => InvalidCharacters.Replace(name, "_"); } diff --git a/XmlSchemaClassGenerator/Generator.cs b/XmlSchemaClassGenerator/Generator.cs index c2dc59f6..0e790717 100644 --- a/XmlSchemaClassGenerator/Generator.cs +++ b/XmlSchemaClassGenerator/Generator.cs @@ -11,7 +11,7 @@ namespace XmlSchemaClassGenerator { public class Generator { - private readonly GeneratorConfiguration _configuration = new GeneratorConfiguration(); + private readonly GeneratorConfiguration _configuration = new(); public GeneratorConfiguration Configuration => _configuration; diff --git a/XmlSchemaClassGenerator/NamespaceHierarchyItem.cs b/XmlSchemaClassGenerator/NamespaceHierarchyItem.cs index 7ce8d6f4..5cc867b1 100644 --- a/XmlSchemaClassGenerator/NamespaceHierarchyItem.cs +++ b/XmlSchemaClassGenerator/NamespaceHierarchyItem.cs @@ -8,9 +8,9 @@ namespace XmlSchemaClassGenerator { public class NamespaceHierarchyItem { - private readonly List InternalSubNamespaces = new List(); - private readonly List InternalNamespaceModels = new List(); - private readonly List InternalTypeModels = new List(); + private readonly List InternalSubNamespaces = new(); + private readonly List InternalNamespaceModels = new(); + private readonly List InternalTypeModels = new(); private NamespaceHierarchyItem(string name, string fullName) { diff --git a/XmlSchemaClassGenerator/NamespaceProvider.cs b/XmlSchemaClassGenerator/NamespaceProvider.cs index 753b9146..b86b3614 100644 --- a/XmlSchemaClassGenerator/NamespaceProvider.cs +++ b/XmlSchemaClassGenerator/NamespaceProvider.cs @@ -9,7 +9,7 @@ namespace XmlSchemaClassGenerator { public class NamespaceProvider : IDictionary { - private readonly Dictionary InternalDictionary = new Dictionary(); + private readonly Dictionary InternalDictionary = new(); public GenerateNamespaceDelegate GenerateNamespace { get; set; } diff --git a/XmlSchemaClassGenerator/NamingExtensions.cs b/XmlSchemaClassGenerator/NamingExtensions.cs index 4a4152b4..48104918 100644 --- a/XmlSchemaClassGenerator/NamingExtensions.cs +++ b/XmlSchemaClassGenerator/NamingExtensions.cs @@ -9,7 +9,7 @@ public static class NamingExtensions { private static readonly CodeDomProvider Provider = new Microsoft.CSharp.CSharpCodeProvider(); - private static readonly Dictionary InvalidChars = new Dictionary + private static readonly Dictionary InvalidChars = new() { ['\x00'] = "Null", ['\x01'] = "StartOfHeading",