Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zsrdjan committed May 17, 2024
1 parent f55b8f9 commit 1fc9429
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 182 deletions.
50 changes: 25 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ name: CI
on:
push:
branches:
- main
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup dotnet 8.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.204'
- name: Build and Test
run: ./Build.ps1
shell: pwsh
- name: Push to MyGet
if: false
env:
NUGET_URL: https://www.myget.org/F/TODO/api/v3/index.json
NUGET_API_KEY: ${{ secrets.MYGET_FRAKTALIO_CI_API_KEY }}
run: ./Push.ps1
shell: pwsh
- name: Artifacts
if: false
uses: actions/upload-artifact@v2
with:
name: artifacts
path: artifacts/**/*
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup dotnet 8.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.204'
- name: Build and Test
run: ./Build.ps1
shell: pwsh
- name: Push to MyGet
if: false
env:
NUGET_URL: https://www.myget.org/F/TODO/api/v3/index.json
NUGET_API_KEY: ${{ secrets.MYGET_FRAKTALIO_CI_API_KEY }}
run: ./Push.ps1
shell: pwsh
- name: Artifacts
if: false
uses: actions/upload-artifact@v2
with:
name: artifacts
path: artifacts/**/*
20 changes: 9 additions & 11 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="FakeItEasy" Version="8.1.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="NUnit" Version="3.14.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="OneOf" Version="3.0.263" />
<PackageVersion Include="OneOf.SourceGenerator" Version="3.0.263" />
<PackageVersion Include="Verify.NUnit" Version="22.5.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.0"/>
<PackageVersion Include="FakeItEasy" Version="8.1.0"/>
<PackageVersion Include="FluentAssertions" Version="6.12.0"/>
<PackageVersion Include="JetBrains.Annotations" Version="2023.3.0"/>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageVersion Include="NUnit" Version="3.14.0"/>
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0"/>
<PackageVersion Include="Verify.NUnit" Version="22.5.0"/>
<PackageVersion Include="NUnit.Analyzers" Version="4.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
</ItemGroup>
</Project>
</Project>
16 changes: 8 additions & 8 deletions src/Fraktalio.FModel.Contracts/Fraktalio.FModel.Contracts.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations"/>
</ItemGroup>

</Project>
2 changes: 0 additions & 2 deletions src/Fraktalio.FModel.Contracts/ISaga.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Fraktalio.FModel.Contracts;

using System.Collections.Generic;

/// <summary>
/// An interface of the Saga
/// </summary>
Expand Down
16 changes: 8 additions & 8 deletions src/Fraktalio.FModel/Fraktalio.FModel.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Fraktalio.FModel.Contracts\Fraktalio.FModel.Contracts.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Fraktalio.FModel.Contracts\Fraktalio.FModel.Contracts.csproj"/>
</ItemGroup>

</Project>
24 changes: 11 additions & 13 deletions src/Fraktalio.FModel/InternalDecider.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
namespace Fraktalio.FModel;



/// <summary>
/// [InternalDecider] is a datatype that represents the main decision-making algorithm.
/// It has five generic parameters [C], [Si], [So], [Ei], [Eo] , representing the type of the values that [InternalDecider] may contain or use.
Expand Down Expand Up @@ -60,7 +58,7 @@ internal InternalDecider(Func<C, Si, IEnumerable<Eo>> decide,
/// <param name="f"></param>
/// <typeparam name="Cn">Cn Command new</typeparam>
/// <returns></returns>
public InternalDecider<Cn, Si, So, Ei, Eo> MapLeftOnCommand<Cn>(Func<Cn, C> f)
internal InternalDecider<Cn, Si, So, Ei, Eo> MapLeftOnCommand<Cn>(Func<Cn, C> f)
{
return new InternalDecider<Cn, Si, So, Ei, Eo>(
(cn, si) => Decide(f(cn), si),
Expand Down Expand Up @@ -142,7 +140,7 @@ public InternalDecider<C, Sin, So, Ei, Eo> MapLeftOnState<Sin>(Func<Sin, Si> f)
/// <param name="f"></param>
/// <typeparam name="Son"></typeparam>
/// <returns></returns>
public InternalDecider<C, Si, Son, Ei, Eo> MapOnState<Son>(Func<So, Son> f)
private InternalDecider<C, Si, Son, Ei, Eo> MapOnState<Son>(Func<So, Son> f)
{
return DimapOnState<Si, Son>(si => si, f);
}
Expand All @@ -153,7 +151,7 @@ public InternalDecider<C, Si, Son, Ei, Eo> MapOnState<Son>(Func<So, Son> f)
/// <param name="ff"></param>
/// <typeparam name="Son"></typeparam>
/// <returns></returns>
public InternalDecider<C, Si, Son, Ei, Eo> ApplyOnState<Son>(InternalDecider<C, Si, Func<So, Son>, Ei, Eo> ff)
private InternalDecider<C, Si, Son, Ei, Eo> ApplyOnState<Son>(InternalDecider<C, Si, Func<So, Son>, Ei, Eo> ff)
{
return new InternalDecider<C, Si, Son, Ei, Eo>(
(c, si) => ff.Decide(c, si).Concat(Decide(c, si)),
Expand All @@ -168,7 +166,7 @@ public InternalDecider<C, Si, Son, Ei, Eo> ApplyOnState<Son>(InternalDecider<C,
/// <param name="fb"></param>
/// <typeparam name="Son"></typeparam>
/// <returns></returns>
public InternalDecider<C, Si, Tuple<So, Son>, Ei, Eo> ProductOnState<Son>(InternalDecider<C, Si, Son, Ei, Eo> fb)
internal InternalDecider<C, Si, Tuple<So, Son>, Ei, Eo> ProductOnState<Son>(InternalDecider<C, Si, Son, Ei, Eo> fb)
{
return ApplyOnState(fb.MapOnState(b => new Func<So, Tuple<So, Son>>(a => new Tuple<So, Son>(a, b))));
}
Expand Down Expand Up @@ -205,19 +203,19 @@ internal static class InternalDeciderExtensions
this InternalDecider<C?, Si, So, Ei?, Eo?> x,
InternalDecider<C2?, Si2, So2, Ei2?, Eo2?> y)
where C : class?, C_SUPER?
where C2 : class?, C_SUPER
where Ei : Ei_SUPER
where C2 : class, C_SUPER
where Ei : class?, Ei_SUPER?
where Eo : Eo_SUPER
where Ei2 : Ei_SUPER
where Ei2 : class, Ei_SUPER
where Eo2 : Eo_SUPER
{
var deciderX = x.MapLeftOnCommand<C_SUPER?>(c => (c as C)!)
var deciderX = x.MapLeftOnCommand<C_SUPER?>(c => c as C)
.MapLeftOnState<Tuple<Si, Si2>>(pair => pair.Item1)
.DimapOnEvent<Ei_SUPER, Eo_SUPER?>(ei => (Ei)ei!, eo => eo);
.DimapOnEvent<Ei_SUPER, Eo_SUPER?>(ei => ei as Ei, eo => eo);

var deciderY = y.MapLeftOnCommand<C_SUPER?>(c => (c as C2)!)
var deciderY = y.MapLeftOnCommand<C_SUPER?>(c => c as C2)
.MapLeftOnState<Tuple<Si, Si2>>(pair => pair.Item2)
.DimapOnEvent<Ei_SUPER, Eo_SUPER?>(ei => (Ei2)ei!, eo => eo);
.DimapOnEvent<Ei_SUPER, Eo_SUPER?>(ei => ei as Ei2, eo => eo);

return deciderX.ProductOnState(deciderY);
}
Expand Down
23 changes: 18 additions & 5 deletions src/Fraktalio.FModel/SagaExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ namespace Fraktalio.FModel;

public static class SagaExtensions
{
/// <summary>
/// Saga DSL - A convenient builder DSL for the see cref="Saga{AR,A}"/>
/// </summary>
/// <param name="react"></param>
/// <typeparam name="AR"></typeparam>
/// <typeparam name="A"></typeparam>
/// <returns></returns>
public static Saga<AR, A> ToSaga<AR, A>(this Func<AR, IEnumerable<A>> react)
{
return new Saga<AR, A>(react);
}

/// <summary>
/// Combines [Saga]s into one [Saga]
///
Expand All @@ -18,11 +30,12 @@ public static class SagaExtensions
/// <typeparam name="AR_SUPER">common superclass for [AR] and [AR2]</typeparam>
/// <typeparam name="A_SUPER">common superclass for [A] and [A2]</typeparam>
/// <returns>new Saga of type Saga`[AR_SUPER], [A_SUPER]>`</returns>
public static Saga<AR_SUPER, A_SUPER?> Combine<AR, A, AR2, A2, AR_SUPER, A_SUPER>(this Saga<AR?, A> sagaX, Saga<AR2?, A2> sagaY)
where AR : AR_SUPER
where A : A_SUPER
where AR2 : AR_SUPER
where A2 : A_SUPER
public static Saga<AR_SUPER, A_SUPER?> Combine<AR, A, AR2, A2, AR_SUPER, A_SUPER>(this Saga<AR?, A> sagaX,
Saga<AR2?, A2> sagaY)
where AR : AR_SUPER
where A : A_SUPER
where AR2 : AR_SUPER
where A2 : A_SUPER
{
var newSagaX = sagaX.MapLeftOnActionResult<AR_SUPER>(it => it is AR ar ? ar : default)
.MapOnAction<A_SUPER>(it => it);
Expand Down
16 changes: 0 additions & 16 deletions src/Fraktalio.FModel/SagaFactory.cs

This file was deleted.

3 changes: 2 additions & 1 deletion test/Fraktalio.FModel.Tests/DeciderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ namespace Fraktalio.FModel.Tests;

public static class DeciderExtensions
{
public static IEnumerable<E> GivenEvents<C, S, E>(this IDecider<C, S, E> decider, IEnumerable<E> events, Func<C> command)
public static IEnumerable<E> GivenEvents<C, S, E>(this IDecider<C, S, E> decider, IEnumerable<E> events,
Func<C> command)
{
var currentState = events.Aggregate(decider.InitialState, (s, e) => decider.Evolve(s, e));
return decider.Decide(command(), currentState);
Expand Down
Loading

0 comments on commit 1fc9429

Please sign in to comment.