awshelleyBeckman
awshelleyBeckman

Reputation: 412

How do I prevent ReSharper/Rider from auto-formatting certain auto-generated files on save, in a way that will be shared with my team?

We use ReSharper/Rider on our .NET 4.7 project, and we have it configured to auto-format the files we edit whenever we save. This behavior applies to *.cs files, as expected, but it unfortunately also applies to some files that the IDE generates(for example: those huge App.Config files with all of those binding redirects). This is a problem because ReSharper/Rider's formatting rules do not match the format the IDE uses when generating(or automatically modifying) them. If we ever need to make a manual change to such a file(IE: to solve a merge conflict), then ReSharper/Rider will automatically re-indent everything upon saving, using its own rules. Then the next time that file gets modified by the IDE(IE: to add a new binding redirect for a newly-installed package), it will be re-indented using the IDE's formatting rules(which are different from ReSharper's).

To avoid this problem, we would like to exclude certain file types from being auto-formatted by ReSharper/Rider. And we'd like this setting to be automatically shared amongst all of our developers, similar to how ReSharper/Rider's other settings are(IE: in an editorconfig or a dotsettings file).

I have tried using the setting File | Settings | Editor | Code Style | Do not format:, but that setting does not get shared with my team. It appears to not be saved in the DotSettings file. Please don't tell me to change this setting.

I tried changing the setting specified in this other StackOverflow question, but that didn't work; it did get shared with my coworkers, but it didn't have any effect on which files get auto-formatted. I'm assuming that answer is out-of-date, given that it is from 2015.

I also tried changing File | Settings | Editor | Inspection Settings | File masks, but still no luck. This setting does get shared with the rest of the team, but it doesn't prevent any files from being auto-formatted. Or this one, either.

I do not believe this question is a duplicate. To prove that I've done my due diligence, here are the closest questions I've found, and why I don't believe it's a duplicate.

Upvotes: 0

Views: 2693

Answers (1)

Igor Akhmetov
Igor Akhmetov

Reputation: 1930

If you set "Scheme" to "Project" on the "Code Style" settings page, the value of the "Do not format" setting should be stored in the .idea folder of your project and you can share it with other developers if you want to by committing to your repo. Specifically, you want to commit the .idea\.idea.[Solution_Name]\.idea\codeStyles\Project.xml file.

Upvotes: -1

Related Questions