razor icon indicating copy to clipboard operation
razor copied to clipboard

Visual studio 2022 community code cleanup in razor files

Open vsfeedback opened this issue 1 year ago • 0 comments

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice] I have issues with the visual studio 2022 analyze > code cleanup functionnality. It's working fine in regular C#. My code formats correctly based on my preferences defined in the editorconfig file and the visual studio config. But when using the ctrl k + ctrl d command from within a razor file, the C# code inside a @{ } block is acting weird. When writing a statement on multiple lines, it removes spaces to make all lines start at the same indent level.

Here are the two codess : The first one is the correctly formatted code inside a regular C# file, the second one is the code inside a code block in a razor file.

First :

IFormGroup? linkedProduct =
        identificationGroups
          . FirstOrDefault( group =>
            group
              . FormItemsCollection
              . OfType<IFormItem>( )
              . Any( item =>
                item
                  . Field == nameof( StockItemDetailDTO.LinkedProduct.Id )
              )
          );

Second :

var linkedProduct =
    identificationGroups
    . FirstOrDefault(group =>
    group
    . FormItemsCollection
    . OfType<IFormItem>()
    . Any(item =>
    item
    . Field == nameof(StockItemDetailDTO.LinkedProduct.Id)
    )
    );

Can you provide me help ?


Original Comments

Feedback Bot on 9/17/2024, 06:30 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

vsfeedback avatar Sep 26 '24 21:09 vsfeedback