Skip to content

Commit 9bc5a82

Browse files
Feature/10.0.x updates (#208)
* CommandBus updates * CommandBus Obsolete Updates * chg to not null GetDescription enum ext * minor nuget updates, dependentbot tweaks --------- Co-authored-by: Chris Straw <chris.straw@contractors.courts.in.gov>
1 parent e6c5d7d commit 9bc5a82

File tree

20 files changed

+92
-165
lines changed

20 files changed

+92
-165
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"dotnet-sonarscanner": {
6-
"version": "11.0.0",
6+
"version": "11.1.0",
77
"commands": [
88
"dotnet-sonarscanner"
99
]

.github/dependabot.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ updates:
33
- package-ecosystem: "github-actions"
44
directory: "/" # Location of package manifests
55
schedule:
6-
interval: "weekly"
6+
interval: monthly
77
labels:
88
- "dependencies"
99
- "github-actions"
1010

1111
- package-ecosystem: "nuget"
1212
directory: "/tests"
1313
schedule:
14-
interval: "weekly"
14+
interval: monthly
15+
ignore:
16+
- dependency-name: "*"
17+
update-types:
18+
- "version-update:semver-patch"
1519
labels:
1620
- "dependencies"
1721
- "nuget"

src/Directory.Build.props

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
</PropertyGroup>
2323

2424
<ItemGroup>
25-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
25+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.103">
26+
<PrivateAssets>all</PrivateAssets>
27+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
28+
</PackageReference>
2629
</ItemGroup>
2730

2831
<ItemGroup>

src/OLT.Core.Attribute.Abstractions/Code/OltCodeAttributeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static class OltCodeAttributeExtensions
2323
/// Returns Code value from <see cref="CodeAttribute"/> attribute
2424
/// </summary>
2525
/// <param name="value"></param>
26-
/// <returns><see cref="string"/> Code from <see cref="CodeAttribute"/> or <see langword="null"/></returns>
26+
/// <returns><see cref="string"/> Code from <see cref="CodeAttribute"/></returns>
2727
/// <exception cref="ArgumentNullException"></exception>
2828
public static string GetCodeEnumSafe(this Enum value)
2929
{

src/OLT.Core.Attribute.Abstractions/Extensions/OltAttributeExtensions.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,13 @@ public static class OltAttributeExtensions
7070
/// Gets <see cref="DescriptionAttribute"/>
7171
/// </summary>
7272
/// <param name="value"></param>
73-
/// <returns><see cref="DescriptionAttribute.Description"/> or <seealso cref="Enum"/> ToString() or <see langword="null"/></returns>
74-
public static string? GetDescription(this Enum value)
73+
/// <returns><see cref="DescriptionAttribute.Description"/> or <seealso cref="Enum"/> ToString() </returns>
74+
public static string GetDescription(this Enum value)
7575
{
7676
var attribute = GetAttributeInstance<DescriptionAttribute>(value);
77-
return attribute?.Description ?? value?.ToString();
77+
return attribute?.Description ?? value.ToString();
7878
}
7979

80-
8180
/// <summary>
8281
/// Searches <typeparamref name="TEnum"/> for <see cref="DescriptionAttribute"/> or Name matching string
8382
/// </summary>

src/OLT.Core.CommandBus.Abstractions/Interfaces/IOltCommandBus.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Threading;
23
using System.Threading.Tasks;
34

45
namespace OLT.Core
@@ -10,19 +11,22 @@ public interface IOltCommandBus : IOltInjectableScoped
1011
/// Runs Command Validation
1112
/// </summary>
1213
/// <param name="command"></param>
14+
/// <param name="cancellationToken">Optional cancellation token.</param>
1315
/// <returns></returns>
1416
/// <exception cref="OltCommandHandlerNotFoundException"></exception>
1517
/// <exception cref="OltCommandHandlerMultipleException"></exception>
16-
Task<IOltCommandValidationResult> ValidateAsync(IOltCommand command);
18+
Task<IOltCommandValidationResult> ValidateAsync(IOltCommand command, CancellationToken cancellationToken = default);
1719

1820
/// <summary>
1921
/// Processes Command using <see cref="IOltCommandHandler"/> for <see cref="IOltCommand"/>
2022
/// </summary>
2123
/// <param name="command"></param>
24+
/// <param name="cancellationToken">Optional cancellation token.</param>
2225
/// <returns></returns>
2326
/// <exception cref="OltCommandHandlerNotFoundException"></exception>
2427
/// <exception cref="OltCommandHandlerMultipleException"></exception>
25-
Task ProcessAsync(IOltCommand command);
28+
[Obsolete("Removing in 10.x, ProcessAsync<T> is deprecated, use IOltCommand<TResult>")]
29+
Task ProcessAsync(IOltCommand command, CancellationToken cancellationToken = default);
2630

2731

2832
/// <summary>
@@ -40,11 +44,13 @@ public interface IOltCommandBus : IOltInjectableScoped
4044
/// Processes Command using <see cref="IOltCommandHandler"/> for <see cref="IOltCommand"/>
4145
/// </summary>
4246
/// <param name="command"></param>
47+
/// <param name="cancellationToken">Optional cancellation token.</param>
4348
/// <typeparam name="TResult"><see cref="IOltCommandHandler"/> Returned Result</typeparam>
4449
/// <returns></returns>
4550
/// <exception cref="OltCommandHandlerNotFoundException"></exception>
4651
/// <exception cref="NullReferenceException">Thrown is command result is null</exception>
52+
/// <exception cref="InvalidCastException">Thrown is command result doesn't match handler type</exception>
4753
/// <returns></returns>
48-
Task<TResult> ProcessAsync<TResult>(IOltCommand<TResult> command) where TResult : notnull;
54+
Task<TResult> ProcessAsync<TResult>(IOltCommand<TResult> command, CancellationToken cancellationToken = default) where TResult : notnull;
4955
}
5056
}

src/OLT.Core.CommandBus.Abstractions/Records/OltCommandResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace OLT.Core
44
{
5-
[Obsolete("Removing in 10.x, Complete<T> is deprecated, use IOltCommand<TResult> with OltCommandHandler<TCommand, TResult>")]
5+
66
public record OltCommandResult(object? Result = null) : IOltCommandResult
77
{
88
public static OltCommandResult Complete()
99
{
1010
return new OltCommandResult();
1111
}
1212

13-
13+
[Obsolete("Removing in 10.x, Complete<T> is deprecated, use IOltCommand<TResult> with OltCommandHandler<TCommand, TResult>")]
1414
public static OltCommandResult Complete<T>(T result) //Issue #149
1515
{
1616
return new OltCommandResult(result);

src/OLT.Core.CommandBus/OltCommandBus.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Concurrent;
44
using System.Collections.Generic;
55
using System.Linq;
6+
using System.Threading;
67
using System.Threading.Tasks;
78

89
namespace OLT.Core
@@ -23,6 +24,8 @@ protected OltCommandBus(
2324
protected virtual TContext Context { get; }
2425
protected virtual List<IOltCommandHandler> Handlers { get; }
2526

27+
public CancellationToken CancellationToken { get; private set; } = CancellationToken.None;
28+
2629
/// <summary>
2730
/// Attempts to locate <see cref="IOltCommandHandler"/> for <see cref="IOltCommand"/>
2831
/// </summary>
@@ -53,21 +56,23 @@ protected virtual IOltCommandHandler GetHandler(IOltCommand command)
5356
/// <param name="command"></param>
5457
/// <param name="handler"></param>
5558
/// <returns></returns>
56-
protected virtual Task<IOltCommandValidationResult> ValidateAsync(IOltCommandHandler handler, IOltCommand command)
57-
{
59+
protected virtual Task<IOltCommandValidationResult> ValidateAsync_Internal(IOltCommandHandler handler, IOltCommand command)
60+
{
5861
return handler.ValidateAsync(this, command);
5962
}
6063

6164
/// <summary>
6265
/// Validates Command and CommandHandler can Execute
6366
/// </summary>
6467
/// <param name="command"></param>
68+
/// <param name="cancellationToken">Optional cancellation token.</param>
6569
/// <returns></returns>
6670
/// <exception cref="OltCommandHandlerNotFoundException"></exception>
67-
/// <exception cref="OltCommandHandlerMultipleException"></exception>
68-
public virtual Task<IOltCommandValidationResult> ValidateAsync(IOltCommand command)
71+
/// <exception cref="OltCommandHandlerMultipleException"></exception>
72+
public virtual Task<IOltCommandValidationResult> ValidateAsync(IOltCommand command, CancellationToken cancellationToken = default)
6973
{
70-
return this.ValidateAsync(GetHandler(command), command);
74+
this.CancellationToken = cancellationToken;
75+
return this.ValidateAsync_Internal(GetHandler(command), command);
7176
}
7277

7378
/// <summary>
@@ -76,9 +81,10 @@ public virtual Task<IOltCommandValidationResult> ValidateAsync(IOltCommand comma
7681
/// <param name="command"></param>
7782
/// <param name="handler"></param>
7883
/// <returns></returns>
84+
[Obsolete("Removing in 10.x, ProcessAsync<T> is deprecated, use IOltCommand<TResult>")]
7985
protected virtual async Task<IOltCommandBusResult> ExecuteAsync(IOltCommandHandler handler, IOltCommand command)
8086
{
81-
var validationResult = await ValidateAsync(handler, command);
87+
var validationResult = await ValidateAsync_Internal(handler, command);
8288
if (!validationResult.Valid)
8389
{
8490
throw validationResult.ToException();
@@ -95,16 +101,6 @@ protected virtual async Task<IOltCommandBusResult> ExecuteAsync(IOltCommandHandl
95101
}
96102

97103

98-
/////// <summary>
99-
/////// Executes Command
100-
/////// </summary>
101-
/////// <param name="command"></param>
102-
/////// <returns></returns>
103-
////protected virtual Task<IOltCommandBusResult> ExecuteAsync(IOltCommand command)
104-
////{
105-
//// return ExecuteAsync(GetHandler(command), command);
106-
////}
107-
108104
/// <summary>
109105
/// Runs in order (or Queues if in Transaction) the <seealso cref="IOltPostCommandHandler.PostExecuteAsync(IOltCommand, IOltCommandResult)"/>
110106
/// </summary>
@@ -115,7 +111,6 @@ protected virtual async Task<IOltCommandBusResult> ExecuteAsync(IOltCommandHandl
115111
protected virtual async Task PostExecuteAsync<TResult>(IOltCommandHandler currentHandler, IOltCommand command, TResult result)
116112
where TResult: notnull
117113
{
118-
119114
if (currentHandler is IOltPostCommandHandler<TResult> typedPostHandler)
120115
{
121116
PostProcessItems.Enqueue(new OltAfterCommandQueueItem<TResult>(typedPostHandler, command, result));
@@ -138,12 +133,15 @@ protected virtual async Task PostExecuteAsync<TResult>(IOltCommandHandler curren
138133
/// Processes Command using <see cref="IOltCommandHandler"/> for <see cref="IOltCommand"/>
139134
/// </summary>
140135
/// <param name="command"></param>
136+
/// <param name="cancellationToken">Optional cancellation token.</param>
141137
/// <returns></returns>
142138
/// <exception cref="OltCommandHandlerNotFoundException"></exception>
143139
/// <exception cref="OltCommandHandlerMultipleException"></exception>
144140
/// <exception cref="OltValidationException"></exception>
145-
public virtual Task ProcessAsync(IOltCommand command)
141+
[Obsolete("Removing in 10.x, ProcessAsync<T> is deprecated, use IOltCommand<TResult>")]
142+
public virtual Task ProcessAsync(IOltCommand command, CancellationToken cancellationToken = default)
146143
{
144+
this.CancellationToken = cancellationToken;
147145
return ExecuteAsync(GetHandler(command), command);
148146
}
149147

@@ -165,20 +163,22 @@ public virtual async Task<T> ProcessAsync<T>(IOltCommand command)
165163
}
166164

167165

168-
169-
170166
/// <summary>
171167
/// Processes Command using <see cref="IOltCommandHandler"/> for <see cref="IOltCommand"/>
172168
/// </summary>
173169
/// <param name="command"></param>
170+
/// <param name="cancellationToken">Optional cancellation token.</param>
174171
/// <typeparam name="TResult"><see cref="IOltCommandHandler"/> Returned Result</typeparam>
175172
/// <returns></returns>
176173
/// <exception cref="OltCommandHandlerNotFoundException"></exception>
177174
/// <exception cref="NullReferenceException">Thrown is command result is null</exception>
178175
/// <exception cref="OltValidationException"></exception>
176+
/// <exception cref="InvalidCastException"></exception>
179177
/// <returns></returns>
180-
public virtual async Task<TResult> ProcessAsync<TResult>(IOltCommand<TResult> command) where TResult : notnull
178+
public virtual async Task<TResult> ProcessAsync<TResult>(IOltCommand<TResult> command, CancellationToken cancellationToken = default) where TResult : notnull
181179
{
180+
this.CancellationToken = cancellationToken;
181+
182182
var validationResult = await ValidateAsync(command);
183183
if (!validationResult.Valid)
184184
{
@@ -199,7 +199,7 @@ public virtual async Task<TResult> ProcessAsync<TResult>(IOltCommand<TResult> co
199199
return result;
200200
}
201201

202-
return await ProcessAsync<TResult>((IOltCommand)command);
202+
throw new InvalidCastException($"Unable to cast to {typeof(IOltCommandHandler<TResult>)}");
203203
}
204204
}
205205
}

src/OLT.Extensions.Configuration.Amazon.SystemManager/OLT.Extensions.Configuration.Amazon.SystemManager.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Amazon.Extensions.Configuration.SystemsManager" Version="7.0.0" />
12+
<PackageReference Include="Amazon.Extensions.Configuration.SystemsManager" Version="7.1.0" />
1313
</ItemGroup>
1414

1515
</Project>

src/OLT.Extensions.Configuration.Azure.AppConfig/OLT.Extensions.Configuration.Azure.AppConfig.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<ItemGroup>
1212
<PackageReference Include="Azure.Identity" Version="1.17.1" />
1313
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.13.1" />
14-
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="8.4.0" />
14+
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="8.5.0" />
1515
</ItemGroup>
1616

1717
</Project>

0 commit comments

Comments
 (0)