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

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

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

問(wèn)題描述

在 Visual Studio 中,我可以選擇將警告視為錯(cuò)誤"選項(xiàng),以防止在出現(xiàn)任何警告時(shí)編譯我的代碼.我們的團(tuán)隊(duì)使用此選項(xiàng),但我們希望保留兩個(gè)警告作為警告.

有一個(gè)禁止警告的選項(xiàng),但我們確實(shí)希望它們顯示為警告,所以這不起作用.

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

除了令人頭疼的維護(hù)之外,這種方法的最大缺點(diǎn)是一些警告沒(méi)有數(shù)字,因此無(wú)法明確引用.例如,無(wú)法解析此引用.找不到程序集 'Data....'"

有人知道更好的方法嗎?

<小時(shí)>

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

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

文字#warning"警告也是獨(dú)一無(wú)二的.我經(jīng)常想要檢查它,但我不想破壞構(gòu)建.

解決方案

在 Visual Studio 2022 中,我們有一個(gè)新的項(xiàng)目屬性 UI,其中包括一個(gè)編輯器.

構(gòu)建下 |錯(cuò)誤和警告 如果您將 Treat warnings as errors 設(shè)置為 All,則會(huì)出現(xiàn)另一個(gè)屬性,允許您免除特定警告被視為錯(cuò)誤:p>

這會(huì)將以下屬性添加到您的項(xiàng)目中:

<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>

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

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

相關(guān)文檔推薦

Is there a C# library that will perform the Excel NORMINV function?(是否有執(zhí)行 Excel NORMINV 函數(shù)的 C# 庫(kù)?)
Select x random elements from a weighted list in C# (without replacement)(從 C# 中的加權(quán)列表中選擇 x 個(gè)隨機(jī)元素(無(wú)需替換))
Create a summary description of a schedule given a list of shifts(給定輪班列表,創(chuàng)建時(shí)間表的摘要描述)
C# Normal Random Number(C# 普通隨機(jī)數(shù))
Standard deviation of generic list?(通用列表的標(biāo)準(zhǔn)偏差?)
AsyncCTP: Creating a class that is IAwaitable(AsyncCTP:創(chuàng)建一個(gè) IAwaitable 的類)
主站蜘蛛池模板: 成人午夜视频在线观看 | 亚洲深夜福利 | xxxx色 | 91看片看淫黄大片 | 一级大片免费看 | 日韩一区二区三区av | 国产小视频在线播放 | 91精品国产99久久久久久红楼 | 欧美黄色免费 | 久久国产欧美 | 日韩欧美精品一区二区 | 成人欧美一区二区三区黑人免费 | 国产精品国产 | 成人国产精品久久久网站 | 精品免费 | 日韩精品免费在线观看 | 日韩午夜影院 | 在线观看的av网站 | 国内福利视频 | 亚洲久久久 | 国产精品一品二区三区的使用体验 | 波多野结衣视频在线播放 | 一级片免费观看 | 亚洲综合国产 | 五月天激情综合 | 婷婷五月在线视频 | 在线色网 | 亚洲欧美中文字幕 | 国产理论在线观看 | 中文字幕在线免费播放 | 欧美日韩小视频 | 黄色录像免费看 | 夜夜骚av | 日本不卡在线 | 亚洲视频一区在线观看 | 日韩福利 | 黄色在线免费网站 | 一级毛片播放 | 日韩在线播放视频 | av女人天堂| 青青草国产在线视频 |