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

  • Roslyn Cookbook
  • Manish Vasani
  • 280字
  • 2021-07-15 17:07:38

How to do it...

  1. Create a C# class library project, say ClassLibrary, in Visual Studio 2017.
  2. From the top-level menu, navigate to Tools | Extensions and Updates.
  3. Navigate to Online | Visual Studio Marketplace on the left tab of the dialog to view the available VSIXes in the Visual Studio extension gallery/marketplace:
  1. Search analyzers in the search textbox in the upper-right corner of the dialog and download an analyzer VSIX, say Refactoring Essentials for Visual Studio:
  1. Once the download completes, you will get a message at the bottom of the dialog saying that the install will be scheduled to execute once Visual Studio and related windows are closed:
  1. Close the dialog and then close the Visual Studio instance to start the install.
  2. In the VSIX Installer dialog, click on Modify to start installation:
  1. The subsequent message prompts you to kill all the active Visual Studio and satellite processes. Save all your relevant work in all the open Visual Studio instances and click on End Tasks to kill these processes and install the VSIX:
  1. After installation, restart VS, click on Tools | Extensions And Updates, and verify that Refactoring Essentials VSIX is installed:
  1. Create a new C# project with the following source code and verify analyzer diagnostic RECS0085 (Redundant array creation expression) in the error list:
namespace ClassLibrary
{
public class Class1
{
void Method()
{
int[] values = new int[] { 1, 2, 3 };
}
}
}
  1. Build the project from Visual Studio 2017 or the command line and confirm that no analyzer diagnostic shows up in the output window or the command line, respectively, confirming that the VSIX analyzer did not execute as a part of the build.
主站蜘蛛池模板: 教育| 阳朔县| 文昌市| 沁水县| 德州市| 扎兰屯市| 乌拉特中旗| 宁乡县| 芷江| 呼伦贝尔市| 柳河县| 明水县| 江孜县| 蓬安县| 五家渠市| 武隆县| 织金县| 丽江市| 邢台市| 安仁县| 易门县| 星子县| 三亚市| 友谊县| 剑河县| 翁源县| 肃南| 沙洋县| 兴隆县| 康保县| 张掖市| 浑源县| 清水县| 武乡县| 垣曲县| 高雄县| 宝丰县| 平陆县| 广德县| 子长县| 灌阳县|