问题描述
根据
如果您感兴趣的话,这里是在市场中。
这是。
目前,它不检查对象是否具有对运算符 ==和!=的替代。愿意捐款的人绝对值得欢迎。
According to the documentation of the ==
operator in MSDN,
But, to be honest, I never check if two references are the same with ==
.
I prefer using ReferenceEquals(obj1, obj2)
and so do the default override of the Equals
function.
Therefore, in my projects, when the == operator is used on other types than string, equals to a bug.
Is there a way to trigger a warning/error through Visual Studio or ReSharper when == is used on references (apart from string)?
As suggested, I created an extension to do that.
If you're interested, here is the link to the extension in the marketplace.
And here is the link to the source code.
At the moment it does not check if the object has an override for the operators "==" and "!=". Whoever wants to contribute is more than welcome to do so.
这篇关于关于==的警告,用于引用(Visual Studio或ReSharper)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!