- 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:

推薦閱讀
- Mastering OpenCV Android Application Programming
- Python深度學習
- JavaScript+jQuery開發實戰
- Julia機器學習核心編程:人人可用的高性能科學計算
- 64位匯編語言的編程藝術
- TypeScript實戰指南
- C++面向對象程序設計習題解答與上機指導(第三版)
- Mastering Elasticsearch(Second Edition)
- 寫給大家看的Midjourney設計書
- 計算語言學導論
- INSTANT Apache Hive Essentials How-to
- SCRATCH編程課:我的游戲我做主
- HTML5+CSS3+jQuery Mobile+Bootstrap開發APP從入門到精通(視頻教學版)
- Learning Java Lambdas
- C++教程