- Roslyn Cookbook
- Manish Vasani
- 171字
- 2021-07-15 17:07:33
How to do it...
- In Solution Explorer, double-click on Resources.resx file in CSharpAnalyzers project to open the resource file in the resource editor.
- Replace the existing resource strings for AnalyzerDescription, AnalyzerMessageFormat and AnalyzerTitle with new strings.

- Replace the Initialize method implementation with the code from CSharpAnalyzers/CSharpAnalyzers/CSharpAnalyzers/DiagnosticAnalyzer.cs/ method named Initialize.
- 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.
- Click on Ctrl + F5 to start a new Visual Studio instance with the analyzer enabled.
- 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;
}
}
}
- Verify the analyzer diagnostic is not reported for param1 and param2, but is reported for param3 and param4:

- Now, add code to use param3 in the local declaration statement, delete param4, and verify the diagnostics go away:

推薦閱讀
- Learn TypeScript 3 by Building Web Applications
- Advanced Machine Learning with Python
- Python計算機視覺編程
- Backbone.js Blueprints
- MATLAB for Machine Learning
- RabbitMQ Cookbook
- 匯編語言編程基礎:基于LoongArch
- Processing創意編程指南
- 編寫高質量代碼:改善Objective-C程序的61個建議
- FPGA嵌入式項目開發實戰
- Python語言科研繪圖與學術圖表繪制從入門到精通
- 小程序從0到1:微信全棧工程師一本通
- Node.js區塊鏈開發
- Tableau Desktop可視化高級應用
- Mudbox 2013 Cookbook