Azure / Azure/data-api-builder

[Refactor] Move to file-scoped namespaces

Offen
#1,595 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
cleanup good first issue hacktoberfest improvement
Vorherrschende Sprache
C#
Sterne
1.5k
Forks
370
Ø Merge
3 T. 22 Std.
Gemergte PRs (30 T.)
9

Beschreibung

C# introduced [file scoped namespaces](https://learn.microsoft.com/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces) which means that instead of writing this:

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

We can write this:

```c#
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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Es werden keine spezifischen Dateien oder Tests genannt. Beginne damit, C#-Dateien mit blockbezogenen Namespace-Deklarationen zu finden und zu prüfen, ob das Repository eine .editorconfig-Regel für Namespace-Deklarationen enthält. Konvertiere die Deklarationen schrittweise und überprüfe anschließend, ob die betroffenen Projekte weiterhin erstellt werden und ihre Tests bestehen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp
Bereich
tooling
Issue-Typ
Refactoring
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.