官术网_书友最值得收藏!

How to do it...

  1. In Solution Explorer, double-click on Resources.resx file in CSharpAnalyzers project to open the resource file in the resource editor.
  2. Replace the existing resource strings for AnalyzerDescription, AnalyzerMessageFormat and AnalyzerTitle with new strings.
  1. Replace the Initialize method implementation with the code from CSharpAnalyzers/CSharpAnalyzers/CSharpAnalyzers/DiagnosticAnalyzer.cs/ method named Initialize.
  2. Add private class UnusedParametersAnalyzer from CSharpAnalyzers/CSharpAnalyzers/CSharpAnalyzers/DiagnosticAnalyzer.cs/ type named UnusedParametersAnalyzer in your analyzer to perform the core method body analysis for a given method.
  3. Click on Ctrl + F5 to start a new Visual Studio instance with the analyzer enabled.

 

  1. In the new Visual Studio instance, create a new C# class library with the following code:
namespace ClassLibrary
{
public class Class1
{
void M(int param1, ref int param2, int param3, params int[] param4)
{
int local1 = param1;
param2 = 0;
}
}
}
  1. Verify the analyzer diagnostic is not reported for param1 and param2, but is reported for param3 and param4:
  1. Now, add code to use param3 in the local declaration statement, delete param4, and verify the diagnostics go away:
主站蜘蛛池模板: 梁河县| 湘西| 威信县| 古蔺县| 高要市| 上杭县| 巨鹿县| 乌兰浩特市| 安吉县| 洱源县| 锡林浩特市| 凯里市| 浦江县| 文山县| 辛集市| 栾川县| 印江| 永福县| 巩义市| 拉萨市| 静安区| 自治县| 澜沧| 运城市| 保德县| 宝清县| 台州市| 庆云县| 平阴县| 河南省| 大田县| 界首市| 栖霞市| 蒙自县| 镇原县| 格尔木市| 麻阳| 曲松县| 丘北县| 文山县| 县级市|