Skip to content

Make cohost formatting honour C# formatting options#12042

Merged
davidwengier merged 4 commits intodotnet:mainfrom
davidwengier:CohostFormattingOptions
Jul 29, 2025
Merged

Make cohost formatting honour C# formatting options#12042
davidwengier merged 4 commits intodotnet:mainfrom
davidwengier:CohostFormattingOptions

Conversation

@davidwengier
Copy link
Member

Fixes #11839
Needs dotnet/roslyn#79458 before it will compile

This just tweaks the "override C# settings for tests" system we had into a formal "can specify C# settings before formatting" option, and then in cohosting we grab the options from Roslyn (via new EA API) before jumping to OOP.

@davidwengier davidwengier requested a review from a team as a code owner July 18, 2025 04:34
[DataMember(Order = 2)]
public bool CodeBlockBraceOnNextLine { get; init; } = false;
[DataMember(Order = 3)]
public RazorCSharpSyntaxFormattingOptions? CSharpSyntaxFormattingOptions { get; init; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ get; init; }

We are fine with all defaults here? No need to assign explicitly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, null is fine for the default and matches existing behaviour. In future we can probably clean it up more, if we remove the old LSP, and we can roll out proper formatting options support to code actions and auto insert etc. but no need to open that can of worms now.

Copy link
Contributor

@alexgav alexgav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

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.

Send Roslyn formatting options to OOP

3 participants