C# 编译器扩展在生成时不显示消息
C# Compiler Extension doesn't show messages on build
我有一个 DiagnosticAnalyzer
子类可以正确识别我的问题,并在 VS 的错误 window 中显示它们。接下来是编写代码修复程序,但我预计不会有任何问题。
但是,当我实际构建我的应用程序时,我添加的警告和错误并没有出现。这是诊断分析仪的局限性吗?如果没有,我如何通知 Roslyn 我也想在构建时看到这些问题?
来自the docs:
Roslyn code analyzers can be installed per-project via a NuGet package. Some are also available as a Visual Studio extension, in which case they apply to any solution you open in Visual Studio. There are some key behavior differences between these two methods of installing analyzers.
Scope
If you install analyzers as a Visual Studio extension, they apply at the solution level and to all instances of Visual Studio. If you install the analyzers as a NuGet package, which is the preferred method, they apply only to the project where the NuGet package was installed. In team environments, analyzers installed as NuGet packages are in scope for all developers that work on that project.
Build errors
To have rules enforced at build time, including through the command line or as part of a continuous integration (CI) build, install the analyzers as a NuGet package. Analyzer warnings and errors don't show up in the build report if you install the analyzers as an extension.
我有一个 DiagnosticAnalyzer
子类可以正确识别我的问题,并在 VS 的错误 window 中显示它们。接下来是编写代码修复程序,但我预计不会有任何问题。
但是,当我实际构建我的应用程序时,我添加的警告和错误并没有出现。这是诊断分析仪的局限性吗?如果没有,我如何通知 Roslyn 我也想在构建时看到这些问题?
来自the docs:
Roslyn code analyzers can be installed per-project via a NuGet package. Some are also available as a Visual Studio extension, in which case they apply to any solution you open in Visual Studio. There are some key behavior differences between these two methods of installing analyzers.
Scope
If you install analyzers as a Visual Studio extension, they apply at the solution level and to all instances of Visual Studio. If you install the analyzers as a NuGet package, which is the preferred method, they apply only to the project where the NuGet package was installed. In team environments, analyzers installed as NuGet packages are in scope for all developers that work on that project.
Build errors
To have rules enforced at build time, including through the command line or as part of a continuous integration (CI) build, install the analyzers as a NuGet package. Analyzer warnings and errors don't show up in the build report if you install the analyzers as an extension.