question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible to set this up within Jetbrains Rider using the folder watch to format on save?

See original GitHub issue

Has anyone set this up with Rider? I have never set up a watcher from scratch as with GoLand you just tell it to format on save and it is built into the IDE, but I would imagine it should be possible to set this up to be able to format the particular file you are working on and autoformat it on file save?

I tried to see if I could get a single folder to format but I believe I might have done it incorrectly as nothing happened. When I omitted the --files and subsequent path it did indeed work, but of course it did the entire project which then forced a reimport of all of the files into Unity which would end up becoming quite time consuming on larger projects.

This is what I attempted:

dotnet-format -v diag --workspace /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Navigation_DOTS_20192.sln --files  /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Assets/_instance.id/_ECS/scripts/Waypoint/Systems

I made a few purposeful changes to force the need for formatting and tried again with increased verbosity:

~ » dotnet-format -v diag --workspace /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Navigation_DOTS_20192.sln --files  /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Assets/_instance.id/_ECS/scripts/Waypoint/Systems
  Formatting code files in workspace '/home/mosthated/_dev/_unity/Navigation_DOTS_20192/Navigation_DOTS_20192.sln'.
  Loading workspace.
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Sirenix.OdinInspector.CompatibilityLayer.Editor.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Sirenix.OdinInspector.CompatibilityLayer.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/BovineLabs.Entities.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Assembly-CSharp-firstpass.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Sirenix.OdinInspector.CompatibilityLayer.Editor.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Sirenix.OdinInspector.CompatibilityLayer.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/BovineLabs.Entities.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Assembly-CSharp-firstpass.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Sirenix.OdinInspector.CompatibilityLayer.Editor.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Sirenix.OdinInspector.CompatibilityLayer.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/BovineLabs.Entities.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Assembly-CSharp-firstpass.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Assembly-CSharp.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Assembly-CSharp-Editor-firstpass.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Sirenix.OdinInspector.CompatibilityLayer.Editor.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Sirenix.OdinInspector.CompatibilityLayer.csproj
  Found project reference without a matching metadata reference: /home/mosthated/_dev/_unity/Navigation_DOTS_20192/BovineLabs.Entities.csproj
  Complete in 2385ms.
  Determining formattable files.
  Complete in 188ms.
  Running formatters.
  Complete in 11ms.
  Formatted 0 of 395 files.
  Format complete in 2589ms.

This is what ended up working though and did all files.

dotnet-format -v diag --workspace /home/mosthated/_dev/_unity/Navigation_DOTS_20192/Navigation_DOTS_20192.sln

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
scottsaubercommented, Aug 11, 2019

Same - I’m so happy there’s a formatter for .NET, because having it in JavaScript is amazing with Prettier. I just don’t even worry about formatting anymore, I just left Prettier take care of it. The possibilities of stuff that can be done is making me really excited.

1reaction
valin0kcommented, Sep 9, 2021

@JoeRobich thanks for your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

File Watchers | JetBrains Rider Documentation
Press Ctrl Alt 0S to open the IDE settings and then select Tools | Actions on Save. Enable the File Watcher option and...
Read more >
Apply formatting rules | JetBrains Rider Documentation
Press Ctrl Alt 0S to open the IDE settings and then select Tools | Actions on Save. Select Reformat and Cleanup Code, choose...
Read more >
Configure formatting rules | JetBrains Rider Documentation
Press Ctrl Alt 0S or choose File | Settings (Windows and Linux) or JetBrains Rider | Preferences (macOS) from the menu . Use...
Read more >
Feature request: reformat on save : RIDER-7960 - YouTrack
As a workaround, you can create a macro that will reformat and then save on ... In CLion I was able to use...
Read more >
Prettier | JetBrains Rider Documentation
With JetBrains Rider, you can format selected code fragments as well as entire files or directories using the Reformat with Prettier action.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found