Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Net5.0 and Net6.0-preview5 TargetFramework #22

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static Func<TContext, TKey, Task<TEntity>> CreateQuery<TContext, TGrain,
var compiledLambdaBody = Expression.Call(
typeof(EntityFrameworkQueryableExtensions).GetMethods().Single(mi =>
mi.Name == nameof(EntityFrameworkQueryableExtensions.SingleOrDefaultAsync) &&
mi.GetParameters().Count() == 3)
mi.GetParameters().Count() == 3 && mi.GetParameters()[1].ParameterType.Name.StartsWith("Expression"))
.MakeGenericMethod(typeof(TEntity)),
queryable,
Expression.Quote(predicate),
Expand Down Expand Up @@ -76,7 +76,7 @@ public static Func<TContext, TKey, string, Task<TEntity>> CreateCompoundQuery<TC
var compiledLambdaBody = Expression.Call(
typeof(EntityFrameworkQueryableExtensions).GetMethods().Single(mi =>
mi.Name == nameof(EntityFrameworkQueryableExtensions.SingleOrDefaultAsync) &&
mi.GetParameters().Count() == 3)
mi.GetParameters().Count() == 3 && mi.GetParameters()[1].ParameterType.Name.StartsWith("Expression"))
.MakeGenericMethod(typeof(TEntity)),
queryable,
Expression.Quote(predicate),
Expand Down Expand Up @@ -105,7 +105,7 @@ public static Func<TContext, TKey, Task<TEntity>> CreateCompiledQuery<TContext,

var compiledLambdaBody = Expression.Call(
typeof(Queryable).GetMethods().Single(mi =>
mi.Name == nameof(Queryable.SingleOrDefault) && mi.GetParameters().Count() == 2)
mi.Name == nameof(Queryable.SingleOrDefault) && mi.GetParameters().Count() == 2 && mi.GetParameters()[1].ParameterType.Name.StartsWith("Expression"))
.MakeGenericMethod(typeof(TEntity)),
queryable,
Expression.Quote(predicate));
Expand Down Expand Up @@ -149,7 +149,7 @@ public static Expression<Func<TEntity, bool>> CreateKeyPredicate<TEntity, TKey>(

var compiledLambdaBody = Expression.Call(
typeof(Queryable).GetMethods().Single(mi =>
mi.Name == nameof(Queryable.SingleOrDefault) && mi.GetParameters().Count() == 2)
mi.Name == nameof(Queryable.SingleOrDefault) && mi.GetParameters().Count() == 2 && mi.GetParameters()[1].ParameterType.Name.StartsWith("Expression"))
.MakeGenericMethod(typeof(TEntity)),
queryable,
Expression.Quote(predicate));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net5.0;net6.0</TargetFrameworks>
<IsPackable>True</IsPackable>
</PropertyGroup>

<!-- Workaround for this bug (replace the analyzer name with the one you need to exclude (filename only, no extension) -->
<!--https://github.com/dotnet/runtime/issues/53476-->
<!--https://github.com/dotnet/aspnetcore/issues/33747-->
<!--https://github.com/dotnet/sdk/issues/18269-->
<!--https://github.com/dotnet/sdk/issues/18148-->
<!--https://github.com/dotnet/runtime/issues/53454-->
<Target Name="RemoveLoggingAnalyzer" BeforeTargets="CoreCompile">
<ItemGroup>
<Analyzer Remove="@(Analyzer)" Condition="%(FileName) == 'Microsoft.Extensions.Logging.Generators'" />
</ItemGroup>
</Target>

<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand All @@ -23,11 +34,24 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="Microsoft.Extensions.Options" />
<PackageReference Include="Microsoft.Orleans.Core" />
<PackageReference Include="Microsoft.Orleans.Runtime.Abstractions" />
<ItemGroup>
<PackageReference Include="Microsoft.Orleans.Core" Version="3.4.3" />
<PackageReference Include="Microsoft.Orleans.Runtime.Abstractions" Version="3.4.3"/>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.16"/>
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7"/>
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-preview.5.21301.9"/>
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0-preview.5.21301.5" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,22 @@ TestGrainReference grainRef

// This should fail
grainState.State.Title = "Failing Update";
await Assert.ThrowsAsync<InconsistentStateException>(() =>
//This fail at Net6.0
// await Assert.ThrowsAsync<InconsistentStateException>(() =>
// _storage.WriteStateAsync(typeof(GrainWithIntegerKeyWithEtag).FullName,
// grainRef,
// grainState));

try
{
_storage.WriteStateAsync(typeof(GrainWithIntegerKeyWithEtag).FullName,
grainRef,
grainState));
grainState);
}
catch (Exception ex)
{
Assert.True(ex is InconsistentStateException);
}
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ object IGrainState.State
public Type Type => typeof(TestGrainState<T>);

public string ETag { get; set; }
public bool RecordExists { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,16 @@ protected override void OnModelCreating(ModelBuilder builder)

builder.Entity<EntityWithIntegerKeyWithEtag>()
.Property(e => e.ETag)
.HasConversion<byte[]>(
value => BitConverter.GetBytes(Random.Next()),
storedValue => storedValue
)
.IsConcurrencyToken();

//A timestamp/rowversion is a property for which a new value is automatically generated by the database every time a row is inserted or updated. see https://docs.microsoft.com/en-us/ef/core/modeling/concurrency?tabs=fluent-api#timestamprowversion
//duplicate! Model had set this "public byte[] ETag { get; set; }= BitConverter.GetBytes(Random.Next());"

//.HasConversion<byte[]>(
// value => BitConverter.GetBytes(Random.Next()),
// storedValue => storedValue
//)
//.IsConcurrencyToken();
.IsRowVersion();

builder.Entity<EntityWithGuidCompoundKey>()
.HasKey(e => new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class EntityWithStringKey : Entity<string>

public class EntityWithIntegerKeyWithEtag : EntityWithIntegerKey
{
[Timestamp]
//[Timestamp]
public byte[] ETag { get; set; } = BitConverter.GetBytes(Random.Next());


Expand Down Expand Up @@ -129,4 +129,4 @@ public class InvalidConfiguredEntityWithCustomGuidKey

public bool IsPersisted { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,71 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<IsPackable>False</IsPackable>
</PropertyGroup>

<!-- Workaround for this bug (replace the analyzer name with the one you need to exclude (filename only, no extension) -->
<!--https://github.com/dotnet/runtime/issues/53476-->
<!--https://github.com/dotnet/aspnetcore/issues/33747-->
<!--https://github.com/dotnet/sdk/issues/18269-->
<!--https://github.com/dotnet/sdk/issues/18148-->
<!--https://github.com/dotnet/runtime/issues/53454-->
<Target Name="RemoveLoggingAnalyzer" BeforeTargets="CoreCompile">
<ItemGroup>
<Analyzer Remove="@(Analyzer)" Condition="%(FileName) == 'Microsoft.Extensions.Logging.Generators'" />
<Analyzer Remove="@(Analyzer)" Condition="%(FileName) == 'System.Text.Json.SourceGeneration'" />
</ItemGroup>
</Target>

<PropertyGroup>
<LangVersion>7.1</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="xunit" Version="2.4.1" />

<PackageReference Include="coverlet.collector" Version="3.0.3">
<IncludeAssets>runtime; build; native; contentfiles; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="microsoft.orleans.core.abstractions" Version="3.4.3" />
<PackageReference Include="microsoft.orleans.core" Version="3.4.3" />
</ItemGroup>

<!--<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<IncludeAssets>runtime; build; native; contentfiles; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="dotnet-xunit" />
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="microsoft.orleans.core.abstractions" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.reporters" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="Microsoft.Extensions.Logging.console" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.16"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.16" />
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
</ItemGroup>-->

<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.7" />
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-preview.5.21301.9"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0-preview.5.21301.9" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0-preview.5.21301.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0-preview.5.21301.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Orleans.Providers.EntityFramework\Orleans.Providers.EntityFramework.csproj" />
</ItemGroup>
Expand Down
34 changes: 30 additions & 4 deletions toys/TestConsole/TestConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,39 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net5.0;net6.0</TargetFrameworks>
<IsPackable>False</IsPackable>
</PropertyGroup>
<!-- Workaround for this bug (replace the analyzer name with the one you need to exclude (filename only, no extension) -->
<!--https://github.com/dotnet/runtime/issues/53476-->
<!--https://github.com/dotnet/aspnetcore/issues/33747-->
<!--https://github.com/dotnet/sdk/issues/18269-->
<!--https://github.com/dotnet/sdk/issues/18148-->
<!--https://github.com/dotnet/runtime/issues/53454-->
<Target Name="RemoveLoggingAnalyzer" BeforeTargets="CoreCompile">
<ItemGroup>
<Analyzer Remove="@(Analyzer)" Condition="%(FileName) == 'Microsoft.Extensions.Logging.Generators'" />
</ItemGroup>
</Target>


<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.16" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.16" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.7" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-preview.5.21301.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0-preview.5.21301.9" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Orleans.Providers.EntityFramework\Orleans.Providers.EntityFramework.csproj" />
</ItemGroup>

</Project>