Skip to content

Commit a0a435d

Browse files
haonantttHaonan Tang (from Dev Box)
andauthored
Update C# templates to introduce file scoped namespaces (#4911)
* Update C# templates to introduce file scoped namespaces * introduce file scoped namespaces to dev/VSIX/Extension and dev/VSIX/Shared folders as well * resolve comments: 1. mark all classes 'partial' 2. align the MainWindow to be an empty Grid without the Button and handler * Enable Mica * remove mica for non-window level * 1. Remove 'Button' from C++ templates 2. Remove Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" from Blank Page item template * 1. Remove 'this.' and change 'm_' to '_' 2. Add empty line between functions * revert file scoped namesapce for VSPackages.cs and WizardImplementation.cs --------- Co-authored-by: Haonan Tang (from Dev Box) <[email protected]>
1 parent 16f4ec2 commit a0a435d

File tree

34 files changed

+180
-215
lines changed

34 files changed

+180
-215
lines changed

dev/VSIX/Extension/Cs/Dev17/VSPackage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace WindowsAppSDK.Cs.Extension
2828
/// </remarks>
2929
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
3030
[Guid(VSPackage.PackageGuidString)]
31-
public sealed class VSPackage : AsyncPackage
31+
public sealed partial class VSPackage : AsyncPackage
3232
{
3333
/// <summary>
3434
/// VSPackage GUID string.
@@ -55,4 +55,4 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
5555

5656
#endregion
5757
}
58-
}
58+
}

dev/VSIX/ItemTemplates/Desktop/CSharp/BlankWindow/BlankWindow.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
mc:Ignorable="d"
1010
Title="$itemname$">
1111

12+
<Window.SystemBackdrop>
13+
<MicaBackdrop />
14+
</Window.SystemBackdrop>
15+
1216
<Grid>
1317

1418
</Grid>

dev/VSIX/ItemTemplates/Desktop/CSharp/BlankWindow/BlankWindow.xaml.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
// To learn more about WinUI, the WinUI project structure,
1717
// and more about our project templates, see: http://aka.ms/winui-project-info.
1818

19-
namespace $rootnamespace$
19+
namespace $rootnamespace$;
20+
21+
/// <summary>
22+
/// An empty window that can be used on its own or navigated to within a Frame.
23+
/// </summary>
24+
public sealed partial class $safeitemname$ : Window
2025
{
21-
/// <summary>
22-
/// An empty window that can be used on its own or navigated to within a Frame.
23-
/// </summary>
24-
public sealed partial class $safeitemname$ : Window
26+
public $safeitemname$()
2527
{
26-
public $safeitemname$()
27-
{
28-
this.InitializeComponent();
29-
}
28+
InitializeComponent();
3029
}
3130
}

dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,4 @@ namespace winrt::$rootnamespace$::implementation
2121
{
2222
throw hresult_not_implemented();
2323
}
24-
25-
void $safeitemname$::myButton_Click(IInspectable const&, RoutedEventArgs const&)
26-
{
27-
myButton().Content(box_value(L"Clicked"));
28-
}
2924
}

dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ namespace winrt::$rootnamespace$::implementation
1414

1515
int32_t MyProperty();
1616
void MyProperty(int32_t value);
17-
18-
void myButton_Click(IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
1917
};
2018
}
2119

dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
mc:Ignorable="d"
1010
Title="$itemname$">
1111

12-
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
13-
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
14-
</StackPanel>
12+
<Grid>
13+
14+
</Grid>
1515
</Window>

dev/VSIX/ItemTemplates/Neutral/CSharp/BlankPage/BlankPage.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
xmlns:local="using:$rootnamespace$"
77
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
88
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9-
mc:Ignorable="d"
10-
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
9+
mc:Ignorable="d">
1110

1211
<Grid>
1312

dev/VSIX/ItemTemplates/Neutral/CSharp/BlankPage/BlankPage.xaml.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
// To learn more about WinUI, the WinUI project structure,
1717
// and more about our project templates, see: http://aka.ms/winui-project-info.
1818

19-
namespace $rootnamespace$
19+
namespace $rootnamespace$;
20+
21+
/// <summary>
22+
/// An empty page that can be used on its own or navigated to within a Frame.
23+
/// </summary>
24+
public sealed partial class $safeitemname$ : Page
2025
{
21-
/// <summary>
22-
/// An empty page that can be used on its own or navigated to within a Frame.
23-
/// </summary>
24-
public sealed partial class $safeitemname$ : Page
26+
public $safeitemname$()
2527
{
26-
public $safeitemname$()
27-
{
28-
this.InitializeComponent();
29-
}
28+
InitializeComponent();
3029
}
3130
}

dev/VSIX/ItemTemplates/Neutral/CSharp/TemplatedControl/CustomControl.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
// To learn more about WinUI, the WinUI project structure,
1313
// and more about our project templates, see: http://aka.ms/winui-project-info.
1414

15-
namespace $rootnamespace$
15+
namespace $rootnamespace$;
16+
17+
public sealed partial class $safeitemname$ : Control
1618
{
17-
public sealed class $safeitemname$ : Control
19+
public $safeitemname$()
1820
{
19-
public $safeitemname$()
20-
{
21-
this.DefaultStyleKey = typeof($safeitemname$);
22-
}
21+
DefaultStyleKey = typeof($safeitemname$);
2322
}
2423
}

dev/VSIX/ItemTemplates/Neutral/CSharp/UserControl/UserControl.xaml.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
// To learn more about WinUI, the WinUI project structure,
1717
// and more about our project templates, see: http://aka.ms/winui-project-info.
1818

19-
namespace $rootnamespace$
19+
namespace $rootnamespace$;
20+
21+
public sealed partial class $safeitemname$ : UserControl
2022
{
21-
public sealed partial class $safeitemname$ : UserControl
23+
public $safeitemname$()
2224
{
23-
public $safeitemname$()
24-
{
25-
this.InitializeComponent();
26-
}
25+
InitializeComponent();
2726
}
2827
}

0 commit comments

Comments
 (0)