久久久久久久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 的類)
主站蜘蛛池模板: 欧美男人天堂 | 成人激情视频网 | 欧美日韩久久久 | 日日干日日 | 国产福利一区二区 | 一区二区三区四区免费在线观看 | 在线视频中文字幕 | 国产色爽 | 久久se精品一区精品二区 | 超碰免费在线 | 亚洲一一在线 | 国产在线网站 | 久久综合久久久 | 亚洲黄色片免费观看 | 亚洲精品 在线播放 | 久久久久久久91 | 欧洲一区在线观看 | 欧美一区二区三区视频在线观看 | 午夜精品一区 | 欧美理论片在线 | 日本免费网 | 欧美综合久久 | 午夜精 | 在线亚洲欧美 | 精品免费国产一区二区三区 | 欧美精品一区二区三区在线播放 | 午夜精品网站 | 成人欧美一区二区三区视频xxx | 日韩1区| 久久久久国产一区二区三区四区 | 国产欧美一区二区三区在线看蜜臀 | 一区二区三区四区免费视频 | 日韩欧美国产精品一区 | 欧美区日韩区 | 精品中文字幕在线 | 国产一二三区电影 | 日韩高清中文字幕 | 黄色一级电影免费观看 | 精品蜜桃一区二区三区 | 天天躁日日躁性色aⅴ电影 免费在线观看成年人视频 国产欧美精品 | 中文字幕在线播放不卡 |