Skip to content

Commit

Permalink
Added Directory.Build.props; removed obsolete code; minor changes (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvSapphire authored Nov 17, 2023
1 parent 740247c commit bd8d26c
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 238 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ _TeamCity*
!.axoCover/settings.json

# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
*coverage*.json
*coverage*.xml
*coverage*.info

# Visual Studio code coverage results
*.coverage
Expand Down
18 changes: 18 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<PackageIcon>logo.png</PackageIcon>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<Title>PowerPipe</Title>
<Authors>Maksym Vorchakov</Authors>
<Description>A library for .NET that uses a fluent interface to construct advanced workflows with ease</Description>
<PackageTags>pipeline, powerpipe, pipe, builder, chain, chain-of-responsibility, workflow, workflow-engine</PackageTags>
<RepositoryUrl>https://github.com/mvSapphire/PowerPipe</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)assets\logo.png" Pack="true" PackagePath="" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions samples/PowerPipe.Sample/PowerPipe.Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,8 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>true</IsPackable>
<PackageId>PowerPipe.Extensions.MicrosoftDependencyInjection</PackageId>
<Authors>Maksym Vorchakov</Authors>
<Title>PowerPipe</Title>
<Description>Dependency injection extensions for PowerPipe.</Description>
<RepositoryUrl>https://github.com/mvSapphire/PowerPipe</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>pipeline, powerpipe, pipe, di, dependency injection</PackageTags>
<PackageIcon>logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\assets\logo.png" Pack="true" PackagePath=""/>
<None Include="..\..\README.md" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\PowerPipe\PowerPipe.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using PowerPipe.Factories;
using PowerPipe.Interfaces;

namespace Microsoft.Extensions.DependencyInjection;

Expand All @@ -9,71 +7,6 @@ namespace Microsoft.Extensions.DependencyInjection;
/// </summary>
public static class ServiceCollectionExtension
{
/// <summary>
/// Adds PowerPipe services to the DI container with the specified lifetime.
/// </summary>
/// <param name="serviceCollection">The DI service collection to which services are added.</param>
/// <param name="lifetime">The lifetime of the added services (Transient, Scoped, or Singleton).</param>
/// <returns>The modified DI service collection.</returns>
[Obsolete("Use new registration with PowerPipeConfiguration")]
public static IServiceCollection AddPowerPipe(
this IServiceCollection serviceCollection, ServiceLifetime lifetime = ServiceLifetime.Transient)
{
return lifetime switch
{
ServiceLifetime.Transient => serviceCollection.AddTransient<IPipelineStepFactory, PipelineStepFactory>(),
ServiceLifetime.Scoped => serviceCollection.AddScoped<IPipelineStepFactory, PipelineStepFactory>(),
ServiceLifetime.Singleton => serviceCollection.AddSingleton<IPipelineStepFactory, PipelineStepFactory>(),
_ => throw new ArgumentOutOfRangeException(nameof(lifetime), lifetime, null)
};
}

/// <summary>
/// Adds a PowerPipe step to the DI container with the specified lifetime.
/// </summary>
/// <typeparam name="TStep">The type of the step to add.</typeparam>
/// <typeparam name="TContext">The type of context used in the pipeline.</typeparam>
/// <param name="serviceCollection">The DI service collection to which the step is added.</param>
/// <param name="lifetime">The lifetime of the added step (Transient, Scoped, or Singleton).</param>
/// <returns>The modified DI service collection.</returns>
[Obsolete("Use new registration with PowerPipeConfiguration")]
public static IServiceCollection AddPowerPipeStep<TStep, TContext>(
this IServiceCollection serviceCollection, ServiceLifetime lifetime = ServiceLifetime.Transient)
where TStep : class, IStepBase<TContext>
where TContext : class
{
return lifetime switch
{
ServiceLifetime.Transient => serviceCollection.AddTransient<TStep>(),
ServiceLifetime.Scoped => serviceCollection.AddScoped<TStep>(),
ServiceLifetime.Singleton => serviceCollection.AddSingleton<TStep>(),
_ => throw new ArgumentOutOfRangeException(nameof(lifetime), lifetime, null)
};
}

/// <summary>
/// Adds a PowerPipe compensation step to the DI container with the specified lifetime.
/// </summary>
/// <typeparam name="TStep">The type of the compensation step to add.</typeparam>
/// <typeparam name="TContext">The type of context used in the pipeline.</typeparam>
/// <param name="serviceCollection">The DI service collection to which the compensation step is added.</param>
/// <param name="lifetime">The lifetime of the added compensation step (Transient, Scoped, or Singleton).</param>
/// <returns>The modified DI service collection.</returns>
[Obsolete("Use new registration with PowerPipeConfiguration")]
public static IServiceCollection AddPowerPipeCompensationStep<TStep, TContext>(
this IServiceCollection serviceCollection, ServiceLifetime lifetime = ServiceLifetime.Transient)
where TStep : class, IPipelineCompensationStep<TContext>
where TContext : class
{
return lifetime switch
{
ServiceLifetime.Transient => serviceCollection.AddTransient<TStep>(),
ServiceLifetime.Scoped => serviceCollection.AddScoped<TStep>(),
ServiceLifetime.Singleton => serviceCollection.AddSingleton<TStep>(),
_ => throw new ArgumentOutOfRangeException(nameof(lifetime), lifetime, null)
};
}

/// <summary>
/// Registers Pipeline builder and Step types from the specified assemblies
/// </summary>
Expand All @@ -87,7 +20,7 @@ public static IServiceCollection AddPowerPipe(
configuration.Invoke(serviceConfig);
return services.AddPowerPipe(serviceConfig);
}

/// <summary>
/// Registers Pipeline builder and Step types from the specified assemblies
/// </summary>
Expand Down
14 changes: 3 additions & 11 deletions src/PowerPipe/Builder/Steps/CompensationStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

namespace PowerPipe.Builder.Steps;

/// <summary>
/// Represents a compensation step used in pipeline processing to perform compensation actions.
/// </summary>
/// <typeparam name="TContext">The type of context used in the pipeline.</typeparam>
/// <inheritdoc/>
internal class CompensationStep<TContext> : IPipelineCompensationStep<TContext>
{
private readonly Lazy<IPipelineCompensationStep<TContext>> _step;
Expand All @@ -31,16 +28,11 @@ internal CompensationStep(Func<IPipelineCompensationStep<TContext>> factory)
});
}

/// <summary>
/// Performs compensation actions asynchronously.
/// </summary>
/// <param name="context">The context on which the compensation action is performed.</param>
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param>
/// <returns>A task representing the asynchronous compensation operation.</returns>
/// <inheritdoc/>
public async Task CompensateAsync(TContext context, CancellationToken cancellationToken)
{
IsCompensated = true;

await _step.Value.CompensateAsync(context, cancellationToken);
}
}
}
13 changes: 3 additions & 10 deletions src/PowerPipe/Builder/Steps/InternalStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ namespace PowerPipe.Builder.Steps;
/// <typeparam name="TContext">The type of context used in the pipeline.</typeparam>
internal abstract class InternalStep<TContext> : IPipelineStep<TContext>, IPipelineParallelStep<TContext>
{
/// <summary>
/// Gets or sets the next step in the pipeline.
/// </summary>
/// <inheritdoc/>
public IPipelineStep<TContext> NextStep { get; set; }

/// <summary>
Expand Down Expand Up @@ -74,12 +72,7 @@ public void ConfigureErrorHandling(PipelineStepErrorHandling errorHandling, Time
ErrorHandlingPredicate = predicate;
}

/// <summary>
/// Executes the pipeline step asynchronously.
/// </summary>
/// <param name="context">The context on which the step operates.</param>
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <inheritdoc/>
public async Task ExecuteAsync(TContext context, CancellationToken cancellationToken)
{
try
Expand Down Expand Up @@ -166,4 +159,4 @@ public enum PipelineStepErrorHandling
/// Retries the step execution in case of an error.
/// </summary>
Retry = 1,
}
}
15 changes: 3 additions & 12 deletions src/PowerPipe/Pipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@

namespace PowerPipe;

/// <summary>
/// Represents a pipeline for executing a series of steps.
/// </summary>
/// <typeparam name="TContext">The type of context used in the pipeline.</typeparam>
/// <typeparam name="TResult">The type of result returned by the pipeline.</typeparam>
/// <inheritdoc/>
public class Pipeline<TContext, TResult> : IPipeline<TResult>
where TContext : PipelineContext<TResult>
where TResult : class
Expand All @@ -31,12 +27,7 @@ public Pipeline(TContext context, IReadOnlyList<IPipelineStep<TContext>> steps)
SetupSteps(steps);
}

/// <summary>
/// Runs the pipeline asynchronously with the option to return a result.
/// </summary>
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param>
/// <param name="returnResult">A flag indicating whether to return a result.</param>
/// <returns>A task representing the asynchronous operation and optionally the result.</returns>
/// <inheritdoc/>
public async Task<TResult> RunAsync(CancellationToken cancellationToken, bool returnResult = true)
{
await _initStep.ExecuteAsync(_context, cancellationToken);
Expand All @@ -52,4 +43,4 @@ private static void SetupSteps(IReadOnlyList<IPipelineStep<TContext>> steps)
steps[i].NextStep = steps[i + 1];
}
}
}
}
15 changes: 0 additions & 15 deletions src/PowerPipe/PowerPipe.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,8 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>true</IsPackable>
<PackageId>PowerPipe</PackageId>
<Authors>Maksym Vorchakov</Authors>
<Title>PowerPipe</Title>
<Description>A library for .NET that uses a fluent interface to construct advanced pipelines with ease.</Description>
<RepositoryUrl>https://github.com/mvSapphire/PowerPipe</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>pipeline, powerpipe, pipe, builder, chain, chain-of-responsibility</PackageTags>
<PackageIcon>logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\assets\logo.png" Pack="true" PackagePath="" />
<None Include="..\..\README.md" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="$(AssemblyName).UnitTests" />
</ItemGroup>
Expand Down
24 changes: 0 additions & 24 deletions tests/PowerPipe.UnitTests/Fixtures/AutoDIFixture.cs

This file was deleted.

27 changes: 0 additions & 27 deletions tests/PowerPipe.UnitTests/Fixtures/DIFixture.cs

This file was deleted.

48 changes: 0 additions & 48 deletions tests/PowerPipe.UnitTests/PipelineDITests.cs

This file was deleted.

Loading

0 comments on commit bd8d26c

Please sign in to comment.