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

Try to embrace the future early #23296

Merged
merged 1 commit into from
Nov 18, 2020
Merged
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
7 changes: 2 additions & 5 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
</PropertyGroup>

<PropertyGroup>
<DefaultNetCoreTargetFramework>net5.0</DefaultNetCoreTargetFramework>
</PropertyGroup>

<PropertyGroup>
<StrongNameKeyId>MicrosoftAspNetCore</StrongNameKeyId>
<PackageTags>Entity Framework Core;entity-framework-core;EF;Data;O/RM;EntityFramework;EntityFrameworkCore;EFCore</PackageTags>
<Product>Microsoft Entity Framework Core</Product>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>8.0</LangVersion>
<WarningsNotAsErrors>nullable</WarningsNotAsErrors>
bricelam marked this conversation as resolved.
Show resolved Hide resolved
<LangVersion>9.0</LangVersion>
<DebugType>portable</DebugType>
<PackageProjectUrl>https://docs.microsoft.com/ef/core/</PackageProjectUrl>
</PropertyGroup>
Expand Down
23 changes: 3 additions & 20 deletions benchmark/EFCore.Benchmarks/EFCore.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug' ">netcoreapp3.1</TargetFrameworks>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Microsoft.EntityFrameworkCore.Benchmarks</RootNamespace>
</PropertyGroup>

<PropertyGroup Condition="$(Configuration.StartsWith('Release'))">
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize>
</PropertyGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug' ">
<ItemGroup>
<ProjectReference Include="..\..\src\EFCore.Relational\EFCore.Relational.csproj" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(MicrosoftCodeAnalysisVersion)" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release22' Or '$(Configuration)' == 'Debug22' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.4" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release21' Or '$(Configuration)' == 'Debug21' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.1.11" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release20' Or '$(Configuration)' == 'Debug20' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.0.3" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release22' Or '$(Configuration)' == 'Release21' Or '$(Configuration)' == 'Release20' Or '$(Configuration)' == 'Debug22' Or '$(Configuration)' == 'Debug21' Or '$(Configuration)' == 'Debug20'">
<DefineConstants>$(DefineConstants);OLD_FROM_SQL</DefineConstants>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug' ">netcoreapp3.1</TargetFrameworks>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Microsoft.EntityFrameworkCore.Benchmarks</RootNamespace>
<OutputType>Exe</OutputType>
</PropertyGroup>

<PropertyGroup Condition="$(Configuration.StartsWith('Release'))">
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize>
</PropertyGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug' ">
<ItemGroup>
<ProjectReference Include="..\..\src\EFCore.SqlServer\EFCore.SqlServer.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release22' Or '$(Configuration)' == 'Debug22' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release21' Or '$(Configuration)' == 'Debug21' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.11" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release20' Or '$(Configuration)' == 'Debug20' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.3" />
<ProjectReference Include="..\EFCore.Benchmarks\EFCore.Benchmarks.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -34,8 +22,4 @@
<None Remove="BenchmarkDotNet.Artifacts\**" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EFCore.Benchmarks\EFCore.Benchmarks.csproj" />
</ItemGroup>

</Project>
22 changes: 3 additions & 19 deletions benchmark/EFCore.Sqlite.Benchmarks/EFCore.Sqlite.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,42 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug' ">netcoreapp3.1</TargetFrameworks>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Microsoft.EntityFrameworkCore.Benchmarks</RootNamespace>
<OutputType>Exe</OutputType>
</PropertyGroup>

<PropertyGroup Condition="$(Configuration.StartsWith('Release'))">
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\EFCore.Benchmarks\EFCore.Benchmarks.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug' ">
<ProjectReference Include="..\..\src\EFCore.Sqlite.Core\EFCore.Sqlite.Core.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug' ">
<ItemGroup>
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.0.4" PrivateAssets="None" />
<PackageReference Include="Microsoft.Win32.Primitives" Version="4.3.0" />
<PackageReference Include="System.Net.Primitives" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release22' Or '$(Configuration)' == 'Debug22' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release21' Or '$(Configuration)' == 'Debug21' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.11" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release20' Or '$(Configuration)' == 'Debug20' ">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.0.3" />
</ItemGroup>

<ItemGroup>
<None Update="AdventureWorks2014.db">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.IO;

namespace Microsoft.EntityFrameworkCore.Benchmarks.Models.AdventureWorks
{
public static class AdventureWorksSqliteFixture
{
private static readonly string _baseDirectory
= Path.GetDirectoryName(new Uri(typeof(AdventureWorksSqliteFixture).Assembly.CodeBase).LocalPath);
= Path.GetDirectoryName(typeof(AdventureWorksSqliteFixture).Assembly.Location);

private static readonly string _connectionString
= $"Data Source={Path.Combine(_baseDirectory, "AdventureWorks2014.db")}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Benchmarks.Models.Orders
public class OrdersSqliteFixture : OrdersFixtureBase
{
private static readonly string _baseDirectory
= Path.GetDirectoryName(new Uri(typeof(OrdersSqliteFixture).Assembly.CodeBase).LocalPath);
= Path.GetDirectoryName(typeof(OrdersSqliteFixture).Assembly.Location);

private readonly string _connectionString;

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Abstractions/EFCore.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Provides abstractions and attributes that are used to configure Entity Framework Core</Description>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<MinClientVersion>3.6</MinClientVersion>
<AssemblyName>Microsoft.EntityFrameworkCore.Abstractions</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/EFCore.Cosmos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Azure Cosmos provider for Entity Framework Core.</Description>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<MinClientVersion>3.6</MinClientVersion>
<AssemblyName>Microsoft.EntityFrameworkCore.Cosmos</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore.Cosmos</RootNamespace>
Expand Down
7 changes: 3 additions & 4 deletions src/EFCore.Cosmos/Extensions/CosmosQueryableExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
Expand All @@ -19,9 +20,7 @@ namespace Microsoft.EntityFrameworkCore
public static class CosmosQueryableExtensions
{
internal static readonly MethodInfo WithPartitionKeyMethodInfo
= typeof(CosmosQueryableExtensions)
.GetTypeInfo()
.GetDeclaredMethod(nameof(WithPartitionKey));
= typeof(CosmosQueryableExtensions).GetRequiredDeclaredMethod(nameof(WithPartitionKey));

/// <summary>
/// Specify the partition key for partition used for the query. Required when using
Expand All @@ -33,7 +32,7 @@ internal static readonly MethodInfo WithPartitionKeyMethodInfo
/// <returns> A new query with the set partition key. </returns>
public static IQueryable<TEntity> WithPartitionKey<TEntity>(
[NotNull] this IQueryable<TEntity> source,
[NotNull] [NotParameterized] string partitionKey)
[NotNull][NotParameterized] string partitionKey)
where TEntity : class
{
Check.NotNull(source, nameof(source));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
{
var innerQueryable = Visit(methodCallExpression.Arguments[0]);

_cosmosQueryCompilationContext.PartitionKeyFromExtension =
(string)((ConstantExpression)methodCallExpression.Arguments[1]).Value;
_cosmosQueryCompilationContext.PartitionKeyFromExtension = methodCallExpression.Arguments[1].GetConstantValue<string>();

return innerQueryable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected override ProjectionExpression GetProjection(ProjectionBindingExpressio

private int GetProjectionIndex(ProjectionBindingExpression projectionBindingExpression)
=> projectionBindingExpression.ProjectionMember != null
? (int)((ConstantExpression)_selectExpression.GetMappedProjection(projectionBindingExpression.ProjectionMember)).Value
? _selectExpression.GetMappedProjection(projectionBindingExpression.ProjectionMember).GetConstantValue<int>()
: projectionBindingExpression.Index
?? throw new InvalidOperationException(CoreStrings.QueryFailed(projectionBindingExpression.Print(), GetType().Name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
var genericMethod = method.IsGenericMethod ? method.GetGenericMethodDefinition() : null;
if (genericMethod == EntityFrameworkCore.Infrastructure.ExpressionExtensions.ValueBufferTryReadValueMethod)
{
var property = (IProperty)((ConstantExpression)methodCallExpression.Arguments[2]).Value;
var property = methodCallExpression.Arguments[2].GetConstantValue<IProperty>();
Expression innerExpression;
if (methodCallExpression.Arguments[0] is ProjectionBindingExpression projectionBindingExpression)
{
Expand Down
6 changes: 3 additions & 3 deletions src/EFCore.Cosmos/Query/Internal/SqlConstantExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public SqlConstantExpression([NotNull] ConstantExpression constantExpression, [C
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual object Value
public virtual object? Value
=> _constantExpression.Value;

/// <summary>
Expand Down Expand Up @@ -83,7 +83,7 @@ protected override void Print(ExpressionPrinter expressionPrinter)
}

private void Print(
object value,
object? value,
ExpressionPrinter expressionPrinter)
{
if (value is IEnumerable enumerable
Expand All @@ -110,7 +110,7 @@ private void Print(
}
}

private JToken? GenerateJToken(object value, CoreTypeMapping? typeMapping)
private JToken? GenerateJToken(object? value, CoreTypeMapping? typeMapping)
{
var mappingClrType = typeMapping?.ClrType.UnwrapNullableType() ?? Type;
if (value?.GetType().IsInteger() == true
Expand Down
6 changes: 5 additions & 1 deletion src/EFCore.Cosmos/Query/Internal/SqlParameterExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
public sealed class SqlParameterExpression : SqlExpression
{
private readonly ParameterExpression _parameterExpression;
private readonly string _name;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -31,7 +32,10 @@ public sealed class SqlParameterExpression : SqlExpression
public SqlParameterExpression([NotNull] ParameterExpression parameterExpression, [CanBeNull] CoreTypeMapping? typeMapping)
: base(parameterExpression.Type, typeMapping)
{
Check.DebugAssert(parameterExpression.Name != null, "Parameter must have name.");

_parameterExpression = parameterExpression;
_name = parameterExpression.Name;
}

/// <summary>
Expand All @@ -41,7 +45,7 @@ public SqlParameterExpression([NotNull] ParameterExpression parameterExpression,
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public string Name
=> _parameterExpression.Name;
=> _name;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
6 changes: 3 additions & 3 deletions src/EFCore.Cosmos/Query/Internal/StringMethodTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
public class StringMethodTranslator : IMethodCallTranslator
{
private static readonly MethodInfo _containsMethodInfo
= typeof(string).GetRuntimeMethod(nameof(string.Contains), new[] { typeof(string) });
= typeof(string).GetRequiredRuntimeMethod(nameof(string.Contains), new[] { typeof(string) });

private static readonly MethodInfo _startsWithMethodInfo
= typeof(string).GetRuntimeMethod(nameof(string.StartsWith), new[] { typeof(string) });
= typeof(string).GetRequiredRuntimeMethod(nameof(string.StartsWith), new[] { typeof(string) });

private static readonly MethodInfo _endsWithMethodInfo
= typeof(string).GetRuntimeMethod(nameof(string.EndsWith), new[] { typeof(string) });
= typeof(string).GetRequiredRuntimeMethod(nameof(string.EndsWith), new[] { typeof(string) });

private static readonly MethodInfo _firstOrDefaultMethodInfoWithoutArgs
= typeof(Enumerable).GetRuntimeMethods().Single(
Expand Down
3 changes: 1 addition & 2 deletions src/EFCore.Design/EFCore.Design.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Shared design-time components for Entity Framework Core tools.</Description>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<AssemblyName>Microsoft.EntityFrameworkCore.Design</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down Expand Up @@ -31,7 +31,6 @@

<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.8.26" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.HostFactoryResolver.Sources" PrivateAssets="All" Version="$(MicrosoftExtensionsHostFactoryResolverSourcesVersion)" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.InMemory/EFCore.InMemory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>In-memory database provider for Entity Framework Core (to be used for testing purposes).</Description>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we extract this to the common Directory.Build.props or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I like to keep the csproj files relativly "vanilla" even if it's not as DRY. I hate hunting through msbuild files to find basic properties.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<MinClientVersion>3.6</MinClientVersion>
<AssemblyName>Microsoft.EntityFrameworkCore.InMemory</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore.InMemory</RootNamespace>
Expand Down
Loading