diff --git a/CQRSlite.nuspec b/CQRSlite.nuspec
index 663411a..d6f8e72 100644
--- a/CQRSlite.nuspec
+++ b/CQRSlite.nuspec
@@ -11,7 +11,7 @@
A lightweight framework to help write CQRS and Eventsourcing applications in C#
Copyright 2017
-
+
@@ -36,7 +36,7 @@
-
-
+
+
diff --git a/Framework/CQRSlite/Bus/InProcessBus.cs b/Framework/CQRSlite/Bus/InProcessBus.cs
index 1db35b7..b3de4bd 100644
--- a/Framework/CQRSlite/Bus/InProcessBus.cs
+++ b/Framework/CQRSlite/Bus/InProcessBus.cs
@@ -35,7 +35,8 @@ public void RegisterHandler(Func handler) where T
public Task Publish(T @event, CancellationToken cancellationToken = default(CancellationToken)) where T : class, IEvent
{
if (!_routes.TryGetValue(@event.GetType(), out var handlers))
- return Task.CompletedTask;
+ return Task.FromResult(0);
+
return Task.WhenAll(handlers.Select(handler => handler(@event, cancellationToken)));
}
}
diff --git a/Framework/CQRSlite/CQRSlite.csproj b/Framework/CQRSlite/CQRSlite.csproj
index 5efeafc..54ce9de 100644
--- a/Framework/CQRSlite/CQRSlite.csproj
+++ b/Framework/CQRSlite/CQRSlite.csproj
@@ -1,6 +1,6 @@
- netstandard1.3;netstandard1.5;net461
+ netstandard1.3;netstandard1.5;net452
TRACE;DEBUG
@@ -18,7 +18,7 @@
-
+
diff --git a/Framework/CQRSlite/Cache/MemoryCache.cs b/Framework/CQRSlite/Cache/MemoryCache.cs
index 713916e..a4a93fb 100644
--- a/Framework/CQRSlite/Cache/MemoryCache.cs
+++ b/Framework/CQRSlite/Cache/MemoryCache.cs
@@ -1,6 +1,6 @@
using System;
using CQRSlite.Domain;
-#if NET461
+#if NET452
using System.Runtime.Caching;
#else
using Microsoft.Extensions.Caching.Memory;
@@ -10,7 +10,7 @@ namespace CQRSlite.Cache
{
public class MemoryCache : ICache
{
-#if NET461
+#if NET452
private readonly System.Runtime.Caching.MemoryCache _cache;
private Func _policyFactory;
#else
@@ -21,7 +21,7 @@ public class MemoryCache : ICache
public MemoryCache()
{
-#if NET461
+#if NET452
_cache = System.Runtime.Caching.MemoryCache.Default;
_policyFactory = () => new CacheItemPolicy {
SlidingExpiration = TimeSpan.FromMinutes(15)
@@ -38,7 +38,7 @@ public MemoryCache()
public bool IsTracked(Guid id)
{
-#if NET461
+#if NET452
return _cache.Contains(id.ToString());
#else
return _cache.TryGetValue(id, out var o) && o != null;
@@ -47,7 +47,7 @@ public bool IsTracked(Guid id)
public void Set(Guid id, AggregateRoot aggregate)
{
-#if NET461
+#if NET452
_cache.Add(id.ToString(), aggregate, _policyFactory.Invoke());
#else
_cache.Set(id, aggregate, _cacheOptions);
@@ -56,7 +56,7 @@ public void Set(Guid id, AggregateRoot aggregate)
public AggregateRoot Get(Guid id)
{
-#if NET461
+#if NET452
return (AggregateRoot)_cache.Get(id.ToString());
#else
return (AggregateRoot) _cache.Get(id);
@@ -65,7 +65,7 @@ public AggregateRoot Get(Guid id)
public void Remove(Guid id)
{
-#if NET461
+#if NET452
_cache.Remove(id.ToString());
#else
_cache.Remove(id);
@@ -74,7 +74,7 @@ public void Remove(Guid id)
public void RegisterEvictionCallback(Action action)
{
-#if NET461
+#if NET452
_policyFactory = () => new CacheItemPolicy
{
SlidingExpiration = TimeSpan.FromMinutes(15),
diff --git a/Framework/CQRSlite/Domain/Session.cs b/Framework/CQRSlite/Domain/Session.cs
index 7a05658..d265525 100644
--- a/Framework/CQRSlite/Domain/Session.cs
+++ b/Framework/CQRSlite/Domain/Session.cs
@@ -28,7 +28,7 @@ public Session(IRepository repository)
{
throw new ConcurrencyException(aggregate.Id);
}
- return Task.CompletedTask;
+ return Task.FromResult(0);
}
public async Task Get(Guid id, int? expectedVersion = null, CancellationToken cancellationToken = default(CancellationToken)) where T : AggregateRoot
diff --git a/Framework/CQRSlite/Snapshots/SnapshotRepository.cs b/Framework/CQRSlite/Snapshots/SnapshotRepository.cs
index 8e04d1e..1cf5405 100644
--- a/Framework/CQRSlite/Snapshots/SnapshotRepository.cs
+++ b/Framework/CQRSlite/Snapshots/SnapshotRepository.cs
@@ -58,7 +58,7 @@ private async Task TryRestoreAggregateFromSnapshot(Guid id, T aggregate,
private Task TryMakeSnapshot(AggregateRoot aggregate)
{
if (!_snapshotStrategy.ShouldMakeSnapShot(aggregate))
- return Task.CompletedTask;
+ return Task.FromResult(0);
var snapshot = aggregate.AsDynamic().GetSnapshot();
snapshot.Version = aggregate.Version + aggregate.GetUncommittedChanges().Length;