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

如何強制執行空檢查?

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

問題描述

我正在從事一個大型項目,即使有成百上千的自動化測試和 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.

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

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

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

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

推薦答案

您應該查看 代碼合同.靜態檢查器僅適用于高端 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.

網上有很多資源,<plug> 你還可以閱讀 C# 2nd edition in Depth 中關于代碼契約的章節的預發布版本 - 免費下載第 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.)

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

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

相關文檔推薦

Why shouldn#39;t I always use nullable types in C#(為什么我不應該總是在 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#中將空值設置為int?)
How to handle nulls in LINQ when using Min or Max?(使用 Min 或 Max 時如何處理 LINQ 中的空值?)
Method call if not null in C#(在 C# 中如果不為 null 的方法調用)
主站蜘蛛池模板: 色888www视频在线观看 | 亚洲精品1区2区3区 91免费看片 | 国产亚洲成av人片在线观看桃 | 奇米四色在线观看 | 夜夜骑首页 | 成人免费一区二区三区视频网站 | 国产99热在线 | 欧美日韩中文字幕在线 | 久久不卡| 毛片在线免费播放 | 国产一区二区免费 | 亚洲精品电影在线观看 | 黄色网址在线免费播放 | 在线观看国产精品一区二区 | 国产免费一区二区三区 | 日韩欧美国产精品一区二区三区 | 在线看片国产精品 | 五月婷婷丁香婷婷 | 国产一区二区在线免费观看 | 精精精精xxxx免费视频 | 男人天堂av网站 | 国产午夜精品一区二区三区嫩草 | 麻豆国产一区二区三区四区 | 久久综合一区二区三区 | 九九九久久国产免费 | 羞羞视频网站免费观看 | 一区在线播放 | 欧美精品一区二区三区四区 | 精品美女在线观看 | a看片| 美女黄网 | 99这里只有精品视频 | 中文字幕日韩欧美一区二区三区 | 亚洲欧美日韩国产 | 黑人一级片视频 | 国产在线视频在线观看 | www.成人.com| 中文字幕视频在线观看 | 国产最新视频在线 | 国产视频久久久 | 国产精品久久久久久久久久久久久久 |