Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f45b6b463 | |||
| 9485ad3ec4 | |||
| 595b63dc23 |
@@ -9,14 +9,18 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
name: .NET tests
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: https://github.com/actions/setup-dotnet@v3
|
uses: https://github.com/actions/setup-dotnet@v4
|
||||||
with:
|
with:
|
||||||
dotnet-version: 8.x
|
dotnet-version: 10.x
|
||||||
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore Railway/Railway.csproj
|
run: dotnet restore Railway/Railway.csproj
|
||||||
|
|||||||
@@ -14,28 +14,47 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
name: .NET tests
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: https://github.com/actions/setup-dotnet@v3
|
uses: https://github.com/actions/setup-dotnet@v4
|
||||||
with:
|
with:
|
||||||
dotnet-version: 8.x
|
dotnet-version: |
|
||||||
|
8.0.x
|
||||||
|
9.0.x
|
||||||
|
10.0.x
|
||||||
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore
|
run: dotnet restore
|
||||||
|
|
||||||
- name: Build
|
- name: Build .NET 10.0
|
||||||
run: dotnet build --no-restore
|
run: dotnet build --no-restore --framework net10.0 --configuration Release ./Raliway.Tests/Raliway.Tests.csproj
|
||||||
|
|
||||||
- name: Test
|
- name: Build .NET 9.0
|
||||||
run: dotnet test --no-build --verbosity normal --logger trx --results-directory "TestResults-8.x"
|
run: dotnet build --no-restore --framework net9.0 --configuration Release ./Raliway.Tests/Raliway.Tests.csproj
|
||||||
|
|
||||||
|
- name: Build .NET 8.0
|
||||||
|
run: dotnet build --no-restore --framework net8.0 --configuration Release ./Raliway.Tests/Raliway.Tests.csproj
|
||||||
|
|
||||||
|
- name: Test .NET 10.0
|
||||||
|
run: dotnet run --no-build --framework net10.0 --configuration Release --project ./Raliway.Tests/Raliway.Tests.csproj -- -trx TestResults/results-net10.trx
|
||||||
|
|
||||||
|
- name: Test .NET 9.0
|
||||||
|
run: dotnet run --no-build --framework net9.0 --configuration Release --project ./Raliway.Tests/Raliway.Tests.csproj -- -trx TestResults/results-net9.trx
|
||||||
|
|
||||||
|
- name: Test .NET 8.0
|
||||||
|
run: dotnet run --no-build --framework net8.0 --configuration Release --project ./Raliway.Tests/Raliway.Tests.csproj -- -trx TestResults/results-net8.trx
|
||||||
|
|
||||||
- name: Upload dotnet test results
|
- name: Upload dotnet test results
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: dotnet-results-8.x
|
name: test-results
|
||||||
path: TestResults-8.x
|
path: TestResults
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2023-2024 JustFixMe
|
Copyright (c) 2023-2025 JustFixMe
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -221,15 +221,22 @@ public sealed class ExceptionalError : Error
|
|||||||
private static ImmutableDictionary<string, string> ExtractExtensionData(Exception exception)
|
private static ImmutableDictionary<string, string> ExtractExtensionData(Exception exception)
|
||||||
{
|
{
|
||||||
if (!(exception.Data?.Count > 0))
|
if (!(exception.Data?.Count > 0))
|
||||||
return ImmutableDictionary<string, string>.Empty;
|
return ImmutableDictionary<string, string>.Empty;
|
||||||
|
|
||||||
|
var values = GetGenericExtData(exception);
|
||||||
|
|
||||||
|
return values is not null ? values.ToImmutable() : ImmutableDictionary<string, string>.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ImmutableDictionary<string, string>.Builder? GetGenericExtData(Exception ex)
|
||||||
|
{
|
||||||
ImmutableDictionary<string, string>.Builder? values = null;
|
ImmutableDictionary<string, string>.Builder? values = null;
|
||||||
|
|
||||||
foreach (var key in exception.Data.Keys)
|
foreach (var key in ex.Data.Keys)
|
||||||
{
|
{
|
||||||
if (key is null) continue;
|
if (key is null) continue;
|
||||||
|
|
||||||
var value = exception.Data[key];
|
var value = ex.Data[key];
|
||||||
if (value is null) continue;
|
if (value is null) continue;
|
||||||
|
|
||||||
var keyString = key.ToString();
|
var keyString = key.ToString();
|
||||||
@@ -239,7 +246,8 @@ public sealed class ExceptionalError : Error
|
|||||||
values ??= ImmutableDictionary.CreateBuilder<string, string>();
|
values ??= ImmutableDictionary.CreateBuilder<string, string>();
|
||||||
values.Add(keyString, valueString);
|
values.Add(keyString, valueString);
|
||||||
}
|
}
|
||||||
return values is not null ? values.ToImmutable() : ImmutableDictionary<string, string>.Empty;
|
|
||||||
|
return values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
|
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
|
||||||
<LangVersion>10.0</LangVersion>
|
<LangVersion>12.0</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AssemblyName>Just.Railway</AssemblyName>
|
<AssemblyName>Just.Railway</AssemblyName>
|
||||||
<RootNamespace>Just.Railway</RootNamespace>
|
<RootNamespace>Just.Railway</RootNamespace>
|
||||||
|
|
||||||
<Description>Base for railway-oriented programming in .NET. Package includes Result object, Error class and most of the common extensions.</Description>
|
<Description>Base for railway-oriented programming in .NET. Package includes Result object, Error class and most of the common extensions.</Description>
|
||||||
<PackageTags>railway-oriented;functional;result-pattern;result-object;error-handling</PackageTags>
|
<PackageTags>railway-oriented;functional;result-pattern;result-object;error-handling</PackageTags>
|
||||||
<Authors>JustFixMe</Authors>
|
<Authors>JustFixMe</Authors>
|
||||||
<Copyright>Copyright (c) 2023-2024 JustFixMe</Copyright>
|
<Copyright>Copyright (c) 2023-2025 JustFixMe</Copyright>
|
||||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<RepositoryUrl>https://github.com/JustFixMe/Just.Railway/</RepositoryUrl>
|
<RepositoryUrl>https://github.com/JustFixMe/Just.Railway/</RepositoryUrl>
|
||||||
|
|
||||||
<EmitCompilerGeneratedFiles Condition="'$(Configuration)'=='Debug'">true</EmitCompilerGeneratedFiles>
|
<EmitCompilerGeneratedFiles Condition="'$(Configuration)'=='Debug'">true</EmitCompilerGeneratedFiles>
|
||||||
<ReleaseVersion Condition=" '$(ReleaseVersion)' == '' ">1.0.0</ReleaseVersion>
|
<ReleaseVersion Condition=" '$(ReleaseVersion)' == '' ">1.0.0</ReleaseVersion>
|
||||||
<VersionSuffix Condition=" '$(VersionSuffix)' != '' ">$(VersionSuffix)</VersionSuffix>
|
<VersionSuffix Condition=" '$(VersionSuffix)' != '' ">$(VersionSuffix)</VersionSuffix>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Just.Railway;
|
|||||||
public static partial class ResultExtensions
|
public static partial class ResultExtensions
|
||||||
{
|
{
|
||||||
#region Match (with fallback)
|
#region Match (with fallback)
|
||||||
|
|
||||||
public static T Match<T>(this in Result<T> result, Func<Error, T> fallback)
|
public static T Match<T>(this in Result<T> result, Func<Error, T> fallback)
|
||||||
{
|
{
|
||||||
return result.State switch
|
return result.State switch
|
||||||
@@ -15,7 +15,7 @@ public static partial class ResultExtensions
|
|||||||
_ => throw new ResultNotInitializedException(nameof(result))
|
_ => throw new ResultNotInitializedException(nameof(result))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<T> Match<T>(this Result<T> result, Func<Error, Task<T>> fallback)
|
public static async Task<T> Match<T>(this Result<T> result, Func<Error, Task<T>> fallback)
|
||||||
{
|
{
|
||||||
return result.State switch
|
return result.State switch
|
||||||
@@ -77,7 +77,7 @@ public static partial class ResultExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Merge
|
#region Merge
|
||||||
|
|
||||||
public static Result Merge(this IEnumerable<Result> results)
|
public static Result Merge(this IEnumerable<Result> results)
|
||||||
|
|||||||
@@ -1,23 +1,20 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
|
||||||
<AssemblyName>Just.Railway.Tests</AssemblyName>
|
<AssemblyName>Just.Railway.Tests</AssemblyName>
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
<IsTestProject>true</IsTestProject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
<PackageReference Include="xunit.v3" Version="3.2.0" />
|
||||||
<PackageReference Include="xunit" Version="2.6.1" />
|
<PackageReference Include="coverlet.collector" Version="6.0.4">
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="coverlet.collector" Version="6.0.0">
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
Reference in New Issue
Block a user