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

Update C# templates to introduce file scoped namespaces #4911

Merged
merged 8 commits into from
Dec 17, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace $rootnamespace$
namespace $rootnamespace$;

/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class $safeitemname$ : Window
{
/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class $safeitemname$ : Window
public $safeitemname$()
{
public $safeitemname$()
{
this.InitializeComponent();
}
this.InitializeComponent();
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace $rootnamespace$
namespace $rootnamespace$;

/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class $safeitemname$ : Page
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class $safeitemname$ : Page
public $safeitemname$()
{
public $safeitemname$()
{
this.InitializeComponent();
}
this.InitializeComponent();
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace $rootnamespace$
namespace $rootnamespace$;

public sealed class $safeitemname$ : Control
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
{
public sealed class $safeitemname$ : Control
public $safeitemname$()
{
public $safeitemname$()
{
this.DefaultStyleKey = typeof($safeitemname$);
}
this.DefaultStyleKey = typeof($safeitemname$);
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace $rootnamespace$
namespace $rootnamespace$;

public sealed partial class $safeitemname$ : UserControl
{
public sealed partial class $safeitemname$ : UserControl
public $safeitemname$()
{
public $safeitemname$()
{
this.InitializeComponent();
}
this.InitializeComponent();
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace $safeprojectname$
namespace $safeprojectname$;

public class Class1
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
{
public class Class1
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,31 @@
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace $safeprojectname$
namespace $safeprojectname$;

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App : Application
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public partial class App : Application
public App()
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
}

/// <summary>
/// Invoked when the application is launched.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
m_window.Activate();
}
this.InitializeComponent();
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}

private Window? m_window;
/// <summary>
/// Invoked when the application is launched.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
m_window.Activate();
}

private Window? m_window;
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace $safeprojectname$
namespace $safeprojectname$;

/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainWindow : Window
{
/// <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()
{
public MainWindow()
{
this.InitializeComponent();
}
this.InitializeComponent();
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}

private void myButton_Click(object sender, RoutedEventArgs e)
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
{
myButton.Content = "Clicked";
}
private void myButton_Click(object sender, RoutedEventArgs e)
{
myButton.Content = "Clicked";
}
niels9001 marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,31 @@
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace $safeprojectname$
namespace $safeprojectname$;

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App : Application
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public partial class App : Application
public App()
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
}

/// <summary>
/// Invoked when the application is launched.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
m_window.Activate();
}
this.InitializeComponent();
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}

private Window? m_window;
/// <summary>
/// Invoked when the application is launched.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
m_window.Activate();
}

private Window? m_window;
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace $safeprojectname$
namespace $safeprojectname$;

/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainWindow : Window
{
/// <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()
{
public MainWindow()
{
this.InitializeComponent();
}
this.InitializeComponent();
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}

private void myButton_Click(object sender, RoutedEventArgs e)
{
myButton.Content = "Clicked";
}
private void myButton_Click(object sender, RoutedEventArgs e)
{
myButton.Content = "Clicked";
}
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,37 @@
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace $safeprojectname$
namespace $safeprojectname$;

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class UnitTestApp : Application
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public UnitTestApp()
{
this.InitializeComponent();
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}

/// <summary>
/// Invoked when the application is launched.
/// </summary>
public partial class UnitTestApp : Application
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public UnitTestApp()
{
this.InitializeComponent();
}

/// <summary>
/// Invoked when the application is launched.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();

m_window = new UnitTestAppWindow();
m_window.Activate();

UITestMethodAttribute.DispatcherQueue = m_window.DispatcherQueue;

Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(Environment.CommandLine);
}

private Window? m_window;
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();

m_window = new UnitTestAppWindow();
m_window.Activate();

UITestMethodAttribute.DispatcherQueue = m_window.DispatcherQueue;
haonanttt marked this conversation as resolved.
Show resolved Hide resolved

Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(Environment.CommandLine);
}

private Window? m_window;
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace $safeprojectname$
namespace $safeprojectname$;

public sealed partial class UnitTestAppWindow : Window
{
public sealed partial class UnitTestAppWindow : Window
public UnitTestAppWindow()
{
public UnitTestAppWindow()
{
this.InitializeComponent();
}
this.InitializeComponent();
haonanttt marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading