Skip to content

Commit dd2313e

Browse files
author
Michael Ganss
committed
Add VS suggestions
1 parent 9d04882 commit dd2313e

10 files changed

+15
-15
lines changed

XmlSchemaClassGenerator.Tests/Compiler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static CompilationResult GenerateAssembly(Compilation compilation)
3333
};
3434
}
3535

36-
private static readonly ConcurrentDictionary<string, Assembly> Assemblies = new ConcurrentDictionary<string, Assembly>();
36+
private static readonly ConcurrentDictionary<string, Assembly> Assemblies = new();
3737

3838
private static readonly string[] DependencyAssemblies = new[]
3939
{

XmlSchemaClassGenerator.Tests/IntegerTypeTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace XmlSchemaClassGenerator.Tests {
1010
public class IntegerTypeTests
1111
{
12-
private IEnumerable<string> ConvertXml(string name, string xsd, Generator generatorPrototype = null)
12+
private static IEnumerable<string> ConvertXml(string name, string xsd, Generator generatorPrototype = null)
1313
{
1414
if (name is null)
1515
{

XmlSchemaClassGenerator.Tests/MemoryOutputWriter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace XmlSchemaClassGenerator.Tests
66
{
77
internal class MemoryOutputWriter : OutputWriter
88
{
9-
private readonly List<string> _contents = new List<string>();
9+
private readonly List<string> _contents = new();
1010

1111
public IEnumerable<string> Content => _contents;
1212

XmlSchemaClassGenerator.Tests/VisitorTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace XmlSchemaClassGenerator.Tests {
1010
public class VisitorTests
1111
{
12-
private IEnumerable<string> ConvertXml(string name, string xsd, Generator generatorPrototype = null)
12+
private static IEnumerable<string> ConvertXml(string name, string xsd, Generator generatorPrototype = null)
1313
{
1414
if (name is null)
1515
{

XmlSchemaClassGenerator/CodeUtilities.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace XmlSchemaClassGenerator
1111
public static class CodeUtilities
1212
{
1313
// Match non-letter followed by letter
14-
static readonly Regex PascalCaseRegex = new Regex(@"[^\p{L}]\p{L}", RegexOptions.Compiled);
14+
static readonly Regex PascalCaseRegex = new(@"[^\p{L}]\p{L}", RegexOptions.Compiled);
1515

1616
// Uppercases first letter and all letters following non-letters.
1717
// Examples: testcase -> Testcase, html5element -> Html5Element, test_case -> Test_Case
@@ -312,14 +312,14 @@ public static string GetUniquePropertyName(this TypeModel tm, string name)
312312
return name;
313313
}
314314

315-
static readonly Regex NormalizeNewlinesRegex = new Regex(@"(^|[^\r])\n", RegexOptions.Compiled);
315+
static readonly Regex NormalizeNewlinesRegex = new (@"(^|[^\r])\n", RegexOptions.Compiled);
316316

317317
internal static string NormalizeNewlines(string text)
318318
{
319319
return NormalizeNewlinesRegex.Replace(text, "$1\r\n");
320320
}
321321

322-
static readonly List<string> CSharpKeywords = new List<string>
322+
static readonly List<string> CSharpKeywords = new()
323323
{
324324
"abstract", "as", "base", "bool",
325325
"break", "byte", "case", "catch",
@@ -365,7 +365,7 @@ public static KeyValuePair<NamespaceKey, string> ParseNamespace(string nsArg, st
365365
return new KeyValuePair<NamespaceKey, string>(new NamespaceKey(source, xmlNs), netNs);
366366
}
367367

368-
public static readonly List<(string Namespace, Func<GeneratorConfiguration,bool> Condition)> UsingNamespaces = new List<(string, Func<GeneratorConfiguration, bool>)> {
368+
public static readonly List<(string Namespace, Func<GeneratorConfiguration,bool> Condition)> UsingNamespaces = new() {
369369
("System", c => c.CompactTypeNames),
370370
("System.CodeDom.Compiler", c => c.CompactTypeNames),
371371
("System.Collections.Generic", c => c.CompactTypeNames),

XmlSchemaClassGenerator/FileOutputWriter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private void WriteSeparateFiles(CodeNamespace cn)
8888
}
8989
}
9090

91-
static readonly Regex InvalidCharacters = new Regex($"[{string.Join("", Path.GetInvalidFileNameChars())}]", RegexOptions.Compiled);
91+
static readonly Regex InvalidCharacters = new($"[{string.Join("", Path.GetInvalidFileNameChars())}]", RegexOptions.Compiled);
9292

9393
private string ValidateName(string name) => InvalidCharacters.Replace(name, "_");
9494
}

XmlSchemaClassGenerator/Generator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace XmlSchemaClassGenerator
1111
{
1212
public class Generator
1313
{
14-
private readonly GeneratorConfiguration _configuration = new GeneratorConfiguration();
14+
private readonly GeneratorConfiguration _configuration = new();
1515

1616
public GeneratorConfiguration Configuration => _configuration;
1717

XmlSchemaClassGenerator/NamespaceHierarchyItem.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace XmlSchemaClassGenerator
88
{
99
public class NamespaceHierarchyItem
1010
{
11-
private readonly List<NamespaceHierarchyItem> InternalSubNamespaces = new List<NamespaceHierarchyItem>();
12-
private readonly List<NamespaceModel> InternalNamespaceModels = new List<NamespaceModel>();
13-
private readonly List<TypeModel> InternalTypeModels = new List<TypeModel>();
11+
private readonly List<NamespaceHierarchyItem> InternalSubNamespaces = new();
12+
private readonly List<NamespaceModel> InternalNamespaceModels = new();
13+
private readonly List<TypeModel> InternalTypeModels = new();
1414

1515
private NamespaceHierarchyItem(string name, string fullName)
1616
{

XmlSchemaClassGenerator/NamespaceProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace XmlSchemaClassGenerator
99
{
1010
public class NamespaceProvider : IDictionary<NamespaceKey, string>
1111
{
12-
private readonly Dictionary<NamespaceKey, string> InternalDictionary = new Dictionary<NamespaceKey, string>();
12+
private readonly Dictionary<NamespaceKey, string> InternalDictionary = new();
1313

1414
public GenerateNamespaceDelegate GenerateNamespace { get; set; }
1515

XmlSchemaClassGenerator/NamingExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static class NamingExtensions
99
{
1010
private static readonly CodeDomProvider Provider = new Microsoft.CSharp.CSharpCodeProvider();
1111

12-
private static readonly Dictionary<char, string> InvalidChars = new Dictionary<char, string>
12+
private static readonly Dictionary<char, string> InvalidChars = new()
1313
{
1414
['\x00'] = "Null",
1515
['\x01'] = "StartOfHeading",

0 commit comments

Comments
 (0)