This repository has been archived by the owner on Nov 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* release/0.32.1: (GH-60) Update to Cake 0.32.1 Add support for asynchronous tasks (maint) Update readme and nuget feeds
- Loading branch information
Showing
25 changed files
with
234 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Cake.Frosting.Tests/Data/Tasks/OnErrorRunAsyncFailedTask.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using Cake.Core; | ||
using Cake.Core.Diagnostics; | ||
|
||
namespace Cake.Frosting.Tests.Data.Tasks | ||
{ | ||
[TaskName("On-Error-RunAsync-Failed")] | ||
public sealed class OnErrorRunAsyncFailedTask : AsyncFrostingTask<ICakeContext> | ||
{ | ||
public override Task RunAsync(ICakeContext context) | ||
{ | ||
throw new InvalidOperationException("On test exception"); | ||
} | ||
|
||
public override void OnError(Exception exception, ICakeContext context) | ||
{ | ||
context.Log.Error("An error has occurred. {0}", exception.Message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Threading.Tasks; | ||
using Cake.Core; | ||
using Cake.Frosting.Internal; | ||
|
||
namespace Cake.Frosting | ||
{ | ||
/// <summary> | ||
/// Base class for an asynchronous Frosting task using the standard context. | ||
/// </summary> | ||
/// <seealso cref="ICakeContext" /> | ||
public abstract class AsyncFrostingTask : AsyncFrostingTask<ICakeContext> | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Base class for an asynchronous Frosting task using a custom context. | ||
/// </summary> | ||
/// <typeparam name="T">The context type.</typeparam> | ||
/// <seealso cref="IFrostingTask" /> | ||
public abstract class AsyncFrostingTask<T> : IFrostingTask | ||
where T : ICakeContext | ||
{ | ||
/// <summary> | ||
/// Runs the task using the specified context. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
public virtual Task RunAsync(T context) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
/// <summary> | ||
/// Gets whether or not the task should be run. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <returns> | ||
/// <c>true</c> if the task should run; otherwise <c>false</c>. | ||
/// </returns> | ||
public virtual bool ShouldRun(T context) | ||
{ | ||
return true; | ||
} | ||
|
||
/// <summary> | ||
/// The error handler to be executed using the specified context if an exception occurs in the task. | ||
/// </summary> | ||
/// <param name="exception">The exception.</param> | ||
/// <param name="context">The context.</param> | ||
public virtual void OnError(Exception exception, T context) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// The finally handler to be executed using the specified context after the task has finished executing. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
public virtual void Finally(T context) | ||
{ | ||
} | ||
|
||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Explicit implementation.")] | ||
Task IFrostingTask.RunAsync(ICakeContext context) | ||
{ | ||
Guard.ArgumentNotNull(context, nameof(context)); | ||
|
||
return RunAsync((T)context); | ||
} | ||
|
||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Explicit implementation.")] | ||
bool IFrostingTask.ShouldRun(ICakeContext context) | ||
{ | ||
Guard.ArgumentNotNull(context, nameof(context)); | ||
|
||
return ShouldRun((T)context); | ||
} | ||
|
||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Explicit implementation.")] | ||
void IFrostingTask.OnError(Exception exception, ICakeContext context) | ||
{ | ||
Guard.ArgumentNotNull(exception, nameof(exception)); | ||
Guard.ArgumentNotNull(context, nameof(context)); | ||
|
||
OnError(exception, (T)context); | ||
} | ||
|
||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Explicit implementation.")] | ||
void IFrostingTask.Finally(ICakeContext context) | ||
{ | ||
Guard.ArgumentNotNull(context, nameof(context)); | ||
|
||
Finally((T)context); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.