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

EditorConfig template should contain all rules #4393

Open
cremor opened this issue Feb 15, 2022 · 7 comments
Open

EditorConfig template should contain all rules #4393

cremor opened this issue Feb 15, 2022 · 7 comments
Labels
feature The issue defines new feature. triaged The issue was evaluated by the triage team, placed on correct area, next action defined.
Milestone

Comments

@cremor
Copy link

cremor commented Feb 15, 2022

The file created by dotnet new editorconfig (source) does not contain all available rules. Compared with an EditorConfig file exported by Visual Studio 2022 (via Tools - Options - Text Editor - C# - Code Style - Generate .editorconfig file from settings) it is missing some rules.

As of SDK version 7.0.302 the .editorconfig template is missing the following rules:

dotnet_style_namespace_match_folder
dotnet_style_prefer_foreach_explicit_cast_in_source

csharp_style_implicit_object_creation_when_type_is_apparent
csharp_style_namespace_declarations
csharp_style_prefer_extended_property_pattern
csharp_style_prefer_local_over_anonymous_function
csharp_style_prefer_method_group_conversion
csharp_style_prefer_null_check_over_type_check
csharp_style_prefer_readonly_struct
csharp_style_prefer_readonly_struct_member
csharp_style_prefer_top_level_statements
csharp_style_prefer_tuple_swap
csharp_style_prefer_utf8_string_literals

dotnet_style_allow_multiple_blank_lines_experimental
dotnet_style_allow_statement_immediately_after_block_experimental
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental
csharp_style_allow_blank_lines_between_consecutive_braces_experimental
csharp_style_allow_embedded_statements_on_same_line_experimental
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental

Also see dotnet/roslyn#60539 for the experimental rules.

Additionally, the .editorconfig template contains the rule csharp_style_pattern_local_over_anonymous_function. This rule doesn't exist any more. It is the old name of the rule csharp_style_prefer_local_over_anonymous_function.

@vlada-shubina
Copy link
Member

@cremor we are considering fixing it as part of #4126.
Could you please follow that issue? Thank you.

Closing as duplicate.

@cremor
Copy link
Author

cremor commented Nov 21, 2022

@vlada-shubina Please reopen this issue since it is not part of #4126 any more per your comment #4126 (comment) there.

And could you please move it to dotnet/sdk? Because the .editorconfig template was moved there.

@vlada-shubina vlada-shubina reopened this Nov 21, 2022
@vlada-shubina
Copy link
Member

Discussion notes:

  • We discussed implementing separate, additional, very basic template engine generator for that to be included to dotnet new that will run when the user does dotnet new editorconfig
    • generator will generate the editorconfig string using Roslyn API and write it to the file
    • ​concerns to address: correct line endings and encoding based on OS
  • Step 1: prepare an example of custom generator + test; ensure that multiple generators work end-2-end
  • Step 2: implement new generator in sdk repo, incorporate code to generate editorconfig content using Roslyn API in dotnet CLI
  • No parameters to generation are needed, except supporting currently existing --empty​ flag to generate empty editorconfig with root = true

@vlada-shubina vlada-shubina added the triaged The issue was evaluated by the triage team, placed on correct area, next action defined. label Dec 5, 2022
@vlada-shubina vlada-shubina added this to the January 2023 milestone Dec 5, 2022
@vlada-shubina
Copy link
Member

Example of custom generator is here: #5773

@baronfel
Copy link
Member

@jmarolf here's the custom generator example that we spoke about in our last chat. Will you be able to take a look and SWAG out an editorconfig generator in dotnet/sdk?

@baronfel baronfel added the feature The issue defines new feature. label Jan 31, 2023
@baronfel baronfel modified the milestones: January 2023, Backlog Jan 31, 2023
@vlada-shubina
Copy link
Member

@jmarolf here's the custom generator example that we spoke about in our last chat. Will you be able to take a look and SWAG out an editorconfig generator in dotnet/sdk?

feel free to reach me if you'd need some help on understanding that. There are some features which are not available in example, as localization; but imo we can polish it later.

@vlada-shubina
Copy link
Member

vlada-shubina commented Jun 14, 2023

Discussion notes:

  • We discussed implementing separate, additional, very basic template engine generator for that to be included to dotnet new that will run when the user does dotnet new editorconfig

    • generator will generate the editorconfig string using Roslyn API and write it to the file
    • ​concerns to address: correct line endings and encoding based on OS
  • Step 1: prepare an example of custom generator + test; ensure that multiple generators work end-2-end

  • Step 2: implement new generator in sdk repo, incorporate code to generate editorconfig content using Roslyn API in dotnet CLI

  • No parameters to generation are needed, except supporting currently existing --empty​ flag to generate empty editorconfig with root = true

Step 1 was done in #5773. This PR demonstrates how the custom generator can be implemented. The testing is performed - it works as expected.

The remaining work is step 2:

  • implement new generator in sdk repo, insert it as new component.
  • incorporate code to generate editorconfig content using Roslyn API (similarly to what VS is done)
  • no template parameters to generation are needed, except supporting currently existing --empty​ flag to generate empty editorconfig with root = true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature The issue defines new feature. triaged The issue was evaluated by the triage team, placed on correct area, next action defined.
Projects
None yet
Development

No branches or pull requests

3 participants