Skip to content

Commit

Permalink
Merge pull request #49 from brminnick/release-5.0.0
Browse files Browse the repository at this point in the history
Release 5.0.0
  • Loading branch information
TheCodeTraveler authored Nov 2, 2020
2 parents 88a8c30 + fefcfbe commit b69bb7e
Show file tree
Hide file tree
Showing 49 changed files with 1,347 additions and 937 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ fastlane/screenshots/screenshots.html
# scan temporary files
fastlane/test_output

**/__*.json
**/local.settings.json


### XamarinStudio ###
bin/
Expand Down Expand Up @@ -316,7 +319,6 @@ rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt

# Visual Studio cache files
Expand Down Expand Up @@ -664,6 +666,8 @@ sysinfo.txt
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# MFractor
.mfractor/

### VisualStudio ###
## Ignore Visual Studio temporary files, build results, and
Expand Down
56 changes: 52 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ Available on NuGet: https://www.nuget.org/packages/AsyncAwaitBestPractices/
- `AsyncCommand : IAsyncCommand`
- `IAsyncCommand<T> : ICommand`
- `AsyncCommand<T> : IAsyncCommand<T>`
- `IAsyncCommand<TExecute, TCanExecute> : IAsyncCommand<TExecute>`
- `AsyncCommand<TExecute, TCanExecute> : IAsyncCommand<TExecute, TCanExecute>`

- Allows for `ValueTask` to safely be used asynchronously with `ICommand`:
- `IAsyncValueCommand : ICommand`
- `AsyncValueCommand : IAsyncValueCommand`
- `IAsyncValueCommand<T> : ICommand`
- `AsyncValueCommand<T> : IAsyncValueCommand<T>`
- `IAsyncValueCommand<TExecute, TCanExecute> : IAsyncValueCommand<TExecute>`
- `AsyncValueCommand<TExecute, TCanExecute> : IAsyncValueCommand<TExecute, TCanExecute>`
- [Usage instructions](#asyncawaitbestpracticesmvvm-2)

## Setup
Expand Down Expand Up @@ -328,21 +332,30 @@ void OnActionEvent(string message) => _weakActionEventManager.RaiseEvent(message

Allows for `Task` to safely be used asynchronously with `ICommand`:

- `AsyncCommand<TExecute, TCanExecute> : IAsyncCommand<TExecute, TCanExecute>`
- `IAsyncCommand<TExecute, TCanExecute> : IAsyncCommand<TExecute>`
- `AsyncCommand<T> : IAsyncCommand<T>`
- `IAsyncCommand<T> : ICommand`
- `AsyncCommand : IAsyncCommand`
- `IAsyncCommand : ICommand`

```csharp
public AsyncCommand(Func<TExecute, Task> execute,
Func<TCanExecute, bool>? canExecute = null,
Action<Exception>? onException = null,
bool continueOnCapturedContext = false)
```

```csharp
public AsyncCommand(Func<T, Task> execute,
Func<object, bool>? canExecute = null,
Func<object?, bool>? canExecute = null,
Action<Exception>? onException = null,
bool continueOnCapturedContext = false)
```

```csharp
public AsyncCommand(Func<Task> execute,
Func<object, bool>? canExecute = null,
Func<object?, bool>? canExecute = null,
Action<Exception>? onException = null,
bool continueOnCapturedContext = false)
```
Expand All @@ -356,13 +369,15 @@ public class ExampleClass
{
ExampleAsyncCommand = new AsyncCommand(ExampleAsyncMethod);
ExampleAsyncIntCommand = new AsyncCommand<int>(ExampleAsyncMethodWithIntParameter);
ExampleAsyncIntCommandWithCanExecute = new AsyncCommand<int, int>(ExampleAsyncMethodWithIntParameter, CanExecuteInt);
ExampleAsyncExceptionCommand = new AsyncCommand(ExampleAsyncMethodWithException, onException: ex => Console.WriteLine(ex.ToString()));
ExampleAsyncCommandWithCanExecuteChanged = new AsyncCommand(ExampleAsyncMethod, _ => !IsBusy);
ExampleAsyncCommandReturningToTheCallingThread = new AsyncCommand(ExampleAsyncMethod, continueOnCapturedContext: true);
}

public IAsyncCommand ExampleAsyncCommand { get; }
public IAsyncCommand<int> ExampleAsyncIntCommand { get; }
public IAsyncCommand<int, int> ExampleAsyncIntCommandWithCanExecute { get; }
public IAsyncCommand ExampleAsyncExceptionCommand { get; }
public IAsyncCommand ExampleAsyncCommandWithCanExecuteChanged { get; }
public IAsyncCommand ExampleAsyncCommandReturningToTheCallingThread { get; }
Expand Down Expand Up @@ -396,6 +411,14 @@ public class ExampleClass
throw new Exception();
}

bool CanExecuteInt(int count)
{
if(count > 2)
return true;

return false;
}

void ExecuteCommands()
{
_isBusy = true;
Expand All @@ -409,6 +432,9 @@ public class ExampleClass

if(ExampleAsyncCommandWithCanExecuteChanged.CanExecute(null))
ExampleAsyncCommandWithCanExecuteChanged.Execute(null);

if(ExampleAsyncIntCommandWithCanExecute.CanExecute(1))
ExampleAsyncIntCommandWithCanExecute.Execute(1);
}
finally
{
Expand All @@ -425,21 +451,30 @@ Allows for `ValueTask` to safely be used asynchronously with `ICommand`.
If you're new to ValueTask, check out this great write-up, [Understanding the Whys, Whats, and Whens of ValueTask
](https://blogs.msdn.microsoft.com/dotnet/2018/11/07/understanding-the-whys-whats-and-whens-of-valuetask?WT.mc_id=mobile-0000-bramin).

- `AsyncValueCommand<TExecute, TCanExecute> : IAsyncValueCommand<TExecute, TCanExecute>`
- `IAsyncValueCommand<TExecute, TCanExecute> : IAsyncValueCommand<TExecute>`
- `AsyncValueCommand<T> : IAsyncValueCommand<T>`
- `IAsyncValueCommand<T> : ICommand`
- `AsyncValueCommand : IAsyncValueCommand`
- `IAsyncValueCommand : ICommand`

```csharp
public AsyncValueCommand(Func<TExecute, ValueTask> execute,
Func<TCanExecute, bool>? canExecute = null,
Action<Exception>? onException = null,
bool continueOnCapturedContext = false)
```

```csharp
public AsyncValueCommand(Func<T, ValueTask> execute,
Func<object, bool>? canExecute = null,
Func<object?, bool>? canExecute = null,
Action<Exception>? onException = null,
bool continueOnCapturedContext = false)
```

```csharp
public AsyncValueCommand(Func<ValueTask> execute,
Func<object, bool>? canExecute = null,
Func<object?, bool>? canExecute = null,
Action<Exception>? onException = null,
bool continueOnCapturedContext = false)
```
Expand All @@ -453,13 +488,15 @@ public class ExampleClass
{
ExampleValueTaskCommand = new AsyncValueCommand(ExampleValueTaskMethod);
ExampleValueTaskIntCommand = new AsyncValueCommand<int>(ExampleValueTaskMethodWithIntParameter);
ExampleValueTaskIntCommandWithCanExecute = new AsyncValueCommand<int, int>(ExampleValueTaskMethodWithIntParameter, CanExecuteInt);
ExampleValueTaskExceptionCommand = new AsyncValueCommand(ExampleValueTaskMethodWithException, onException: ex => Debug.WriteLine(ex.ToString()));
ExampleValueTaskCommandWithCanExecuteChanged = new AsyncValueCommand(ExampleValueTaskMethod, _ => !IsBusy);
ExampleValueTaskCommandReturningToTheCallingThread = new AsyncValueCommand(ExampleValueTaskMethod, continueOnCapturedContext: true);
}

public IAsyncValueCommand ExampleValueTaskCommand { get; }
public IAsyncValueCommand<int> ExampleValueTaskIntCommand { get; }
public IAsyncCommand<int, int> ExampleValueTaskIntCommandWithCanExecute { get; }
public IAsyncValueCommand ExampleValueTaskExceptionCommand { get; }
public IAsyncValueCommand ExampleValueTaskCommandWithCanExecuteChanged { get; }
public IAsyncValueCommand ExampleValueTaskCommandReturningToTheCallingThread { get; }
Expand Down Expand Up @@ -500,6 +537,14 @@ public class ExampleClass
throw new Exception();
}

bool CanExecuteInt(int count)
{
if(count > 2)
return true;

return false;
}

void ExecuteCommands()
{
_isBusy = true;
Expand All @@ -513,6 +558,9 @@ public class ExampleClass

if (ExampleValueTaskCommandWithCanExecuteChanged.CanExecute(null))
ExampleValueTaskCommandWithCanExecuteChanged.Execute(null);

if(ExampleValueTaskIntCommandWithCanExecute.CanExecute(2))
ExampleValueTaskIntCommandWithCanExecute.Execute(2);
}
finally
{
Expand Down
41 changes: 0 additions & 41 deletions Src/AsyncAwaitBestPractices.MVVM.nuspec

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<TargetFrameworks>netstandard1.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>AsyncAwaitBestPracticesMVVM.snk</AssemblyOriginatorKeyFile>
<AssemblyName>AsyncAwaitBestPractices.MVVM</AssemblyName>
<RootNamespace>AsyncAwaitBestPractices.MVVM</RootNamespace>
<PackageId>AsyncAwaitBestPractices.MVVM</PackageId>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Summary>
Async Extensions for ICommand

Includes AsyncCommand and IAsyncCommand which allows ICommand to safely be used asynchronously with Task.
Includes AsyncValueCommand and IAsyncValueCommand which allows ICommand to safely be used asynchronously with ValueTask
</Summary>
<PackageTags>task, fire and forget, threading, extensions, system.threading.tasks, async, await, command, icommand, asynccommand, valuetask, asyncvaluecommand</PackageTags>
<Title>Async Extensions for ICommand</Title>
<Description>
Async Extensions for ICommand

Includes AsyncCommand and IAsyncCommand which allows ICommand to safely be used asynchronously with Task.
Includes AsyncValueCommand and IAsyncValueCommand which allows ICommand to safely be used asynchronously with ValueTask
</Description>
<PackageReleaseNotes>
New in this release:
- Add `IAsyncCommand&lt;TExecute, TCanExecute&gt;`
- Add `IAsyncValueCommand&lt;TExecute, TCanExecute&gt;`
- Add `AsyncCommand&lt;TExecute, TCanExecute&gt;`
- Add `AsyncValueCommand&lt;TExecute, TCanExecute&gt;`
- Implement SourceLink
</PackageReleaseNotes>
<Version>5.0.0</Version>
<RepositoryUrl>https://github.com/brminnick/AsyncAwaitBestPractices</RepositoryUrl>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<AssemblyFileVersion>1.0.0.0</AssemblyFileVersion>
<PackageVersion>$(Version)$(VersionSuffix)</PackageVersion>
<Authors>Brandon Minnick, John Thiriet</Authors>
<Owners>Brandon Minnick</Owners>
<NeutralLanguage>en</NeutralLanguage>
<Copyright>©Copyright 2020 Brandon Minnick. All rights reserved.</Copyright>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<DefineConstants>$(DefineConstants);</DefineConstants>
<UseFullSemVerForNuGet>false</UseFullSemVerForNuGet>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/brminnick/AsyncAwaitBestPractices</PackageProjectUrl>
<DebugType>portable</DebugType>
<Configurations>Debug;Release</Configurations>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)'=='Debug' ">
<!-- Manage TargetFrameworks for development (Debug Mode) -->
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<DocumentationFile>bin\Release\netstandard2.0\AsyncAwaitBestPractices.MVVM.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup Condition=" '$(Configuration)'=='Release' ">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<Compile Include="**/*.shared.cs" />
<Compile Include="**/*.shared.*.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AsyncAwaitBestPractices\AsyncAwaitBestPractices.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AsyncAwaitBestPractices\AsyncAwaitBestPractices.csproj" />
<PackageReference Update="NETStandard.Library" PrivateAssets="all" />
</ItemGroup>
</Project>
Loading

0 comments on commit b69bb7e

Please sign in to comment.