Skip to content

Commit

Permalink
refactor vsix
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 committed Dec 1, 2024
1 parent 63cb8d0 commit 0c42af8
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using NuGet.Common;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using NuGet.Common;
using NuGet.Configuration;
using NuGet.Packaging.Core;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
using NuGet.Versioning;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace DevWinUI_Template
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class GlobalUsingOption
public GlobalUsingOption(Dictionary<string, string> replacementsDictionary, string safeProjectName, bool fileLogger, bool debugLogger)
{
StringBuilder outputBuilder = new StringBuilder();

if (WizardConfig.UseJsonSettings)
{
outputBuilder.AppendLine(Environment.NewLine + $"global using static {safeProjectName}.Common.AppHelper;");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Library
public bool IsSelected { get; set; }
public Library()
{

}
public Library(string name, string version, string net9Version, Group group, bool includePreRelease = false)
{
Expand All @@ -37,15 +37,15 @@ public Library(string name, string version, string net9Version, Group group, boo
public Library(string name, Group group, bool includePreRelease = false)
{
Name = name;
Group= group;
Group = group;
IncludePreRelease = includePreRelease;
Net9Version = null;
Version = null;
}
public Library(string name, bool includePreRelease = false)
{
Name = name;
Group= Group.None;
Group = Group.None;
IncludePreRelease = includePreRelease;
Net9Version = null;
Version = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static class PredefinedCodes
await menuService.SaveAsync(menu);
}
"""";

public static readonly string SettingsCardCommentCode =
"""
<!-- <dev:SettingsCard Description="Your Description"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static class WizardConfig
public static string SolutionFolderName = "Solution Items";
public static string TrimMode = "partial";
public static string Nullable = "disable";

public static bool UseGithubWorkflowFile;
public static bool UseXamlStylerFile;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.VisualStudio.Shell;
using System;
using System;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.VisualStudio.Shell;
using Task = System.Threading.Tasks.Task;

namespace DevWinUI_Template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevWinUI_Template.Options;
using DevWinUI_Template.WizardUI;
using EnvDTE;

using EnvDTE80;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.TemplateWizard;
using Microsoft.VisualStudio.Threading;
using NuGet.VisualStudio;
using DevWinUI_Template.Options;
using DevWinUI_Template.WizardUI;

namespace DevWinUI_Template
{
Expand Down Expand Up @@ -120,10 +119,10 @@ public async void RunStarted(object automationObject, Dictionary<string, string>
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

_dte = automationObject as _DTE;

var inputForm = new MainWindow();
var result = inputForm.ShowDialog();

await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

if (result.HasValue && result.Value)
Expand All @@ -134,7 +133,7 @@ public async void RunStarted(object automationObject, Dictionary<string, string>
VSIXRootFolderPath = vsix.VSIXRootFolder;

_shouldAddProjectItem = true;

AddEditorConfigFile();

// Add Base Library Versions
Expand All @@ -143,7 +142,7 @@ public async void RunStarted(object automationObject, Dictionary<string, string>
replacementsDictionary.Add("$MinimumTargetPlatform$", WizardConfig.MinimumTargetPlatform.ToString());
replacementsDictionary.Add("$Platforms$", WizardConfig.Platforms.ToString());
replacementsDictionary.Add("$RuntimeIdentifiers$", WizardConfig.RuntimeIdentifiers.ToString());

replacementsDictionary.Add("$Nullable$", WizardConfig.Nullable);
replacementsDictionary.Add("$TrimMode$", WizardConfig.TrimMode);
replacementsDictionary.Add("$PublishAot$", WizardConfig.PublishAot.ToString());
Expand Down Expand Up @@ -619,7 +618,7 @@ private async Task StartInstallationAsync()
}
}
}

private void SaveAllProjects()
{
ThreadHelper.ThrowIfNotOnUIThread("SaveAllProjects must be called on the UI thread.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using EnvDTE;
using Microsoft.VisualStudio.TemplateWizard;
using System.Collections.Generic;
using System.Collections.Generic;
using DevWinUI_Template.WizardUI;
using EnvDTE;
using Microsoft.VisualStudio.TemplateWizard;

namespace DevWinUI_Template
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using EnvDTE;
using Microsoft.VisualStudio.TemplateWizard;
using System.Collections.Generic;
using System.Collections.Generic;
using DevWinUI_Template.WizardUI;
using EnvDTE;
using Microsoft.VisualStudio.TemplateWizard;

namespace DevWinUI_Template
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Collections.Generic;

using DevWinUI_Template.WizardUI;
using EnvDTE;

using Microsoft.VisualStudio.TemplateWizard;
using DevWinUI_Template.WizardUI;

namespace DevWinUI_Template
{
Expand Down Expand Up @@ -109,13 +107,13 @@ public bool ShouldAddProjectItem(string filePath)
{
return false;
}
else if (!WizardConfig.UseHomeLandingPage &&
!WizardConfig.UseColorsDic &&
else if (!WizardConfig.UseHomeLandingPage &&
!WizardConfig.UseColorsDic &&
filePath.Contains("ThemeResources.xaml"))
{
return false;
}
else if (filePath.Contains("Resources") &&
else if (filePath.Contains("Resources") &&
!filePath.Contains("ThemeResources"))
{
return false;
Expand All @@ -124,8 +122,8 @@ public bool ShouldAddProjectItem(string filePath)
{
return false;
}
else if (!WizardImplementation.UseDebugLogger &&
!WizardImplementation.UseFileLogger &&
else if (!WizardImplementation.UseDebugLogger &&
!WizardImplementation.UseFileLogger &&
filePath.Contains("LoggerSetup"))
{
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Collections.Generic;

using DevWinUI_Template.WizardUI;
using EnvDTE;

using Microsoft.VisualStudio.TemplateWizard;
using DevWinUI_Template.WizardUI;

namespace DevWinUI_Template
{
Expand Down Expand Up @@ -42,8 +40,8 @@ public bool ShouldAddProjectItem(string filePath)
return false;
}

if (!WizardConfig.UseJsonSettings &&
(filePath.Contains("AppConfig") ||
if (!WizardConfig.UseJsonSettings &&
(filePath.Contains("AppConfig") ||
filePath.Contains("AppHelper")))
{
return false;
Expand All @@ -57,8 +55,8 @@ public bool ShouldAddProjectItem(string filePath)
{
return false;
}
else if (!WizardImplementation.UseDebugLogger &&
!WizardImplementation.UseFileLogger &&
else if (!WizardImplementation.UseDebugLogger &&
!WizardImplementation.UseFileLogger &&
filePath.Contains("LoggerSetup"))
{
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using EnvDTE;
using Microsoft.VisualStudio.TemplateWizard;
using System.Collections.Generic;
using System.Collections.Generic;
using DevWinUI_Template.WizardUI;
using EnvDTE;
using Microsoft.VisualStudio.TemplateWizard;

namespace DevWinUI_Template
{
Expand Down Expand Up @@ -40,16 +40,16 @@ public bool ShouldAddProjectItem(string filePath)
return false;
}

if (!WizardConfig.UseHomeLandingPage &&
if (!WizardConfig.UseHomeLandingPage &&
filePath.Contains("HomeLanding"))
{
return false;
}
else if (!WizardConfig.UseSettingsPage &&
(filePath.Contains("SettingsPage.xaml") ||
filePath.Contains("AboutUsSettingPage") ||
filePath.Contains("ThemeSettingPage") ||
filePath.Contains("GeneralSettingPage") ||
else if (!WizardConfig.UseSettingsPage &&
(filePath.Contains("SettingsPage.xaml") ||
filePath.Contains("AboutUsSettingPage") ||
filePath.Contains("ThemeSettingPage") ||
filePath.Contains("GeneralSettingPage") ||
filePath.Contains("AppUpdateSettingPage") ||
filePath.Contains("Backdrop.png") ||
filePath.Contains("Tint.png") ||
Expand All @@ -63,7 +63,7 @@ public bool ShouldAddProjectItem(string filePath)
{
return false;
}
else if (WizardConfig.UseSettingsPage &&
else if (WizardConfig.UseSettingsPage &&
!WizardConfig.UseAboutPage &&
(filePath.Contains("AboutUsSettingPage") ||
filePath.Contains("Info.png")))
Expand Down Expand Up @@ -96,13 +96,13 @@ public bool ShouldAddProjectItem(string filePath)
return false;
}
else if (!WizardConfig.UseJsonSettings &&
(filePath.Contains("AppConfig") ||
(filePath.Contains("AppConfig") ||
filePath.Contains("AppHelper")))
{
return false;
}
else if (!WizardConfig.UseHomeLandingPage &&
!WizardConfig.UseColorsDic &&
else if (!WizardConfig.UseHomeLandingPage &&
!WizardConfig.UseColorsDic &&
filePath.Contains("ThemeResources.xaml"))
{
return false;
Expand All @@ -116,8 +116,8 @@ public bool ShouldAddProjectItem(string filePath)
{
return false;
}
else if (!WizardImplementation.UseDebugLogger &&
!WizardImplementation.UseFileLogger &&
else if (!WizardImplementation.UseDebugLogger &&
!WizardImplementation.UseFileLogger &&
filePath.Contains("LoggerSetup"))
{
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Collections.Generic;

using DevWinUI_Template.WizardUI;
using EnvDTE;

using Microsoft.VisualStudio.TemplateWizard;
using DevWinUI_Template.WizardUI;

namespace DevWinUI_Template
{
Expand Down Expand Up @@ -42,8 +40,8 @@ public bool ShouldAddProjectItem(string filePath)
return false;
}

if (!WizardConfig.UseJsonSettings &&
(filePath.Contains("AppConfig") ||
if (!WizardConfig.UseJsonSettings &&
(filePath.Contains("AppConfig") ||
filePath.Contains("AppHelper")))
{
return false;
Expand All @@ -57,8 +55,8 @@ public bool ShouldAddProjectItem(string filePath)
{
return false;
}
else if (!WizardImplementation.UseDebugLogger &&
!WizardImplementation.UseFileLogger &&
else if (!WizardImplementation.UseDebugLogger &&
!WizardImplementation.UseFileLogger &&
filePath.Contains("LoggerSetup"))
{
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Windows;
using System;
using Wpf.Ui.Controls;
using System;
using System.Windows;
using DevWinUI_Template.WizardUI;
using Wpf.Ui.Controls;

namespace DevWinUI_Template;

Expand Down Expand Up @@ -34,9 +34,9 @@ private void MainWindowWizard_Loaded(object sender, RoutedEventArgs e)
try
{
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(
this,
Wpf.Ui.Controls.WindowBackdropType.Mica,
true
this,
Wpf.Ui.Controls.WindowBackdropType.Mica,
true
);
}
catch (Exception)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<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">
<Metadata>
<Identity Id="DevWinUI_Template.18eb89b1-bd1f-4e22-9196-6ea05b8ca61d" Version="11.0.1" Language="en-US" Publisher="Mahdi Hosseini" />
<Identity Id="DevWinUI_Template.18eb89b1-bd1f-4e22-9196-6ea05b8ca61d" Version="11.0.2" Language="en-US" Publisher="Mahdi Hosseini" />
<DisplayName>DevWinUI Templates for WinUI</DisplayName>
<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).
We also always use the latest version of WindowsAppSDK.
Expand Down

0 comments on commit 0c42af8

Please sign in to comment.