Search code examples
c#resharpereditorconfig

What rule (Resharper/C# .editorconfig) rewrites "throw new()" as "throw new Exception()"?


I'm running the Resharper CLI on check-in to clean up C# code Prettier-style. It works great but I'm running into an issue where throw new() is rewritten as throw new Exception(). We use this mainly as a very brief sanity check for nullables, e.g. return somethingNullable ?? throw new()

The only rule I found in .editorconfig for exception/new/throw was:

csharp_style_throw_expression = true:suggestion

But deleting this rule does not fix the issue.

I tried a --verbose log, and while it shows all file output, it doesn't seem to provide a clue about what rule is actually causing the change.


Solution

  • Most likely it's csharp_object_creation_when_type_not_evident (see R# docs).