Skip to content

Commit 8966e2e

Browse files
Merge pull request #31 from brminnick/Release-v4.1.0
Release v4.1.0
2 parents 018863e + 0c04825 commit 8966e2e

34 files changed

+294
-237
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ An extension method to safely fire-and-forget a `Task`.
132132
`SafeFireAndForget` allows a Task to safely run on a different thread while the calling thread does not wait for its completion.
133133

134134
```csharp
135-
public static async void SafeFireAndForget(this System.Threading.Tasks.Task task, bool continueOnCapturedContext = false, System.Action<System.Exception>? onException = null)
135+
public static async void SafeFireAndForget(this System.Threading.Tasks.Task task, System.Action<System.Exception>? onException = null, bool continueOnCapturedContext = false)
136136
```
137137

138138
```csharp
139-
public static async void SafeFireAndForget(this System.Threading.Tasks.ValueTask task, bool continueOnCapturedContext = false, System.Action<System.Exception>? onException = null)
139+
public static async void SafeFireAndForget(this System.Threading.Tasks.ValueTask task, System.Action<System.Exception>? onException = null, bool continueOnCapturedContext = false)
140140
```
141141

142142
#### Basic Usage - Task

Src/AsyncAwaitBestPractices.MVVM.nuspec

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata minClientVersion="2.5">
44
<id>AsyncAwaitBestPractices.MVVM</id>
5-
<version>4.0.1</version>
5+
<version>4.1.0-pre2</version>
66
<title>Async Extensions for ICommand</title>
77
<authors>Brandon Minnick, John Thiriet</authors>
88
<owners>Brandon Minnick</owners>
@@ -24,18 +24,17 @@
2424
</summary>
2525
<tags>task, valuetask, fire and forget, threading, extensions, system.threading.tasks, async, await</tags>
2626
<dependencies>
27-
<dependency id="AsyncAwaitBestPractices" version="4.0.1" />
27+
<dependency id="AsyncAwaitBestPractices" version="4.1.0-pre2" />
2828
</dependencies>
2929
<releaseNotes>
3030
New In This Release:
31-
- Added Support for ValueTask
32-
- Added `IAsyncValueCommand : ICommand`
33-
- Added `AsyncValueCommand : IAsyncValueCommand`
34-
- Added `IAsyncValueCommand&lt;T&gt; : ICommand`
35-
- Added `AsyncValueCommand&lt;T&gt; : IAsyncValueCommand&lt;T&gt;`
36-
- Added `RaiseCanExecuteChanged` to `IAsyncCommand` and `IAsyncValueCommand`
31+
- Unseal AsyncCommand
32+
- Unseal AsyncCommand&lt;T&gt;
33+
- Unseal AsyncValueCommand
34+
- Unseal AsyncValueCommand&lt;T&gt;
35+
- Include Assembly Signing
3736
</releaseNotes>
38-
<repository type="git" url="https://github.com/brminnick/AsyncAwaitBestPractices.git" branch="master" commit="561e937cdb287c40bcae9d194bee3f9d95593ffe" />
37+
<repository type="git" url="https://github.com/brminnick/AsyncAwaitBestPractices.git" branch="Release-v4.1.0" commit="fad5284ab4b72010ab0c07863bca99c3b7791ee7" />
3938
<copyright>Copyright (c) 2018 Brandon Minnick</copyright>
4039
</metadata>
4140
<files>

Src/AsyncAwaitBestPractices.MVVM/AsyncAwaitBestPractices.MVVM.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
44
<TargetFramework>netstandard1.0</TargetFramework>
5-
<LangVersion>8.0</LangVersion>
5+
<LangVersion>latest</LangVersion>
66
<Nullable>enable</Nullable>
77
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
88
<SignAssembly>true</SignAssembly>

Src/AsyncAwaitBestPractices.MVVM/AsyncCommand.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
namespace AsyncAwaitBestPractices.MVVM
77
{
88
/// <summary>
9-
/// An implmentation of IAsyncCommand. Allows Commands to safely be used asynchronously with Task.
9+
/// An implementation of IAsyncCommand. Allows Commands to safely be used asynchronously with Task.
1010
/// </summary>
11-
public sealed class AsyncCommand<T> : IAsyncCommand<T>
11+
public class AsyncCommand<T> : IAsyncCommand<T>
1212
{
1313
readonly Func<T, Task> _execute;
1414
readonly Func<object?, bool> _canExecute;
@@ -19,7 +19,7 @@ public sealed class AsyncCommand<T> : IAsyncCommand<T>
1919
/// <summary>
2020
/// Initializes a new instance of the <see cref="T:TaskExtensions.MVVM.AsyncCommand`1"/> class.
2121
/// </summary>
22-
/// <param name="execute">The Function executed when Execute or ExecuteAysnc is called. This does not check canExecute before executing and will execute even if canExecute is false</param>
22+
/// <param name="execute">The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false</param>
2323
/// <param name="canExecute">The Function that verifies whether or not AsyncCommand should execute.</param>
2424
/// <param name="onException">If an exception is thrown in the Task, <c>onException</c> will execute. If onException is null, the exception will be re-thrown</param>
2525
/// <param name="continueOnCapturedContext">If set to <c>true</c> continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to <c>false</c> continue on a different context; this will allow the Synchronization Context to continue on a different thread</param>
@@ -67,12 +67,12 @@ void ICommand.Execute(object parameter)
6767
switch (parameter)
6868
{
6969
case T validParameter:
70-
ExecuteAsync(validParameter).SafeFireAndForget(_continueOnCapturedContext, _onException);
70+
ExecuteAsync(validParameter).SafeFireAndForget(_onException, _continueOnCapturedContext);
7171
break;
7272

7373
#pragma warning disable CS8601 //Possible null reference assignment
7474
case null when !typeof(T).GetTypeInfo().IsValueType:
75-
ExecuteAsync((T)parameter).SafeFireAndForget(_continueOnCapturedContext, _onException);
75+
ExecuteAsync((T)parameter).SafeFireAndForget(_onException, _continueOnCapturedContext);
7676
break;
7777
#pragma warning restore CS8601
7878

@@ -86,9 +86,9 @@ void ICommand.Execute(object parameter)
8686
}
8787

8888
/// <summary>
89-
/// An implmentation of IAsyncCommand. Allows Commands to safely be used asynchronously with Task.
89+
/// An implementation of IAsyncCommand. Allows Commands to safely be used asynchronously with Task.
9090
/// </summary>
91-
public sealed class AsyncCommand : IAsyncCommand
91+
public class AsyncCommand : IAsyncCommand
9292
{
9393
readonly Func<Task> _execute;
9494
readonly Func<object?, bool> _canExecute;
@@ -99,7 +99,7 @@ public sealed class AsyncCommand : IAsyncCommand
9999
/// <summary>
100100
/// Initializes a new instance of the <see cref="T:TaskExtensions.MVVM.AsyncCommand`1"/> class.
101101
/// </summary>
102-
/// <param name="execute">The Function executed when Execute or ExecuteAysnc is called. This does not check canExecute before executing and will execute even if canExecute is false</param>
102+
/// <param name="execute">The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false</param>
103103
/// <param name="canExecute">The Function that verifies whether or not AsyncCommand should execute.</param>
104104
/// <param name="onException">If an exception is thrown in the Task, <c>onException</c> will execute. If onException is null, the exception will be re-thrown</param>
105105
/// <param name="continueOnCapturedContext">If set to <c>true</c> continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to <c>false</c> continue on a different context; this will allow the Synchronization Context to continue on a different thread</param>
@@ -141,6 +141,6 @@ public event EventHandler CanExecuteChanged
141141
/// <returns>The executed Task</returns>
142142
public Task ExecuteAsync() => _execute();
143143

144-
void ICommand.Execute(object parameter) => _execute().SafeFireAndForget(_continueOnCapturedContext, _onException);
144+
void ICommand.Execute(object parameter) => _execute().SafeFireAndForget(_onException, _continueOnCapturedContext);
145145
}
146146
}

Src/AsyncAwaitBestPractices.MVVM/AsyncValueCommand.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
namespace AsyncAwaitBestPractices.MVVM
77
{
88
/// <summary>
9-
/// An implmentation of IAsyncValueCommand. Allows Commands to safely be used asynchronously with Task.
9+
/// An implementation of IAsyncValueCommand. Allows Commands to safely be used asynchronously with Task.
1010
/// </summary>
11-
public sealed class AsyncValueCommand<T> : IAsyncValueCommand<T>
11+
public class AsyncValueCommand<T> : IAsyncValueCommand<T>
1212
{
1313
readonly Func<T, ValueTask> _execute;
1414
readonly Func<object?, bool> _canExecute;
@@ -19,7 +19,7 @@ public sealed class AsyncValueCommand<T> : IAsyncValueCommand<T>
1919
/// <summary>
2020
/// Initializes a new instance of the <see cref="T:TaskExtensions.MVVM.AsyncCommand`1"/> class.
2121
/// </summary>
22-
/// <param name="execute">The Function executed when Execute or ExecuteAysnc is called. This does not check canExecute before executing and will execute even if canExecute is false</param>
22+
/// <param name="execute">The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false</param>
2323
/// <param name="canExecute">The Function that verifies whether or not AsyncCommand should execute.</param>
2424
/// <param name="onException">If an exception is thrown in the Task, <c>onException</c> will execute. If onException is null, the exception will be re-thrown</param>
2525
/// <param name="continueOnCapturedContext">If set to <c>true</c> continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to <c>false</c> continue on a different context; this will allow the Synchronization Context to continue on a different thread</param>
@@ -67,12 +67,12 @@ void ICommand.Execute(object parameter)
6767
switch (parameter)
6868
{
6969
case T validParameter:
70-
ExecuteAsync(validParameter).SafeFireAndForget(_continueOnCapturedContext, _onException);
70+
ExecuteAsync(validParameter).SafeFireAndForget(_onException, _continueOnCapturedContext);
7171
break;
7272

7373
#pragma warning disable CS8601 //Possible null reference assignment
7474
case null when !typeof(T).GetTypeInfo().IsValueType:
75-
ExecuteAsync((T)parameter).SafeFireAndForget(_continueOnCapturedContext, _onException);
75+
ExecuteAsync((T)parameter).SafeFireAndForget(_onException, _continueOnCapturedContext);
7676
break;
7777
#pragma warning restore CS8601
7878

@@ -86,9 +86,9 @@ void ICommand.Execute(object parameter)
8686
}
8787

8888
/// <summary>
89-
/// An implmentation of IAsyncValueCommand. Allows Commands to safely be used asynchronously with Task.
89+
/// An implementation of IAsyncValueCommand. Allows Commands to safely be used asynchronously with Task.
9090
/// </summary>
91-
public sealed class AsyncValueCommand : IAsyncValueCommand
91+
public class AsyncValueCommand : IAsyncValueCommand
9292
{
9393
readonly Func<ValueTask> _execute;
9494
readonly Func<object?, bool> _canExecute;
@@ -99,7 +99,7 @@ public sealed class AsyncValueCommand : IAsyncValueCommand
9999
/// <summary>
100100
/// Initializes a new instance of the <see cref="T:TaskExtensions.MVVM.AsyncCommand`1"/> class.
101101
/// </summary>
102-
/// <param name="execute">The Function executed when Execute or ExecuteAysnc is called. This does not check canExecute before executing and will execute even if canExecute is false</param>
102+
/// <param name="execute">The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false</param>
103103
/// <param name="canExecute">The Function that verifies whether or not AsyncCommand should execute.</param>
104104
/// <param name="onException">If an exception is thrown in the Task, <c>onException</c> will execute. If onException is null, the exception will be re-thrown</param>
105105
/// <param name="continueOnCapturedContext">If set to <c>true</c> continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to <c>false</c> continue on a different context; this will allow the Synchronization Context to continue on a different thread</param>
@@ -141,6 +141,6 @@ public event EventHandler CanExecuteChanged
141141
/// <returns>The executed Task</returns>
142142
public ValueTask ExecuteAsync() => _execute();
143143

144-
void ICommand.Execute(object parameter) => _execute().SafeFireAndForget(_continueOnCapturedContext, _onException);
144+
void ICommand.Execute(object parameter) => _execute().SafeFireAndForget(_onException, _continueOnCapturedContext);
145145
}
146146
}

Src/AsyncAwaitBestPractices.MVVM/IAsyncCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace AsyncAwaitBestPractices.MVVM
22
{
33
/// <summary>
4-
/// An Async implmentation of ICommand for Task
4+
/// An Async implementation of ICommand for Task
55
/// </summary>
66
public interface IAsyncCommand<T> : System.Windows.Input.ICommand
77
{
@@ -19,7 +19,7 @@ public interface IAsyncCommand<T> : System.Windows.Input.ICommand
1919
}
2020

2121
/// <summary>
22-
/// An Async implmentation of ICommand for Task
22+
/// An Async implementation of ICommand for Task
2323
/// </summary>
2424
public interface IAsyncCommand : System.Windows.Input.ICommand
2525
{

Src/AsyncAwaitBestPractices.MVVM/IAsyncValueCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace AsyncAwaitBestPractices.MVVM
22
{
33
/// <summary>
4-
/// An Async implmentation of ICommand for ValueTask
4+
/// An Async implementation of ICommand for ValueTask
55
/// </summary>
66
public interface IAsyncValueCommand<T> : System.Windows.Input.ICommand
77
{
@@ -19,7 +19,7 @@ public interface IAsyncValueCommand<T> : System.Windows.Input.ICommand
1919
}
2020

2121
/// <summary>
22-
/// An Async implmentation of ICommand for ValueTask
22+
/// An Async implementation of ICommand for ValueTask
2323
/// </summary>
2424
public interface IAsyncValueCommand : System.Windows.Input.ICommand
2525
{

Src/AsyncAwaitBestPractices.MVVM/InvalidCommandParameterException.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,45 @@ public class InvalidCommandParameterException : Exception
1010
/// <summary>
1111
/// Initializes a new instance of the <see cref="T:TaskExtensions.MVVM.InvalidCommandParameterException"/> class.
1212
/// </summary>
13-
/// <param name="excpectedType">Excpected parameter type for AsyncCommand.Execute.</param>
13+
/// <param name="expectedType">Expected parameter type for AsyncCommand.Execute.</param>
1414
/// <param name="actualType">Actual parameter type for AsyncCommand.Execute.</param>
1515
/// <param name="innerException">Inner Exception</param>
16-
public InvalidCommandParameterException(Type excpectedType, Type actualType, Exception innerException) : base(CreateErrorMessage(excpectedType, actualType), innerException)
16+
public InvalidCommandParameterException(Type expectedType, Type actualType, Exception innerException) : base(CreateErrorMessage(expectedType, actualType), innerException)
1717
{
1818

1919
}
2020

2121
/// <summary>
2222
/// Initializes a new instance of the <see cref="T:TaskExtensions.MVVM.InvalidCommandParameterException"/> class.
2323
/// </summary>
24-
/// <param name="excpectedType">Excpected parameter type for AsyncCommand.Execute.</param>
24+
/// <param name="expectedType">Expected parameter type for AsyncCommand.Execute.</param>
2525
/// <param name="actualType">Actual parameter type for AsyncCommand.Execute.</param>
26-
public InvalidCommandParameterException(Type excpectedType, Type actualType) : base(CreateErrorMessage(excpectedType, actualType))
26+
public InvalidCommandParameterException(Type expectedType, Type actualType) : base(CreateErrorMessage(expectedType, actualType))
2727
{
2828

2929
}
3030

3131
/// <summary>
3232
/// Initializes a new instance of the <see cref="T:TaskExtensions.MVVM.InvalidCommandParameterException"/> class.
3333
/// </summary>
34-
/// <param name="excpectedType">Excpected parameter type for AsyncCommand.Execute.</param>
34+
/// <param name="expectedType">Expected parameter type for AsyncCommand.Execute.</param>
3535
/// <param name="innerException">Inner Exception</param>
36-
public InvalidCommandParameterException(Type excpectedType, Exception innerException) : base(CreateErrorMessage(excpectedType), innerException)
36+
public InvalidCommandParameterException(Type expectedType, Exception innerException) : base(CreateErrorMessage(expectedType), innerException)
3737
{
3838

3939
}
4040

4141
/// <summary>
4242
/// Initializes a new instance of the <see cref="T:TaskExtensions.MVVM.InvalidCommandParameterException"/> class.
4343
/// </summary>
44-
/// <param name="excpectedType">Excpected parameter type for AsyncCommand.Execute.</param>
45-
public InvalidCommandParameterException(Type excpectedType) : base(CreateErrorMessage(excpectedType))
44+
/// <param name="expectedType">Expected parameter type for AsyncCommand.Execute.</param>
45+
public InvalidCommandParameterException(Type expectedType) : base(CreateErrorMessage(expectedType))
4646
{
4747

4848
}
4949

50-
static string CreateErrorMessage(Type excpectedType) => $"Invalid type for parameter. Expected Type {excpectedType}";
50+
static string CreateErrorMessage(Type expectedType) => $"Invalid type for parameter. Expected Type {expectedType}";
5151

52-
static string CreateErrorMessage(Type excpectedType, Type actualType) => $"Invalid type for parameter. Expected Type {excpectedType}, but received Type {actualType}";
52+
static string CreateErrorMessage(Type expectedType, Type actualType) => $"Invalid type for parameter. Expected Type {expectedType}, but received Type {actualType}";
5353
}
5454
}

Src/AsyncAwaitBestPractices.UnitTests/AsyncAwaitBestPractices.UnitTests.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<Nullable>enable</Nullable>
66
<IsPackable>false</IsPackable>
7-
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
7+
<SignAssembly>true</SignAssembly>
8+
<AssemblyOriginatorKeyFile>AsyncAwaitBestPracticesUnitTests.snk</AssemblyOriginatorKeyFile>
89
</PropertyGroup>
910
<ItemGroup>
1011
<PackageReference Include="nunit" Version="3.12.0" />
11-
<PackageReference Include="NUnit3TestAdapter" Version="3.16.0"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
12+
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1213
<PrivateAssets>all</PrivateAssets>
1314
</PackageReference>
1415
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
Binary file not shown.

0 commit comments

Comments
 (0)