Skip to content

Commit

Permalink
Add VS suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Aug 25, 2021
1 parent 9d04882 commit dd2313e
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator.Tests/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static CompilationResult GenerateAssembly(Compilation compilation)
};
}

private static readonly ConcurrentDictionary<string, Assembly> Assemblies = new ConcurrentDictionary<string, Assembly>();
private static readonly ConcurrentDictionary<string, Assembly> Assemblies = new();

private static readonly string[] DependencyAssemblies = new[]
{
Expand Down
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator.Tests/IntegerTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace XmlSchemaClassGenerator.Tests {
public class IntegerTypeTests
{
private IEnumerable<string> ConvertXml(string name, string xsd, Generator generatorPrototype = null)
private static IEnumerable<string> ConvertXml(string name, string xsd, Generator generatorPrototype = null)
{
if (name is null)
{
Expand Down
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator.Tests/MemoryOutputWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace XmlSchemaClassGenerator.Tests
{
internal class MemoryOutputWriter : OutputWriter
{
private readonly List<string> _contents = new List<string>();
private readonly List<string> _contents = new();

public IEnumerable<string> Content => _contents;

Expand Down
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator.Tests/VisitorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace XmlSchemaClassGenerator.Tests {
public class VisitorTests
{
private IEnumerable<string> ConvertXml(string name, string xsd, Generator generatorPrototype = null)
private static IEnumerable<string> ConvertXml(string name, string xsd, Generator generatorPrototype = null)
{
if (name is null)
{
Expand Down
8 changes: 4 additions & 4 deletions XmlSchemaClassGenerator/CodeUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<string> CSharpKeywords = new List<string>
static readonly List<string> CSharpKeywords = new()
{
"abstract", "as", "base", "bool",
"break", "byte", "case", "catch",
Expand Down Expand Up @@ -365,7 +365,7 @@ public static KeyValuePair<NamespaceKey, string> ParseNamespace(string nsArg, st
return new KeyValuePair<NamespaceKey, string>(new NamespaceKey(source, xmlNs), netNs);
}

public static readonly List<(string Namespace, Func<GeneratorConfiguration,bool> Condition)> UsingNamespaces = new List<(string, Func<GeneratorConfiguration, bool>)> {
public static readonly List<(string Namespace, Func<GeneratorConfiguration,bool> Condition)> UsingNamespaces = new() {
("System", c => c.CompactTypeNames),
("System.CodeDom.Compiler", c => c.CompactTypeNames),
("System.Collections.Generic", c => c.CompactTypeNames),
Expand Down
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator/FileOutputWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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, "_");
}
Expand Down
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace XmlSchemaClassGenerator
{
public class Generator
{
private readonly GeneratorConfiguration _configuration = new GeneratorConfiguration();
private readonly GeneratorConfiguration _configuration = new();

public GeneratorConfiguration Configuration => _configuration;

Expand Down
6 changes: 3 additions & 3 deletions XmlSchemaClassGenerator/NamespaceHierarchyItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace XmlSchemaClassGenerator
{
public class NamespaceHierarchyItem
{
private readonly List<NamespaceHierarchyItem> InternalSubNamespaces = new List<NamespaceHierarchyItem>();
private readonly List<NamespaceModel> InternalNamespaceModels = new List<NamespaceModel>();
private readonly List<TypeModel> InternalTypeModels = new List<TypeModel>();
private readonly List<NamespaceHierarchyItem> InternalSubNamespaces = new();
private readonly List<NamespaceModel> InternalNamespaceModels = new();
private readonly List<TypeModel> InternalTypeModels = new();

private NamespaceHierarchyItem(string name, string fullName)
{
Expand Down
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator/NamespaceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace XmlSchemaClassGenerator
{
public class NamespaceProvider : IDictionary<NamespaceKey, string>
{
private readonly Dictionary<NamespaceKey, string> InternalDictionary = new Dictionary<NamespaceKey, string>();
private readonly Dictionary<NamespaceKey, string> InternalDictionary = new();

public GenerateNamespaceDelegate GenerateNamespace { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator/NamingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static class NamingExtensions
{
private static readonly CodeDomProvider Provider = new Microsoft.CSharp.CSharpCodeProvider();

private static readonly Dictionary<char, string> InvalidChars = new Dictionary<char, string>
private static readonly Dictionary<char, string> InvalidChars = new()
{
['\x00'] = "Null",
['\x01'] = "StartOfHeading",
Expand Down

0 comments on commit dd2313e

Please sign in to comment.