Skip to content
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
1 change: 1 addition & 0 deletions src/EFCore.Analyzers/EFCore.Analyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)..\..\rulesets\EFCore.noxmldocs.ruleset</CodeAnalysisRuleSet>
<ImplicitUsings>true</ImplicitUsings>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<NoWarn>NU5128</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/EFCore.Analyzers/EFCore.Analyzers.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<files>
$CommonFileElements$
<file src="PACKAGE.md" target="docs\" />
<file src="_._" target="lib\$targetFramework$\" />
<file src="$OutputBinary$" target="analyzers\dotnet\cs\" />
<file src="$OutputSymbol$" target="analyzers\dotnet\cs\" />
</files>
Expand Down
Empty file removed src/EFCore.Analyzers/_._
Empty file.
6 changes: 4 additions & 2 deletions src/EFCore.Design/Design/Internal/DbContextOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public virtual string ScriptDbContext(string? contextType)
/// 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 void Optimize(string? outputDir, string? modelNamespace, string? contextTypeName)
public virtual IReadOnlyList<string> Optimize(string? outputDir, string? modelNamespace, string? contextTypeName)
{
using var context = CreateContext(contextTypeName);
var contextType = context.GetType();
Expand All @@ -141,7 +141,7 @@ public virtual void Optimize(string? outputDir, string? modelNamespace, string?

var finalModelNamespace = modelNamespace ?? GetNamespaceFromOutputPath(outputDir) ?? "";

scaffolder.ScaffoldModel(
var scaffoldedFiles = scaffolder.ScaffoldModel(
context.GetService<IDesignTimeModel>().Model,
outputDir,
new CompiledModelCodeGenerationOptions
Expand All @@ -165,6 +165,8 @@ public virtual void Optimize(string? outputDir, string? modelNamespace, string?
{
_reporter.WriteWarning(DesignStrings.CompiledModelCustomCacheKeyFactory(cacheKeyFactory.GetType().ShortDisplayName()));
}

return scaffoldedFiles;
}

private string? GetNamespaceFromOutputPath(string directoryPath)
Expand Down
53 changes: 0 additions & 53 deletions src/EFCore.Design/Design/Internal/IOperationReporter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.CodeDom.Compiler;
using System.Text;

namespace Microsoft.EntityFrameworkCore.Design.Internal;

/// <summary>
Expand Down Expand Up @@ -45,54 +42,4 @@ public interface IOperationReporter
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
void WriteVerbose(string message);

/// <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>
void Write(CompilerError error)
{
var builder = new StringBuilder();

if (!string.IsNullOrEmpty(error.FileName))
{
builder.Append(error.FileName);

if (error.Line > 0)
{
builder
.Append("(")
.Append(error.Line);

if (error.Column > 0)
{
builder
.Append(",")
.Append(error.Column);
}

builder.Append(")");
}

builder.Append(" : ");
}

builder
.Append(error.IsWarning ? "warning" : "error")
.Append(" ")
.Append(error.ErrorNumber)
.Append(": ")
.AppendLine(error.ErrorText);

if (error.IsWarning)
{
WriteWarning(builder.ToString());
}
else
{
WriteError(builder.ToString());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.CodeDom.Compiler;
using System.Text;

namespace Microsoft.EntityFrameworkCore.Design.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 static class OperationReporterExtensions
{
/// <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 Write(this IOperationReporter reporter, CompilerError error)
{
var builder = new StringBuilder();

if (!string.IsNullOrEmpty(error.FileName))
{
builder.Append(error.FileName);

if (error.Line > 0)
{
builder
.Append("(")
.Append(error.Line);

if (error.Column > 0)
{
builder
.Append(",")
.Append(error.Column);
}

builder.Append(")");
}

builder.Append(" : ");
}

builder
.Append(error.IsWarning ? "warning" : "error")
.Append(" ")
.Append(error.ErrorNumber)
.Append(": ")
.AppendLine(error.ErrorText);

if (error.IsWarning)
{
reporter.WriteWarning(builder.ToString());
}
else
{
reporter.WriteError(builder.ToString());
}
}
}
2 changes: 1 addition & 1 deletion src/EFCore.Design/Design/OperationExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public OptimizeContext(
}
}

private void OptimizeContextImpl(string? outputDir, string? modelNamespace, string? contextType)
private IReadOnlyList<string> OptimizeContextImpl(string? outputDir, string? modelNamespace, string? contextType)
=> ContextOperations.Optimize(outputDir, modelNamespace, contextType);

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/EFCore.Design/Design/OperationReportHandler.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

namespace Microsoft.EntityFrameworkCore.Design;

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/EFCore.Design/Design/OperationResultHandler.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

namespace Microsoft.EntityFrameworkCore.Design;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Design/EFCore.Design.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AssemblyName>Microsoft.EntityFrameworkCore.Design</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DevelopmentDependency>True</DevelopmentDependency>
<DevelopmentDependency>true</DevelopmentDependency>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>

Expand Down
12 changes: 6 additions & 6 deletions src/EFCore.Tools/EFCore.Tools.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<file src="lib\**\*" target="lib/" />
<file src="tools\**\*" target="tools/" />
<file src="$intermediateOutputPath$*.psd1" target="tools/" />
<file src="../../artifacts/bin/ef/$configuration$/net461/ef.exe" target="tools/net461/any/" />
<file src="../../artifacts/bin/ef/$configuration$/net461/ef.pdb" target="tools/net461/any/" />
<file src="../../artifacts/bin/ef/x86/$configuration$/net461/ef.exe" target="tools/net461/win-x86/" />
<file src="../../artifacts/bin/ef/x86/$configuration$/net461/ef.pdb" target="tools/net461/win-x86/" />
<file src="../../artifacts/bin/ef/ARM64/$configuration$/net461/ef.exe" target="tools/net461/win-arm64/" />
<file src="../../artifacts/bin/ef/ARM64/$configuration$/net461/ef.pdb" target="tools/net461/win-arm64/" />
<file src="../../artifacts/bin/ef/$configuration$/net472/ef.exe" target="tools/net472/any/" />
<file src="../../artifacts/bin/ef/$configuration$/net472/ef.pdb" target="tools/net472/any/" />
<file src="../../artifacts/bin/ef/x86/$configuration$/net472/ef.exe" target="tools/net472/win-x86/" />
<file src="../../artifacts/bin/ef/x86/$configuration$/net472/ef.pdb" target="tools/net472/win-x86/" />
<file src="../../artifacts/bin/ef/ARM64/$configuration$/net472/ef.exe" target="tools/net472/win-arm64/" />
<file src="../../artifacts/bin/ef/ARM64/$configuration$/net472/ef.pdb" target="tools/net472/win-arm64/" />
<file src="../../artifacts/bin/ef/$configuration$/netcoreapp2.0/ef.dll" target="tools/netcoreapp2.0/any/" />
<file src="../../artifacts/bin/ef/$configuration$/netcoreapp2.0/ef.pdb" target="tools/netcoreapp2.0/any/" />
<file src="../../artifacts/bin/ef/$configuration$/netcoreapp2.0/ef.runtimeconfig.json" target="tools/netcoreapp2.0/any/" />
Expand Down
6 changes: 3 additions & 3 deletions src/EFCore.Tools/tools/EntityFrameworkCore.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1220,15 +1220,15 @@ function EF($project, $startupProject, $params, $applicationArgs, [switch] $skip
$platformTarget = GetPlatformTarget $startupProject
if ($platformTarget -eq 'x86')
{
$exePath = Join-Path $PSScriptRoot 'net461\win-x86\ef.exe'
$exePath = Join-Path $PSScriptRoot 'net472\win-x86\ef.exe'
}
elseif ($platformTarget -eq 'ARM64')
{
$exePath = Join-Path $PSScriptRoot 'net461\win-arm64\ef.exe'
$exePath = Join-Path $PSScriptRoot 'net472\win-arm64\ef.exe'
}
elseif ($platformTarget -in 'AnyCPU', 'x64')
{
$exePath = Join-Path $PSScriptRoot 'net461\any\ef.exe'
$exePath = Join-Path $PSScriptRoot 'net472\any\ef.exe'
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/dotnet-ef/RootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected override int Execute(string[] _)
{
executable = Path.Combine(
toolsPath,
"net461",
"net472",
startupProject.PlatformTarget == "x86"
? "win-x86"
: "any",
Expand All @@ -126,7 +126,7 @@ protected override int Execute(string[] _)
{
executable = Path.Combine(
toolsPath,
"net461",
"net472",
startupProject.PlatformTarget switch
{
"x86" => "win-x86",
Expand Down
12 changes: 6 additions & 6 deletions src/dotnet-ef/dotnet-ef.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ dotnet ef database update
<NuspecProperty Include="OutputBinary=..\..\artifacts\bin\ef\$(Configuration)\netcoreapp2.0\ef.dll" />
<NuspecProperty Include="OutputRuntimeConfig=..\..\artifacts\bin\ef\$(Configuration)\netcoreapp2.0\ef.runtimeconfig.json" />
<NuspecProperty Include="OutputSymbol=..\..\artifacts\bin\ef\$(Configuration)\netcoreapp2.0\ef.pdb" />
<NuspecProperty Include="OutputExe=..\..\artifacts\bin\ef\$(Configuration)\net461\ef.exe" />
<NuspecProperty Include="OutputExeSymbol=..\..\artifacts\bin\ef\$(Configuration)\net461\ef.pdb" />
<NuspecProperty Include="OutputX86Exe=..\..\artifacts\bin\ef\x86\$(Configuration)\net461\ef.exe" />
<NuspecProperty Include="OutputX86ExeSymbol=..\..\artifacts\bin\ef\x86\$(Configuration)\net461\ef.pdb" />
<NuspecProperty Include="OutputARM64Exe=..\..\artifacts\bin\ef\ARM64\$(Configuration)\net461\ef.exe" />
<NuspecProperty Include="OutputARM64ExeSymbol=..\..\artifacts\bin\ef\ARM64\$(Configuration)\net461\ef.pdb" />
<NuspecProperty Include="OutputExe=..\..\artifacts\bin\ef\$(Configuration)\net472\ef.exe" />
<NuspecProperty Include="OutputExeSymbol=..\..\artifacts\bin\ef\$(Configuration)\net472\ef.pdb" />
<NuspecProperty Include="OutputX86Exe=..\..\artifacts\bin\ef\x86\$(Configuration)\net472\ef.exe" />
<NuspecProperty Include="OutputX86ExeSymbol=..\..\artifacts\bin\ef\x86\$(Configuration)\net472\ef.pdb" />
<NuspecProperty Include="OutputARM64Exe=..\..\artifacts\bin\ef\ARM64\$(Configuration)\net472\ef.exe" />
<NuspecProperty Include="OutputARM64ExeSymbol=..\..\artifacts\bin\ef\ARM64\$(Configuration)\net472\ef.pdb" />
</ItemGroup>
</Target>
</Project>
12 changes: 6 additions & 6 deletions src/dotnet-ef/dotnet-ef.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<file src="$OutputBinary$" target="tools\$targetFramework$\any\tools\netcoreapp2.0\any" />
<file src="$OutputRuntimeConfig$" target="tools\$targetFramework$\any\tools\netcoreapp2.0\any" />
<file src="$OutputSymbol$" target="tools\$targetFramework$\any\tools\netcoreapp2.0\any" />
<file src="$OutputExe$" target="tools\$targetFramework$\any\tools\net461\any" />
<file src="$OutputExeSymbol$" target="tools\$targetFramework$\any\tools\net461\any" />
<file src="$OutputX86Exe$" target="tools\$targetFramework$\any\tools\net461\win-x86" />
<file src="$OutputX86ExeSymbol$" target="tools\$targetFramework$\any\tools\net461\win-x86" />
<file src="$OutputARM64Exe$" target="tools\$targetFramework$\any\tools\net461\win-arm64" />
<file src="$OutputARM64ExeSymbol$" target="tools\$targetFramework$\any\tools\net461\win-arm64" />
<file src="$OutputExe$" target="tools\$targetFramework$\any\tools\net472\any" />
<file src="$OutputExeSymbol$" target="tools\$targetFramework$\any\tools\net472\any" />
<file src="$OutputX86Exe$" target="tools\$targetFramework$\any\tools\net472\win-x86" />
<file src="$OutputX86ExeSymbol$" target="tools\$targetFramework$\any\tools\net472\win-x86" />
<file src="$OutputARM64Exe$" target="tools\$targetFramework$\any\tools\net472\win-arm64" />
<file src="$OutputARM64ExeSymbol$" target="tools\$targetFramework$\any\tools\net472\win-arm64" />
</files>
</package>
37 changes: 25 additions & 12 deletions src/ef/AppDomainOperationExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#if NET461
#if NET472
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Tools.Properties;

Expand All @@ -17,6 +18,7 @@ internal class AppDomainOperationExecutor : OperationExecutorBase
private readonly object _executor;
private readonly AppDomain _domain;
private bool _disposed;
private const string ReportHandlerTypeName = "Microsoft.EntityFrameworkCore.Design.OperationReportHandler";

public AppDomainOperationExecutor(
string assembly,
Expand All @@ -26,31 +28,42 @@ public AppDomainOperationExecutor(
string? rootNamespace,
string? language,
bool nullable,
string[] remainingArguments)
: base(assembly, startupAssembly, projectDir, rootNamespace, language, nullable, remainingArguments)
string[] remainingArguments,
IOperationReportHandler reportHandler)
: base(assembly, startupAssembly, projectDir, rootNamespace, language, nullable, remainingArguments, reportHandler)
{
var info = new AppDomainSetup { ApplicationBase = AppBasePath };

var reporter = new OperationReporter(reportHandler);
var configurationFile = (startupAssembly ?? assembly) + ".config";
if (File.Exists(configurationFile))
{
Reporter.WriteVerbose(Resources.UsingConfigurationFile(configurationFile));
reporter.WriteVerbose(Resources.UsingConfigurationFile(configurationFile));
info.ConfigurationFile = configurationFile;
}

_domain = AppDomain.CreateDomain("EntityFrameworkCore.DesignDomain", null, info);

if (dataDirectory != null)
{
Reporter.WriteVerbose(Resources.UsingDataDir(dataDirectory));
reporter.WriteVerbose(Resources.UsingDataDir(dataDirectory));
_domain.SetData("DataDirectory", dataDirectory);
}

var reportHandler = new OperationReportHandler(
Reporter.WriteError,
Reporter.WriteWarning,
Reporter.WriteInformation,
Reporter.WriteVerbose);
var designReportHandler = _domain.CreateInstanceAndUnwrap(
DesignAssemblyName,
ReportHandlerTypeName,
false,
BindingFlags.Default,
null,
[
(Action<string>)reportHandler.OnError,
(Action<string>)reportHandler.OnWarning,
(Action<string>)reportHandler.OnInformation,
(Action<string>)reportHandler.OnVerbose
],
null,
null);

_executor = _domain.CreateInstanceAndUnwrap(
DesignAssemblyName,
Expand All @@ -59,7 +72,7 @@ public AppDomainOperationExecutor(
BindingFlags.Default,
null,
[
reportHandler,
designReportHandler,
new Hashtable
{
{ "targetName", AssemblyFileName },
Expand Down Expand Up @@ -100,7 +113,7 @@ public override void Dispose()
}
}
}
#elif NETCOREAPP2_0
#elif NETCOREAPP2_0_OR_GREATER
#else
#error target frameworks need to be updated.
#endif
Loading