Skip to content

Commit

Permalink
Merge branch 'release/6.0-rc2' into release/6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcvickers committed Sep 17, 2021
2 parents b58a57f + 99de4a6 commit a69c2ca
Show file tree
Hide file tree
Showing 21 changed files with 681 additions and 208 deletions.
44 changes: 22 additions & 22 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="6.0.0-rc.2.21464.21">
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="6.0.0-rc.2.21466.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>b3a9b0b740cce9322b03200db0b4ab736d7cd12d</Sha>
<Sha>0bc0c0ac28e74b5d107781a3caa456f9ef2be4bb</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.0-rc.2.21464.21">
<Dependency Name="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.0-rc.2.21466.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>b3a9b0b740cce9322b03200db0b4ab736d7cd12d</Sha>
<Sha>0bc0c0ac28e74b5d107781a3caa456f9ef2be4bb</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0-rc.2.21464.21">
<Dependency Name="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0-rc.2.21466.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>b3a9b0b740cce9322b03200db0b4ab736d7cd12d</Sha>
<Sha>0bc0c0ac28e74b5d107781a3caa456f9ef2be4bb</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="6.0.0-rc.2.21464.21">
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="6.0.0-rc.2.21466.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>b3a9b0b740cce9322b03200db0b4ab736d7cd12d</Sha>
<Sha>0bc0c0ac28e74b5d107781a3caa456f9ef2be4bb</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration" Version="6.0.0-rc.2.21464.21">
<Dependency Name="Microsoft.Extensions.Configuration" Version="6.0.0-rc.2.21466.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>b3a9b0b740cce9322b03200db0b4ab736d7cd12d</Sha>
<Sha>0bc0c0ac28e74b5d107781a3caa456f9ef2be4bb</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="6.0.0-rc.2.21464.21">
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="6.0.0-rc.2.21466.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>b3a9b0b740cce9322b03200db0b4ab736d7cd12d</Sha>
<Sha>0bc0c0ac28e74b5d107781a3caa456f9ef2be4bb</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="6.0.0-rc.2.21464.21">
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="6.0.0-rc.2.21466.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>b3a9b0b740cce9322b03200db0b4ab736d7cd12d</Sha>
<Sha>0bc0c0ac28e74b5d107781a3caa456f9ef2be4bb</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.HostFactoryResolver.Sources" Version="6.0.0-rc.2.21464.21">
<Dependency Name="Microsoft.Extensions.HostFactoryResolver.Sources" Version="6.0.0-rc.2.21466.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>b3a9b0b740cce9322b03200db0b4ab736d7cd12d</Sha>
<Sha>0bc0c0ac28e74b5d107781a3caa456f9ef2be4bb</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Logging" Version="6.0.0-rc.2.21464.21">
<Dependency Name="Microsoft.Extensions.Logging" Version="6.0.0-rc.2.21466.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>b3a9b0b740cce9322b03200db0b4ab736d7cd12d</Sha>
<Sha>0bc0c0ac28e74b5d107781a3caa456f9ef2be4bb</Sha>
</Dependency>
<Dependency Name="System.Collections.Immutable" Version="6.0.0-rc.2.21464.21">
<Dependency Name="System.Collections.Immutable" Version="6.0.0-rc.2.21466.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>b3a9b0b740cce9322b03200db0b4ab736d7cd12d</Sha>
<Sha>0bc0c0ac28e74b5d107781a3caa456f9ef2be4bb</Sha>
</Dependency>
<Dependency Name="System.Diagnostics.DiagnosticSource" Version="6.0.0-rc.2.21464.21">
<Dependency Name="System.Diagnostics.DiagnosticSource" Version="6.0.0-rc.2.21466.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>b3a9b0b740cce9322b03200db0b4ab736d7cd12d</Sha>
<Sha>0bc0c0ac28e74b5d107781a3caa456f9ef2be4bb</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
22 changes: 11 additions & 11 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
<UsingToolXliff>False</UsingToolXliff>
</PropertyGroup>
<PropertyGroup Label="Dependencies from dotnet/runtime">
<SystemCollectionsImmutableVersion>6.0.0-rc.2.21464.21</SystemCollectionsImmutableVersion>
<SystemDiagnosticsDiagnosticSourceVersion>6.0.0-rc.2.21464.21</SystemDiagnosticsDiagnosticSourceVersion>
<MicrosoftExtensionsCachingMemoryVersion>6.0.0-rc.2.21464.21</MicrosoftExtensionsCachingMemoryVersion>
<MicrosoftExtensionsConfigurationVersion>6.0.0-rc.2.21464.21</MicrosoftExtensionsConfigurationVersion>
<MicrosoftExtensionsConfigurationAbstractionsVersion>6.0.0-rc.2.21464.21</MicrosoftExtensionsConfigurationAbstractionsVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>6.0.0-rc.2.21464.21</MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>
<MicrosoftExtensionsConfigurationJsonVersion>6.0.0-rc.2.21464.21</MicrosoftExtensionsConfigurationJsonVersion>
<MicrosoftExtensionsDependencyInjectionVersion>6.0.0-rc.2.21464.21</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsDependencyModelVersion>6.0.0-rc.2.21464.21</MicrosoftExtensionsDependencyModelVersion>
<MicrosoftExtensionsHostFactoryResolverSourcesVersion>6.0.0-rc.2.21464.21</MicrosoftExtensionsHostFactoryResolverSourcesVersion>
<MicrosoftExtensionsLoggingVersion>6.0.0-rc.2.21464.21</MicrosoftExtensionsLoggingVersion>
<SystemCollectionsImmutableVersion>6.0.0-rc.2.21466.4</SystemCollectionsImmutableVersion>
<SystemDiagnosticsDiagnosticSourceVersion>6.0.0-rc.2.21466.4</SystemDiagnosticsDiagnosticSourceVersion>
<MicrosoftExtensionsCachingMemoryVersion>6.0.0-rc.2.21466.4</MicrosoftExtensionsCachingMemoryVersion>
<MicrosoftExtensionsConfigurationVersion>6.0.0-rc.2.21466.4</MicrosoftExtensionsConfigurationVersion>
<MicrosoftExtensionsConfigurationAbstractionsVersion>6.0.0-rc.2.21466.4</MicrosoftExtensionsConfigurationAbstractionsVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>6.0.0-rc.2.21466.4</MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>
<MicrosoftExtensionsConfigurationJsonVersion>6.0.0-rc.2.21466.4</MicrosoftExtensionsConfigurationJsonVersion>
<MicrosoftExtensionsDependencyInjectionVersion>6.0.0-rc.2.21466.4</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsDependencyModelVersion>6.0.0-rc.2.21466.4</MicrosoftExtensionsDependencyModelVersion>
<MicrosoftExtensionsHostFactoryResolverSourcesVersion>6.0.0-rc.2.21466.4</MicrosoftExtensionsHostFactoryResolverSourcesVersion>
<MicrosoftExtensionsLoggingVersion>6.0.0-rc.2.21466.4</MicrosoftExtensionsLoggingVersion>
</PropertyGroup>
<PropertyGroup Label="Other dependencies">
<MicrosoftCodeAnalysisVersion>3.7.0</MicrosoftCodeAnalysisVersion>
Expand Down
63 changes: 36 additions & 27 deletions src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
Expand Down Expand Up @@ -614,36 +615,40 @@ protected virtual void GenerateKey(
Check.NotNull(key, nameof(key));
Check.NotNull(stringBuilder, nameof(stringBuilder));

stringBuilder
.AppendLine()
var keyBuilderName = new StringBuilder()
.Append(entityTypeBuilderName)
.Append(primary ? ".HasKey(" : ".HasAlternateKey(")
.Append(string.Join(", ", key.Properties.Select(p => Code.Literal(p.Name))))
.Append(")");
.Append(")")
.ToString();

stringBuilder
.AppendLine()
.Append(keyBuilderName);

// Note that GenerateAnnotations below does the corresponding decrement
stringBuilder.IncrementIndent();

GenerateKeyAnnotations(entityTypeBuilderName, key, stringBuilder);
GenerateKeyAnnotations(keyBuilderName, key, stringBuilder);
}

/// <summary>
/// Generates code for the annotations on a key.
/// </summary>
/// <param name="entityTypeBuilderName"> The name of the builder variable. </param>
/// <param name="keyBuilderName"> The name of the builder variable. </param>
/// <param name="key"> The key. </param>
/// <param name="stringBuilder"> The builder code is added to. </param>
protected virtual void GenerateKeyAnnotations(string entityTypeBuilderName, IKey key, IndentedStringBuilder stringBuilder)
protected virtual void GenerateKeyAnnotations(string keyBuilderName, IKey key, IndentedStringBuilder stringBuilder)
{
Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName));
Check.NotNull(keyBuilderName, nameof(keyBuilderName));
Check.NotNull(key, nameof(key));
Check.NotNull(stringBuilder, nameof(stringBuilder));

var annotations = Dependencies.AnnotationCodeGenerator
.FilterIgnoredAnnotations(key.GetAnnotations())
.ToDictionary(a => a.Name, a => a);

GenerateAnnotations(entityTypeBuilderName, key, stringBuilder, annotations, inChainedCall: true);
GenerateAnnotations(keyBuilderName, key, stringBuilder, annotations, inChainedCall: true);
}

/// <summary>
Expand Down Expand Up @@ -1056,9 +1061,11 @@ protected virtual void GenerateForeignKey(
Check.NotNull(foreignKey, nameof(foreignKey));
Check.NotNull(stringBuilder, nameof(stringBuilder));

var foreignKeyBuilderNameStringBuilder = new StringBuilder();

if (!foreignKey.IsOwnership)
{
stringBuilder
foreignKeyBuilderNameStringBuilder
.Append(entityTypeBuilderName)
.Append(".HasOne(")
.Append(Code.Literal(foreignKey.PrincipalEntityType.Name))
Expand All @@ -1070,19 +1077,23 @@ protected virtual void GenerateForeignKey(
}
else
{
stringBuilder
foreignKeyBuilderNameStringBuilder
.Append(entityTypeBuilderName)
.Append(".WithOwner(");

if (foreignKey.DependentToPrincipal != null)
{
stringBuilder
foreignKeyBuilderNameStringBuilder
.Append(Code.Literal(foreignKey.DependentToPrincipal.Name));
}
}

foreignKeyBuilderNameStringBuilder.Append(")");

var foreignKeyBuilderName = foreignKeyBuilderNameStringBuilder.ToString();

stringBuilder
.Append(")")
.Append(foreignKeyBuilderName)
.AppendLine();

// Note that GenerateAnnotations below does the corresponding decrement
Expand Down Expand Up @@ -1170,29 +1181,29 @@ protected virtual void GenerateForeignKey(
}
}

GenerateForeignKeyAnnotations(entityTypeBuilderName, foreignKey, stringBuilder);
GenerateForeignKeyAnnotations(foreignKeyBuilderName, foreignKey, stringBuilder);
}

/// <summary>
/// Generates code for the annotations on a foreign key.
/// </summary>
/// <param name="entityTypeBuilderName"> The name of the builder variable. </param>
/// <param name="foreignKeyBuilderName"> The name of the builder variable. </param>
/// <param name="foreignKey"> The foreign key. </param>
/// <param name="stringBuilder"> The builder code is added to. </param>
protected virtual void GenerateForeignKeyAnnotations(
string entityTypeBuilderName,
string foreignKeyBuilderName,
IForeignKey foreignKey,
IndentedStringBuilder stringBuilder)
{
Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName));
Check.NotNull(foreignKeyBuilderName, nameof(foreignKeyBuilderName));
Check.NotNull(foreignKey, nameof(foreignKey));
Check.NotNull(stringBuilder, nameof(stringBuilder));

var annotations = Dependencies.AnnotationCodeGenerator
.FilterIgnoredAnnotations(foreignKey.GetAnnotations())
.ToDictionary(a => a.Name, a => a);

GenerateAnnotations(entityTypeBuilderName, foreignKey, stringBuilder, annotations, inChainedCall: true);
GenerateAnnotations(foreignKeyBuilderName, foreignKey, stringBuilder, annotations, inChainedCall: true);
}

/// <summary>
Expand Down Expand Up @@ -1269,11 +1280,9 @@ protected virtual void GenerateNavigation(
Check.NotNull(navigation, nameof(navigation));
Check.NotNull(stringBuilder, nameof(stringBuilder));

stringBuilder
.Append(entityTypeBuilderName)
.Append(".Navigation(")
.Append(Code.Literal(navigation.Name))
.Append(")");
var navigationBuilderName = $"{entityTypeBuilderName}.Navigation({Code.Literal(navigation.Name)})";

stringBuilder.Append(navigationBuilderName);

// Note that GenerateAnnotations below does the corresponding decrement
stringBuilder.IncrementIndent();
Expand All @@ -1287,29 +1296,29 @@ protected virtual void GenerateNavigation(
.Append(".IsRequired()");
}

GenerateNavigationAnnotations(entityTypeBuilderName, navigation, stringBuilder);
GenerateNavigationAnnotations(navigationBuilderName, navigation, stringBuilder);
}

/// <summary>
/// Generates code for the annotations on a navigation.
/// </summary>
/// <param name="entityTypeBuilderName"> The name of the builder variable. </param>
/// <param name="navigationBuilderName"> The name of the builder variable. </param>
/// <param name="navigation"> The navigation. </param>
/// <param name="stringBuilder"> The builder code is added to. </param>
protected virtual void GenerateNavigationAnnotations(
string entityTypeBuilderName,
string navigationBuilderName,
INavigation navigation,
IndentedStringBuilder stringBuilder)
{
Check.NotNull(entityTypeBuilderName, nameof(entityTypeBuilderName));
Check.NotNull(navigationBuilderName, nameof(navigationBuilderName));
Check.NotNull(navigation, nameof(navigation));
Check.NotNull(stringBuilder, nameof(stringBuilder));

var annotations = Dependencies.AnnotationCodeGenerator
.FilterIgnoredAnnotations(navigation.GetAnnotations())
.ToDictionary(a => a.Name, a => a);

GenerateAnnotations(entityTypeBuilderName, navigation, stringBuilder, annotations, inChainedCall: true);
GenerateAnnotations(navigationBuilderName, navigation, stringBuilder, annotations, inChainedCall: true);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;

namespace Microsoft.EntityFrameworkCore.Query.Internal
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 class QueryExpressionReplacingExpressionVisitor : ExpressionVisitor
{
private readonly Expression _oldQuery;
private readonly Expression _newQuery;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 QueryExpressionReplacingExpressionVisitor(Expression oldQuery, Expression newQuery)
{
_oldQuery = oldQuery;
_newQuery = newQuery;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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>
[return: NotNullIfNotNull("expression")]
public override Expression? Visit(Expression? expression)
{
return expression is ProjectionBindingExpression projectionBindingExpression
&& ReferenceEquals(projectionBindingExpression.QueryExpression, _oldQuery)
? projectionBindingExpression.ProjectionMember != null
? new ProjectionBindingExpression(
_newQuery, projectionBindingExpression.ProjectionMember!, projectionBindingExpression.Type)
: new ProjectionBindingExpression(
_newQuery, projectionBindingExpression.Index!.Value, projectionBindingExpression.Type)
: base.Visit(expression);
}
}
}
Loading

0 comments on commit a69c2ca

Please sign in to comment.