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

如何強制執(zhí)行空檢查?

How do I enforce null checking?(如何強制執(zhí)行空檢查?)
本文介紹了如何強制執(zhí)行空檢查?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在從事一個大型項目,即使有成百上千的自動化測試和 100% 的代碼覆蓋率,我們也會遇到大量錯誤.我們得到的大約 95% 的錯誤都是 NullReferenceExceptions.

I'm working on a large project where, even with 10s of 1000s of automated tests and 100% code coverage, we're getting a ridiculous number of errors. About 95% of errors we get are NullReferenceExceptions.

有沒有辦法在編譯時強制執(zhí)行空檢查?

Is there any way to enforce null-checking at compile time?

除此之外,有沒有什么方法可以在單元測試中自動強制執(zhí)行空檢查,而不必自己為空情況編寫測試?

Barring that, is there any way to automagically enforce null-checking in unit tests without having to write the tests for null cases myself?

推薦答案

您應(yīng)該查看 代碼合同.靜態(tài)檢查器僅適用于高端 VS 版本,但這基本上是您所追求的.

You should look into Code Contracts. The static checker is only available for the higher-end VS editions, but that's basically what you're after.

網(wǎng)上有很多資源,<plug> 你還可以閱讀 C# 2nd edition in Depth 中關(guān)于代碼契約的章節(jié)的預(yù)發(fā)布版本 - 免費下載第 15 章.</plug>(這一章相對于最新和最偉大的代碼契約版本來說有點過時,但沒什么大不了的.)

There are plenty of resources online, and <plug> you can also read a prerelease version of the chapter on Code Contracts from the 2nd edition of C# in Depth - download chapter 15 for free. </plug> (The chapter is slightly out of date with respect to the latest and greatest build of Code Contracts, but nothing huge.)

這篇關(guān)于如何強制執(zhí)行空檢查?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Why shouldn#39;t I always use nullable types in C#(為什么我不應(yīng)該總是在 C# 中使用可空類型)
C# HasValue vs !=null(C# HasValue vs !=null)
C# ADO.NET: nulls and DbNull -- is there more efficient syntax?(C# ADO.NET:空值和 DbNull —— 有沒有更高效的語法?)
How to set null value to int in c#?(如何在c#中將空值設(shè)置為int?)
How to handle nulls in LINQ when using Min or Max?(使用 Min 或 Max 時如何處理 LINQ 中的空值?)
Method call if not null in C#(在 C# 中如果不為 null 的方法調(diào)用)
主站蜘蛛池模板: 久久精品中文字幕 | 久久精品成人 | 天天干天天玩天天操 | 谁有毛片 | 一级一片在线观看 | 亚洲不卡一 | 国产精品a久久久久 | 中文在线a在线 | 免费看91| 久久黄色网| 九九九视频在线观看 | 一级午夜aaa免费看三区 | 免费观看av | 九九精品网 | 一区二区三区不卡视频 | 精品国产青草久久久久福利 | 一级毛片大全免费播放 | 综合久久久 | 国产精品久久久久久久久污网站 | 成人九区 | 毛片黄片免费看 | 日本欧美国产在线观看 | 国产日韩欧美精品一区二区 | 一区二区三区国产 | 欧美亚洲一级 | 亚洲国产精品久久久 | 992tv人人草 久久精品超碰 | 狠狠的操 | 精品国产乱码久久久久久图片 | 久草久草久草 | 亚洲精品久久久久久久久久久 | 国产亚洲欧美另类一区二区三区 | 成人国产一区二区三区精品麻豆 | 国产重口老太伦 | 国产精品视频一二三区 | 国产精品永久免费视频 | 亚洲免费视频一区 | 一区二区三区在线 | 九色视频网 | 精品久久久久久一区二区 | 99re66在线观看精品热 |