Rosdi Kasim
Rosdi Kasim

Reputation: 26016

How to turn off Visual Studio 2015 Roslyn error highlighting?

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?'

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)

Upvotes: 4

Views: 6475

Answers (2)

Wietze
Wietze

Reputation: 412

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

Upvotes: 0

John Koerner
John Koerner

Reputation: 38087

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

Visual Studio 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.

Upvotes: 8

Related Questions