提交 5925aaef 编写于 作者: J Jason Malinowski

Merge pull request #8478 from jasonmalinowski/localize-error-message

Correctly localize the "Failure" and "Warning" strings
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis
{
[DebuggerDisplay("{GetDebuggerDisplay(),nq}")]
public class WorkspaceDiagnostic
{
public WorkspaceDiagnosticKind Kind { get; }
......@@ -18,13 +18,16 @@ public WorkspaceDiagnostic(WorkspaceDiagnosticKind kind, string message)
public override string ToString()
{
return GetDebuggerDisplay();
}
string kindText;
/// <remarks>Internal for testing purposes</remarks>
internal string GetDebuggerDisplay()
{
return string.Format("[{0}] {1}", this.Kind.ToString(), this.Message);
switch (Kind)
{
case WorkspaceDiagnosticKind.Failure: kindText = WorkspacesResources.Failure; break;
case WorkspaceDiagnosticKind.Warning: kindText = WorkspacesResources.Warning; break;
default: throw ExceptionUtilities.UnexpectedValue(Kind);
}
return $"[{kindText}] {Message}";
}
}
}
......@@ -430,6 +430,15 @@ internal class WorkspacesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Failure.
/// </summary>
internal static string Failure {
get {
return ResourceManager.GetString("Failure", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to File was externally modified: {0}..
/// </summary>
......@@ -1069,6 +1078,15 @@ internal class WorkspacesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Warning.
/// </summary>
internal static string Warning {
get {
return ResourceManager.GetString("Warning", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Workspace is not empty..
/// </summary>
......
......@@ -459,4 +459,10 @@
<data name="FixableDiagnosticIdsIncorrectlyInitialized" xml:space="preserve">
<value>'{0}' returned an uninitialized ImmutableArray</value>
</data>
<data name="Failure" xml:space="preserve">
<value>Failure</value>
</data>
<data name="Warning" xml:space="preserve">
<value>Warning</value>
</data>
</root>
\ No newline at end of file
......@@ -1299,7 +1299,7 @@ public void TestWorkspaceDiagnosticHasDebuggerText()
Assert.NotNull(diagnostic);
var dd = diagnostic as DocumentDiagnostic;
Assert.NotNull(dd);
Assert.Equal(dd.GetDebuggerDisplay(), string.Format("[{0}] {1}", dd.Kind.ToString(), dd.Message));
Assert.Equal(dd.ToString(), string.Format("[{0}] {1}", WorkspacesResources.Failure, dd.Message));
}
private bool WaitFor(Func<bool> condition, TimeSpan timeout)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册