Skip to content

Commit c5c90c0

Browse files
author
Kapil Borle
committed
Localize error messages in PlaceOpenBrace rule
1 parent a5fb09b commit c5c90c0

File tree

2 files changed

+40
-37
lines changed

2 files changed

+40
-37
lines changed

Rules/PlaceOpenBrace.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private IEnumerable<DiagnosticRecord> FindViolationsForBraceShouldBeOnSameLine(
126126
&& tokens[k - 1].Kind == TokenKind.NewLine)
127127
{
128128
yield return new DiagnosticRecord(
129-
GetError(),
129+
GetError(Strings.PlaceOpenBraceErrorShouldBeOnSameLine),
130130
tokens[k].Extent,
131131
GetName(),
132132
GetDiagnosticSeverity(),
@@ -155,7 +155,7 @@ private IEnumerable<DiagnosticRecord> FindViolationsForNoNewLineAfterBrace(
155155
&& tokens[k + 1].Kind != TokenKind.NewLine)
156156
{
157157
yield return new DiagnosticRecord(
158-
GetError(),
158+
GetError(Strings.PlaceOpenBraceErrorNoNewLineAfterBrace),
159159
tokens[k].Extent,
160160
GetName(),
161161
GetDiagnosticSeverity(),
@@ -204,7 +204,7 @@ private IEnumerable<DiagnosticRecord> FindViolationsForBraceShouldNotBeOnSameLin
204204
&& !tokensToIgnore.Contains(tokens[k]))
205205
{
206206
yield return new DiagnosticRecord(
207-
GetError(),
207+
GetError(Strings.PlaceOpenBraceErrorShouldNotBeOnSameLine),
208208
tokens[k].Extent,
209209
GetName(),
210210
GetDiagnosticSeverity(),
@@ -284,12 +284,9 @@ public override string GetCommonName()
284284
return string.Format(CultureInfo.CurrentCulture, Strings.PlaceOpenBraceCommonName);
285285
}
286286

287-
public string GetError()
287+
public string GetError(string errorString)
288288
{
289-
return string.Format(
290-
CultureInfo.CurrentCulture,
291-
Strings.PlaceOpenBraceError,
292-
"same");
289+
return string.Format(CultureInfo.CurrentCulture, errorString);
293290
}
294291

295292
/// <summary>

Rules/Strings.resx

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<root>
3-
<!--
4-
Microsoft ResX Schema
5-
3+
<!--
4+
Microsoft ResX Schema
5+
66
Version 2.0
7-
8-
The primary goals of this format is to allow a simple XML format
9-
that is mostly human readable. The generation and parsing of the
10-
various data types are done through the TypeConverter classes
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
1111
associated with the data types.
12-
12+
1313
Example:
14-
14+
1515
... ado.net/XML headers & schema ...
1616
<resheader name="resmimetype">text/microsoft-resx</resheader>
1717
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
2626
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
2727
<comment>This is a comment</comment>
2828
</data>
29-
30-
There are any number of "resheader" rows that contain simple
29+
30+
There are any number of "resheader" rows that contain simple
3131
name/value pairs.
32-
33-
Each data row contains a name, and value. The row also contains a
34-
type or mimetype. Type corresponds to a .NET class that support
35-
text/value conversion through the TypeConverter architecture.
36-
Classes that don't support this are serialized and stored with the
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
3737
mimetype set.
38-
39-
The mimetype is used for serialized objects, and tells the
40-
ResXResourceReader how to depersist the object. This is currently not
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
4141
extensible. For a given mimetype the value must be set accordingly:
42-
43-
Note - application/x-microsoft.net.object.binary.base64 is the format
44-
that the ResXResourceWriter will generate, however the reader can
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
4545
read any of the formats listed below.
46-
46+
4747
mimetype: application/x-microsoft.net.object.binary.base64
48-
value : The object must be serialized with
48+
value : The object must be serialized with
4949
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050
: and then encoded with base64 encoding.
51-
51+
5252
mimetype: application/x-microsoft.net.object.soap.base64
53-
value : The object must be serialized with
53+
value : The object must be serialized with
5454
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
5555
: and then encoded with base64 encoding.
5656
5757
mimetype: application/x-microsoft.net.object.bytearray.base64
58-
value : The object must be serialized into a byte array
58+
value : The object must be serialized into a byte array
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
@@ -879,8 +879,14 @@
879879
<data name="PlaceOpenBraceDescription" xml:space="preserve">
880880
<value>Place open braces either on the same line as the preceding expression or on a new line.</value>
881881
</data>
882-
<data name="PlaceOpenBraceError" xml:space="preserve">
883-
<value>Open brace not on {0} line</value>
882+
<data name="PlaceOpenBraceErrorShouldBeOnSameLine" xml:space="preserve">
883+
<value>Open brace not on same line as preceding keyword. It should be on the same line.</value>
884+
</data>
885+
<data name="PlaceOpenBraceErrorShouldNotBeOnSameLine" xml:space="preserve">
886+
<value>Open brace is on same line as preceding keyword. It should be on a new line.</value>
887+
</data>
888+
<data name="PlaceOpenBraceErrorNoNewLineAfterBrace" xml:space="preserve">
889+
<value>No new line after open brace. A new line should follown an open brace.</value>
884890
</data>
885891
<data name="PlaceCloseBraceName" xml:space="preserve">
886892
<value>PlaceCloseBrace</value>

0 commit comments

Comments
 (0)