Skip to content

Commit

Permalink
Fix #49
Browse files Browse the repository at this point in the history
Update NuGet packages
💄
  • Loading branch information
Michael Ganss committed Feb 22, 2018
1 parent 5215339 commit 738e333
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator.Console/Glob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ public override string ToString()
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{
Expand Down
4 changes: 2 additions & 2 deletions XmlSchemaClassGenerator.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
var namespaceMap = namespaces.Select(n => ParseNamespace(n, namespacePrefix)).ToNamespaceProvider(key =>
{
var xn = key.XmlSchemaNamespace;
var name = string.Join(".", xn.Split('/').Where(p => Regex.IsMatch(p, @"^[A-Za-z]+$") && p != "schema")
var name = string.Join(".", xn.Split('/').Where(p => p != "schema" && GeneratorConfiguration.IdentifierRegex.IsMatch(p))
.Select(n => n.ToTitleCase(NamingScheme.PascalCase)));
if (!string.IsNullOrEmpty(namespacePrefix)) { name = namespacePrefix + (string.IsNullOrEmpty(name) ? "" : ("." + name)); }
return name;
Expand Down Expand Up @@ -132,7 +132,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
}

if (verbose) { generator.Log = s => System.Console.Out.WriteLine(s); }

generator.Generate(files);
}

Expand Down
8 changes: 4 additions & 4 deletions XmlSchemaClassGenerator.Tests/NamespaceProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void ContainsKeyTest()
Assert.True(ns.ContainsKey(new NamespaceKey("y")));
Assert.False(ns.ContainsKey(new NamespaceKey("z")));
ns.Clear();
Assert.Equal(0, ns.Count);
Assert.Empty(ns);
}

[Fact]
Expand All @@ -37,9 +37,9 @@ public void IndexTest()
var ns = new NamespaceProvider();
ns[new NamespaceKey("x")] = "c";
ns.GenerateNamespace = k => k.XmlSchemaNamespace != "z" ? k.XmlSchemaNamespace : null;
Assert.Equal(ns[new NamespaceKey("x")], "c");
Assert.Equal(ns[new NamespaceKey("y")], "y");
Assert.Equal(ns[new NamespaceKey("y")], "y");
Assert.Equal("c", ns[new NamespaceKey("x")]);
Assert.Equal("y", ns[new NamespaceKey("y")]);
Assert.Equal("y", ns[new NamespaceKey("y")]);
Assert.Throws<KeyNotFoundException>(() => ns[new NamespaceKey("z")]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit.runner.console" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.extensibility.core" Version="2.2.0" />
<PackageReference Include="xunit.extensibility.execution" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit.runner.console" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.extensibility.core" Version="2.3.1" />
<PackageReference Include="xunit.extensibility.execution" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator.Tests/XsdElsterDatenabholung5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void CanCompileClasses()
var outputName = Path.Combine(outputPath, "Elster.Test.dll");
var fileNames = new DirectoryInfo(inputPath).GetFiles("*.cs").Select(x => x.FullName).ToArray();
var results = provider.CompileAssemblyFromFile(new CompilerParameters(assemblies, outputName), fileNames);
Assert.Equal(0, results.Errors.Count);
Assert.Empty(results.Errors);
results.CompiledAssembly.GetType("Elster.Datenabholung5.Elster", true);
results.CompiledAssembly.GetType("Elster.Basis.TransferHeaderCType", true);
}
Expand Down
4 changes: 3 additions & 1 deletion XmlSchemaClassGenerator/GeneratorConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace XmlSchemaClassGenerator
{
public class GeneratorConfiguration
{
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);

public GeneratorConfiguration()
{
NamespaceProvider = new NamespaceProvider()
Expand All @@ -19,7 +21,7 @@ public GeneratorConfiguration()
{
var xn = key.XmlSchemaNamespace;
var name = string.Join(".",
xn.Split('/').Where(p => Regex.IsMatch(p, @"^[A-Za-z]+$") && p != "schema")
xn.Split('/').Where(p => p != "schema" && IdentifierRegex.IsMatch(p))
.Select(n => n.ToTitleCase(NamingScheme.PascalCase)));
if (!string.IsNullOrEmpty(NamespacePrefix))
{
Expand Down
3 changes: 1 addition & 2 deletions XmlSchemaClassGenerator/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,9 @@ private CodeTypeReference TypeReference

private void AddDocs(CodeTypeMember member)
{
var simpleType = PropertyType as SimpleModel;
var docs = new List<DocumentationModel>(Documentation);

if (simpleType != null)
if (PropertyType is SimpleModel simpleType)
{
docs.AddRange(simpleType.Documentation);
docs.AddRange(simpleType.Restrictions.Select(r => new DocumentationModel { Language = "en", Text = r.Description }));
Expand Down
4 changes: 4 additions & 0 deletions XmlSchemaClassGenerator/XmlSchemaClassGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.ComponentModel.Annotations" Version="4.4.1" />
</ItemGroup>

</Project>

0 comments on commit 738e333

Please sign in to comment.