未验证 提交 2e69542e 编写于 作者: J Jinu 提交者: GitHub

Merge pull request #26718 from sharwell/fix-resource

Fix the message for Make Field Readonly
......@@ -36,6 +36,75 @@ internal virtual (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderA
: CreateDiagnosticProviderAndFixer(workspace, parameters);
}
[Fact]
public void TestSupportedDiagnosticsMessageTitle()
{
using (var workspace = new AdhocWorkspace())
{
var diagnosticAnalyzer = CreateDiagnosticProviderAndFixer(workspace).Item1;
if (diagnosticAnalyzer == null)
{
return;
}
foreach (var descriptor in diagnosticAnalyzer.SupportedDiagnostics)
{
if (descriptor.CustomTags.Contains(WellKnownDiagnosticTags.NotConfigurable))
{
// The title only displayed for rule configuration
continue;
}
Assert.NotEqual("", descriptor.Title?.ToString() ?? "");
}
}
}
[Fact]
public void TestSupportedDiagnosticsMessageDescription()
{
using (var workspace = new AdhocWorkspace())
{
var diagnosticAnalyzer = CreateDiagnosticProviderAndFixer(workspace).Item1;
if (diagnosticAnalyzer == null)
{
return;
}
foreach (var descriptor in diagnosticAnalyzer.SupportedDiagnostics)
{
if (descriptor.CustomTags.Contains(WellKnownDiagnosticTags.NotConfigurable))
{
if (!descriptor.IsEnabledByDefault || descriptor.DefaultSeverity == DiagnosticSeverity.Hidden)
{
// The message only displayed if either enabled and not hidden, or configurable
continue;
}
}
Assert.NotEqual("", descriptor.MessageFormat?.ToString() ?? "");
}
}
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/26717")]
public void TestSupportedDiagnosticsMessageHelpLinkUri()
{
using (var workspace = new AdhocWorkspace())
{
var diagnosticAnalyzer = CreateDiagnosticProviderAndFixer(workspace).Item1;
if (diagnosticAnalyzer == null)
{
return;
}
foreach (var descriptor in diagnosticAnalyzer.SupportedDiagnostics)
{
Assert.NotEqual("", descriptor.HelpLinkUri ?? "");
}
}
}
internal async override Task<IEnumerable<Diagnostic>> GetDiagnosticsAsync(
TestWorkspace workspace, TestParameters parameters)
{
......
......@@ -30,7 +30,9 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.AddImp
End Function
Friend Overrides Function CreateDiagnosticProviderAndFixer(workspace As Workspace) As (DiagnosticAnalyzer, CodeFixProvider)
Throw New NotImplementedException()
' This is used by inherited tests to ensure the properties of diagnostic analyzers are correct. It's not
' needed by the tests in this class, but can't throw an exception.
Return (Nothing, Nothing)
End Function
Friend Overrides Function CreateDiagnosticProviderAndFixer(workspace As Workspace, parameters As TestParameters) As (DiagnosticAnalyzer, CodeFixProvider)
......
......@@ -17,7 +17,7 @@ protected AbstractMakeFieldReadonlyDiagnosticAnalyzer()
: base(
IDEDiagnosticIds.MakeFieldReadonlyDiagnosticId,
new LocalizableResourceString(nameof(FeaturesResources.Add_readonly_modifier), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
new LocalizableResourceString(nameof(FeaturesResources.Make_field_readonly), WorkspacesResources.ResourceManager, typeof(WorkspacesResources)))
new LocalizableResourceString(nameof(FeaturesResources.Make_field_readonly), FeaturesResources.ResourceManager, typeof(FeaturesResources)))
{
}
......
......@@ -14,7 +14,8 @@ public static class DescriptorFactory
/// </summary>
/// <remarks>
/// Returned <see cref="DiagnosticDescriptor"/> has
/// - empty <see cref="DiagnosticDescriptor.Title"/>, <see cref="DiagnosticDescriptor.MessageFormat"/> and <see cref="DiagnosticDescriptor.Category"/>
/// - empty <see cref="DiagnosticDescriptor.Title"/> and <see cref="DiagnosticDescriptor.Category"/>
/// - <see cref="DiagnosticDescriptor.MessageFormat"/> set to <paramref name="id"/>
/// - <see cref="DiagnosticDescriptor.DefaultSeverity"/> set to <see cref="DiagnosticSeverity.Hidden"/>
/// - <see cref="WellKnownDiagnosticTags.NotConfigurable"/> custom tag added in <see cref="DiagnosticDescriptor.CustomTags"/>.
/// </remarks>
......@@ -22,7 +23,7 @@ public static class DescriptorFactory
/// <returns>A <see cref="DiagnosticDescriptor"/> with specified <see cref="DiagnosticDescriptor.Id"/>.</returns>
public static DiagnosticDescriptor CreateSimpleDescriptor(string id)
{
return new DiagnosticDescriptor(id, title: "", messageFormat: "", category: "",
return new DiagnosticDescriptor(id, title: "", messageFormat: id, category: "",
defaultSeverity: DiagnosticSeverity.Hidden, isEnabledByDefault: true,
customTags: WellKnownDiagnosticTags.NotConfigurable);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册