Skip to content

Commit

Permalink
Rename Rule ID for analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
Hixon10 committed Feb 4, 2024
1 parent 6f428dd commit fa39efb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private static async Task ExecuteTest(string textCode, string packageName)
{
var expected1 = Verifier.Diagnostic()
.WithLocation(2, 1)
.WithMessage($"Type name '{packageName}' contains the company name")
.WithMessage($"Detected Newtonsoft usage: '{packageName}'")
.WithArguments(packageName);

var test = new CSharpAnalyzerTest<NewtonsoftJsonUsageAnalyzer, XUnitVerifier>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

Rule ID | Category | Severity | Notes
--------|----------|----------|-------
AB0001 | Design | Error | C# events can cause memory leaks in an NSObject subclass. Remove the event or add the [UnconditionalSuppressMessage("Memory", "MA0001")] attribute with a justification as to why the event will not leak.
NS0001 | Design | Error | Newtonsoft.Json library usage is not allowed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ namespace NewtonsoftJsonUsageAnalyzer;
public class NewtonsoftJsonUsageAnalyzer : DiagnosticAnalyzer
{
// Preferred format of DiagnosticId is Your Prefix + Number, e.g. CA1234.
public const string DiagnosticId = "AB0001";
public const string DiagnosticId = "NS0001";

// Feel free to use raw strings if you don't need localization.
private static readonly LocalizableString Title = new LocalizableResourceString(nameof(Resources.AB0001Title),
private static readonly LocalizableString Title = new LocalizableResourceString(nameof(Resources.NS0001Title),
Resources.ResourceManager, typeof(Resources));

// The message that will be displayed to the user.
private static readonly LocalizableString MessageFormat =
new LocalizableResourceString(nameof(Resources.AB0001MessageFormat), Resources.ResourceManager,
new LocalizableResourceString(nameof(Resources.NS0001MessageFormat), Resources.ResourceManager,
typeof(Resources));

private static readonly LocalizableString Description =
new LocalizableResourceString(nameof(Resources.AB0001Description), Resources.ResourceManager,
new LocalizableResourceString(nameof(Resources.NS0001Description), Resources.ResourceManager,
typeof(Resources));

// The category of the diagnostic (Design, Naming etc.).
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AB0001Description" xml:space="preserve">
<value>Type names should not contain the company name.</value><comment>An optional longer localizable description of the diagnostic.</comment>
<data name="NS0001Description" xml:space="preserve">
<value>Code shouldn't contain any Newtonsoft usage.</value>
</data>
<data name="AB0001MessageFormat" xml:space="preserve">
<value>Type name '{0}' contains the company name</value><comment>The format-able message the diagnostic displays.</comment>
<data name="NS0001MessageFormat" xml:space="preserve">
<value>Detected Newtonsoft usage: '{0}'</value>
</data>
<data name="AB0001Title" xml:space="preserve">
<value>Type name contains the company name</value><comment>The title of the diagnostic.</comment>
<data name="NS0001Title" xml:space="preserve">
<value>Code contains Newtonsoft.Json library usage</value>
</data>
</root>

0 comments on commit fa39efb

Please sign in to comment.