summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/mod-build-config.md12
-rw-r--r--docs/screenshots/code-analyzer-example.pngbin4022 -> 3473 bytes
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs1
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer/ObsoleteFieldAnalyzer.cs1
-rw-r--r--src/SMAPI/Framework/SGame.cs2
5 files changed, 7 insertions, 9 deletions
diff --git a/docs/mod-build-config.md b/docs/mod-build-config.md
index d942beeb..74ee34e4 100644
--- a/docs/mod-build-config.md
+++ b/docs/mod-build-config.md
@@ -140,11 +140,11 @@ To enable it, add this above the first `</PropertyGroup>` in your `.csproj`:
The NuGet package adds code warnings in Visual Studio specific to Stardew Valley. For example:
![](screenshots/code-analyzer-example.png)
-You can hide the warnings...
+You can hide the warnings using the warning ID (shown under 'code' in the Error List). See...
* [for specific code](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-pragma-warning);
* for a method using this attribute:
```cs
- [System.Diagnostics.CodeAnalysis.SuppressMessage("SMAPI.CommonErrors", "SMAPI001")] // implicit net field conversion
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("SMAPI.CommonErrors", "AvoidNetField")]
```
* for an entire project:
1. Expand the _References_ node for the project in Visual Studio.
@@ -163,11 +163,11 @@ Stardew Valley uses net types (like `NetBool` and `NetInt`) to handle multiplaye
can implicitly convert to their equivalent normal values (like `bool x = new NetBool()`), but their
conversion rules are unintuitive and error-prone. For example,
`item?.category == null && item?.category != null` can both be true at once, and
-`building.indoors != null` will be true for a null value in some cases.
+`building.indoors != null` can be true for a null value.
Suggested fix:
* Some net fields have an equivalent non-net property like `monster.Health` (`int`) instead of
- `monster.health` (`NetInt`). The package will add a separate [SMAPI002](#smapi002) warning for
+ `monster.health` (`NetInt`). The package will add a separate [AvoidNetField](#avoid-net-field) warning for
these. Use the suggested property instead.
* For a reference type (i.e. one that can contain `null`), you can use the `.Value` property:
```c#
@@ -189,8 +189,8 @@ Suggested fix:
Warning text:
> '{{expression}}' is a {{net type}} field; consider using the {{property name}} property instead.
-Your code accesses a net field, which has some unusual behavior (see [SMAPI001](#smapi001)). This
-field has an equivalent non-net property that avoids those issues.
+Your code accesses a net field, which has some unusual behavior (see [AvoidImplicitNetFieldCast](#avoid-implicit-net-field-cast)).
+This field has an equivalent non-net property that avoids those issues.
Suggested fix: access the suggested property name instead.
diff --git a/docs/screenshots/code-analyzer-example.png b/docs/screenshots/code-analyzer-example.png
index 3b930dc5..de38f643 100644
--- a/docs/screenshots/code-analyzer-example.png
+++ b/docs/screenshots/code-analyzer-example.png
Binary files differ
diff --git a/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs b/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs
index 72d3bbf8..e3c92617 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs
+++ b/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs
@@ -175,7 +175,6 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
/// <param name="context">The analysis context.</param>
public override void Initialize(AnalysisContext context)
{
- // SMAPI002: avoid net fields if possible
context.RegisterSyntaxNodeAction(
this.AnalyzeMemberAccess,
SyntaxKind.SimpleMemberAccessExpression,
diff --git a/src/SMAPI.ModBuildConfig.Analyzer/ObsoleteFieldAnalyzer.cs b/src/SMAPI.ModBuildConfig.Analyzer/ObsoleteFieldAnalyzer.cs
index 943d0350..a770f47d 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer/ObsoleteFieldAnalyzer.cs
+++ b/src/SMAPI.ModBuildConfig.Analyzer/ObsoleteFieldAnalyzer.cs
@@ -56,7 +56,6 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
/// <param name="context">The analysis context.</param>
public override void Initialize(AnalysisContext context)
{
- // SMAPI003: avoid obsolete fields
context.RegisterSyntaxNodeAction(
this.AnalyzeObsoleteFields,
SyntaxKind.SimpleMemberAccessExpression,
diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs
index 67390882..be98aeb1 100644
--- a/src/SMAPI/Framework/SGame.cs
+++ b/src/SMAPI/Framework/SGame.cs
@@ -633,7 +633,7 @@ namespace StardewModdingAPI.Framework
[SuppressMessage("ReSharper", "RedundantCast", Justification = "copied from game code as-is")]
[SuppressMessage("ReSharper", "RedundantExplicitNullableCreation", Justification = "copied from game code as-is")]
[SuppressMessage("ReSharper", "RedundantTypeArgumentsOfMethod", Justification = "copied from game code as-is")]
- [SuppressMessage("SMAPI.CommonErrors", "SMAPI002", Justification = "copied from game code as-is")]
+ [SuppressMessage("SMAPI.CommonErrors", "AvoidNetField", Justification = "copied from game code as-is")]
private void DrawImpl(GameTime gameTime)
{
if (Game1.debugMode)