Code cleanup, expression body style being ignored?

Answered

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:

https://recordit.co/sKaoEr2etd

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.

0
3 comments

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.

0

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:

https://recordit.co/4mYlvG4BCr

The complete settings we have are:

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

0

Aruecope, please uncheck the "Apply style heuristics" option. An explanation of this behavior can be found here: https://youtrack.jetbrains.com/issue/RSRP-484441#focus=Comments-27-4897188.0-0

0

Please sign in to leave a comment.