❔ Suppress Visual Studio IDE0270 style rule without adding '.editorconfig'
I have some cases in my code where I have if statements like the following:
But the visual studio 'Error List' shows 'messages' that say 'Null check can be simplified' (fg. 1) which in some cases I am ok with simplifying but with the above example it would want to make it like this:
Which I personally don't like in this case.
So how can I suppress this specific rule style code? I know you can configure code style within the code style section of the settings (fg. 2) but I have the 'perfer throw-expression' already set to 'no' so I don't know why this message still shows up.
Obviously you can add a .editorconfig to the actual project but I do not want to do that. I want it as part of the permanent code style within my visual studio.
Maybe this is just bugged? If you click the link in the error list for this error code 'IDE0270' it takes you to a 404... (https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0270).
5 Replies
// Disable IDE0270
I think that should work
@whiteviperx Maybe but like I said I want to make it permanent since I am working in several solutions and I don't want to modify the repositories. All other code styles I have managed to configure but this one.
An odd idea might be to add it the the default header??
if you get a chance can you look at my question?
You could also try this ... create the editorconfig file and put it in the folder C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE.... or similar??? just a thought
@whiteviperx that might work. I am away right now but will try that when I get a chance
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.