Skip to content

Use file-scoped namespace for classes in project templates #4394

@cremor

Description

@cremor

If you create a new project in a solution that uses file-scoped namespaces the classes created by the project template should also use file-scoped namespaces.

Similar to #3930, which only handled new item templates (which work fine).

Repro steps:

  1. Create a new repository/solution with an EditorConfig file. Make sure the EditorConfig file contains csharp_style_namespace_declarations = file_scoped:suggestion.
  2. Create a new project that contains at least one class with a namespace (e.g. class library or WPF application).
  3. See that the namespace in the generated class file uses the old block scoped style and that IDE0161 "Convert to file-scoped namespace" is triggered immediately.

Tested with Visual Studio 2022 17.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions