From 97120c6df2f59a12eef0129f13d773bdde305184 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 14 Apr 2018 20:33:43 -0400 Subject: [PATCH] update references to old warning IDs (#471) --- docs/mod-build-config.md | 12 ++++++------ docs/screenshots/code-analyzer-example.png | Bin 4022 -> 3473 bytes .../NetFieldAnalyzer.cs | 1 - .../ObsoleteFieldAnalyzer.cs | 1 - src/SMAPI/Framework/SGame.cs | 2 +- 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 `` 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 3b930dc5f57dd9101a5a9fec8cdb6f6cdca278ee..de38f6433e43ff831d0bb5a11dae93dd49816970 100644 GIT binary patch literal 3473 zcmb7GcTf{d(?=pj5h7ix0xAd*r1vTqT0jD!_Y%O+!O-EMD)o^rCDM@+sUjT&M0%BK zD1sCN0Zbs$;RD~9@6UJUy_vh)z5VTPZ)a|AHs-kwnEEE`O%f6kY7KQ&Ct1Sq zc}VA@X6&Qy4)^i3@p2#mdpS6`c{{oLSi&eTU8pHFRFw__K$w?GXpM zt9Kix&&?6L^#{@$i{2f{8_W6Vx{>4Wh+XfIO$eb_>+&v_159&E?61Hs|77g1;IZEa z7{(H8{aNj)7EUCYbcK$0l*nFu|JIY>aqSB6`Ir(w4ZIK7>l38NqFrNWt_=PCYwjoS z(CCgOP==JqV0Z5d=0YPm7N2!DI;1m`UT9Xy8-d5+R}$&{YnyyAF*K8~Q%%4XEIXWn z^=IK`h$sGaL=>CTAurjpkIYD(5X9@nNNWKx*9bq~IY`Q`<`*6w14A?BI_&aE zC&&Hn#l#v^m&(P|N^p52ZMJN09B?lqX4+2+bA#51Rndb2z8A+)UGE#%G=bYAPlvkA z?$3uDzI~Y80=%o(d=cHzQ#y0?B1k@~9)>*&ejX=;K0M`hJ)`A31;t^N!zWp`57BRa z=c^9!NyLtZs}gvHDjNNNP_Vv(uNW7Svo`&8CYkOEpP@ix+9>vp1OBO?NpqV;wHq zR}2jmS@Eg3%7i=IaM}(ZUnvU(3lRBwW`ZXo>D-eZC`k|^JK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&Uk>%rdZ!R(TdhKNCYFWdyZmCu!EF^wpeLa**BIpbw0zC zDU&w|kfFdA*pYZyFcc%_HAe9szYWF?+X!Hv4A`<)$L$9#WVL?G*Ar!O#RMO#ql)$2 zO)=X_DT%pg;Wj(t!PS1Jz^3Y}hcG^N6k&qXc-Vg|OPu88?oJ7X42p#gICN4@UzPP{ z+=B6S9w|_obs(sbrkQ3yrfRz!>2V7cC}zbNFs47)^s+p+ZRoNrJv#_!UNG1@@^|OX zoP{=@gi^N`N{#J$VyTYUY});q3^I<;tW|35EV?GHByT9SyVF3ma?aiU0(8x4J#Ihn@={ShVO=cmKG#7f z8s~1C$6#VycD0nUtnXw=7xUM-YIs8*0pK!J9YeMmD?k^qix74+X0*6^mqnl21$efF zA4udb84GQ7C8y+$ZmFeEv)SSk$h4*VS(IBO@$NEoN?8m~f}5CPJ11+w5b&9mn1^`O zlCRykcZr+%n`PKLh>qJUvMn+_EwKNz;ncn7FNb#o!n57eB$Ab{T0h+4(>13Ug(#vY z`*S>qh%LurRz_WGKK4697f*|PN?Zy?r_vP& z2`&pk zRL>RE9+_A8jKV3`tPYuMx>OAmi6T2o`vAZ`%(IJ$z3e_wYJ`V%}5DwIp?TVkfkCdo(wMCvzW$Lt=ppUpc z8VAf&H1&2$OGNfI)wxJi=xyuJ*z&D|-9G1`!qKtl=L|En$J h{|wrdn4eBMWIw5|RdeT+ZQb#K1FCDNL(;kz{(rMimbL%@ 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 /// The analysis context. 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 /// The analysis context. 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)