我希望能够发出警告,如果某一物体可能提出“Null Reference”例外,那么我就可以为这些例外撰写防御守则。
我看着Resharper,但看不出在这方面取得的成就。
《法典》合同可能是非开端合同;申请数量很大,在《法典》合同正式公布之前,在“NET”3.5中写成。
我希望能够发出警告,如果某一物体可能提出“Null Reference”例外,那么我就可以为这些例外撰写防御守则。
我看着Resharper,但看不出在这方面取得的成就。
《法典》合同可能是非开端合同;申请数量很大,在《法典》合同正式公布之前,在“NET”3.5中写成。
Resharper does in fact accomplish something like this. Possible NullReferenceExpections are highlighted in the IDE in blue, with tooltips when you hover over them.
然后,Resharper在自己的检查结果窗口上跟踪潜在的错误和警告(与视觉演播室的编辑错误和警告分开)。
一般说来,除非您具体提出反对, 至少就汇编者而言,它总是有可能放弃否定的参考。
为了检查提及物体是否可能无效,必须绕开你方案能够走的每一种可能途径,包括你可能使用的任何外部图书馆的道路。 即便是最简单的方案,这种算法也会杀害你的编辑。
我不反对在守则和每种方法中为每个领域盲目辩护的想法。
下面的帮助我决定,在什么地方制止无效价值:
1- Who will be invoking your methods?
If a method is private and you have control over how s it s being accessed, I don t see it makes sense to protect against null checks unless it s part of the method s logic to expect null values.
If a method is exposed to the public (Such as an API), then of course null checks should be a huge concern.
2- Software Design:
Image you have are calling method1(fromAnimalToString(animal));
and for some reason fromAnimalToString()
never returns null (Though might return an empty string instead).
Then in such case, it wouldn t make sense to check animal != null
in method1() s body
3- Testing:
In software engineering, it s almost impossible to test all possible scenarios that can ever execute. However, test normal and alternative scenarios and make sure the flow is as expected.
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...