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

推薦閱讀
- Cocos2d Cross-Platform Game Development Cookbook(Second Edition)
- Advanced Machine Learning with Python
- Oracle WebLogic Server 12c:First Look
- 騰訊iOS測試實踐
- ASP.NET Core 2 and Vue.js
- oreilly精品圖書:軟件開發者路線圖叢書(共8冊)
- Java性能權威指南(第2版)
- SSM輕量級框架應用實戰
- 學習正則表達式
- Java網絡編程核心技術詳解(視頻微課版)
- 微信小程序開發與實戰(微課版)
- Building Dynamics CRM 2015 Dashboards with Power BI
- C編程技巧:117個問題解決方案示例
- Python Machine Learning Blueprints:Intuitive data projects you can relate to
- Data Manipulation with R(Second Edition)