Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new lines before members in object initializers #47

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

asimmon
Copy link
Member

@asimmon asimmon commented Oct 23, 2024

Description of changes

Insert new lines between members in object initializers with Rider (or R#). The default .NET styling option doesn't work.

When using our .NET Coding standards, reformating in Rider these pieces of code:

var builder = WebApplication.CreateSlimBuilder(new WebApplicationOptions
{
    EnvironmentName = Environments.Production,
});

// ...

await notificationService.PublishUpdateAsync(proxyResource, state => state with
{
    State = KnownResourceStates.Running,
    Urls = [new UrlSnapshot(Name: "http", Url: "http://127.0.0.1:1234", IsInternal: false)],
});

… will automatically inline the object initializer to:

var builder = WebApplication.CreateSlimBuilder(new WebApplicationOptions { EnvironmentName = Environments.Production, });

// ...

await notificationService.PublishUpdateAsync(proxyResource, state => state with { State = KnownResourceStates.Running, Urls = [new UrlSnapshot(Name: "http", Url: "http://127.0.0.1:1234", IsInternal: false)], });

This would affect code that developers haven’t edited, resulting in unwanted changes that make code less readable and require reviewers to ask the PR author to revert the code to its original state.

This happens sometimes automatically as some IDEs are configured to reformat new changes automatically.

I've seen PRs of developers using our coding standards where they would complain about it (but still commit the inlined code anyway).

Breaking changes

There's no warning or errors involved here, it's mostly styling.

@asimmon asimmon requested a review from a team as a code owner October 23, 2024 19:55
@asimmon asimmon merged commit 2edd9af into main Oct 23, 2024
4 checks passed
@asimmon asimmon deleted the feature/idp-2470 branch October 23, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants