Skip to content

[automated] Merge branch 'release/9.0' => 'main' #35741

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

Merged
merged 24 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5da58c4
Merge commit 'd6af2df76c953d3140f1c67caa1d18c548f53892'
Jan 7, 2025
c331f21
Merge commit '20425191f4efe08fa1fad13e0daaf69613894f4b'
Jan 14, 2025
c0528cb
Merge commit 'da24700c1a2e0a8634067f7ef1ec4cf6a5d8cacb'
Jan 14, 2025
e14d5d8
Merge commit 'f8051b1767eb3ba8a37378be86ea97826e527bbc'
Jan 15, 2025
1bdfaae
Merged PR 46809: [internal/release/8.0] Update dependencies from dnce…
Jan 17, 2025
bd39e43
Merge branch 'release/8.0' into 'release/8.0-staging' (#35541)
AndriySvyryd Jan 28, 2025
60c5867
Merge commit '1bdfaaeddf567214d363aa2396fd4874abf204cc' into internal…
vseanreesermsft Feb 11, 2025
d8a07b1
Merge pull request #35621 from vseanreesermsft/internal-merge-8.0-202…
maumar Feb 11, 2025
73ed771
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Feb 12, 2025
336f505
Merge branch 'release/9.0' into merge/release/8.0-to-release/9.0
maumar Feb 14, 2025
d680b19
Merge pull request #35626 from dotnet/merge/release/8.0-to-release/9.0
maumar Feb 14, 2025
fb2f189
Set the environment when executing Scaffold-DBContext (#35693)
AndriySvyryd Feb 27, 2025
e52e0fb
Improve LoadExtension to work correctly with dotnet run and lib* name…
roji Mar 4, 2025
eeab918
Transform Span-based overloads to Enumerable in funcletizer (#35720)
roji Mar 4, 2025
7cbf9ce
Process Coalesce-simplified Convert node properly in funcletizer (#35…
roji Mar 4, 2025
6e2f99c
Improve LoadExtension to work correctly with dotnet run and lib* name…
roji Mar 4, 2025
67f52d8
Transform Span-based overloads to Enumerable in funcletizer (#35719)
roji Mar 5, 2025
51e50e9
Update branding to 8.0.15 (#35738)
vseanreesermsft Mar 6, 2025
a43de14
Update branding to 9.0.4 (#35739)
vseanreesermsft Mar 6, 2025
5f9d0dc
Merge branch 'release/8.0-staging' => 'release/8.0' (#35742)
AndriySvyryd Mar 6, 2025
873d1a5
Merge branch 'release/9.0-staging' => 'release/9.0' (#35743)
AndriySvyryd Mar 6, 2025
901da54
Merge branch 'release/8.0' into 'release/9.0'
AndriySvyryd Mar 7, 2025
c18fc67
[automated] Merge branch 'release/8.0' => 'release/9.0' (#35740)
AndriySvyryd Mar 7, 2025
3c9c35e
Merge branch 'release/9.0' into `main`
AndriySvyryd Mar 7, 2025
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
26 changes: 26 additions & 0 deletions src/EFCore.Design/Design/Internal/AppServiceProviderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,30 @@ private IServiceProvider CreateEmptyServiceProvider()

return new ServiceCollection().BuildServiceProvider();
}

/// <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 static void SetEnvironment(IOperationReporter reporter)
{
var aspnetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var dotnetEnvironment = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT");
var environment = aspnetCoreEnvironment
?? dotnetEnvironment
?? "Development";
if (aspnetCoreEnvironment == null)
{
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", environment);
}

if (dotnetEnvironment == null)
{
Environment.SetEnvironmentVariable("DOTNET_ENVIRONMENT", environment);
}

reporter.WriteVerbose(DesignStrings.UsingEnvironment(environment));
}
}
3 changes: 3 additions & 0 deletions src/EFCore.Design/Design/Internal/DatabaseOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Design.Internal;
/// </summary>
public class DatabaseOperations
{
private readonly IOperationReporter _reporter;
private readonly string _projectDir;
private readonly string? _rootNamespace;
private readonly string? _language;
Expand All @@ -34,6 +35,7 @@ public DatabaseOperations(
bool nullable,
string[]? args)
{
_reporter = reporter;
_projectDir = projectDir;
_rootNamespace = rootNamespace;
_language = language;
Expand Down Expand Up @@ -73,6 +75,7 @@ public virtual SavedModelFiles ScaffoldContext(
? Path.GetFullPath(Path.Combine(_projectDir, outputContextDir))
: outputDir;

AppServiceProviderFactory.SetEnvironment(_reporter);
var services = _servicesBuilder.Build(provider);
using var scope = services.CreateScope();

Expand Down
17 changes: 1 addition & 16 deletions src/EFCore.Design/Design/Internal/DbContextOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,22 +503,7 @@ private IDictionary<Type, Func<DbContext>> FindContextTypes(string? name = null,
{
_reporter.WriteVerbose(DesignStrings.FindingContexts);

var aspnetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var dotnetEnvironment = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT");
var environment = aspnetCoreEnvironment
?? dotnetEnvironment
?? "Development";
if (aspnetCoreEnvironment == null)
{
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", environment);
}

if (dotnetEnvironment == null)
{
Environment.SetEnvironmentVariable("DOTNET_ENVIRONMENT", environment);
}

_reporter.WriteVerbose(DesignStrings.UsingEnvironment(environment));
AppServiceProviderFactory.SetEnvironment(_reporter);

var contexts = new Dictionary<Type, Func<DbContext>?>();

Expand Down
70 changes: 68 additions & 2 deletions test/EFCore.Design.Tests/Design/Internal/DatabaseOperationsTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.EntityFrameworkCore.Internal;

namespace Microsoft.EntityFrameworkCore.Design.Internal;

public class DatabaseOperationsTest
Expand All @@ -10,16 +12,80 @@ public void Can_pass_null_args()
{
// Even though newer versions of the tools will pass an empty array
// older versions of the tools can pass null args.
CreateOperations(null);
}

[ConditionalFact]
public void ScaffoldContext_throws_exceptions_for_invalid_context_name()
{
ValidateContextNameInReverseEngineerGenerator("Invalid!CSharp*Class&Name");
ValidateContextNameInReverseEngineerGenerator("1CSharpClassNameCannotStartWithNumber");
ValidateContextNameInReverseEngineerGenerator("volatile");
}

private void ValidateContextNameInReverseEngineerGenerator(string contextName)
{
var operations = CreateOperations([]);

Assert.Equal(
DesignStrings.ContextClassNotValidCSharpIdentifier(contextName),
Assert.Throws<ArgumentException>(
() => operations.ScaffoldContext(
"Microsoft.EntityFrameworkCore.SqlServer",
"connectionstring",
"",
"",
dbContextClassName: contextName,
null,
null,
"FakeNamespace",
contextNamespace: null,
useDataAnnotations: false,
overwriteFiles: true,
useDatabaseNames: false,
suppressOnConfiguring: true,
noPluralize: false))
.Message);
}

[ConditionalFact]
[SqlServerConfiguredCondition]
public void ScaffoldContext_sets_environment()
{
var operations = CreateOperations([]);
operations.ScaffoldContext(
"Microsoft.EntityFrameworkCore.SqlServer",
TestEnvironment.DefaultConnection,
"",
"",
dbContextClassName: nameof(TestContext),
schemas: ["Empty"],
null,
null,
contextNamespace: null,
useDataAnnotations: false,
overwriteFiles: true,
useDatabaseNames: false,
suppressOnConfiguring: true,
noPluralize: false);

Assert.Equal("Development", Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"));
Assert.Equal("Development", Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT"));
}

private static DatabaseOperations CreateOperations(string[] args)
{
var assembly = MockAssembly.Create(typeof(TestContext));
_ = new TestDatabaseOperations(
var operations = new DatabaseOperations(
new TestOperationReporter(),
assembly,
assembly,
"projectDir",
"RootNamespace",
"C#",
nullable: false,
args: null);
args: args);
return operations;
}

public class TestContext : DbContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2453,7 +2453,7 @@ public void InsertDataOperation_required_empty_array()
Assert.Single(o.Columns);
Assert.Equal(1, o.Values.GetLength(0));
Assert.Equal(1, o.Values.GetLength(1));
Assert.Equal([], (string[])o.Values[0, 0]);
Assert.Equal(new string[0], (string[])o.Values[0, 0]);
});

[ConditionalFact]
Expand All @@ -2478,7 +2478,7 @@ public void InsertDataOperation_required_empty_array_composite()
Assert.Equal(1, o.Values.GetLength(0));
Assert.Equal(3, o.Values.GetLength(1));
Assert.Null(o.Values[0, 1]);
Assert.Equal([], (string[])o.Values[0, 2]);
Assert.Equal(new string[0], (string[])o.Values[0, 2]);
});

[ConditionalFact]
Expand Down

This file was deleted.

16 changes: 0 additions & 16 deletions test/EFCore.Design.Tests/TestUtilities/TestDatabaseOperations.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ public void Navigations_on_base_type_should_be_inherited()
var specialCustomerType = model.AddEntityType(typeof(SpecialCustomer));

Assert.Equal(new[] { "Orders" }, customerType.GetNavigations().Select(p => p.Name).ToArray());
Assert.Equal([], specialCustomerType.GetNavigations().Select(p => p.Name).ToArray());
Assert.Equal(new string[0], specialCustomerType.GetNavigations().Select(p => p.Name).ToArray());

specialCustomerType.BaseType = customerType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void Can_convert_bytes_to_strings()
var converter = _bytesToStringConverter.ConvertFromProviderExpression.Compile();

Assert.Equal(new byte[] { 83, 112, 196, 177, 110, 204, 136, 97, 108, 32, 84, 97, 112 }, converter("U3DEsW7MiGFsIFRhcA=="));
Assert.Equal([], converter(""));
Assert.Equal(new byte[0], converter(""));
}

[ConditionalFact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void Can_convert_strings_to_UTF8()
var converter = _stringToUtf8Converter.ConvertToProviderExpression.Compile();

Assert.Equal(new byte[] { 83, 112, 196, 177, 110, 204, 136, 97, 108, 32, 84, 97, 112 }, converter("Spın̈al Tap"));
Assert.Equal([], converter(""));
Assert.Equal(new byte[0], converter(""));
}

[ConditionalFact]
Expand Down