Code cleanup, expression body style being ignored?


Something that's been bothering me for a while is that R# code cleanup is ignoring our body-style preference. Possibly it's a configuration issue but I just can't find it. When I highlight an expression body method and select 'Detect formatting settings' it responds with 'We can't recommend any changes...' but if that's the case why does code cleanup not change code that isn't correct. See attached recording:

We have code cleanup set to run on every save and it does a lot of other things but for some reason it won't convert block methods to expression bodies.


Aruecope, thank you for your question. What option do you have set for "ReSharper | Options | Code Editing | C# | Syntax Style | Code body | Methods and operators"?

As for 'Detect formatting settings' - it only detects formatting, not code style.


I've worked out what the problem is. R# is only offering to convert to expression body if there is a return type. It won't do it for void even though that's valid:

The complete settings we have are:

And it appears to be the 'Apply style heuristics' that's the issue.


Aruecope, please uncheck the "Apply style heuristics" option. An explanation of this behavior can be found here:


Please sign in to leave a comment.