How to turn off Visual Studio 2015 Roslyn error highlighting?

落花浮王杯 提交于 2019-12-10 07:52:38

问题


For Resharper we can selectively turn it on/off, but I could not find a way to turn off the built-in Visual Studio 2015 code highlights/suggestions.

The reason I want to do this is because I have quite a few left-join linqs and these queries messed up Visual Studio.

I am seeing lots of squiggles on my linqs and I prefer to turn them off.

Here is one of the error I am talking about.. I have no idea how to get rid of it.

The result of the expression is always 'true' since a value of type 'int' is never equal to 'null' of type 'int?'

EDIT

I have found a way to fix this from ScottGu's blog here: The C# ?? null coalescing operator (and using it with LINQ)


回答1:


If you are talking about the Code Analysis rules. Then under the project references, there is an analyzers node.

If you right click and select "Open Active Rule Set", then you can turn off any of the analyzers you don't want.




回答2:


Have you tried ((int?)result.Id).HasValue? This is the correct way to check a nullable type for nul value.



来源:https://stackoverflow.com/questions/31353155/how-to-turn-off-visual-studio-2015-roslyn-error-highlighting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!