Have some default C# code styles changed in Rider 2021?

In the middle of Rider 2021, I suspect that the following two C# "default" code styles have changed.

  1. Within single-line expression braces (unchecked to checked)
  2. After type cast parentheses (checked to unchecked)

The behavior in each version seems to be as follows.

  • Before 2021.1: Old
  • 2021.2: New
  • 2021.3: New (old when Rider is newly installed)
  • 2022.1 EAP: New (new even if newly installed)

I'm sorry if the details are different.

I would like to ask about the development team's views on this and future plans.

Will such changes occur in the future too?

4 comments
Comment actions Permalink
Hello Tamura Kazunori,
 
I tried reproducing your case, however, could not get the same results.
I have done the following:
  1. I have installed all versions of Rider simultaneously.
  2. I have installed version one by one, cleaning caches and files after each using our documentation.
Both times I go the same result:
  • Within single-line expression braces (unchecked in stable versions, checked in EAP)
  • After type cast parentheses (checked in stable versions, unchecked in EAP)
Could you please clarify the following:
What do you mean by old when Rider is newly installed?
Do you use some kind of Settings Sync plugin?
Could you please provide me with the step-by-step instruction on how the issue is reproduced?
0
Comment actions Permalink

Hello Anna Morozyk,

Thank you for your reply.

I re-tried to install Rider 2021.3.3 using JetBrains Toolbox, after uninstalling all versions and cleaning caches and files.

I also disabled Settings Sync and removed settings from cloud.

I got the result:

  • Within single-line expression braces (unchecked)
  • After type cast parentheses (checked)

In this situation, the content of  ~/Library/Application Support/JetBrains/Rider2021.3/resharper-host/GlobalSettingsStorage.DotSettings is as follows. (I use macOS 12.0.1)

<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">True</s:Boolean>
    <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">False</s:Boolean>
    <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
    <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
    <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
    <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
    <s:Boolean x:Key="/Default/Housekeeping/GlobalSettingsUpgraded/IsUpgraded/@EntryValue">True</s:Boolean>
    <s:String x:Key="/Default/Housekeeping/OptionsDialog/SelectedPageId/@EntryValue">CSharpOtherPage</s:String>
    <s:Boolean x:Key="/Default/RiderDebugger/RiderRestoreDecompile/RestoreDecompileSetting/@EntryValue">False</s:Boolean></wpf:ResourceDictionary>

This shows the two code styles(SPACE_AFTER_TYPECAST_PARENTHESES and SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES) are overwritten by the auto-generated settings.

And then, if I reset the settings layer This Computer by Manage Layers, the two overwriting settings are removed, and the resulting settings are:

  • Within single-line expression braces (checked)
  • After type cast parentheses (unchecked)

So, the default behavior of these two settings is just ambiguous.

And this overwriting behavior does not exist in Rider 2022.1 EAP7...

0
Comment actions Permalink

I have verified this behaviour with developers and I am ready to bring you more details on this matter:

Usually, such styling settings are not changed with versions, however, this time we had a request to change them according to the Visual Studio default ones:  RSRP-479702

So getting back to the initial questions: 

> I would like to ask about the development team's views on this and future plans.

There are no future plans on changing these settings

> Will such changes occur in the future too?

Until there is a  solid reason for it (like matching default code styles) there is a quite low chance of changing these parameters. 

However, you may ensure, that your set up will remain intact by using Layer Settings, which modify file ~/Library/Application Support/JetBrains/Rider2021.3/resharper-host/GlobalSettingsStorage.DotSettings , mentioned above, or Editorconfig, that will store your formatting style. 

I hope, I could make it clearer for you! 

0
Comment actions Permalink

Thank you for the clear answer!

I'm glad to know the details.

Our team will adopt the "new" code styles :)

0

Please sign in to leave a comment.