Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ jobs:
sourceRepositoryCommit: $env:GITHUB_SHA

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1.7.2
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.101
architecture: x64

- name: Dotnet restore
run: dotnet restore --verbosity ${{ env.dotnetVerbosity }}
Expand Down Expand Up @@ -64,7 +67,7 @@ jobs:
shell: pwsh

- name: Upload packages
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifactName }}
path: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -41,7 +41,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v4

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v4
4 changes: 2 additions & 2 deletions ActiveLogin.Identity.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
# Visual Studio Version 18
VisualStudioVersion = 18.4.11519.219 insiders
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9A0CF459-87CC-448D-B49D-EFC3D6482AA6}"
EndProject
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.102",
"version": "10.0.101",
"rollForward": "latestFeature"
}
}
2 changes: 1 addition & 1 deletion samples/ConsoleSample.CSharp/ConsoleSample.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
4 changes: 2 additions & 2 deletions samples/ConsoleSample.CSharp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using ActiveLogin.Identity.Swedish;
Expand Down Expand Up @@ -168,7 +168,7 @@ private static void Sample_ParseUserInput()
{
WriteHeader("What is your (Swedish) Personal Identity Number or Coordination Number?");
var userRawPersonalIdentityNumber = Console.ReadLine();
WriteIndividualIdentityNumberInfo(userRawPersonalIdentityNumber);
WriteIndividualIdentityNumberInfo(userRawPersonalIdentityNumber ?? "");
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion samples/ConsoleSample.FSharp/ConsoleSample.FSharp.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.201" PrivateAssets="All" />
</ItemGroup>

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

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.201" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.201" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 3 additions & 9 deletions src/ActiveLogin.Identity.Swedish/CoordinationNumber.fs
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,13 @@ module internal CoordinationNumber =
parseInSpecificYearInternal strictMode parseYear str

let tryParseInSpecificYear strictMode parseYear str =
try
parseInSpecificYearInternal strictMode parseYear str
|> Some
with
exn -> None
let pYear = Year.create parseYear
Parse.tryParseInSpecificYear create strictMode pYear str

let parse strictMode str = Parse.parse create strictMode str

let tryParse strictMode str =
try
parse strictMode str |> Some
with
exn -> None
Parse.tryParse create strictMode str

open CoordinationNumber

Expand Down
11 changes: 3 additions & 8 deletions src/ActiveLogin.Identity.Swedish/IndividualIdentityNumber.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,13 @@ module internal IndividualIdentityNumber =
parseInSpecificYearInternal parseYear str

let tryParseInSpecificYear parseYear str =
try
parseInSpecificYearInternal parseYear str |> Some
with
exn -> None
let pYear = parseYear |> Year.create
Parse.tryParseInSpecificYear create StrictModeInternal.Off pYear str

let parse str = Parse.parse create StrictModeInternal.Off str

let tryParse str =
try
parse str |> Some
with
exn -> None
Parse.tryParse create StrictModeInternal.Off str

let to10DigitStringInSpecificYear serializationYear (num: IndividualIdentityNumberInternal) =
match num with
Expand Down
57 changes: 37 additions & 20 deletions src/ActiveLogin.Identity.Swedish/Parse.fs
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,40 @@ module private Helpers =
let checksum = str.[10..10] |> int
(fullYear, month, day, birthNumber, checksum)

let tee f x = f x; x
let parseInSpecificYear createFunc strictMode parseYear str =
try
str
|> Helpers.requireNotEmpty
|> Helpers.requireDigitCount strictMode
|> Helpers.clean strictMode
|> Helpers.addImplicitHyphen
|> Helpers.parseNumberValues parseYear
|> createFunc
with
| :? ArgumentOutOfRangeException as ex ->
FormatException(sprintf "String was not recognized as a valid IdentityNumber. %s" ex.Message, ex) |> raise
| :? ArgumentNullException -> reraise()
| :? ArgumentException as ex ->
FormatException(sprintf "String was not recognized as a valid IdentityNumber. %s" ex.Message, ex) |> raise

let parse createFunc strictMode str =
let year = DateTime.UtcNow.Year |> Year.create
parseInSpecificYear createFunc strictMode year str
let tee f x = f x; x

let private runPipeline createFunc strictMode parseYear str =
str
|> Helpers.requireNotEmpty
|> Helpers.requireDigitCount strictMode
|> Helpers.clean strictMode
|> Helpers.addImplicitHyphen
|> Helpers.parseNumberValues parseYear
|> createFunc

let tryParseInSpecificYear createFunc strictMode parseYear str =
try
runPipeline createFunc strictMode parseYear str |> Some
with
| :? ArgumentNullException -> None
| :? ArgumentOutOfRangeException -> None
| :? ArgumentException -> None
| :? FormatException -> None

let parseInSpecificYear createFunc strictMode parseYear str =
try
runPipeline createFunc strictMode parseYear str
with
| :? ArgumentOutOfRangeException as ex ->
FormatException(sprintf "String was not recognized as a valid IdentityNumber. %s" ex.Message, ex) |> raise
| :? ArgumentNullException -> reraise()
| :? ArgumentException as ex ->
FormatException(sprintf "String was not recognized as a valid IdentityNumber. %s" ex.Message, ex) |> raise

let tryParse createFunc strictMode str =
let year = DateTime.UtcNow.Year |> Year.create
tryParseInSpecificYear createFunc strictMode year str

let parse createFunc strictMode str =
let year = DateTime.UtcNow.Year |> Year.create
parseInSpecificYear createFunc strictMode year str
13 changes: 3 additions & 10 deletions src/ActiveLogin.Identity.Swedish/PersonalIdentityNumber.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,13 @@ module internal PersonalIdentityNumber =
parseInSpecificYearInternal strictMode parseYear str

let tryParseInSpecificYear strictMode parseYear str =
try
parseInSpecificYearInternal strictMode parseYear str
|> Some
with
exn -> None
let pYear = parseYear |> Year.create
Parse.tryParseInSpecificYear create strictMode pYear str

let parse strictMode str = Parse.parse create strictMode str

let tryParse strictMode str =
try
parse strictMode str
|> Some
with
exn -> None
Parse.tryParse create strictMode str


open PersonalIdentityNumber
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="AltCover" Version="6.5.739" />
<PackageReference Include="AltCover" Version="9.0.102" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Benchmarkdotnet" Version="0.13.4" />
<PackageReference Include="Benchmarkdotnet" Version="0.15.8" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<GenerateProgramFile>false</GenerateProgramFile>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -29,12 +29,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Expecto" Version="8.13.1" />
<PackageReference Include="Expecto.FsCheck" Version="8.13.1" />
<PackageReference Include="FsCheck" Version="2.14.0" />
<PackageReference Include="Unquote" Version="5.0.0" />
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Expecto" Version="10.2.3" />
<PackageReference Include="Expecto.FsCheck" Version="10.2.3" />
<PackageReference Include="FsCheck" Version="2.16.6" />
<PackageReference Include="Unquote" Version="7.0.1" />
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.15.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading