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

[automated] Merge branch 'release/8.0' => 'main' #31582

Merged
merged 4 commits into from
Aug 31, 2023
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
52 changes: 26 additions & 26 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="8.0.0-rc.2.23426.4">
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0-rc.2.23426.4">
<Dependency Name="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0-rc.2.23426.4">
<Dependency Name="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.2.23426.4">
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration" Version="8.0.0-rc.2.23426.4">
<Dependency Name="Microsoft.Extensions.Configuration" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="8.0.0-rc.2.23426.4">
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="8.0.0-rc.2.23426.4">
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.HostFactoryResolver.Sources" Version="8.0.0-rc.2.23426.4">
<Dependency Name="Microsoft.Extensions.HostFactoryResolver.Sources" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Logging" Version="8.0.0-rc.2.23426.4">
<Dependency Name="Microsoft.Extensions.Logging" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
<Dependency Name="System.Text.Json" Version="8.0.0-rc.2.23426.4">
<Dependency Name="System.Text.Json" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="8.0.0-rc.2.23426.4">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="8.0.0-rc.2.23426.4">
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
<!-- NB: Using BrowserDebugHost to represent the nonshipping version of Microsoft.NETCore.App -->
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="8.0.0-rc.2.23426.4">
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="8.0.0-rc.2.23430.5">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
26 changes: 13 additions & 13 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
<UsingToolXliff>False</UsingToolXliff>
</PropertyGroup>
<PropertyGroup Label="Dependencies from dotnet/runtime">
<MicrosoftExtensionsCachingMemoryVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsCachingMemoryVersion>
<MicrosoftExtensionsConfigurationVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsConfigurationVersion>
<MicrosoftExtensionsConfigurationAbstractionsVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsConfigurationAbstractionsVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>
<MicrosoftExtensionsConfigurationJsonVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsConfigurationJsonVersion>
<MicrosoftExtensionsDependencyInjectionVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsDependencyModelVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsDependencyModelVersion>
<MicrosoftExtensionsHostFactoryResolverSourcesVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsHostFactoryResolverSourcesVersion>
<MicrosoftExtensionsLoggingVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsLoggingVersion>
<SystemTextJsonVersion>8.0.0-rc.2.23426.4</SystemTextJsonVersion>
<MicrosoftNETCoreAppRefVersion>8.0.0-rc.2.23426.4</MicrosoftNETCoreAppRefVersion>
<MicrosoftNETCoreAppRuntimewinx64Version>8.0.0-rc.2.23426.4</MicrosoftNETCoreAppRuntimewinx64Version>
<MicrosoftNETCoreBrowserDebugHostTransportVersion>8.0.0-rc.2.23426.4</MicrosoftNETCoreBrowserDebugHostTransportVersion>
<MicrosoftExtensionsCachingMemoryVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsCachingMemoryVersion>
<MicrosoftExtensionsConfigurationVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsConfigurationVersion>
<MicrosoftExtensionsConfigurationAbstractionsVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsConfigurationAbstractionsVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>
<MicrosoftExtensionsConfigurationJsonVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsConfigurationJsonVersion>
<MicrosoftExtensionsDependencyInjectionVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsDependencyModelVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsDependencyModelVersion>
<MicrosoftExtensionsHostFactoryResolverSourcesVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsHostFactoryResolverSourcesVersion>
<MicrosoftExtensionsLoggingVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsLoggingVersion>
<SystemTextJsonVersion>8.0.0-rc.2.23430.5</SystemTextJsonVersion>
<MicrosoftNETCoreAppRefVersion>8.0.0-rc.2.23430.5</MicrosoftNETCoreAppRefVersion>
<MicrosoftNETCoreAppRuntimewinx64Version>8.0.0-rc.2.23430.5</MicrosoftNETCoreAppRuntimewinx64Version>
<MicrosoftNETCoreBrowserDebugHostTransportVersion>8.0.0-rc.2.23430.5</MicrosoftNETCoreBrowserDebugHostTransportVersion>
</PropertyGroup>
<PropertyGroup Label="Dependencies from dotnet/arcade">
<MicrosoftDotNetBuildTasksTemplatingVersion>8.0.0-beta.23419.1</MicrosoftDotNetBuildTasksTemplatingVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore.Design;

/// <summary>
/// Design-time <see cref="MethodCallCodeFragment"/> extensions.
/// </summary>
public static class MethodCallCodeFragmentExtensions
{
/// <summary>
/// Gets the using statements required for this method call.
/// </summary>
/// <param name="methodCall">The method call.</param>
/// <returns>The usings.</returns>
public static IEnumerable<string> GetRequiredUsings(this MethodCallCodeFragment methodCall)
{
var method = methodCall.MethodInfo;
if (method?.IsStatic == true)
{
yield return method.DeclaringType!.Namespace!;
}

foreach (var argument in methodCall.Arguments)
{
if (argument is NestedClosureCodeFragment nestedClosure)
{
foreach (var nestedUsing in nestedClosure.MethodCalls.SelectMany(GetRequiredUsings))
{
yield return nestedUsing;
}
}
else if (argument is not null)
{
yield return argument.GetType().Namespace!;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ public virtual string TransformText()

}

var useProviderCall = providerCode.GenerateUseProvider(Options.ConnectionString);
usings.AddRange(useProviderCall.GetRequiredUsings());

this.Write(" => optionsBuilder");
this.Write(this.ToStringHelper.ToStringWithCulture(code.Fragment(providerCode.GenerateUseProvider(Options.ConnectionString), indent: 3)));
this.Write(this.ToStringHelper.ToStringWithCulture(code.Fragment(useProviderCall, indent: 3)));
this.Write(";\r\n\r\n");

}
Expand Down Expand Up @@ -617,7 +620,7 @@ public class CSharpDbContextGeneratorBase
/// <summary>
/// The string builder that generation-time code is using to assemble generated output
/// </summary>
protected System.Text.StringBuilder GenerationEnvironment
public System.Text.StringBuilder GenerationEnvironment
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ public partial class <#= Options.ContextName #> : DbContext
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
<#
}

var useProviderCall = providerCode.GenerateUseProvider(Options.ConnectionString);
usings.AddRange(useProviderCall.GetRequiredUsings());
#>
=> optionsBuilder<#= code.Fragment(providerCode.GenerateUseProvider(Options.ConnectionString), indent: 3) #>;
=> optionsBuilder<#= code.Fragment(useProviderCall, indent: 3) #>;

<#
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,17 @@ public virtual Expression Translate(SelectExpression selectExpression, Expressio

if (expression is MethodCallExpression methodCallExpression)
{
if (methodCallExpression.Method.IsGenericMethod
&& methodCallExpression.Method.DeclaringType == typeof(Enumerable)
&& methodCallExpression.Method.Name == nameof(Enumerable.ToList)
&& methodCallExpression.Arguments.Count == 1
&& methodCallExpression.Arguments[0].Type.TryGetElementType(typeof(IQueryable<>)) != null)
if (methodCallExpression is
{
Method.IsGenericMethod: true,
Method.Name: nameof(Enumerable.ToList),
Method: var method,
Arguments: [var argument]
}
&& method.DeclaringType == typeof(Enumerable)
&& argument.Type.TryGetElementType(typeof(IQueryable<>)) != null)
{
var subquery = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery(
methodCallExpression.Arguments[0]);
if (subquery != null)
if (_queryableMethodTranslatingExpressionVisitor.TranslateSubquery(argument) is ShapedQueryExpression subquery)
{
_clientProjections!.Add(subquery);
// expression.Type here will be List<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// </summary>
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public virtual CrossApplyExpression Update(TableExpressionBase table)
public override CrossApplyExpression Update(TableExpressionBase table)
=> table != Table
? new CrossApplyExpression(table, GetAnnotations())
: this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// </summary>
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public virtual CrossJoinExpression Update(TableExpressionBase table)
public override CrossJoinExpression Update(TableExpressionBase table)
=> table != Table
? new CrossJoinExpression(table, GetAnnotations())
: this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,22 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
/// <param name="joinPredicate">The <see cref="PredicateJoinExpressionBase.JoinPredicate" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public virtual InnerJoinExpression Update(TableExpressionBase table, SqlExpression joinPredicate)
public override InnerJoinExpression Update(TableExpressionBase table, SqlExpression joinPredicate)
=> table != Table || joinPredicate != JoinPredicate
? new InnerJoinExpression(table, joinPredicate, GetAnnotations())
: this;

/// <summary>
/// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will
/// return this expression.
/// </summary>
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public override InnerJoinExpression Update(TableExpressionBase table)
=> table != Table
? new InnerJoinExpression(table, JoinPredicate, GetAnnotations())
: this;

/// <inheritdoc />
protected override TableExpressionBase CreateWithAnnotations(IEnumerable<IAnnotation> annotations)
=> new InnerJoinExpression(Table, JoinPredicate, annotations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ protected JoinExpressionBase(TableExpressionBase table, IEnumerable<IAnnotation>
/// </summary>
public virtual TableExpressionBase Table { get; }

/// <summary>
/// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will
/// return this expression.
/// </summary>
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public abstract JoinExpressionBase Update(TableExpressionBase table);

/// <inheritdoc />
public override bool Equals(object? obj)
=> obj != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,22 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
/// <param name="joinPredicate">The <see cref="PredicateJoinExpressionBase.JoinPredicate" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public virtual LeftJoinExpression Update(TableExpressionBase table, SqlExpression joinPredicate)
public override LeftJoinExpression Update(TableExpressionBase table, SqlExpression joinPredicate)
=> table != Table || joinPredicate != JoinPredicate
? new LeftJoinExpression(table, joinPredicate, GetAnnotations())
: this;

/// <summary>
/// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will
/// return this expression.
/// </summary>
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public override LeftJoinExpression Update(TableExpressionBase table)
=> table != Table
? new LeftJoinExpression(table, JoinPredicate, GetAnnotations())
: this;

/// <inheritdoc />
protected override TableExpressionBase CreateWithAnnotations(IEnumerable<IAnnotation> annotations)
=> new LeftJoinExpression(Table, JoinPredicate, annotations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// </summary>
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public virtual OuterApplyExpression Update(TableExpressionBase table)
public override OuterApplyExpression Update(TableExpressionBase table)
=> table != Table
? new OuterApplyExpression(table, GetAnnotations())
: this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ protected PredicateJoinExpressionBase(
/// </summary>
public virtual SqlExpression JoinPredicate { get; }

/// <summary>
/// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will
/// return this expression.
/// </summary>
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
/// <param name="joinPredicate">The <see cref="PredicateJoinExpressionBase.JoinPredicate" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public abstract PredicateJoinExpressionBase Update(TableExpressionBase table, SqlExpression joinPredicate);

/// <inheritdoc />
public override bool Equals(object? obj)
=> obj != null
Expand Down
Loading