Skip to content

Commit

Permalink
Add server command diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-r-g committed May 15, 2023
1 parent b185670 commit 1dd9434
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion SboxAnalyzers/AnalyzerReleases.Unshipped.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ Rule ID | Category | Severity | Notes
--------|----------|----------|-------
SB9009 | Events | Error | Incorrect event listener parameter count.
SB9010 | Events | Error | Incorrect event listener parameter type.
SB9011 | Events | Warning | Listener uses event with no MethodArgumentsAttribute.
SB9011 | Events | Warning | Listener uses event with no MethodArgumentsAttribute.
SB9012 | Commands | Error | Server command parameter type is unsupported.
30 changes: 30 additions & 0 deletions SboxAnalyzers/Diagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,34 @@ public static class NetProperty
NetworkableRule,
AutoPropertyRule );
}

/// <summary>
/// Contains information for analyzers relating to server commands.
/// </summary>
public static class ServerCmd
{
/// <summary>
/// An error diagnostic to notify that a server commands parameter is not supported.
/// </summary>
public const string UnsupportedId = "SB9012";
/// <summary>
/// The category that all of the diagnostics fit into.
/// </summary>
private const string Category = "Commands";

private static readonly LocalizableString UnsupportedTitle = new LocalizableResourceString( nameof( ServerCmdResources.UnsupportedTitle ), ServerCmdResources.ResourceManager, typeof( ServerCmdResources ) );
private static readonly LocalizableString UnsupportedMessageFormat = new LocalizableResourceString( nameof( ServerCmdResources.UnsupportedMessageFormat ), ServerCmdResources.ResourceManager, typeof( ServerCmdResources ) );
private static readonly LocalizableString UnsupportedDescription = new LocalizableResourceString( nameof( ServerCmdResources.UnsupportedDescription ), ServerCmdResources.ResourceManager, typeof( ServerCmdResources ) );
internal static readonly DiagnosticDescriptor UnsupportedRule = new(
UnsupportedId,
UnsupportedTitle,
UnsupportedMessageFormat,
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: UnsupportedDescription );

internal static readonly ImmutableArray<DiagnosticDescriptor> AllRules = ImmutableArray.Create(
UnsupportedRule );
}
}

0 comments on commit 1dd9434

Please sign in to comment.