Skip to content

Commit

Permalink
Add .NET 5.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
VahidN committed Oct 14, 2020
1 parent c9d6dcf commit 8a4eb97
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.302
dotnet-version: 5.0
- name: Build DNTCaptcha.Core lib
run: dotnet build ./src/EFCoreSecondLevelCacheInterceptor/EFCoreSecondLevelCacheInterceptor.csproj --configuration Release
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.1.302"
"version": "5.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Entity Framework Core Second Level Caching Library.</Description>
<VersionPrefix>1.8.2</VersionPrefix>
<VersionPrefix>1.9.0</VersionPrefix>
<Authors>Vahid Nasiri</Authors>
<TargetFrameworks>netstandard2.0;net461;</TargetFrameworks>
<TargetFrameworks>net5.0;netstandard2.0;net461;</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>EFCoreSecondLevelCacheInterceptor</AssemblyName>
Expand All @@ -22,26 +22,39 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.6" />
<PackageReference Include="CacheManager.Core" Version="1.2.0" />
<PackageReference Include="EasyCaching.Core" Version="0.8.10" />
<PackageReference Include="EasyCaching.Core" Version="0.9.0" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net461'">
<DefineConstants>NET4_6_1</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.6" />
<PackageReference Include="CacheManager.Core" Version="1.2.0" />
<PackageReference Include="EasyCaching.Core" Version="0.8.10" />
<PackageReference Include="EasyCaching.Core" Version="0.9.0" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>NETSTANDARD2_0</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0-rc.2.20475.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.0-rc.2.20475.6" />
<PackageReference Include="CacheManager.Core" Version="1.2.0" />
<PackageReference Include="EasyCaching.Core" Version="0.9.0" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net5.0'">
<DefineConstants>NET5_0</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformTarget>anycpu</PlatformTarget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,30 @@ public SecondLevelCacheInterceptor(IDbCommandInterceptorProcessor processor)
/// <summary>
/// Called immediately after EF calls System.Data.Common.DbCommand.ExecuteNonQueryAsync.
/// </summary>
#if NET5_0
public override ValueTask<int> NonQueryExecutedAsync(
DbCommand command,
CommandExecutedEventData eventData,
int result,
CancellationToken cancellationToken = default)
#else
public override Task<int> NonQueryExecutedAsync(
DbCommand command,
CommandExecutedEventData eventData,
int result,
CancellationToken cancellationToken = default)
#endif
{
if (eventData.Context == null)
{
return base.NonQueryExecutedAsync(command, eventData, result, cancellationToken);
}

#if NET5_0
return ValueTask.FromResult(_processor.ProcessExecutedCommands(command, eventData.Context, result));
#else
return Task.FromResult(_processor.ProcessExecutedCommands(command, eventData.Context, result));
#endif
}

/// <summary>
Expand All @@ -76,18 +88,30 @@ public SecondLevelCacheInterceptor(IDbCommandInterceptorProcessor processor)
/// <summary>
/// Called just before EF intends to call System.Data.Common.DbCommand.ExecuteNonQueryAsync.
/// </summary>
#if NET5_0
public override ValueTask<InterceptionResult<int>> NonQueryExecutingAsync(
DbCommand command,
CommandEventData eventData,
InterceptionResult<int> result,
CancellationToken cancellationToken = default)
#else
public override Task<InterceptionResult<int>> NonQueryExecutingAsync(
DbCommand command,
CommandEventData eventData,
InterceptionResult<int> result,
CancellationToken cancellationToken = default)
#endif
{
if (eventData.Context == null)
{
return base.NonQueryExecutingAsync(command, eventData, result, cancellationToken);
}

#if NET5_0
return ValueTask.FromResult(_processor.ProcessExecutingCommands(command, eventData.Context, result));
#else
return Task.FromResult(_processor.ProcessExecutingCommands(command, eventData.Context, result));
#endif
}

/// <summary>
Expand All @@ -109,18 +133,30 @@ public SecondLevelCacheInterceptor(IDbCommandInterceptorProcessor processor)
/// <summary>
/// Called immediately after EF calls System.Data.Common.DbCommand.ExecuteReaderAsync.
/// </summary>
#if NET5_0
public override ValueTask<DbDataReader> ReaderExecutedAsync(
DbCommand command,
CommandExecutedEventData eventData,
DbDataReader result,
CancellationToken cancellationToken = default)
#else
public override Task<DbDataReader> ReaderExecutedAsync(
DbCommand command,
CommandExecutedEventData eventData,
DbDataReader result,
CancellationToken cancellationToken = default)
#endif
{
if (eventData.Context == null)
{
return base.ReaderExecutedAsync(command, eventData, result, cancellationToken);
}

#if NET5_0
return ValueTask.FromResult(_processor.ProcessExecutedCommands(command, eventData.Context, result));
#else
return Task.FromResult(_processor.ProcessExecutedCommands(command, eventData.Context, result));
#endif
}

/// <summary>
Expand All @@ -142,18 +178,30 @@ public SecondLevelCacheInterceptor(IDbCommandInterceptorProcessor processor)
/// <summary>
/// Called just before EF intends to call System.Data.Common.DbCommand.ExecuteReaderAsync.
/// </summary>
#if NET5_0
public override ValueTask<InterceptionResult<DbDataReader>> ReaderExecutingAsync(
DbCommand command,
CommandEventData eventData,
InterceptionResult<DbDataReader> result,
CancellationToken cancellationToken = default)
#else
public override Task<InterceptionResult<DbDataReader>> ReaderExecutingAsync(
DbCommand command,
CommandEventData eventData,
InterceptionResult<DbDataReader> result,
CancellationToken cancellationToken = default)
#endif
{
if (eventData.Context == null)
{
return base.ReaderExecutingAsync(command, eventData, result, cancellationToken);
}

#if NET5_0
return ValueTask.FromResult(_processor.ProcessExecutingCommands(command, eventData.Context, result));
#else
return Task.FromResult(_processor.ProcessExecutingCommands(command, eventData.Context, result));
#endif
}

/// <summary>
Expand All @@ -175,18 +223,30 @@ public SecondLevelCacheInterceptor(IDbCommandInterceptorProcessor processor)
/// <summary>
/// Called immediately after EF calls System.Data.Common.DbCommand.ExecuteScalarAsync.
/// </summary>
#if NET5_0
public override ValueTask<object> ScalarExecutedAsync(
DbCommand command,
CommandExecutedEventData eventData,
object result,
CancellationToken cancellationToken = default)
#else
public override Task<object> ScalarExecutedAsync(
DbCommand command,
CommandExecutedEventData eventData,
object result,
CancellationToken cancellationToken = default)
#endif
{
if (eventData.Context == null)
{
return base.ScalarExecutedAsync(command, eventData, result, cancellationToken);
}

#if NET5_0
return ValueTask.FromResult(_processor.ProcessExecutedCommands(command, eventData.Context, result));
#else
return Task.FromResult(_processor.ProcessExecutedCommands(command, eventData.Context, result));
#endif
}

/// <summary>
Expand All @@ -208,18 +268,30 @@ public SecondLevelCacheInterceptor(IDbCommandInterceptorProcessor processor)
/// <summary>
/// Called just before EF intends to call System.Data.Common.DbCommand.ExecuteScalarAsync.
/// </summary>
#if NET5_0
public override ValueTask<InterceptionResult<object>> ScalarExecutingAsync(
DbCommand command,
CommandEventData eventData,
InterceptionResult<object> result,
CancellationToken cancellationToken = default)
#else
public override Task<InterceptionResult<object>> ScalarExecutingAsync(
DbCommand command,
CommandEventData eventData,
InterceptionResult<object> result,
CancellationToken cancellationToken = default)
#endif
{
if (eventData.Context == null)
{
return base.ScalarExecutingAsync(command, eventData, result, cancellationToken);
}

#if NET5_0
return ValueTask.FromResult(_processor.ProcessExecutingCommands(command, eventData.Context, result));
#else
return Task.FromResult(_processor.ProcessExecutingCommands(command, eventData.Context, result));
#endif
}
}
}
2 changes: 1 addition & 1 deletion tag-it.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
git tag -a 1.8.2 -m "Published 1.8.2 to nuget.org"
git tag -a 1.9.0 -m "Published 1.9.0 to nuget.org"
git push --follow-tags
pause

0 comments on commit 8a4eb97

Please sign in to comment.