-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from marcwittke/hotfix/2.0.6
Hotfix/2.0.6
- Loading branch information
Showing
7 changed files
with
164 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
scriptDir=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")") | ||
mono ${scriptDir}/GitVersion.exe /updateassemblyinfo /output buildserver | ||
|
||
echo "$GitVersion_Major" | ||
echo "$GitVersion_Minor" | ||
echo "$GitVersion_Patch" | ||
echo "$GitVersion_PreReleaseTag" | ||
echo "$GitVersion_PreReleaseTagWithDash" | ||
echo "$GitVersion_PreReleaseLabel" | ||
echo "$GitVersion_PreReleaseNumber" | ||
echo "$GitVersion_BuildMetaData" | ||
echo "$GitVersion_BuildMetaDataPadded" | ||
echo "$GitVersion_FullBuildMetaData" | ||
echo "$GitVersion_MajorMinorPatch" | ||
echo "$GitVersion_SemVer" | ||
echo "$GitVersion_LegacySemVer" | ||
echo "$GitVersion_LegacySemVerPadded" | ||
echo "$GitVersion_AssemblySemVer" | ||
echo "$GitVersion_FullSemVer" | ||
echo "$GitVersion_InformationalVersion" | ||
echo "$GitVersion_BranchName" | ||
echo "$GitVersion_Sha" | ||
echo "$GitVersion_NuGetVersionV2" | ||
echo "$GitVersion_NuGetVersion" | ||
echo "$GitVersion_CommitsSinceVersionSource" | ||
echo "$GitVersion_CommitsSinceVersionSourcePadded" | ||
echo "$GitVersion_CommitDate" |
Binary file not shown.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,147 @@ | ||
namespace Backend.Fx.Extensions | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
public static class AsyncHelper | ||
{ | ||
private static readonly TaskFactory TheTaskFactory | ||
= new TaskFactory(CancellationToken.None, TaskCreationOptions.None, TaskContinuationOptions.None, TaskScheduler.Default); | ||
/// <summary> | ||
/// Execute's an async Task method which has a void return value synchronously | ||
/// </summary> | ||
/// <param name="task">Task method to execute</param> | ||
/// <remarks> | ||
/// See https://stackoverflow.com/questions/5095183/how-would-i-run-an-async-taskt-method-synchronously | ||
/// This code was the only possibility to make a task synchronously without deadlocking on the SingleCPU Build agent | ||
/// </remarks> | ||
public static void RunSync(Func<Task> task) | ||
{ | ||
var oldContext = SynchronizationContext.Current; | ||
try | ||
{ | ||
var synch = new ExclusiveSynchronizationContext(); | ||
SynchronizationContext.SetSynchronizationContext(synch); | ||
synch.Post(async _ => | ||
{ | ||
try | ||
{ | ||
await task(); | ||
} | ||
catch (Exception e) | ||
{ | ||
synch.InnerException = e; | ||
throw; | ||
} | ||
finally | ||
{ | ||
synch.EndMessageLoop(); | ||
} | ||
}, null); | ||
synch.BeginMessageLoop(); | ||
} | ||
finally | ||
{ | ||
SynchronizationContext.SetSynchronizationContext(oldContext); | ||
} | ||
} | ||
|
||
public static TResult RunSync<TResult>(Func<Task<TResult>> func) | ||
/// <summary> | ||
/// Execute's an async Task<T> method which has a T return type synchronously | ||
/// </summary> | ||
/// <typeparam name="T">Return Type</typeparam> | ||
/// <param name="task">TaskTask<T> method to execute</param> | ||
/// <returns></returns> | ||
public static T RunSync<T>(Func<Task<T>> task) | ||
{ | ||
return TheTaskFactory.StartNew(func).Unwrap().GetAwaiter().GetResult(); | ||
T ret = default(T); | ||
var oldContext = SynchronizationContext.Current; | ||
try | ||
{ | ||
var exclusiveSynchronizationContext = new ExclusiveSynchronizationContext(); | ||
SynchronizationContext.SetSynchronizationContext(exclusiveSynchronizationContext); | ||
exclusiveSynchronizationContext.Post(async _ => | ||
{ | ||
try | ||
{ | ||
ret = await task(); | ||
} | ||
catch (Exception e) | ||
{ | ||
exclusiveSynchronizationContext.InnerException = e; | ||
throw; | ||
} | ||
finally | ||
{ | ||
exclusiveSynchronizationContext.EndMessageLoop(); | ||
} | ||
}, null); | ||
exclusiveSynchronizationContext.BeginMessageLoop(); | ||
} | ||
finally | ||
{ | ||
SynchronizationContext.SetSynchronizationContext(oldContext); | ||
} | ||
return ret; | ||
} | ||
|
||
public static void RunSync(Func<Task> func) | ||
private class ExclusiveSynchronizationContext : SynchronizationContext | ||
{ | ||
TheTaskFactory.StartNew(func).Unwrap().GetAwaiter().GetResult(); | ||
private bool done; | ||
public Exception InnerException { get; set; } | ||
readonly AutoResetEvent workItemsWaiting = new AutoResetEvent(false); | ||
readonly Queue<Tuple<SendOrPostCallback, object>> items = new Queue<Tuple<SendOrPostCallback, object>>(); | ||
|
||
public override void Send(SendOrPostCallback d, object state) | ||
{ | ||
throw new NotSupportedException("We cannot send to our same thread"); | ||
} | ||
|
||
public override void Post(SendOrPostCallback d, object state) | ||
{ | ||
lock (items) | ||
{ | ||
items.Enqueue(Tuple.Create(d, state)); | ||
} | ||
workItemsWaiting.Set(); | ||
} | ||
|
||
public void EndMessageLoop() | ||
{ | ||
Post(_ => done = true, null); | ||
} | ||
|
||
public void BeginMessageLoop() | ||
{ | ||
while (!done) | ||
{ | ||
Tuple<SendOrPostCallback, object> task = null; | ||
lock (items) | ||
{ | ||
if (items.Count > 0) | ||
{ | ||
task = items.Dequeue(); | ||
} | ||
} | ||
if (task != null) | ||
{ | ||
task.Item1(task.Item2); | ||
if (InnerException != null) // the method threw an exeption | ||
{ | ||
throw new AggregateException("AsyncHelpers.Run method threw an exception.", InnerException); | ||
} | ||
} | ||
else | ||
{ | ||
workItemsWaiting.WaitOne(); | ||
} | ||
} | ||
} | ||
|
||
public override SynchronizationContext CreateCopy() | ||
{ | ||
return this; | ||
} | ||
} | ||
} | ||
} | ||
} |