0

Warning messages such as "Variable 'e' is declared but never used" may not allow the solution to compile, in visual studio code with c#. Force developers to create cleaner code. It's possible?

  • From what I remember there is an option called "Treat warnings as errors" or something like this in VS. – Mihai Alexandru-Ionut Dec 09 '21 at 14:16
  • If I understand correctly, this is what you want: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings#treatwarningsaserrors – Jack A. Dec 09 '21 at 14:17
  • could this be just for visual studio ?. I am searching for Visual Studio Code. – Jonathan Roldan Dec 09 '21 at 15:09
  • It's a C# compiler option so it applies to both studio and code. You can set it in your .csproj file using the XML example in that section I linked. – Jack A. Dec 09 '21 at 15:36
  • To apply it to all projects, you should be able to add it to one of the shared MSBuild files: https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2022 – Jack A. Dec 09 '21 at 15:39
  • excellent, there I could configure it. Thank you very much for your time! – Jonathan Roldan Dec 09 '21 at 15:50

0 Answers0