Skip to content

Commit 328398c

Browse files
committed
[VSIX] Add ProfileOptimization Option and Hwnd Property
1 parent ec0af0c commit 328398c

15 files changed

Lines changed: 11426 additions & 7173 deletions

File tree

VSIX/DevWinUI_Template/DevWinUI_Template/Common/PredefinedCodes.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,11 @@ private async void NavigateToLogPath_Click(object sender, RoutedEventArgs e)
188188
<uap5:Extension Category="windows.startupTask">
189189
<uap5:StartupTask TaskId="$safeprojectname$StartOnLoginTask" Enabled="false" DisplayName="$safeprojectname$" />
190190
</uap5:Extension>
191+
"""";
192+
public static readonly string ProfileOptimization =
193+
""""
194+
// Enables Multicore JIT with the specified profile
195+
System.Runtime.ProfileOptimization.SetProfileRoot(Constants.RootDirectoryPath);
196+
System.Runtime.ProfileOptimization.StartProfile("Startup.Profile");
191197
"""";
192198
}

VSIX/DevWinUI_Template/DevWinUI_Template/Common/WizardConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public static class WizardConfig
3232
public static bool IsBlank;
3333
public static bool HasPages;
3434
public static bool IsMVVM;
35+
public static bool IsProfileOptimization;
3536
public static bool UseHomeLandingPage;
3637
public static bool UseSettingsPage;
3738
public static bool UseGeneralSettingPage;

VSIX/DevWinUI_Template/DevWinUI_Template/DevWinUI_Template.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
<Reference Include="WindowsBase" />
135135
</ItemGroup>
136136
<ItemGroup>
137-
<PackageReference Include="NuGet.Protocol" Version="6.12.1" />
137+
<PackageReference Include="NuGet.Protocol" Version="6.13.2" />
138138
<PackageReference Include="Microsoft.VisualStudio.SDK" ExcludeAssets="runtime">
139139
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
140140
<Version>17.4.33103.184</Version>
@@ -143,15 +143,15 @@
143143
<Version>17.10.40170</Version>
144144
</PackageReference>
145145
<PackageReference Include="NuGet.VisualStudio" GeneratePathProperty="true">
146-
<Version>17.12.1</Version>
146+
<Version>17.13.2</Version>
147147
</PackageReference>
148148
<PackageReference Include="Microsoft.VSSDK.BuildTools">
149149
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
150150
<PrivateAssets>all</PrivateAssets>
151151
<Version>17.10.2185</Version>
152152
</PackageReference>
153153
<PackageReference Include="WPF-UI">
154-
<Version>4.0.0-rc.2</Version>
154+
<Version>4.0.2</Version>
155155
</PackageReference>
156156
</ItemGroup>
157157
<ItemGroup>

VSIX/DevWinUI_Template/DevWinUI_Template/TemplateWizard/SharedWizard.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,15 @@ private void AddReplacementsDictionary(Dictionary<string, string> replacementsDi
330330
replacementsDictionary.Add("$AddAboutPage$", WizardConfig.UseAboutPage.ToString());
331331
replacementsDictionary.Add("$T4_NAMESPACE$", SafeProjectName);
332332

333+
if (WizardConfig.IsProfileOptimization)
334+
{
335+
replacementsDictionary.Add("$BoostStartup$", Environment.NewLine + Environment.NewLine + PredefinedCodes.ProfileOptimization);
336+
}
337+
else
338+
{
339+
replacementsDictionary.Add("$BoostStartup$", "");
340+
}
341+
333342
#region CSProjectElements
334343
// Add CSProjectElements
335344
if (WizardConfig.CSProjectElements != null && WizardConfig.CSProjectElements.Count > 0)

VSIX/DevWinUI_Template/DevWinUI_Template/Views/Pages/DashboardPage.xaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@
7070
<ui:SymbolIcon Symbol="Dock20" />
7171
</local:SettingsControl.Icon>
7272
</local:SettingsControl>
73+
<Separator Margin="0,5,0,5"
74+
HorizontalAlignment="Stretch" />
75+
<local:SettingsControl x:Name="tgProfileOptimization"
76+
Title="Boost Startup (ProfileOptimization)"
77+
Description="Enables Multicore JIT with the specified profile"
78+
IsOn="True"
79+
Toggled="tgProfileOptimization_Toggled">
80+
<local:SettingsControl.Icon>
81+
<ui:SymbolIcon Symbol="TopSpeed24" />
82+
</local:SettingsControl.Icon>
83+
</local:SettingsControl>
7384
<local:SettingsControl x:Name="tgUnPackaged"
7485
Title="UnPackaged App"
7586
Description="Create an unpackaged executable (EXE) that runs without an MSIX container."

VSIX/DevWinUI_Template/DevWinUI_Template/Views/Pages/DashboardPage.xaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public DashboardPage()
1818
WizardConfig.UseSolutionFolder = true;
1919
}
2020

21+
WizardConfig.IsProfileOptimization = true;
22+
2123
Loaded += DashboardPage_Loaded;
2224
}
2325

@@ -99,4 +101,9 @@ private void txtSolutionFolderName_TextChanged(object sender, TextChangedEventAr
99101
WizardConfig.SolutionFolderName = WizardConfig.SolutionFolderNameDefault;
100102
}
101103
}
104+
105+
private void tgProfileOptimization_Toggled(object sender, RoutedEventArgs e)
106+
{
107+
WizardConfig.IsProfileOptimization = tgProfileOptimization.IsOn;
108+
}
102109
}

VSIX/DevWinUI_Template/DevWinUI_Template/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="DevWinUI_Template.18eb89b1-bd1f-4e22-9196-6ea05b8ca61d" Version="11.5.1" Language="en-US" Publisher="Mahdi Hosseini" />
4+
<Identity Id="DevWinUI_Template.18eb89b1-bd1f-4e22-9196-6ea05b8ca61d" Version="11.6.0" Language="en-US" Publisher="Mahdi Hosseini" />
55
<DisplayName>DevWinUI Templates for WinUI</DisplayName>
66
<Description xml:space="preserve">DevWinUI Project Template, help you quickly create a new WinUI 3 App with DevWinUI and MVVM Packages. We prepare your project with the following features: NavigationView, Custom TitleBar, HomeLandingPage and Settings Page (with Theme settings).
77
We also always use the latest version of WindowsAppSDK.

VSIX/DevWinUI_Template/WinUIApp-Blank-UnitTest/App.xaml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ public partial class App : Application
44
{
55
public new static App Current => (App)Application.Current;
66
public static Window MainWindow = Window.Current;
7-
7+
public static IntPtr Hwnd => WinRT.Interop.WindowNative.GetWindowHandle(MainWindow);
8+
89
public App()
910
{
10-
this.InitializeComponent();
11+
this.InitializeComponent();$BoostStartup$
1112
}
1213

1314
protected override void OnLaunched(LaunchActivatedEventArgs args)

VSIX/DevWinUI_Template/WinUIApp-Blank/App.xaml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ public partial class App : Application
44
{
55
public new static App Current => (App)Application.Current;
66
public static Window MainWindow = Window.Current;
7-
7+
public static IntPtr Hwnd => WinRT.Interop.WindowNative.GetWindowHandle(MainWindow);
8+
89
public App()
910
{
10-
this.InitializeComponent();
11+
this.InitializeComponent();$BoostStartup$
1112
}
1213

1314
protected override void OnLaunched(LaunchActivatedEventArgs args)

VSIX/DevWinUI_Template/WinUIApp-MVVM-NavigationView/App.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public partial class App : Application
44
{
55
public new static App Current => (App)Application.Current;
66
public static Window MainWindow = Window.Current;
7+
public static IntPtr Hwnd => WinRT.Interop.WindowNative.GetWindowHandle(MainWindow);
78
public IServiceProvider Services { get; }
89
public IJsonNavigationService NavService => GetService<IJsonNavigationService>();
910
public IThemeService ThemeService => GetService<IThemeService>();
@@ -21,7 +22,7 @@ public static T GetService<T>() where T : class
2122
public App()
2223
{
2324
Services = ConfigureServices();
24-
this.InitializeComponent();
25+
this.InitializeComponent();$BoostStartup$
2526
}
2627

2728
private static IServiceProvider ConfigureServices()

0 commit comments

Comments
 (0)