update references to old warning IDs (#471)
This commit is contained in:
parent
1848abe7d5
commit
97120c6df2
|
@ -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:
|
The NuGet package adds code warnings in Visual Studio specific to Stardew Valley. For example:
|
||||||
![](screenshots/code-analyzer-example.png)
|
![](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 specific code](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-pragma-warning);
|
||||||
* for a method using this attribute:
|
* for a method using this attribute:
|
||||||
```cs
|
```cs
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("SMAPI.CommonErrors", "SMAPI001")] // implicit net field conversion
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("SMAPI.CommonErrors", "AvoidNetField")]
|
||||||
```
|
```
|
||||||
* for an entire project:
|
* for an entire project:
|
||||||
1. Expand the _References_ node for the project in Visual Studio.
|
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
|
can implicitly convert to their equivalent normal values (like `bool x = new NetBool()`), but their
|
||||||
conversion rules are unintuitive and error-prone. For example,
|
conversion rules are unintuitive and error-prone. For example,
|
||||||
`item?.category == null && item?.category != null` can both be true at once, and
|
`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:
|
Suggested fix:
|
||||||
* Some net fields have an equivalent non-net property like `monster.Health` (`int`) instead of
|
* 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.
|
these. Use the suggested property instead.
|
||||||
* For a reference type (i.e. one that can contain `null`), you can use the `.Value` property:
|
* For a reference type (i.e. one that can contain `null`), you can use the `.Value` property:
|
||||||
```c#
|
```c#
|
||||||
|
@ -189,8 +189,8 @@ Suggested fix:
|
||||||
Warning text:
|
Warning text:
|
||||||
> '{{expression}}' is a {{net type}} field; consider using the {{property name}} property instead.
|
> '{{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
|
Your code accesses a net field, which has some unusual behavior (see [AvoidImplicitNetFieldCast](#avoid-implicit-net-field-cast)).
|
||||||
field has an equivalent non-net property that avoids those issues.
|
This field has an equivalent non-net property that avoids those issues.
|
||||||
|
|
||||||
Suggested fix: access the suggested property name instead.
|
Suggested fix: access the suggested property name instead.
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.4 KiB |
|
@ -175,7 +175,6 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
|
||||||
/// <param name="context">The analysis context.</param>
|
/// <param name="context">The analysis context.</param>
|
||||||
public override void Initialize(AnalysisContext context)
|
public override void Initialize(AnalysisContext context)
|
||||||
{
|
{
|
||||||
// SMAPI002: avoid net fields if possible
|
|
||||||
context.RegisterSyntaxNodeAction(
|
context.RegisterSyntaxNodeAction(
|
||||||
this.AnalyzeMemberAccess,
|
this.AnalyzeMemberAccess,
|
||||||
SyntaxKind.SimpleMemberAccessExpression,
|
SyntaxKind.SimpleMemberAccessExpression,
|
||||||
|
|
|
@ -56,7 +56,6 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
|
||||||
/// <param name="context">The analysis context.</param>
|
/// <param name="context">The analysis context.</param>
|
||||||
public override void Initialize(AnalysisContext context)
|
public override void Initialize(AnalysisContext context)
|
||||||
{
|
{
|
||||||
// SMAPI003: avoid obsolete fields
|
|
||||||
context.RegisterSyntaxNodeAction(
|
context.RegisterSyntaxNodeAction(
|
||||||
this.AnalyzeObsoleteFields,
|
this.AnalyzeObsoleteFields,
|
||||||
SyntaxKind.SimpleMemberAccessExpression,
|
SyntaxKind.SimpleMemberAccessExpression,
|
||||||
|
|
|
@ -633,7 +633,7 @@ namespace StardewModdingAPI.Framework
|
||||||
[SuppressMessage("ReSharper", "RedundantCast", Justification = "copied from game code as-is")]
|
[SuppressMessage("ReSharper", "RedundantCast", Justification = "copied from game code as-is")]
|
||||||
[SuppressMessage("ReSharper", "RedundantExplicitNullableCreation", 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("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)
|
private void DrawImpl(GameTime gameTime)
|
||||||
{
|
{
|
||||||
if (Game1.debugMode)
|
if (Game1.debugMode)
|
||||||
|
|
Loading…
Reference in New Issue