git – Visual Studio modifies .csproj files on branch switch (possible .editorconfig / Code Cleanup issue)

I added an .editorconfig file to the solution. The linter is CodeLens, the analyzer is SonarQube, and Code Cleanup automatically applies rules (profile 2). After some time, other developers started experiencing an issue where changes appear in .csproj files when switching from one branch to another. We use SourceTree and Visual Studio 2022 / 2026. It looks like changes from the previous branch are being carried over, possibly due to some automatic file processing mechanism being triggered. Also, sometimes files are shown as modified, but no actual changes are visible when opening the diff.

I created two test branches: one with .editorconfig, one without. The issue reproduces every time when switching from one branch to another. I reduced .editorconfig to just root = true, then even made it completely empty – the issue still persists. What could be causing this?

Read more here: Source link