Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

ko_fi: tensiondev
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "nuget" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
92 changes: 92 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: .NET

on:
push:
branches: [ "**" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: windows-latest

strategy:
matrix:
dotnet: [ '8.0.x' ]
name: .NET ${{ matrix.dotnet }}

steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Cache SonarQube Cloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarQube Cloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarQube Cloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Restore dependencies
run: dotnet restore
- name: SonarCloudPrepare
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: .\.sonar\scanner\dotnet-sonarscanner begin /k:"TensionDev_ULID.Serialization.SystemTextJson" /o:"tensiondev" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.scanner.scanAll=false /d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal --collect "XPlat Code Coverage;Format=opencover"
- name: SonarCloudAnalyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"

test:

strategy:
matrix:
dotnet: [ '8.0.x' ]
os: [macos-latest, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.os }}

name: .NET ${{ matrix.dotnet }} on ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal --collect "XPlat Code Coverage;Format=opencover"
47 changes: 47 additions & 0 deletions .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This is a basic workflow to help you get started with Actions

name: Package Release

# Controls when the workflow will run
on:
# Triggers the workflow on push events but only for the tags
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-alpha
- v[0-9]+.[0-9]+.[0-9]+-beta

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

- name: Setup .NET 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Build Release
run: dotnet build --configuration Release --no-restore

- name: Pack
run: dotnet pack --configuration Release

- name: Push NuGet
run: dotnet nuget push "TensionDev.ULID.Serialization.SystemTextJson/bin/Release/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_TOKEN }} --no-symbols --skip-duplicate
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# TensionDev.ULID.Serialization.SystemTextJson

# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
File renamed without changes.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# TensionDev.ULID.Serialization.SystemTextJson
# TensionDev.ULID.Serialization.SystemTextJson

[![.NET](https://github.com/TensionDev/ULID.Serialization.SystemTextJson/actions/workflows/dotnet.yml/badge.svg)](https://github.com/TensionDev/ULID.Serialization.SystemTextJson/actions/workflows/dotnet.yml)
[![Package Release](https://github.com/TensionDev/ULID.Serialization.SystemTextJson/actions/workflows/package-release.yml/badge.svg)](https://github.com/TensionDev/ULID.Serialization.SystemTextJson/actions/workflows/package-release.yml)
[![CodeQL](https://github.com/TensionDev/ULID.Serialization.SystemTextJson/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/TensionDev/ULID.Serialization.SystemTextJson/actions/workflows/github-code-scanning/codeql)

TensionDev.ULID.Serialization.SystemTextJson is a .NET library for serializing and deserializing with Universally Unique Lexicographically Sortable Identifiers (ULIDs) using System.Text.Json.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<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; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\TensionDev.ULID.Serialization.SystemTextJson\TensionDev.ULID.Serialization.SystemTextJson.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
using Moq;
using System;
using System.Buffers;
using System.Text;
using System.Text.Json;
using Xunit;

namespace TensionDev.ULID.Serialization.SystemTextJson.Tests
{
public class UlidSystemTextJsonConverterTests : IDisposable
{
private bool disposedValue;

private readonly UlidSystemTextJsonConverter _converter;

public UlidSystemTextJsonConverterTests()
{
_converter = new UlidSystemTextJsonConverter();
}

[Theory]
[InlineData(true, "00000000000000000000000000")]
[InlineData(true, "7ZZZZZZZZZZZZZZZZZZZZZZZZZ")]
[InlineData(true, "01ARZ3NDEKTSV4RRFFQ69G5FAV")]
[InlineData(false, "00000000000000000000000000")]
[InlineData(false, "7ZZZZZZZZZZZZZZZZZZZZZZZZZ")]
[InlineData(false, "01ARZ3NDEKTSV4RRFFQ69G5FAV")]
public void TestWrite(bool useNullOptions, string input)
{
// Arrange
using var ms = new MemoryStream();
using var writer = new Utf8JsonWriter(ms);
Ulid value = Ulid.Parse(input);
JsonSerializerOptions? options = useNullOptions ? null : new JsonSerializerOptions();

// Act
_converter.Write(writer, value, options);
writer.Flush();
string actual = Encoding.UTF8.GetString(ms.ToArray());

// Assert
string expected = JsonSerializer.Serialize(value.ToString());
Assert.Equal(expected, actual);
}

[Fact]
public void TestReadNotString()
{
// Arrange
// Use a canonical all-zero ULID representation which is commonly accepted by ULID parsers.
const string input = "00000000000000000000000000";

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

The variable 'input' is assigned but its value is never used

Check warning on line 51 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

The variable 'input' is assigned but its value is never used
string jsonText = "0";
byte[] json = Encoding.UTF8.GetBytes(jsonText);
var reader = new Utf8JsonReader(json);
reader.Read();

// Act
JsonException ex = null;

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Converting null literal or possible null value to non-nullable type.

Check warning on line 58 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Converting null literal or possible null value to non-nullable type.
try
{
_converter.Read(ref reader, typeof(Ulid), new JsonSerializerOptions());
}
catch (JsonException caught)
{
ex = caught;
}

// Assert
Assert.NotNull(ex);
}

[Fact]
public void TestReadEmptyString()
{
// Arrange
// Use a canonical all-zero ULID representation which is commonly accepted by ULID parsers.
const string input = "00000000000000000000000000";

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

The variable 'input' is assigned but its value is never used

Check warning on line 77 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

The variable 'input' is assigned but its value is never used
string jsonText = "\"\"";
byte[] json = Encoding.UTF8.GetBytes(jsonText);
var reader = new Utf8JsonReader(json);
reader.Read();

// Act
JsonException ex = null;

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on macos-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on ubuntu-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x on windows-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Converting null literal or possible null value to non-nullable type.

Check warning on line 84 in TensionDev.ULID.Serialization.SystemTextJson.Tests/UlidSystemTextJsonConverterTests.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Converting null literal or possible null value to non-nullable type.
try
{
_converter.Read(ref reader, typeof(Ulid), new JsonSerializerOptions());
}
catch (JsonException caught)
{
ex = caught;
}

// Assert
Assert.NotNull(ex);
}

[Theory]
[InlineData("00000000000000000000000000")]
[InlineData("7ZZZZZZZZZZZZZZZZZZZZZZZZZ")]
[InlineData("01ARZ3NDEKTSV4RRFFQ69G5FAV")]
public void TestReadString(string input)
{
// Arrange
string jsonText = "\"" + input + "\"";
byte[] json = Encoding.UTF8.GetBytes(jsonText);
var reader = new Utf8JsonReader(json);
reader.Read();

// Act
Ulid result = _converter.Read(ref reader, typeof(Ulid), new JsonSerializerOptions());

// Assert
// Compare textual forms to avoid depending on reference equality or unknown equality semantics of Ulid.
Assert.Equal(input, result.ToString());
}

protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
// TODO: dispose managed state (managed objects)
}

// TODO: free unmanaged resources (unmanaged objects) and override finalizer
// TODO: set large fields to null
disposedValue = true;
}
}

// // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
// ~UlidSystemTextJsonConverterTests()
// {
// // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
// Dispose(disposing: false);
// }

public void Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}
8 changes: 7 additions & 1 deletion TensionDev.ULID.Serialization.SystemTextJson.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 18
VisualStudioVersion = 18.3.11520.95 d18.3
VisualStudioVersion = 18.3.11520.95
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TensionDev.ULID.Serialization.SystemTextJson", "TensionDev.ULID.Serialization.SystemTextJson\TensionDev.ULID.Serialization.SystemTextJson.csproj", "{15DBB42E-31D1-4C9A-A699-9692796EE842}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TensionDev.ULID.Serialization.SystemTextJson.Tests", "TensionDev.ULID.Serialization.SystemTextJson.Tests\TensionDev.ULID.Serialization.SystemTextJson.Tests.csproj", "{B20108AB-DFB4-4A2D-8B15-F21843F6BEEB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{15DBB42E-31D1-4C9A-A699-9692796EE842}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15DBB42E-31D1-4C9A-A699-9692796EE842}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15DBB42E-31D1-4C9A-A699-9692796EE842}.Release|Any CPU.Build.0 = Release|Any CPU
{B20108AB-DFB4-4A2D-8B15-F21843F6BEEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B20108AB-DFB4-4A2D-8B15-F21843F6BEEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B20108AB-DFB4-4A2D-8B15-F21843F6BEEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B20108AB-DFB4-4A2D-8B15-F21843F6BEEB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
9 changes: 0 additions & 9 deletions TensionDev.ULID.Serialization.SystemTextJson/Class1.cs

This file was deleted.

Loading