Skip to content

Commit d079c71

Browse files
authored
Retarget tools to .NET Framework 4.7.2 (#33028)
Refactor OperationExecutor to use IOperationReportHandler instead of Reporter directly Part of #24894
1 parent 6081e8c commit d079c71

27 files changed

+173
-144
lines changed

src/EFCore.Analyzers/EFCore.Analyzers.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)..\..\rulesets\EFCore.noxmldocs.ruleset</CodeAnalysisRuleSet>
1111
<ImplicitUsings>true</ImplicitUsings>
1212
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
13+
<NoWarn>NU5128</NoWarn>
1314
</PropertyGroup>
1415

1516
<ItemGroup>

src/EFCore.Analyzers/EFCore.Analyzers.nuspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<files>
1212
$CommonFileElements$
1313
<file src="PACKAGE.md" target="docs\" />
14-
<file src="_._" target="lib\$targetFramework$\" />
1514
<file src="$OutputBinary$" target="analyzers\dotnet\cs\" />
1615
<file src="$OutputSymbol$" target="analyzers\dotnet\cs\" />
1716
</files>

src/EFCore.Analyzers/_._

Whitespace-only changes.

src/EFCore.Design/Design/Internal/DbContextOperations.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public virtual string ScriptDbContext(string? contextType)
117117
/// any release. You should only use it directly in your code with extreme caution and knowing that
118118
/// doing so can result in application failures when updating to a new Entity Framework Core release.
119119
/// </summary>
120-
public virtual void Optimize(string? outputDir, string? modelNamespace, string? contextTypeName)
120+
public virtual IReadOnlyList<string> Optimize(string? outputDir, string? modelNamespace, string? contextTypeName)
121121
{
122122
using var context = CreateContext(contextTypeName);
123123
var contextType = context.GetType();
@@ -141,7 +141,7 @@ public virtual void Optimize(string? outputDir, string? modelNamespace, string?
141141

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

144-
scaffolder.ScaffoldModel(
144+
var scaffoldedFiles = scaffolder.ScaffoldModel(
145145
context.GetService<IDesignTimeModel>().Model,
146146
outputDir,
147147
new CompiledModelCodeGenerationOptions
@@ -165,6 +165,8 @@ public virtual void Optimize(string? outputDir, string? modelNamespace, string?
165165
{
166166
_reporter.WriteWarning(DesignStrings.CompiledModelCustomCacheKeyFactory(cacheKeyFactory.GetType().ShortDisplayName()));
167167
}
168+
169+
return scaffoldedFiles;
168170
}
169171

170172
private string? GetNamespaceFromOutputPath(string directoryPath)
Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.CodeDom.Compiler;
5-
using System.Text;
6-
74
namespace Microsoft.EntityFrameworkCore.Design.Internal;
85

96
/// <summary>
@@ -45,54 +42,4 @@ public interface IOperationReporter
4542
/// doing so can result in application failures when updating to a new Entity Framework Core release.
4643
/// </summary>
4744
void WriteVerbose(string message);
48-
49-
/// <summary>
50-
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
51-
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
52-
/// any release. You should only use it directly in your code with extreme caution and knowing that
53-
/// doing so can result in application failures when updating to a new Entity Framework Core release.
54-
/// </summary>
55-
void Write(CompilerError error)
56-
{
57-
var builder = new StringBuilder();
58-
59-
if (!string.IsNullOrEmpty(error.FileName))
60-
{
61-
builder.Append(error.FileName);
62-
63-
if (error.Line > 0)
64-
{
65-
builder
66-
.Append("(")
67-
.Append(error.Line);
68-
69-
if (error.Column > 0)
70-
{
71-
builder
72-
.Append(",")
73-
.Append(error.Column);
74-
}
75-
76-
builder.Append(")");
77-
}
78-
79-
builder.Append(" : ");
80-
}
81-
82-
builder
83-
.Append(error.IsWarning ? "warning" : "error")
84-
.Append(" ")
85-
.Append(error.ErrorNumber)
86-
.Append(": ")
87-
.AppendLine(error.ErrorText);
88-
89-
if (error.IsWarning)
90-
{
91-
WriteWarning(builder.ToString());
92-
}
93-
else
94-
{
95-
WriteError(builder.ToString());
96-
}
97-
}
9845
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.CodeDom.Compiler;
5+
using System.Text;
6+
7+
namespace Microsoft.EntityFrameworkCore.Design.Internal;
8+
9+
/// <summary>
10+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
11+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
12+
/// any release. You should only use it directly in your code with extreme caution and knowing that
13+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
14+
/// </summary>
15+
public static class OperationReporterExtensions
16+
{
17+
/// <summary>
18+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
19+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
20+
/// any release. You should only use it directly in your code with extreme caution and knowing that
21+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
22+
/// </summary>
23+
public static void Write(this IOperationReporter reporter, CompilerError error)
24+
{
25+
var builder = new StringBuilder();
26+
27+
if (!string.IsNullOrEmpty(error.FileName))
28+
{
29+
builder.Append(error.FileName);
30+
31+
if (error.Line > 0)
32+
{
33+
builder
34+
.Append("(")
35+
.Append(error.Line);
36+
37+
if (error.Column > 0)
38+
{
39+
builder
40+
.Append(",")
41+
.Append(error.Column);
42+
}
43+
44+
builder.Append(")");
45+
}
46+
47+
builder.Append(" : ");
48+
}
49+
50+
builder
51+
.Append(error.IsWarning ? "warning" : "error")
52+
.Append(" ")
53+
.Append(error.ErrorNumber)
54+
.Append(": ")
55+
.AppendLine(error.ErrorText);
56+
57+
if (error.IsWarning)
58+
{
59+
reporter.WriteWarning(builder.ToString());
60+
}
61+
else
62+
{
63+
reporter.WriteError(builder.ToString());
64+
}
65+
}
66+
}

src/EFCore.Design/Design/OperationExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public OptimizeContext(
526526
}
527527
}
528528

529-
private void OptimizeContextImpl(string? outputDir, string? modelNamespace, string? contextType)
529+
private IReadOnlyList<string> OptimizeContextImpl(string? outputDir, string? modelNamespace, string? contextType)
530530
=> ContextOperations.Optimize(outputDir, modelNamespace, contextType);
531531

532532
/// <summary>

src/EFCore.Design/Design/OperationReportHandler.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
5-
64
namespace Microsoft.EntityFrameworkCore.Design;
75

86
/// <summary>

src/EFCore.Design/Design/OperationResultHandler.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
5-
64
namespace Microsoft.EntityFrameworkCore.Design;
75

86
/// <summary>

src/EFCore.Design/EFCore.Design.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<AssemblyName>Microsoft.EntityFrameworkCore.Design</AssemblyName>
77
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace>
88
<GenerateDocumentationFile>true</GenerateDocumentationFile>
9-
<DevelopmentDependency>True</DevelopmentDependency>
9+
<DevelopmentDependency>true</DevelopmentDependency>
1010
<ImplicitUsings>true</ImplicitUsings>
1111
</PropertyGroup>
1212

0 commit comments

Comments
 (0)