Skip to content

Commit

Permalink
rename depends on attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
MattParkerDev committed Jul 5, 2024
1 parent b26f064 commit 76bca73
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ParallelPipelines.Console.Steps._2ProvisionAzureResources;

[DependsOnExp<CreateResourceGroupStep>]
[DependsOnStep<CreateResourceGroupStep>]
public class DeployBicepStep(IPipelineContext context) : IStep
{
private readonly IPipelineContext _context = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ParallelPipelines.Console.Steps._3BuildAndPublish;

[DependsOnExp<RestoreAndBuildStep>]
[DependsOnStep<RestoreAndBuildStep>]
public class PublishWebApiStep : IStep
{
public async Task<BufferedCommandResult?[]?> RunStep(CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

namespace ParallelPipelines.Console.Steps._3BuildAndPublish;

[DependsOnExp<RestoreAndBuildStep>]
[DependsOnExp<InstallDotnetWasmToolsStep>]
[DependsOnStep<RestoreAndBuildStep>]
[DependsOnStep<InstallDotnetWasmToolsStep>]
public class PublishWebUiStep : IStep
{
public async Task<BufferedCommandResult?[]?> RunStep(CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace ParallelPipelines.Console.Steps._3BuildAndPublish;

[DependsOnExp<InstallDotnetWasmToolsStep>]
[DependsOnStep<InstallDotnetWasmToolsStep>]
public class RestoreAndBuildStep : IStep
{
public async Task<BufferedCommandResult?[]?> RunStep(CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace ParallelPipelines.Console.Steps._4Deploy;

[DependsOnExp<PublishWebApiStep>]
[DependsOnExp<DeployBicepStep>]
[DependsOnStep<PublishWebApiStep>]
[DependsOnStep<DeployBicepStep>]
public class DeployWebApiStep(IPipelineContext context) : IStep
{
private readonly IPipelineContext _context = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace ParallelPipelines.Console.Steps._4Deploy;

[DependsOnExp<InstallSwaCliStep>]
[DependsOnExp<DeployBicepStep>]
[DependsOnExp<PublishWebUiStep>]
[DependsOnStep<InstallSwaCliStep>]
[DependsOnStep<DeployBicepStep>]
[DependsOnStep<PublishWebUiStep>]
public class DeployWebUiStep : IStep
{
public bool ShouldSkip() => false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
namespace ParallelPipelines.Application.Attributes;

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
public class DependsOnExpAttribute<T> : Attribute where T : class, IStep
public class DependsOnStepAttribute<T> : Attribute where T : class, IStep
{
}

public static class AttributeExtensions
{
public static bool DependsOn(this Type type1, Type type2)
{
var attributes = type1.GetCustomAttributes(typeof(DependsOnExpAttribute<>), true);
var attributes = type1.GetCustomAttributes(typeof(DependsOnStepAttribute<>), true);
return attributes.Any(a => a.GetType().GetGenericArguments().First() == type2);
}

public static bool HasNoDependencies(this Type type)
{
return !type.GetCustomAttributes(typeof(DependsOnExpAttribute<>), true).Any();
return !type.GetCustomAttributes(typeof(DependsOnStepAttribute<>), true).Any();
}
public static List<Type> GetDependencyTypes(this Type type)
{
var attributes = type.GetCustomAttributes(typeof(DependsOnExpAttribute<>), true);
var attributes = type.GetCustomAttributes(typeof(DependsOnStepAttribute<>), true);
var types = attributes.Select(a => a.GetType().GetGenericArguments().First()).ToList();
return types;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ParallelPipelines/ParallelPipelines.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Authors>MattParkerDev</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<PackageVersion>1.0.0</PackageVersion>
<PackageVersion>1.0.1</PackageVersion>
<PackageProjectUrl>https://github.com/MattParkerDev/ParallelPipelines</PackageProjectUrl>
<Description>Orchestrate Parallel/Concurrent CICD Pipelines in C#</Description>
<PackageTags>Csharp Dotnet Orchestration CICD Pipeline Deploy Deployment Pipelines Parallel Concurrent</PackageTags>
Expand Down
8 changes: 4 additions & 4 deletions tests/ParallelPipelines.Unit.Tests/TestSteps/TestSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class TestStep1 : IStep
}
}

[DependsOnExp<TestStep1>]
[DependsOnStep<TestStep1>]
public class TestStep2 : IStep
{
public async Task<BufferedCommandResult?[]?> RunStep(CancellationToken cancellationToken)
Expand All @@ -23,7 +23,7 @@ public class TestStep2 : IStep
}
}

[DependsOnExp<TestStep1>]
[DependsOnStep<TestStep1>]
public class TestStep3 : IStep
{
public async Task<BufferedCommandResult?[]?> RunStep(CancellationToken cancellationToken)
Expand All @@ -33,8 +33,8 @@ public class TestStep3 : IStep
}
}

[DependsOnExp<TestStep2>]
[DependsOnExp<TestStep3>]
[DependsOnStep<TestStep2>]
[DependsOnStep<TestStep3>]
public class TestStep4 : IStep
{
public async Task<BufferedCommandResult?[]?> RunStep(CancellationToken cancellationToken)
Expand Down

0 comments on commit 76bca73

Please sign in to comment.