Skip to content

C# Template Fix: File scoped namespaces #3329

@michael-hawker

Description

@michael-hawker

Describe the bug

C# 10 introduced file scoped namespaces: https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/namespace

Since the Windows App SDK now targets .NET 6 (which has C# 10 as a default), the templates should be updated to use this new pattern and save a level of indentation in the file.

Follow-on request, related to template clean-up #3324; FYI @bpulliam

Steps to reproduce the bug

Create a new C# project

Expected behavior

namespace MyNamespace;

/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainWindow : Window
{
    public MainWindow()
    {
        this.InitializeComponent();
    }

Screenshots

No response

NuGet package version

Windows App SDK 1.2.2: 1.2.221209.1

Packaging type

No response

Windows version

No response

IDE

Visual Studio 2022

Additional context

No response

Metadata

Metadata

Assignees

Labels

area-DeveloperToolsIssues related to authoring (source and IDL), debugging, HotReload, LiveVisualTree, VS integration

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions