Skip to content

File scoped namespaces - #1700

Merged
Niels Laute (niels9001) merged 4 commits into
microsoft:mainfrom
AndrewKeepCoding:file-scoped-namespaces
Jan 27, 2025
Merged

Niels Laute (niels9001) merged 4 commits into
microsoft:mainfrom
AndrewKeepCoding:file-scoped-namespaces

Conversation

@AndrewKeepCoding

Copy link
Copy Markdown
Contributor

Description

This PR will switch C# files from block-scoped namespaces to file-scoped namespaces.
Closes #1689.

Motivation and Context

Improves readability.

How Has This Been Tested?

  • Confirmed that all unit tests passes.
  • Run the app and navigated through all pages.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
@ghost1372

Copy link
Copy Markdown
Contributor

FYI Andrew KeepCoding (@AndrewKeepCoding)
Do we need all these commits? Use Visual Studio tools!
Animation

@AndrewKeepCoding

Andrew KeepCoding (AndrewKeepCoding) commented Dec 13, 2024 •

Copy link
Copy Markdown
Contributor Author

I did. 🙂
However, I also reviewed all the files to check the changes, which is why there are separate commits. I've seen some cases that VS (or VS Code) doesn't apply this kind of changes correctly.

Comment thread WinUIGallery/.editorconfig
@Marv51

Copy link
Copy Markdown
Contributor

Are you planning to add a .git-blame-ignore-revs file for this PR?

@AndrewKeepCoding

Andrew KeepCoding (AndrewKeepCoding) commented Dec 16, 2024 •

Copy link
Copy Markdown
Contributor Author

Marvin Rühe (@Marv51) You are right. Thanks.
TODO: Update the target commit id at the .git-blame-ignore-revs file.

@marcelwgn

Copy link
Copy Markdown
Contributor

When creating a new UserControl, the namespace is before the usings. Is that behavior also the case for you Andrew KeepCoding (@AndrewKeepCoding) ?

@AndrewKeepCoding

Andrew KeepCoding (AndrewKeepCoding) commented Jan 10, 2025 •

Copy link
Copy Markdown
Contributor Author

Marcel W. (@marcelwgn) No on my side. This is what I get:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace WinUIApp5
{
    public sealed partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            this.InitializeComponent();
        }
    }
}
@AndrewKeepCoding

Copy link
Copy Markdown
Contributor Author

By the way, the item templates are being changed to file scoped namespaces in v1.7-exp2.

@marcelwgn

Copy link
Copy Markdown
Contributor

Huh thats very interesting. Would be good to know why the results differ when creating a new UserControl. But that will be fixed with the new templates anyway (though I would have preferred the namespace to preceed usings but thats a different story).

This topic aside, looks like there are some merge conflicts which are not surprising though with these changes though.

@AndrewKeepCoding

Andrew KeepCoding (AndrewKeepCoding) commented Jan 12, 2025 •

Copy link
Copy Markdown
Contributor Author

This topic aside, looks like there are some merge conflicts which are not surprising though with these changes though.

Marcel W. (@marcelwgn) Thanks! I fixed the conflicts.

Comment thread .git-blame-ignore-revs Outdated
@niels9001

Copy link
Copy Markdown
Collaborator

/azp run

@karkarl

Copy link
Copy Markdown
Collaborator

/azp run

@AndrewKeepCoding

Copy link
Copy Markdown
Contributor Author

A review before another conflict would be greatly appreciated. 😅

@marcelwgn

Copy link
Copy Markdown
Contributor

/azp run

2 similar comments
@marcelwgn

Copy link
Copy Markdown
Contributor

/azp run

@niels9001

Copy link
Copy Markdown
Collaborator

/azp run

@niels9001
Niels Laute (niels9001) merged commit 67943f5 into microsoft:main Jan 27, 2025
@niels9001

Copy link
Copy Markdown
Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

7 participants