Skip to content

Commit 79fd01b

Browse files
authored
Merge pull request #36 from jonsagara/feature/net10
Initial .NET 10 support
2 parents b90afe6 + bac77ea commit 79fd01b

15 files changed

Lines changed: 71 additions & 121 deletions

Directory.Build.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<Project>
22
<PropertyGroup>
33
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
4+
5+
<!-- C# Stuff -->
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
48
</PropertyGroup>
59
</Project>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "9.0.201",
3+
"version": "10.0.100-rc.2.25502.107",
44
"rollForward": "latestPatch"
55
}
66
}

src/IdParser.Core.Benchmarks/IdParser.Core.Benchmarks.csproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net9.0</TargetFramework>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
<Nullable>enable</Nullable>
5+
<TargetFramework>net10.0</TargetFramework>
86
</PropertyGroup>
97

108
<ItemGroup>
11-
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
12-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
9+
<PackageReference Include="BenchmarkDotNet" Version="0.15.4" />
10+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0-rc.2.25502.107" />
1311
</ItemGroup>
1412

1513
<ItemGroup>

src/IdParser.Core.Client/IdParser.Core.Client.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net9.0-windows</TargetFramework>
3+
<TargetFramework>net10.0-windows</TargetFramework>
44
<OutputType>WinExe</OutputType>
55
<AssemblyName>ID Parser</AssemblyName>
66
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
@@ -34,8 +34,8 @@
3434
</Reference>
3535
</ItemGroup>
3636
<ItemGroup>
37-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
38-
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
37+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0-rc.2.25502.107" />
38+
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
3939
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
4040
</ItemGroup>
4141
<ItemGroup>

src/IdParser.Core.Client/Main.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
using System;
2-
using System.Drawing;
3-
using System.IO;
4-
using System.Text;
5-
using System.Windows.Forms;
1+
using System.Text;
62
using Microsoft.PointOfService;
73
using Newtonsoft.Json;
84

95
namespace IdParser.Core.Client
106
{
117
public partial class Main : Form
128
{
13-
private Scanner _scanner;
9+
private Scanner? _scanner;
1410

1511
public Main()
1612
{
@@ -47,7 +43,7 @@ private void Connect()
4743
try
4844
{
4945
var explorer = new PosExplorer();
50-
_scanner = explorer.CreateInstance(explorer.GetDevice(DeviceType.Scanner, txtLogicalName.Text)) as Scanner;
46+
_scanner = (explorer.CreateInstance(explorer.GetDevice(DeviceType.Scanner, txtLogicalName.Text)) as Scanner)!;
5147

5248
AddDataEvent(_scanner);
5349

@@ -153,7 +149,7 @@ private void OnDataEvent(object source, DataEventArgs e)
153149

154150
SetStatus(Level.Info, "Reading data");
155151

156-
var data = Encoding.ASCII.GetString(_scanner.ScanDataLabel);
152+
var data = Encoding.ASCII.GetString(_scanner!.ScanDataLabel);
157153
var symbology = _scanner.ScanDataType;
158154

159155
txtScanData.Text = data;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// xUnit.net v3 reintroduces the ability to capture output that is written to Console, Debug, and Trace
2+
// through two assembly-level attributes. This allows us to get rid of the clunky ITestOutputHelper.
3+
// See: https://xunit.net/docs/capturing-output
4+
5+
// Capture both standard output and standard error.
6+
[assembly: CaptureConsole]
7+
8+
// Capture both Trace and Debug
9+
[assembly: CaptureTrace]

src/IdParser.Core.Test/BaseTest.cs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
using Xunit;
2-
using Xunit.Abstractions;
3-
4-
namespace IdParser.Core.Test;
1+
namespace IdParser.Core.Test;
52

63
public class BaseTest
74
{
8-
protected readonly XUnitTextWriter _output;
9-
10-
public BaseTest(ITestOutputHelper output)
11-
{
12-
_output = new XUnitTextWriter(output);
13-
Console.SetOut(_output);
14-
}
15-
16-
protected string Id(string jurisdiction)
5+
protected string Id(string jurisdiction)
176
=> File.ReadAllText(Path.Combine("Ids", $"{jurisdiction}.txt"));
187

19-
protected string License(string jurisdiction)
8+
protected string License(string jurisdiction)
209
=> File.ReadAllText(Path.Combine("Licenses", $"{jurisdiction}.txt"));
2110

2211
/// <summary>
@@ -108,6 +97,6 @@ protected void LogUnhandledElementIds(BarcodeParseResult parseResult)
10897
return;
10998
}
11099

111-
_output.WriteLine($"State '{parseResult.Card.IssuerIdentificationNumber.Value.GetAbbreviationOrDefault()}' has unhandled element Ids: {string.Join(", ", parseResult.UnhandledElements.Select(ue => ue.ElementId))}.");
100+
Console.WriteLine($"State '{parseResult.Card.IssuerIdentificationNumber.Value.GetAbbreviationOrDefault()}' has unhandled element Ids: {string.Join(", ", parseResult.UnhandledElements.Select(ue => ue.ElementId))}.");
112101
}
113102
}

src/IdParser.Core.Test/DriversLicenseTests.cs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
using IdParser.Core.Constants;
2-
using Xunit;
3-
using Xunit.Abstractions;
42

53
namespace IdParser.Core.Test;
64

75
public class DriversLicenseTests : BaseTest
86
{
9-
public DriversLicenseTests(ITestOutputHelper output)
10-
: base(output)
11-
{
12-
}
13-
14-
157
[Fact]
168
public void TestMA2009License()
179
{
@@ -2193,7 +2185,7 @@ public void TestKSLicense()
21932185
Sex = FV<Sex?>(SubfileElementIds.Sex, Sex.Male),
21942186
EyeColor = FV<EyeColor?>(SubfileElementIds.EyeColor, EyeColor.Green),
21952187
Height = FV<Height?>(SubfileElementIds.Height, new Height(totalInches: 71)),
2196-
2188+
21972189
IdNumber = FV(SubfileElementIds.IdNumber, "K04-76-5990"),
21982190
AAMVAVersionNumber = FV(null, AAMVAVersion.AAMVA2016),
21992191

@@ -2332,7 +2324,7 @@ public void TestHILicense()
23322324
EyeColor = FV<EyeColor?>(SubfileElementIds.EyeColor, EyeColor.Blue),
23332325
HairColor = FV<HairColor?>(SubfileElementIds.EyeColor, HairColor.Blond),
23342326
Height = FV<Height?>(SubfileElementIds.Height, new Height(totalInches: 72)),
2335-
2327+
23362328
IdNumber = FV(SubfileElementIds.IdNumber, "H01387330"),
23372329
AAMVAVersionNumber = FV(null, AAMVAVersion.AAMVA2009),
23382330

@@ -2511,7 +2503,7 @@ public void TestPELicense()
25112503
Sex = FV<Sex?>(SubfileElementIds.Sex, Sex.Female),
25122504
EyeColor = FV<EyeColor?>(SubfileElementIds.EyeColor, EyeColor.Blue),
25132505
Height = FV<Height?>(SubfileElementIds.Height, new Height(centimeters: 157)),
2514-
2506+
25152507
IdNumber = FV(SubfileElementIds.IdNumber, "247725"),
25162508
AAMVAVersionNumber = FV(null, AAMVAVersion.AAMVA2016),
25172509

@@ -2615,7 +2607,7 @@ public void TestNDLicense()
26152607
Sex = FV<Sex?>(SubfileElementIds.Sex, Sex.Male),
26162608
EyeColor = FV<EyeColor?>(SubfileElementIds.EyeColor, EyeColor.Blue),
26172609
Height = FV<Height?>(SubfileElementIds.Height, new Height(totalInches: 74)),
2618-
2610+
26192611
IdNumber = FV(SubfileElementIds.IdNumber, "RUN812345"),
26202612
AAMVAVersionNumber = FV(null, AAMVAVersion.AAMVA2013),
26212613

@@ -2671,7 +2663,7 @@ public void TestCTLicenseUndefinedCharacters()
26712663
Sex = FV<Sex?>(SubfileElementIds.Sex, Sex.Female),
26722664
EyeColor = FV<EyeColor?>(SubfileElementIds.EyeColor, EyeColor.Brown),
26732665
Height = FV<Height?>(SubfileElementIds.Height, new Height(totalInches: 67)),
2674-
2666+
26752667
IdNumber = FV(SubfileElementIds.IdNumber, "123456780"),
26762668
AAMVAVersionNumber = FV(null, AAMVAVersion.AAMVA2016),
26772669

@@ -2832,7 +2824,7 @@ public void TestMSLicense()
28322824
Sex = FV<Sex?>(SubfileElementIds.Sex, Sex.Male),
28332825
EyeColor = FV<EyeColor?>(SubfileElementIds.EyeColor, EyeColor.Blue),
28342826
Height = FV<Height?>(SubfileElementIds.Height, new Height(totalInches: 70)),
2835-
2827+
28362828
IdNumber = FV(SubfileElementIds.IdNumber, "800448123"),
28372829
AAMVAVersionNumber = FV(null, AAMVAVersion.AAMVA2013),
28382830

@@ -2946,7 +2938,7 @@ public void TestLeadingWhitespaceLicense()
29462938
DateOfBirth = FV<DateTime?>(SubfileElementIds.DateOfBirth, new DateTime(1939, 12, 7)),
29472939
Sex = FV<Sex?>(SubfileElementIds.Sex, Sex.Male),
29482940
Height = FV<Height?>(SubfileElementIds.Height, new Height(totalInches: 71)),
2949-
2941+
29502942
IdNumber = FV(SubfileElementIds.IdNumber, "S58239477"),
29512943
AAMVAVersionNumber = FV(null, AAMVAVersion.AAMVA2009),
29522944

@@ -3031,7 +3023,7 @@ public void TestCTLicenseSuffix()
30313023
Sex = FV<Sex?>(SubfileElementIds.Sex, Sex.Male),
30323024
EyeColor = FV<EyeColor?>(SubfileElementIds.EyeColor, EyeColor.Green),
30333025
Height = FV<Height?>(SubfileElementIds.Height, new Height(feet: 6, inches: 0)),
3034-
3026+
30353027
IdNumber = FV(SubfileElementIds.IdNumber, "227881513"),
30363028
AAMVAVersionNumber = FV(null, AAMVAVersion.AAMVA2000),
30373029

@@ -3115,7 +3107,7 @@ public void TestNBLicense()
31153107
DateOfBirth = FV<DateTime?>(SubfileElementIds.DateOfBirth, new DateTime(1962, 8, 8)),
31163108
Sex = FV<Sex?>(SubfileElementIds.Sex, Sex.Female),
31173109
Height = FV<Height?>(SubfileElementIds.Height, new Height(centimeters: 168)),
3118-
3110+
31193111
IdNumber = FV(SubfileElementIds.IdNumber, "1234567"),
31203112
AAMVAVersionNumber = FV(null, AAMVAVersion.AAMVA2003),
31213113

@@ -3156,7 +3148,7 @@ public void TestWYLicense()
31563148
EyeColor = FV<EyeColor?>(SubfileElementIds.EyeColor, EyeColor.Blue),
31573149
HairColor = FV<HairColor?>(SubfileElementIds.EyeColor, HairColor.Blond),
31583150
Height = FV<Height?>(SubfileElementIds.Height, new Height(totalInches: 69)),
3159-
3151+
31603152
IdNumber = FV(SubfileElementIds.IdNumber, "123456-789"),
31613153
AAMVAVersionNumber = FV(null, AAMVAVersion.AAMVA2009),
31623154

src/IdParser.Core.Test/IdParser.Core.Test.csproj

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
56
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
67
<AssemblyTitle>IdParser.Core.Test</AssemblyTitle>
78
<Product>IdParser.Core.Test</Product>
89
<Copyright>Copyright © 2019-2024 Connor O%27Shea, Jon Sagara</Copyright>
9-
<ImplicitUsings>enable</ImplicitUsings>
10-
<Nullable>enable</Nullable>
10+
11+
<!--
12+
This template uses native xUnit.net command line options when using 'dotnet run' and
13+
VSTest by default when using 'dotnet test'. For more information on how to enable support
14+
for Microsoft Testing Platform, please visit:
15+
https://xunit.net/docs/getting-started/v3/microsoft-testing-platform
16+
-->
17+
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
1118
</PropertyGroup>
1219
<ItemGroup>
1320
<Content Include="Ids\*.txt">
@@ -24,14 +31,13 @@
2431
</Content>
2532
</ItemGroup>
2633
<ItemGroup>
27-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
28-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
29-
<PackageReference Include="xunit" Version="2.9.3" />
30-
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
31-
<PrivateAssets>all</PrivateAssets>
32-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
33-
</PackageReference>
34+
<PackageReference Include="xunit.v3" Version="3.1.0" />
35+
</ItemGroup>
36+
37+
<ItemGroup>
38+
<Using Include="Xunit" />
3439
</ItemGroup>
40+
3541
<ItemGroup>
3642
<ProjectReference Include="..\IdParser.Core\IdParser.Core.csproj" />
3743
</ItemGroup>

src/IdParser.Core.Test/IdentificationCardTests.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
using IdParser.Core.Constants;
2-
using Xunit;
3-
using Xunit.Abstractions;
42

53
namespace IdParser.Core.Test;
64

75
public class IdentificationCardTests : BaseTest
86
{
9-
public IdentificationCardTests(ITestOutputHelper output)
10-
: base(output)
11-
{
12-
}
13-
147
[Fact]
158
public void TestTNIdCard()
169
{

0 commit comments

Comments
 (0)