How to diagnose why ReSharper is reporting an error in code analysis

I am working on a solution (new client) where certain items that would normally be reported as a R# warning are instead being reported as an error. For example, "Code is unreachable" (which is a warning by default). I understand that these can be configured to be other than their default reporting level, but I am unable to discover where the override is occurring (it does not appear to be overridden in the standard R# settings - personal, team etc). If I create a simple test solution, unreachable code is reported as a warning, as one would expect.

Does R# report anywhere the various checks that it makes in order to determine whether analysis is going to report something as an warning or an error?

0
6 comments
Avatar
Alexander Nikolaenko

Hello Jameshebben36,

Please check ReSharper options with search. I am sure you will find an inspection with "Error" level.

0

Hello @...,

That is what I thought as well, but that is not the case. I cannot understand where R# is determining that unreachable code should be reported as an error, but it is. Where else does R# check? This is quite a big solution that I am not able to share with you.

 

 

To recap, if I create a simple new C# project, unreachable code is reported as a warning, as would be expected.

 

0
Avatar
Alexander Nikolaenko

Jameshebben36,

Thank you for the update!

Did you try clearing the caches via **ReSharper | Options | General | Clear caches** and then restart Visual Studio?

0

@...,

I've cleared the caches and the same errors are reported. Interestingly, Rider/R# seems to think these are partly errors and partly warnings (could it be Roslyn checks getting in on the act?):

 

0

@..., I think I've got to the bottom of this. There is a Directory.build.props file in the parent folder with

  <TreatWarningsAsErrors>true</TreatWarningsAsErrors>

This seems to cause R# to mark the code item as red (error), but the R# context menu still lists it in the "Configure inspection severity" menu item as a warning.

 

0
Avatar
Alexander Nikolaenko

Hi James,

Thank you for the update. Glad to hear it was sorted out!

0

Please sign in to leave a comment.