Azure/data-api-builder

[Refactor] Move to file-scoped namespaces

Open

#1 595 ouverte le 20 juil. 2023

Voir sur GitHub
 (1 commentaire) (1 réaction) (0 assignés)C# (348 forks)auto 404
cleanupgood first issuehacktoberfestimprovement

Métriques du dépôt

Stars
 (1 459 stars)
Métriques de merge PR
 (Métriques PR en attente)

Description

C# introduced file scoped namespaces which means that instead of writing this:

namespace Some.Namespace {
    public class SomeType {
        public int SomeProperty { get; set; }
    }
}

We can write this:

namespace Some.Namespace;

public class SomeType {
    public int SomeProperty { get; set; }
}

With this, members of a namespace are at the same level as the namespace declaration, reducing the amount of whitespace in a file and aligning with more of how modern C# examples are written.

This can be enforced with an .editorconfig rule:

[*.cs]
csharp_style_namespace_declarations = file_scoped:warning

The refactor is straight forward, navigate to the namespace declaration in the file and add a ; to the end of the line, VS will perform the rest of the refactoring for you.

Undertaking this can be done piece by piece and considered as part of general code hygiene.

Guide contributeur