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

Switch to file-scoped namespace #1689

Open
AndrewKeepCoding opened this issue Dec 11, 2024 · 6 comments · May be fixed by #1700
Open

Switch to file-scoped namespace #1689

AndrewKeepCoding opened this issue Dec 11, 2024 · 6 comments · May be fixed by #1700
Labels
help wanted Extra attention is needed

Comments

@AndrewKeepCoding
Copy link
Contributor

AndrewKeepCoding commented Dec 11, 2024

Issue type

enhancement

Which version of the app?

WinUI 3 Gallery

Description

File-scoped namespace will improve readability.
IMHO, it's something that will be done in the future, so why not now? The sooner, the better.
I'd be happy to do this.

Screenshots

No response

Windows version

No response

Additional context

No response

@Jay-o-Way
Copy link
Contributor

Got an example? :)

@AndrewKeepCoding
Copy link
Contributor Author

For example, App.xaml.cs:

Block-scoped namespace

namespace WinUIGallery
{
    /// <summary>
    /// Provides application-specific behavior to supplement the default Application class.
    /// </summary>
    sealed partial class App : Application
    {
        private static Window startupWindow;

File-scoped namespace

namespace WinUIGallery;

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
    private static Window startupWindow;

@Jay-o-Way
Copy link
Contributor

If you let Visual Studio create such a new file, what does it initially look like? Why would VS prefer one over the other?

@AndrewKeepCoding
Copy link
Contributor Author

Yeah. VS's item templates haven't been updated (yet?).
I'm bringing this up because, in the CommunityToolkit/Labs-Windows repo, I saw they are switching to file-scoped namespaces (CommunityToolkit/Labs-Windows#148), and I thought it might be a good idea to apply the same change here too. They also updated the editor.config to issue warnings for block-scoped namespaces.

@karkarl karkarl added help wanted Extra attention is needed and removed needs-triage labels Dec 12, 2024
@karkarl karkarl moved this to 📋 Backlog in WinUI Gallery Backlog Dec 12, 2024
@karkarl
Copy link
Collaborator

karkarl commented Dec 12, 2024

Thanks for filing this issue. Would you want to take a stab at it?

@AndrewKeepCoding
Copy link
Contributor Author

Thanks for filing this issue. Would you want to take a stab at it?

@karkarl Of course!🙂

@AndrewKeepCoding AndrewKeepCoding linked a pull request Dec 13, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Status: 📋 Backlog
Development

Successfully merging a pull request may close this issue.

3 participants