Base solution for your next web application
Open Closed

Option to Disable Automatic Code Formatting (ExternalCodeFormatter) in RAD Tool #12482


User avatar
0
kansoftware created

I'm currently using the latest version of the AspNet Zero RAD tool integrated with Visual Studio. After a recent update, I've observed that the code generation process now includes a step that automatically formats generated and existing files using external formatters like js-beautify.

While I understand the intention is to maintain consistent formatting, this behavior is impacting our workflow because:

It modifies existing files unexpectedly.

It overrides our team's custom formatting styles.

We were unable to find a configuration setting (like UseExternalFormatter or EnableFormatting) to disable or control this behavior.

It appears this is controlled internally via a class like ExternalCodeFormatter, but we do not have visibility or configuration access.

Request: Please provide a way (e.g. a configuration flag or command-line argument) to disable or opt out of the automatic formatting step during code generation. This would help avoid unintended changes to files and better align with our custom coding standards.

Looking forward to your response or any recommended workaround in the meantime.

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

1 Answer(s)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @kansoftware

    In the latest version of Power Tools, a Dotnet formatting step was added. As you mentioned, we created an issue to make this optional. It is not possible to remove the Dotnet formatting step here at the moment. But as a temporary solution, you can use the configuration below.

    When dotnet format is executed either manually from the terminal or automatically by tools like AspNet Zero Power Tools it relies entirely on the .editorconfig file to determine formatting rules.

    You can define your team's preferred coding style in a .editorconfig file placed at the root of your solution or project. For example:

    # .editorconfig
    root = true
    
    [*]
    indent_style = space
    indent_size = 4
    insert_final_newline = true
    trim_trailing_whitespace = true
    
    [*.cs]
    csharp_new_line_before_open_brace = all
    csharp_indent_case_contents = true
    dotnet_sort_system_directives_first = true
    dotnet_separate_import_directive_groups = true
    

    This ensures dotnet format respects your team's style.

    If you'd prefer that dotnet format makes no impactful changes, provide a minimal .editorconfig like this:

    root = true
    
    [*]
    indent_style = space
    indent_size = 4
    

    This will significantly reduce or eliminate most formatting changes during code generation or formatting runs.

    Place the .editorconfig file in the root of your solution (same folder as your .sln file), or at the project level near your .csproj files.

    Thank you for your understanding. We will make the dotnet format step optional as soon as possible. Wishing you all the best in your work.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)