Skip to content

Commit d928870

Browse files
committed
Target net8.0
Update NuGet packages Implement VS suggestions
1 parent 70f49d8 commit d928870

53 files changed

Lines changed: 33697 additions & 33829 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

XmlSchemaClassGenerator.Console/Program.cs

Lines changed: 310 additions & 311 deletions
Large diffs are not rendered by default.

XmlSchemaClassGenerator.Console/XmlSchemaClassGenerator.Console.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Description>A .NET CLI tool to generate XmlSerializer compatible C# classes from XML Schema files.</Description>
44
<Copyright>Copyright 2013-$([System.DateTime]::Now.Year) Michael Ganss</Copyright>
@@ -16,7 +16,7 @@
1616
<PackageTags>xsd xmlschema generator</PackageTags>
1717
<PackageProjectUrl>https://github.com/mganss/XmlSchemaClassGenerator</PackageProjectUrl>
1818
<PackageLicenseUrl>https://github.com/mganss/XmlSchemaClassGenerator/blob/master/LICENSE</PackageLicenseUrl>
19-
<PackageReadmeFile>README.md</PackageReadmeFile>
19+
<PackageReadmeFile>README.md</PackageReadmeFile>
2020
<RepositoryType>git</RepositoryType>
2121
<RepositoryUrl>git://github.com/mganss/XmlSchemaClassGenerator</RepositoryUrl>
2222
<IncludeBuildOutput>false</IncludeBuildOutput>
@@ -36,9 +36,9 @@
3636
</None>
3737
</ItemGroup>
3838
<ItemGroup>
39-
<PackageReference Include="Glob.cs" Version="5.1.1491" />
39+
<PackageReference Include="Glob.cs" Version="5.1.1643" />
4040
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
41-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
41+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
4242
</ItemGroup>
4343
<ItemGroup>
4444
<None Include="../README.md" Pack="true" PackagePath="" />

XmlSchemaClassGenerator.Tests/AssertEx.cs

Lines changed: 71 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9,101 +9,98 @@
99
using System.Xml.Serialization;
1010
using Xunit;
1111

12-
namespace XmlSchemaClassGenerator.Tests
12+
namespace XmlSchemaClassGenerator.Tests;
13+
14+
class AssertEx
1315
{
14-
class AssertEx
16+
public static async Task ThrowsAsync<TException>(Func<Task> func)
1517
{
16-
public static async Task ThrowsAsync<TException>(Func<Task> func)
18+
var expected = typeof(TException);
19+
Type actual = null;
20+
try
1721
{
18-
var expected = typeof(TException);
19-
Type actual = null;
20-
try
21-
{
22-
await func();
23-
}
24-
#pragma warning disable CA1031 // Do not catch general exception types
25-
catch (Exception e)
26-
{
27-
actual = e.GetType();
28-
}
29-
#pragma warning restore CA1031 // Do not catch general exception types
30-
Assert.Equal(expected, actual);
22+
await func();
3123
}
24+
catch (Exception e)
25+
{
26+
actual = e.GetType();
27+
}
28+
Assert.Equal(expected, actual);
29+
}
30+
31+
public static void Equal(object o1, object o2)
32+
{
33+
if (o1 == null && o2 == null) { return; }
34+
Assert.NotNull(o1);
35+
Assert.NotNull(o2);
36+
37+
var type1 = o1.GetType();
38+
var type2 = o2.GetType();
39+
Assert.Equal(type1, type2);
3240

33-
public static void Equal(object o1, object o2)
41+
if (type1.IsPrimitive || type1.IsEnum || type1 == typeof(string) || type1 == typeof(System.DateTime))
3442
{
35-
if (o1 == null && o2 == null) { return; }
36-
Assert.NotNull(o1);
37-
Assert.NotNull(o2);
43+
Assert.Equal(o1, o2);
44+
}
45+
else if (type1 == typeof(XmlAttribute))
46+
{
47+
var a1 = (XmlAttribute)o1;
48+
var a2 = (XmlAttribute)o2;
3849

39-
var type1 = o1.GetType();
40-
var type2 = o2.GetType();
41-
Assert.Equal(type1, type2);
50+
Assert.Equal(a1.Name, a1.Name);
51+
Assert.Equal(a1.Value, a2.Value);
52+
}
53+
else if (type1 == typeof(XmlElement))
54+
{
55+
var e1 = (XmlElement)o1;
56+
var e2 = (XmlElement)o2;
4257

43-
if (type1.IsPrimitive || type1.IsEnum || type1 == typeof(string) || type1 == typeof(System.DateTime))
44-
{
45-
Assert.Equal(o1, o2);
46-
}
47-
else if (type1 == typeof(XmlAttribute))
48-
{
49-
var a1 = (XmlAttribute)o1;
50-
var a2 = (XmlAttribute)o2;
58+
Assert.Equal(e1.Name, e1.Name);
59+
Assert.Equal(e1.InnerXml, e2.InnerXml);
60+
}
61+
else if (typeof(IList).IsAssignableFrom(type1))
62+
{
63+
var arr1 = (IList)o1;
64+
var arr2 = (IList)o2;
5165

52-
Assert.Equal(a1.Name, a1.Name);
53-
Assert.Equal(a1.Value, a2.Value);
54-
}
55-
else if (type1 == typeof(XmlElement))
56-
{
57-
var e1 = (XmlElement)o1;
58-
var e2 = (XmlElement)o2;
66+
Assert.Equal(arr1.Count, arr2.Count);
5967

60-
Assert.Equal(e1.Name, e1.Name);
61-
Assert.Equal(e1.InnerXml, e2.InnerXml);
68+
for (int i = 0; i < arr1.Count; i++)
69+
{
70+
Equal(arr1[i], arr2[i]);
6271
}
63-
else if (typeof(IList).IsAssignableFrom(type1))
72+
}
73+
else
74+
{
75+
foreach (var prop in type1.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(p => p.CanRead && !p.GetIndexParameters().Any()))
6476
{
65-
var arr1 = (IList)o1;
66-
var arr2 = (IList)o2;
77+
var val1 = prop.GetValue(o1);
78+
var val2 = prop.GetValue(o2);
6779

68-
Assert.Equal(arr1.Count, arr2.Count);
69-
70-
for (int i = 0; i < arr1.Count; i++)
80+
if (prop.PropertyType == typeof(DateTime)
81+
&& val1 is DateTime dt1 && val2 is DateTime dt2
82+
&& prop.GetCustomAttributes<XmlElementAttribute>().All(a => a.DataType == "time"))
7183
{
72-
Equal(arr1[i], arr2[i]);
84+
Equal(dt1.TimeOfDay, dt1.TimeOfDay);
7385
}
74-
}
75-
else
76-
{
77-
foreach (var prop in type1.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(p => p.CanRead && !p.GetIndexParameters().Any()))
86+
else
7887
{
79-
var val1 = prop.GetValue(o1);
80-
var val2 = prop.GetValue(o2);
81-
82-
if (prop.PropertyType == typeof(DateTime)
83-
&& val1 is DateTime dt1 && val2 is DateTime dt2
84-
&& prop.GetCustomAttributes<XmlElementAttribute>().All(a => a.DataType == "time"))
85-
{
86-
Equal(dt1.TimeOfDay, dt1.TimeOfDay);
87-
}
88-
else
89-
{
90-
Equal(val1, val2);
91-
}
88+
Equal(val1, val2);
9289
}
9390
}
9491
}
92+
}
9593

96-
public static void CollectionEqual<T>(IList<T> l1, IList<T> l2)
97-
{
98-
if (l1 == null && l2 == null) { return; }
99-
Assert.NotNull(l1);
100-
Assert.NotNull(l2);
94+
public static void CollectionEqual<T>(IList<T> l1, IList<T> l2)
95+
{
96+
if (l1 == null && l2 == null) { return; }
97+
Assert.NotNull(l1);
98+
Assert.NotNull(l2);
10199

102-
Assert.Equal(l1.Count, l2.Count);
103-
for (int i = 0; i < l1.Count; i++)
104-
{
105-
Assert.Equal(l1[i], l2[i]);
106-
}
100+
Assert.Equal(l1.Count, l2.Count);
101+
for (int i = 0; i < l1.Count; i++)
102+
{
103+
Assert.Equal(l1[i], l2[i]);
107104
}
108105
}
109106
}

0 commit comments

Comments
 (0)