久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

“將所有警告視為錯誤,除了..."在 Visual St

quot;Treat all warnings as errors except...quot; in Visual Studio(“將所有警告視為錯誤,除了...在 Visual Studio 中)
本文介紹了“將所有警告視為錯誤,除了..."在 Visual Studio 中的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

在 Visual Studio 中,我可以選擇將警告視為錯誤"選項,以防止在出現任何警告時編譯我的代碼.我們的團隊使用此選項,但我們希望保留兩個警告作為警告.

有一個禁止警告的選項,但我們確實希望它們顯示為警告,所以這不起作用.

似乎獲得我們想要的行為的唯一方法是在特定警告"文本框中輸入每個 C# 警告編號的列表,除了我們希望視為警告的兩個.

除了令人頭疼的維護之外,這種方法的最大缺點是一些警告沒有數字,因此無法明確引用.例如,無法解析此引用.找不到程序集 'Data....'"

有人知道更好的方法嗎?

<小時>

為那些沒有立即明白為什么這是有用的人澄清.想想大多數警告是如何工作的.他們告訴你,你剛寫的代碼有些不對勁.修復它們大約需要 10 秒,這使代碼庫更加整潔.

過時"警告與此大不相同.有時修復它意味著只使用一個新的方法簽名.但是,如果整個類已經過時,并且您在數十萬行代碼中分散使用它,則可能需要數周或更長時間才能修復.您不希望構建被破壞那么久,但您肯定希望看到有關它的警告.這不僅僅是一個假設的案例——這已經發生在我們身上.

文字#warning"警告也是獨一無二的.我經常想要檢查它,但我不想破壞構建.

解決方案

在 Visual Studio 2022 中,我們有一個新的項目屬性 UI,其中包括一個編輯器.

構建下 |錯誤和警告 如果您將 Treat warnings as errors 設置為 All,則會出現另一個屬性,允許您免除特定警告被視為錯誤:p>

這會將以下屬性添加到您的項目中:

<WarningsNotAsErrors>618,1030,1701,1702</WarningsNotAsErrors>

In Visual Studio, I can select the "Treat warnings as errors" option to prevent my code from compiling if there are any warnings. Our team uses this option, but there are two warnings we would like to keep as warnings.

There is an option to suppress warnings, but we DO want them to show up as warnings, so that won't work.

It appears that the only way to get the behavior we want is to enter a list of every C# warning number into the "Specific warnings" text box, except for the two we want treated as warnings.

Besides the maintenance headache, the biggest disadvantage to this approach is that a few warnings do not have numbers, so they can't be referenced explicitly. For example, "Could not resolve this reference. Could not locate assembly 'Data....'"

Does anyone know of a better way to do this?


Clarifying for those who don't see immediately why this is useful. Think about how most warnings work. They tell you something is a little off in the code you just wrote. It takes about 10 seconds to fix them, and that keeps the code base cleaner.

The "Obsolete" warning is very different from this. Sometimes fixing it means just consuming a new method signature. But if an entire class is obsolete, and you have usage of it scattered through hundreds of thousands of lines of code, it could take weeks or more to fix. You don't want the build to be broken for that long, but you definitely DO want to see a warning about it. This isn't just a hypothetical case--this has happened to us.

Literal "#warning" warnings are also unique. I often want to check it in, but I don't want to break the build.

解決方案

In Visual Studio 2022 we have a new Project Properties UI which includes an editor for this.

Under Build | Errors and Warnings if you set Treat warnings as errors to All, then another property appears which allows you to exempt specific warnings from being treated as errors:

This will add the following property to your project:

<WarningsNotAsErrors>618,1030,1701,1702</WarningsNotAsErrors>

這篇關于“將所有警告視為錯誤,除了..."在 Visual Studio 中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Is there a C# library that will perform the Excel NORMINV function?(是否有執行 Excel NORMINV 函數的 C# 庫?)
Select x random elements from a weighted list in C# (without replacement)(從 C# 中的加權列表中選擇 x 個隨機元素(無需替換))
Create a summary description of a schedule given a list of shifts(給定輪班列表,創建時間表的摘要描述)
C# Normal Random Number(C# 普通隨機數)
Standard deviation of generic list?(通用列表的標準偏差?)
AsyncCTP: Creating a class that is IAwaitable(AsyncCTP:創建一個 IAwaitable 的類)
主站蜘蛛池模板: 亚洲欧美综合精品另类天天更新 | 国产精品久久久久国产a级 欧美日韩国产免费 | 国产精品乱码一二三区的特点 | 亚洲精品乱码久久久久久久久 | 国产精品美女久久久久aⅴ国产馆 | 成人综合一区二区 | 免费一区二区 | 美女三区 | 天天操天天摸天天爽 | 黄色毛片在线看 | 亚洲视频中文字幕 | 国产中文一区二区三区 | 日韩不卡三区 | 在线一区视频 | 成人午夜影院 | 91精品久久久久久久久99蜜臂 | 男女下面一进一出网站 | 欧美日韩精品区 | 中文字幕高清在线 | 日韩中文欧美 | 日韩快播电影 | 欧美一区二区精品 | 精品一区二区三区入口 | 成人无遮挡毛片免费看 | 亚洲男人的天堂网站 | 久久久成人免费视频 | 日韩成人免费视频 | 国产又色又爽又黄又免费 | 青青草av在线播放 | 欧美一级免费观看 | 欧美一区二区免费 | 国产精品无码久久久久 | www.日韩| 亚洲欧美日韩精品久久亚洲区 | 亚洲综合大片69999 | 久久一二 | 亚洲一区二区久久久 | k8久久久一区二区三区 | 黄色一级片在线播放 | 精久久久 | 99自拍视频|