Skip to content

Commit 738e333

Browse files
author
Michael Ganss
committed
Fix #49
Update NuGet packages πŸ’„
1 parent 5215339 commit 738e333

File tree

8 files changed

+22
-17
lines changed

8 files changed

+22
-17
lines changed

β€ŽXmlSchemaClassGenerator.Console/Glob.csβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ public override string ToString()
494494
/// Returns a hash code for this instance.
495495
/// </summary>
496496
/// <returns>
497-
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
497+
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
498498
/// </returns>
499499
public override int GetHashCode()
500500
{

β€ŽXmlSchemaClassGenerator.Console/Program.csβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
9292
var namespaceMap = namespaces.Select(n => ParseNamespace(n, namespacePrefix)).ToNamespaceProvider(key =>
9393
{
9494
var xn = key.XmlSchemaNamespace;
95-
var name = string.Join(".", xn.Split('/').Where(p => Regex.IsMatch(p, @"^[A-Za-z]+$") && p != "schema")
95+
var name = string.Join(".", xn.Split('/').Where(p => p != "schema" && GeneratorConfiguration.IdentifierRegex.IsMatch(p))
9696
.Select(n => n.ToTitleCase(NamingScheme.PascalCase)));
9797
if (!string.IsNullOrEmpty(namespacePrefix)) { name = namespacePrefix + (string.IsNullOrEmpty(name) ? "" : ("." + name)); }
9898
return name;
@@ -132,7 +132,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
132132
}
133133

134134
if (verbose) { generator.Log = s => System.Console.Out.WriteLine(s); }
135-
135+
136136
generator.Generate(files);
137137
}
138138

β€ŽXmlSchemaClassGenerator.Tests/NamespaceProviderTests.csβ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void ContainsKeyTest()
2020
Assert.True(ns.ContainsKey(new NamespaceKey("y")));
2121
Assert.False(ns.ContainsKey(new NamespaceKey("z")));
2222
ns.Clear();
23-
Assert.Equal(0, ns.Count);
23+
Assert.Empty(ns);
2424
}
2525

2626
[Fact]
@@ -37,9 +37,9 @@ public void IndexTest()
3737
var ns = new NamespaceProvider();
3838
ns[new NamespaceKey("x")] = "c";
3939
ns.GenerateNamespace = k => k.XmlSchemaNamespace != "z" ? k.XmlSchemaNamespace : null;
40-
Assert.Equal(ns[new NamespaceKey("x")], "c");
41-
Assert.Equal(ns[new NamespaceKey("y")], "y");
42-
Assert.Equal(ns[new NamespaceKey("y")], "y");
40+
Assert.Equal("c", ns[new NamespaceKey("x")]);
41+
Assert.Equal("y", ns[new NamespaceKey("y")]);
42+
Assert.Equal("y", ns[new NamespaceKey("y")]);
4343
Assert.Throws<KeyNotFoundException>(() => ns[new NamespaceKey("z")]);
4444
}
4545
}

β€ŽXmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csprojβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
25-
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
26-
<PackageReference Include="xunit.runner.console" Version="2.2.0" />
27-
<PackageReference Include="xunit" Version="2.2.0" />
28-
<PackageReference Include="xunit.extensibility.core" Version="2.2.0" />
29-
<PackageReference Include="xunit.extensibility.execution" Version="2.2.0" />
24+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
25+
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
26+
<PackageReference Include="xunit.runner.console" Version="2.3.1" />
27+
<PackageReference Include="xunit" Version="2.3.1" />
28+
<PackageReference Include="xunit.extensibility.core" Version="2.3.1" />
29+
<PackageReference Include="xunit.extensibility.execution" Version="2.3.1" />
3030
</ItemGroup>
3131

3232
<ItemGroup>

β€ŽXmlSchemaClassGenerator.Tests/XsdElsterDatenabholung5.csβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void CanCompileClasses()
8888
var outputName = Path.Combine(outputPath, "Elster.Test.dll");
8989
var fileNames = new DirectoryInfo(inputPath).GetFiles("*.cs").Select(x => x.FullName).ToArray();
9090
var results = provider.CompileAssemblyFromFile(new CompilerParameters(assemblies, outputName), fileNames);
91-
Assert.Equal(0, results.Errors.Count);
91+
Assert.Empty(results.Errors);
9292
results.CompiledAssembly.GetType("Elster.Datenabholung5.Elster", true);
9393
results.CompiledAssembly.GetType("Elster.Basis.TransferHeaderCType", true);
9494
}

β€ŽXmlSchemaClassGenerator/GeneratorConfiguration.csβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace XmlSchemaClassGenerator
1111
{
1212
public class GeneratorConfiguration
1313
{
14+
public static Regex IdentifierRegex = new Regex(@"^@?[_\p{L}\p{Nl}][\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\p{Cf}]*$", RegexOptions.Compiled);
15+
1416
public GeneratorConfiguration()
1517
{
1618
NamespaceProvider = new NamespaceProvider()
@@ -19,7 +21,7 @@ public GeneratorConfiguration()
1921
{
2022
var xn = key.XmlSchemaNamespace;
2123
var name = string.Join(".",
22-
xn.Split('/').Where(p => Regex.IsMatch(p, @"^[A-Za-z]+$") && p != "schema")
24+
xn.Split('/').Where(p => p != "schema" && IdentifierRegex.IsMatch(p))
2325
.Select(n => n.ToTitleCase(NamingScheme.PascalCase)));
2426
if (!string.IsNullOrEmpty(NamespacePrefix))
2527
{

β€ŽXmlSchemaClassGenerator/TypeModel.csβ€Ž

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,9 @@ private CodeTypeReference TypeReference
597597

598598
private void AddDocs(CodeTypeMember member)
599599
{
600-
var simpleType = PropertyType as SimpleModel;
601600
var docs = new List<DocumentationModel>(Documentation);
602601

603-
if (simpleType != null)
602+
if (PropertyType is SimpleModel simpleType)
604603
{
605604
docs.AddRange(simpleType.Documentation);
606605
docs.AddRange(simpleType.Restrictions.Select(r => new DocumentationModel { Language = "en", Text = r.Description }));

β€ŽXmlSchemaClassGenerator/XmlSchemaClassGenerator.csprojβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,8 @@
5252
<Folder Include="Properties\" />
5353
</ItemGroup>
5454

55+
<ItemGroup>
56+
<PackageReference Include="System.ComponentModel.Annotations" Version="4.4.1" />
57+
</ItemGroup>
58+
5559
</Project>

0 commit comments

Comments
Β (0)