diff --git a/src/EFCore.Analyzers/EFCore.Analyzers.csproj b/src/EFCore.Analyzers/EFCore.Analyzers.csproj
index 22d17e2d7bd..88999dabc34 100644
--- a/src/EFCore.Analyzers/EFCore.Analyzers.csproj
+++ b/src/EFCore.Analyzers/EFCore.Analyzers.csproj
@@ -19,6 +19,11 @@
+
+ True
+ True
+ AnalyzerStrings.resx
+
@@ -45,4 +50,12 @@
+
+
+ PublicResXFileCodeGenerator
+ AnalyzerStrings.Designer.cs
+ Microsoft.EntityFrameworkCore
+
+
+
diff --git a/src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs b/src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs
index 4dcb7f177d7..2e5054b0faa 100644
--- a/src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs
+++ b/src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs
@@ -13,23 +13,14 @@ namespace Microsoft.EntityFrameworkCore;
public sealed class InternalUsageDiagnosticAnalyzer : DiagnosticAnalyzer
{
public const string Id = "EF1001";
-
- public const string MessageFormat
- = "{0} 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.";
-
- private const string DefaultTitle = "Internal EF Core API usage.";
- private const string Category = "Usage";
-
private static readonly int EFLen = "EntityFrameworkCore".Length;
private static readonly DiagnosticDescriptor _descriptor
= new(
Id,
- title: DefaultTitle,
- messageFormat: MessageFormat,
- category: Category,
+ title: AnalyzerStrings.InternalUsageTitle,
+ messageFormat: AnalyzerStrings.InternalUsageMessageFormat,
+ category: "Usage",
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
diff --git a/src/EFCore.Analyzers/Properties/AnalyzerStrings.Designer.cs b/src/EFCore.Analyzers/Properties/AnalyzerStrings.Designer.cs
new file mode 100644
index 00000000000..74922826a46
--- /dev/null
+++ b/src/EFCore.Analyzers/Properties/AnalyzerStrings.Designer.cs
@@ -0,0 +1,66 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Microsoft.EntityFrameworkCore {
+ using System;
+
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ public class AnalyzerStrings {
+
+ private static System.Resources.ResourceManager resourceMan;
+
+ private static System.Globalization.CultureInfo resourceCulture;
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal AnalyzerStrings() {
+ }
+
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.Equals(null, resourceMan)) {
+ System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Microsoft.EntityFrameworkCore.Properties.AnalyzerStrings", typeof(AnalyzerStrings).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ public static string UninitializedDbSetWarningSuppressionJustification {
+ get {
+ return ResourceManager.GetString("UninitializedDbSetWarningSuppressionJustification", resourceCulture);
+ }
+ }
+
+ public static string InternalUsageMessageFormat {
+ get {
+ return ResourceManager.GetString("InternalUsageMessageFormat", resourceCulture);
+ }
+ }
+
+ public static string InternalUsageTitle {
+ get {
+ return ResourceManager.GetString("InternalUsageTitle", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/src/EFCore.Analyzers/Properties/AnalyzerStrings.resx b/src/EFCore.Analyzers/Properties/AnalyzerStrings.resx
new file mode 100644
index 00000000000..b94f9ac8eb7
--- /dev/null
+++ b/src/EFCore.Analyzers/Properties/AnalyzerStrings.resx
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ DbSet properties on DbContext subclasses are automatically populated by the DbContext constructor.
+
+
+ {0} 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.
+
+
+ Internal EF Core API usage.
+
+
\ No newline at end of file
diff --git a/src/EFCore.Analyzers/UninitializedDbSetDiagnosticSuppressor.cs b/src/EFCore.Analyzers/UninitializedDbSetDiagnosticSuppressor.cs
index 8a91a10dae9..50bac217aee 100644
--- a/src/EFCore.Analyzers/UninitializedDbSetDiagnosticSuppressor.cs
+++ b/src/EFCore.Analyzers/UninitializedDbSetDiagnosticSuppressor.cs
@@ -14,7 +14,7 @@ public sealed class UninitializedDbSetDiagnosticSuppressor : DiagnosticSuppresso
private static readonly SuppressionDescriptor _suppressUninitializedDbSetRule = new(
id: "SPR1001",
suppressedDiagnosticId: "CS8618",
- justification: "DbSet properties on DbContext subclasses are automatically populated by the DbContext constructor");
+ justification: AnalyzerStrings.UninitializedDbSetWarningSuppressionJustification);
///
public override ImmutableArray SupportedSuppressions { get; }
diff --git a/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTest.cs b/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTest.cs
index afff481ce96..b406149d66d 100644
--- a/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTest.cs
+++ b/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTest.cs
@@ -40,7 +40,7 @@ class MyClass : Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalPara
Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity);
Assert.Equal(
string.Format(
- InternalUsageDiagnosticAnalyzer.MessageFormat,
+ AnalyzerStrings.InternalUsageMessageFormat,
"Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalParameter"),
diagnostic.GetMessage());
@@ -55,7 +55,7 @@ class MyClass : Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalPara
Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity);
Assert.Equal(
string.Format(
- InternalUsageDiagnosticAnalyzer.MessageFormat,
+ AnalyzerStrings.InternalUsageMessageFormat,
"Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalParameter"),
diagnostic.GetMessage());
@@ -201,9 +201,7 @@ private async Task Test(
Assert.Equal(InternalUsageDiagnosticAnalyzer.Id, diagnostic.Id);
Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity);
- Assert.Equal(
- string.Format(InternalUsageDiagnosticAnalyzer.MessageFormat, expectedInternalApi),
- diagnostic.GetMessage());
+ Assert.Equal(string.Format(AnalyzerStrings.InternalUsageMessageFormat, expectedInternalApi), diagnostic.GetMessage());
var span = diagnostic.Location.SourceSpan;
Assert.Equal(expectedDiagnosticSpan, fullSource[span.Start..span.End]);
@@ -219,9 +217,7 @@ private async Task TestFullSource(
Assert.Equal(InternalUsageDiagnosticAnalyzer.Id, diagnostic.Id);
Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity);
- Assert.Equal(
- string.Format(InternalUsageDiagnosticAnalyzer.MessageFormat, expectedInternalApi),
- diagnostic.GetMessage());
+ Assert.Equal(string.Format(AnalyzerStrings.InternalUsageMessageFormat, expectedInternalApi), diagnostic.GetMessage());
var span = diagnostic.Location.SourceSpan;
Assert.Equal(expectedDiagnosticSpan, fullSource[span.Start..span.End]);