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

Honour users' settings as a starting point for Razor formatting #76066

Merged

Conversation

davidwengier
Copy link
Member

@davidwengier davidwengier commented Nov 25, 2024

In dotnet/razor#6166 we changed Razor to pass indentation options into a Roslyn service, rather than create a workspace and apply changes to it, etc. Sadly this regressed C# formatting in Razor files, because the code was just creating a new CSharpSyntaxFormattingOptions and not starting from the users settings.

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2305075
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2305404

@davidwengier davidwengier requested a review from a team as a code owner November 25, 2024 04:02
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 25, 2024
@davidwengier davidwengier requested a review from tmat November 25, 2024 04:02
@davidwengier davidwengier changed the base branch from main to release/dev17.13 November 25, 2024 04:07
@davidwengier davidwengier requested review from a team as code owners November 25, 2024 04:07
@davidwengier davidwengier force-pushed the RazorFormattingDefaults branch from d066a2c to e2ba725 Compare November 25, 2024 04:08
@davidwengier davidwengier removed request for a team November 25, 2024 05:08
@tmat
Copy link
Member

tmat commented Nov 26, 2024

@davidwengier I'm confused. The linked issues repro in VS, but the PR is changing O# ExternalAccess.

@davidwengier
Copy link
Member Author

The change to O# is just to satisfy the interface change.

private static SyntaxFormattingOptions GetFormattingOptions(SolutionServices services, RazorIndentationOptions indentationOptions)
{
var legacyOptionsService = services.GetService<ILegacyGlobalOptionsWorkspaceService>();
var formattingOptions = legacyOptionsService is null
Copy link
Member

Choose a reason for hiding this comment

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

this doesn't run OOP right? IIRC the legacy options service isn't available there

Copy link
Member Author

Choose a reason for hiding this comment

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

Either way this won't work in cohosting. Options are not synced pro-actively to Roslyn OOP, each feature pulls what it needs via callbacks, so even if this service is available the underlying IGlobalOptionsService has only defaults in OOP. Callbacks didn't work for Razor services last time I tried (strange IVT-type issues with service hub assembly loading) so this will have to be solved separately.

Sadly cohosting makes some things worse, then we have to go and make them better again.

@davidwengier
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants