Visual Studio 2019 temporarily enable warning disabled in project

Andrei Mirea 41 Reputation points

Hi. Is there a way to disable an arbitrary warning in project and only enabling it in certain parts of code?
I mean something like

#pragma warning disable C26451   
// code  
#pragma warning restore C26451  

but instead of enable by default and disable explicitly, disable by default and enable explicitly. I couldn't find "enable" in but maybe there's a way to achieve this with push/pop, levels or otherwise.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,877 questions
{count} votes

Accepted answer
  1. Dylan Zhu-MSFT 6,406 Reputation points

    Hi AndreiMirea,

    After my research, temporarily enabling warning which is disabled is not supported. We suggest you can submit it as a suggestion in developer community:

    Best Regards. Dylan

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our * *documentation* to enable e-mail notifications if you want to receive the related email notification for this thread.**

0 additional answers

Sort by: Most helpful