diff --git a/.editorconfig b/.editorconfig index c350f42ae..83cb6abc1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -175,6 +175,14 @@ csharp_style_prefer_method_group_conversion = true:silent curly_bracket_next_line = true indent_brace_style = Allman +# JSON files +[*.json] +charset = utf-8-bom + +# MD files +[*.md] +charset = utf-8-bom + # xaml files [*.xaml] charset = utf-8-bom diff --git a/code/SharedFunctionality.UI/VisualStudio/RightClickActions.cs b/code/SharedFunctionality.UI/VisualStudio/RightClickActions.cs index 5375f758a..645d0385c 100644 --- a/code/SharedFunctionality.UI/VisualStudio/RightClickActions.cs +++ b/code/SharedFunctionality.UI/VisualStudio/RightClickActions.cs @@ -31,7 +31,7 @@ namespace Microsoft.Templates.UI.VisualStudio new RightClickAvailability(Platforms.Uwp, ProgrammingLanguages.CSharp) { TemplateTypes = new List() { TemplateType.Page, TemplateType.Feature, TemplateType.Service, TemplateType.Testing } }, new RightClickAvailability(Platforms.Uwp, ProgrammingLanguages.VisualBasic) { TemplateTypes = new List() { TemplateType.Page, TemplateType.Feature, TemplateType.Service, TemplateType.Testing } }, new RightClickAvailability(Platforms.Wpf, ProgrammingLanguages.CSharp) { TemplateTypes = new List() { TemplateType.Page, TemplateType.Feature, TemplateType.Testing } }, - new RightClickAvailability(Platforms.WinUI, ProgrammingLanguages.CSharp, AppModels.Desktop) { TemplateTypes = new List() { TemplateType.Page, TemplateType.Feature } }, + new RightClickAvailability(Platforms.WinUI, ProgrammingLanguages.CSharp, AppModels.Desktop) { TemplateTypes = new List() { TemplateType.Page, TemplateType.Feature, TemplateType.Testing } }, }; private readonly GenerationService _generationService = GenerationService.Instance; diff --git a/code/TemplateStudioForWinUICs/TemplateStudioForWinUICs.csproj b/code/TemplateStudioForWinUICs/TemplateStudioForWinUICs.csproj index b856dd984..806a580b0 100644 --- a/code/TemplateStudioForWinUICs/TemplateStudioForWinUICs.csproj +++ b/code/TemplateStudioForWinUICs/TemplateStudioForWinUICs.csproj @@ -179,6 +179,9 @@ true + + true + true @@ -203,6 +206,9 @@ true + + true + @@ -225,6 +231,18 @@ source.extension.vsixmanifest + + true + + + true + + + true + + + true + true @@ -259,6 +277,15 @@ true + + true + + + true + + + true + VsctGenerator Menus.ctmenu @@ -386,6 +413,17 @@ true + + true + + + true + + + true + + + true @@ -2105,9 +2143,6 @@ true - - true - true @@ -2252,31 +2287,16 @@ true - - true - - - true - true true - - true - - - true - true - - true - - + true @@ -2291,23 +2311,13 @@ true - - true - - - true - - - true - - + true true - diff --git a/code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/.template.config/template.json b/code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/.template.config/template.json index eb75162fb..ba0f4b938 100644 --- a/code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/.template.config/template.json +++ b/code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/.template.config/template.json @@ -43,10 +43,7 @@ "path": "Param_ProjectName/Models/LocalSettingsOptions.cs" }, { - "path": "Param_ProjectName/Services/LocalSettingsServicePackaged.cs" - }, - { - "path": "Param_ProjectName/Services/LocalSettingsServiceUnpackaged.cs" + "path": "Param_ProjectName/Services/LocalSettingsService.cs" } ], "symbols": { diff --git a/code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/Param_ProjectName/Services/LocalSettingsServiceUnpackaged.cs b/code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/Param_ProjectName/Services/LocalSettingsService.cs similarity index 60% rename from code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/Param_ProjectName/Services/LocalSettingsServiceUnpackaged.cs rename to code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/Param_ProjectName/Services/LocalSettingsService.cs index f5f1d91e5..bbb0ac647 100644 --- a/code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/Param_ProjectName/Services/LocalSettingsServiceUnpackaged.cs +++ b/code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/Param_ProjectName/Services/LocalSettingsService.cs @@ -1,12 +1,16 @@ using Param_RootNamespace.Contracts.Services; using Param_RootNamespace.Core.Contracts.Services; using Param_RootNamespace.Core.Helpers; +using Param_RootNamespace.Helpers; using Param_RootNamespace.Models; + using Microsoft.Extensions.Options; +using Windows.ApplicationModel; +using Windows.Storage; namespace Param_RootNamespace.Services; -public class LocalSettingsServiceUnpackaged : ILocalSettingsService +public class LocalSettingsService : ILocalSettingsService { private const string _defaultApplicationDataFolder = "Param_ProjectName/ApplicationData"; private const string _defaultLocalSettingsFile = "LocalSettings.json"; @@ -22,7 +26,7 @@ public class LocalSettingsServiceUnpackaged : ILocalSettingsService private bool _isInitialized; - public LocalSettingsServiceUnpackaged(IFileService fileService, IOptions options) + public LocalSettingsService(IFileService fileService, IOptions options) { _fileService = fileService; _options = options.Value; @@ -45,13 +49,21 @@ public class LocalSettingsServiceUnpackaged : ILocalSettingsService public async Task ReadSettingAsync(string key) { - await InitializeAsync(); - - object? obj; - - if (_settings != null && _settings.TryGetValue(key, out obj)) + if (RuntimeHelper.IsMSIX) { - return await Json.ToObjectAsync((string)obj); + if (ApplicationData.Current.LocalSettings.Values.TryGetValue(key, out var obj)) + { + return await Json.ToObjectAsync((string)obj); + } + } + else + { + await InitializeAsync(); + + if (_settings != null && _settings.TryGetValue(key, out var obj)) + { + return await Json.ToObjectAsync((string)obj); + } } return default; @@ -59,10 +71,17 @@ public class LocalSettingsServiceUnpackaged : ILocalSettingsService public async Task SaveSettingAsync(string key, T value) { - await InitializeAsync(); + if (RuntimeHelper.IsMSIX) + { + ApplicationData.Current.LocalSettings.Values[key] = await Json.StringifyAsync(value); + } + else + { + await InitializeAsync(); - _settings[key] = await Json.StringifyAsync(value); + _settings[key] = await Json.StringifyAsync(value); - await Task.Run(() => _fileService.Save(_applicationDataFolder, _localsettingsFile, _settings)); + await Task.Run(() => _fileService.Save(_applicationDataFolder, _localsettingsFile, _settings)); + } } } diff --git a/code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/Param_ProjectName/Services/LocalSettingsServicePackaged.cs b/code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/Param_ProjectName/Services/LocalSettingsServicePackaged.cs deleted file mode 100644 index bc7a3b8dc..000000000 --- a/code/TemplateStudioForWinUICs/Templates/Ft/SettingsStorage/Param_ProjectName/Services/LocalSettingsServicePackaged.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Param_RootNamespace.Contracts.Services; -using Param_RootNamespace.Core.Helpers; -using Windows.Storage; - -namespace Param_RootNamespace.Services; - -public class LocalSettingsServicePackaged : ILocalSettingsService -{ - public async Task ReadSettingAsync(string key) - { - if (ApplicationData.Current.LocalSettings.Values.TryGetValue(key, out var obj)) - { - return await Json.ToObjectAsync((string)obj); - } - - return default; - } - - public async Task SaveSettingAsync(string key, T value) - { - ApplicationData.Current.LocalSettings.Values[key] = await Json.StringifyAsync(value); - } -} diff --git a/code/TemplateStudioForWinUICs/Templates/Pg/Settings/ViewModels/Param_ItemNameViewModel.cs b/code/TemplateStudioForWinUICs/Templates/Pg/Settings/ViewModels/Param_ItemNameViewModel.cs index 96af91e14..47610be6c 100644 --- a/code/TemplateStudioForWinUICs/Templates/Pg/Settings/ViewModels/Param_ItemNameViewModel.cs +++ b/code/TemplateStudioForWinUICs/Templates/Pg/Settings/ViewModels/Param_ItemNameViewModel.cs @@ -1,7 +1,9 @@ -using System.Windows.Input; +using System.Reflection; +using System.Windows.Input; using Microsoft.UI.Xaml; using Param_RootNamespace.Contracts.Services; using Param_RootNamespace.Helpers; +using Windows.ApplicationModel; namespace Param_RootNamespace.ViewModels; @@ -47,5 +49,19 @@ public class Param_ItemNameViewModel : System.ComponentModel.INotifyPropertyChan private static string GetVersionDescription() { + Version version; + + if (RuntimeHelper.IsMSIX) + { + var packageVersion = Package.Current.Id.Version; + + version = new(packageVersion.Major, packageVersion.Minor, packageVersion.Build, packageVersion.Revision); + } + else + { + version = Assembly.GetExecutingAssembly().GetName().Version!; + } + + return $"{"AppDisplayName".GetLocalized()} - {version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; } } diff --git a/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName.Core/README.md b/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName.Core/README.md new file mode 100644 index 000000000..906c066e1 --- /dev/null +++ b/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName.Core/README.md @@ -0,0 +1,5 @@ +*Recommended Markdown Viewer: [Markdown Editor](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor2)* + +## Getting Started + +The Core project contains code that can be [reused across multiple application projects](https://docs.microsoft.com/dotnet/standard/net-standard#net-5-and-net-standard). diff --git a/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName.Core/readme.txt b/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName.Core/readme.txt deleted file mode 100644 index 8de55e9a8..000000000 --- a/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName.Core/readme.txt +++ /dev/null @@ -1 +0,0 @@ -This is a .NET Standard project which is meant to contain code that can be reused across multiple .NET implementations. \ No newline at end of file diff --git a/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName/Helpers/ResourceExtensions.cs b/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName/Helpers/ResourceExtensions.cs index a0b615287..4ee932670 100644 --- a/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName/Helpers/ResourceExtensions.cs +++ b/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName/Helpers/ResourceExtensions.cs @@ -2,7 +2,7 @@ namespace Param_RootNamespace.Helpers; -internal static class ResourceExtensions +public static class ResourceExtensions { private static readonly ResourceLoader _resourceLoader = new(); diff --git a/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName/Helpers/RuntimeHelper.cs b/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName/Helpers/RuntimeHelper.cs new file mode 100644 index 000000000..0b1473e54 --- /dev/null +++ b/code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName/Helpers/RuntimeHelper.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; +using System.Text; + +namespace Param_RootNamespace.Helpers; + +public class RuntimeHelper +{ + [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + private static extern int GetCurrentPackageFullName(ref int packageFullNameLength, StringBuilder? packageFullName); + + public static bool IsMSIX + { + get + { + var length = 0; + + return GetCurrentPackageFullName(ref length, null) != 15700L; + } + } +} diff --git a/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/.template.config/icon.xaml b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/.template.config/icon.xaml new file mode 100644 index 000000000..78f394bdb --- /dev/null +++ b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/.template.config/icon.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/.template.config/localize/description.md b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/.template.config/localize/description.md new file mode 100644 index 000000000..ff6a058fe --- /dev/null +++ b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/.template.config/localize/description.md @@ -0,0 +1 @@ +Add an MSTest project to write unit tests. diff --git a/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/.template.config/localize/templatestrings.json b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/.template.config/localize/templatestrings.json new file mode 100644 index 000000000..5dd64860c --- /dev/null +++ b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/.template.config/localize/templatestrings.json @@ -0,0 +1,7 @@ +{ + "name": "MSTest", + "description": "Add an MSTest project to write unit tests.", + + "_name.comment": "Label for an MSTest project.", + "_description.comment": "Label description for MSTest." +} diff --git a/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/.template.config/template.json b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/.template.config/template.json new file mode 100644 index 000000000..9ff799b30 --- /dev/null +++ b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/.template.config/template.json @@ -0,0 +1,100 @@ +{ + "$schema": "http://json.schemastore.org/template", + "author": "Microsoft", + "classifications": [ "Universal" ], + "name": "MSTest", + "shortName": "MSTest", + "groupIdentity": "ts.WinUI.Testing.App.MSTest", + "identity": "ts.WinUI.Testing.App.MSTest", + "description": "Add an MSTest project to write unit tests.", + "tags": { + "language": "C#", + "type": "project", + "ts.type": "testing", + "ts.projecttype": "Blank|NavView|MenuBar", + "ts.outputToParent": "true", + "ts.frontendframework": "all", + "ts.platform": "WinUI", + "ts.appmodel": "Desktop", + "ts.version": "1.0.0", + "ts.displayOrder": "1", + "ts.defaultInstance": "MSTest", + "ts.multipleInstance": "false", + "ts.genGroup": "0", + "ts.rightClickEnabled": "true" + }, + "sourceName": "Param_ProjectName", + "preferNameDirectory": true, + "guids": [], + "PrimaryOutputs": [ + { "path": "Param_ProjectName.Tests.MSTest/Param_ProjectName.Tests.MSTest.csproj" } + ], + "symbols": { + "ts.projectName": { + "type": "parameter", + "replaces": "Param_ProjectName", + "fileRename": "Param_ProjectName" + }, + "ts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + } + }, + "postActions": [ + { + "description": "Add reference to the main WinUI app", + "manualInstructions": [], + "actionId": "849AAEB8-487D-45B3-94B9-77FA74E83A01", + "args": { + "fileIndex": "0", + "projectPath": "Param_ProjectName\\Param_ProjectName.csproj", + "specifiedPathIsTarget": "true" + }, + "continueOnError": true + }, + { + "description": "Add nuget package", + "manualInstructions": [], + "actionId": "0B814718-16A3-4F7F-89F1-69C0F9170EAD", + "args": { + "packageId": "Microsoft.NET.Test.Sdk", + "version": "17.1.0", + "projectPath": "Param_ProjectName.Tests.MSTest\\Param_ProjectName.Tests.MSTest.csproj" + }, + "continueOnError": true + }, + { + "description": "Add nuget package", + "manualInstructions": [], + "actionId": "0B814718-16A3-4F7F-89F1-69C0F9170EAD", + "args": { + "packageId": "MSTest.TestFramework", + "version": "2.2.10", + "projectPath": "Param_ProjectName.Tests.MSTest\\Param_ProjectName.Tests.MSTest.csproj" + }, + "continueOnError": true + }, + { + "description": "Add nuget package", + "manualInstructions": [], + "actionId": "0B814718-16A3-4F7F-89F1-69C0F9170EAD", + "args": { + "packageId": "MSTest.TestAdapter", + "version": "2.2.10", + "projectPath": "Param_ProjectName.Tests.MSTest\\Param_ProjectName.Tests.MSTest.csproj" + }, + "continueOnError": true + }, + { + "description": "Add nuget package", + "manualInstructions": [], + "actionId": "0B814718-16A3-4F7F-89F1-69C0F9170EAD", + "args": { + "packageId": "coverlet.collector", + "version": "3.1.2", + "projectPath": "Param_ProjectName.Tests.MSTest\\Param_ProjectName.Tests.MSTest.csproj" + }, + "continueOnError": true + } + ] +} diff --git a/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/Initialize.cs b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/Initialize.cs new file mode 100644 index 000000000..96ed45146 --- /dev/null +++ b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/Initialize.cs @@ -0,0 +1,21 @@ +using Microsoft.Windows.ApplicationModel.DynamicDependency; + +namespace Param_RootNamespace.Tests.MSTest; + +[TestClass] +public class Initialize +{ + [AssemblyInitialize] + public static void AssemblyInitialize(TestContext context) + { + // TODO: Initialize the appropriate version of the Windows App SDK. + // This is required when testing MSIX apps that are framework-dependent on the Windows App SDK. + Bootstrap.TryInitialize(0x00010001, out var _); + } + + [AssemblyCleanup] + public static void AssemblyCleanup() + { + Bootstrap.Shutdown(); + } +} diff --git a/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/Param_ProjectName.Tests.MSTest.csproj b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/Param_ProjectName.Tests.MSTest.csproj new file mode 100644 index 000000000..3109ec42f --- /dev/null +++ b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/Param_ProjectName.Tests.MSTest.csproj @@ -0,0 +1,10 @@ + + + net6.0-windows10.0.19041.0 + enable + enable + false + x86;x64;arm64 + resources.pri + + diff --git a/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/README.md b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/README.md new file mode 100644 index 000000000..1c6033583 --- /dev/null +++ b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/README.md @@ -0,0 +1,51 @@ +*Recommended Markdown Viewer: [Markdown Editor](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor2)* + +## Getting Started + +[Get started with unit testing](https://docs.microsoft.com/visualstudio/test/getting-started-with-unit-testing?view=vs-2022&tabs=dotnet%2Cmstest), [Use the MSTest framework in unit tests](https://docs.microsoft.com/visualstudio/test/using-microsoft-visualstudio-testtools-unittesting-members-in-unit-tests), and [Run unit tests with Test Explorer](https://docs.microsoft.com/visualstudio/test/run-unit-tests-with-test-explorer) provide an overview of the MSTest framework and Test Explorer. + +## Dependency Injection and Mocking + +Template Studio uses [dependency injection](https://docs.microsoft.com/dotnet/core/extensions/dependency-injection) which means class dependencies implement interfaces and those dependencies are injected via class constructors. + +One of the many benefits of this approach is improved testability, since tests can produce mock implementations of the interfaces and pass them into the object being tested, isolating the object being tested from its dependencies. To mock an interface, create a class that implements the interface, create stub implementations of the interface members, then pass an instance of the class into the object constructor. + +## Example + +The below example demonstrates testing the ViewModel for the Settings page. `SettingsViewModel` depends on `IThemeSelectorService`, so a `MockThemeSelectorService` class is introduced that implements the interface with stub implementations, and then an instance of that class is passed into the `SettingsViewModel` constructor. The `VerifyVersionDescription` test then validates that the `VersionDescription` property of the `SettingsViewModel` returns the expected value. + +```csharp +// SettingsViewModelTests.cs + +[TestClass] +public class SettingsViewModelTests +{ + private readonly SettingsViewModel _viewModel; + + public SettingsViewModelTests() + { + _viewModel = new SettingsViewModel(new MockThemeSelectorService()); + } + + [TestMethod] + public void VerifyVersionDescription() + { + Assert.IsTrue(Regex.IsMatch(_viewModel.VersionDescription, @"App1 - \d\.\d\.\d\.\d")); + } +} +``` + +```csharp +// Mocks/MockThemeSelectorService.cs + +internal class MockThemeSelectorService : IThemeSelectorService +{ + public ElementTheme Theme => ElementTheme.Default; + + public Task InitializeAsync() => Task.CompletedTask; + + public Task SetRequestedThemeAsync() => Task.CompletedTask; + + public Task SetThemeAsync(ElementTheme theme) => Task.CompletedTask; +} +``` diff --git a/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/UnitTest1.cs b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/UnitTest1.cs new file mode 100644 index 000000000..4582516ff --- /dev/null +++ b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/UnitTest1.cs @@ -0,0 +1,42 @@ +using System.Diagnostics; + +namespace Param_RootNamespace.Tests.MSTest; + +[TestClass] +public class UnitTest1 +{ + [ClassInitialize()] + public static void ClassInitialize(TestContext context) + { + Debug.WriteLine("ClassInitialize"); + } + + [ClassCleanup()] + public static void ClassCleanup() + { + Debug.WriteLine("ClassCleanup"); + } + + [TestInitialize()] + public void Initialize() + { + Debug.WriteLine("TestInitialize"); + } + + [TestCleanup()] + public void Cleanup() + { + Debug.WriteLine("TestCleanup"); + } + + [TestMethod] + public void TestMethod1() + { + // TODO: Write unit tests. + // https://docs.microsoft.com/visualstudio/test/getting-started-with-unit-testing + // https://docs.microsoft.com/visualstudio/test/using-microsoft-visualstudio-testtools-unittesting-members-in-unit-tests + // https://docs.microsoft.com/visualstudio/test/run-unit-tests-with-test-explorer + + Assert.IsTrue(true); + } +} diff --git a/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/Usings.cs b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/Usings.cs new file mode 100644 index 000000000..974ab1211 --- /dev/null +++ b/code/TemplateStudioForWinUICs/Templates/Test/App.MSTest/Param_ProjectName.Tests.MSTest/Usings.cs @@ -0,0 +1 @@ +global using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage.Packaged/.template.config/template.json b/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage.Packaged/.template.config/template.json deleted file mode 100644 index 55d9ac136..000000000 --- a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage.Packaged/.template.config/template.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/template", - "author": "Microsoft Community", - "classifications": [ - "Universal" - ], - "name": "ts.WinUI.Feat.SettingsStorage.Packaged", - "shortName": "ts.WinUI.Feat.SettingsStorage.Packaged", - "identity": "ts.WinUI.Feat.SettingsStorage.Packaged", - "tags": { - "language": "C#", - "type": "item", - "ts.type": "composition", - "ts.platform": "WinUI", - "ts.version": "1.0.0", - "ts.compositionFilter": "$frontendframework == MVVMToolkit & groupidentity == ts.WinUI.Feat.SettingsStorage & $feature == ts.WinUI.Feat.MSIXPackaging" - }, - "sourceName": "Param_ItemName", - "preferNameDirectory": true, - "PrimaryOutputs": [ - ], - "symbols": { - "ts.rootNamespace": { - "type": "parameter", - "replaces": "Param_RootNamespace" - } - } -} diff --git a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage.Unpackaged/.template.config/template.json b/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage.Unpackaged/.template.config/template.json deleted file mode 100644 index 0f6f6af52..000000000 --- a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage.Unpackaged/.template.config/template.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/template", - "author": "Microsoft Community", - "classifications": [ - "Universal" - ], - "name": "ts.WinUI.Feat.SettingsStorage.Unpackaged", - "shortName": "ts.WinUI.Feat.SettingsStorage.Unpackaged", - "identity": "ts.WinUI.Feat.SettingsStorage.Unpackaged", - "tags": { - "language": "C#", - "type": "item", - "ts.type": "composition", - "ts.platform": "WinUI", - "ts.version": "1.0.0", - "ts.compositionFilter": "$frontendframework == MVVMToolkit & groupidentity == ts.WinUI.Feat.SettingsStorage & $feature != ts.WinUI.Feat.MSIXPackaging" - }, - "sourceName": "Param_ItemName", - "preferNameDirectory": true, - "PrimaryOutputs": [ - ], - "symbols": { - "ts.rootNamespace": { - "type": "parameter", - "replaces": "Param_RootNamespace" - } - } -} diff --git a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage.Unpackaged/App_postaction.xaml.cs b/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage.Unpackaged/App_postaction.xaml.cs deleted file mode 100644 index 7306c5c4c..000000000 --- a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage.Unpackaged/App_postaction.xaml.cs +++ /dev/null @@ -1,6 +0,0 @@ - ConfigureServices((context, services) => - { - // Services -//{[{ - services.AddSingleton(); -//}]} diff --git a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Page.Settings.Packaged/.template.config/template.json b/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage/.template.config/template.json similarity index 72% rename from code/TemplateStudioForWinUICs/Templates/_comp/MT/Page.Settings.Packaged/.template.config/template.json rename to code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage/.template.config/template.json index f9a8d5423..81feada8e 100644 --- a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Page.Settings.Packaged/.template.config/template.json +++ b/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage/.template.config/template.json @@ -4,16 +4,16 @@ "classifications": [ "Universal" ], - "name": "ts.WinUI.Page.Settings.Packaged", - "shortName": "ts.WinUI.Page.Settings.Packaged", - "identity": "ts.WinUI.Page.Settings.Packaged", + "name": "ts.WinUI.MVVMToolkit.Feat.SettingsStorage", + "shortName": "ts.WinUI.MVVMToolkit.Feat.SettingsStorage", + "identity": "ts.WinUI.MVVMToolkit.Feat.SettingsStorage", "tags": { "language": "C#", "type": "item", "ts.type": "composition", "ts.platform": "WinUI", "ts.version": "1.0.0", - "ts.compositionFilter": "$frontendframework == MVVMToolkit & groupidentity == ts.WinUI.Page.Settings & $feature == ts.WinUI.Feat.MSIXPackaging" + "ts.compositionFilter": "$frontendframework == MVVMToolkit & groupidentity == ts.WinUI.Feat.SettingsStorage" }, "sourceName": "Param_ItemName", "preferNameDirectory": true, diff --git a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage.Packaged/App_postaction.xaml.cs b/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage/App_postaction.xaml.cs similarity index 86% rename from code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage.Packaged/App_postaction.xaml.cs rename to code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage/App_postaction.xaml.cs index 72dd2ee74..7893cd99f 100644 --- a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage.Packaged/App_postaction.xaml.cs +++ b/code/TemplateStudioForWinUICs/Templates/_comp/MT/Feature.SettingsStorage/App_postaction.xaml.cs @@ -2,5 +2,5 @@ { // Services //{[{ - services.AddSingleton(); + services.AddSingleton(); //}]} diff --git a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Page.Settings.Packaged/ViewModels/Param_ItemNameViewModel_postaction.cs b/code/TemplateStudioForWinUICs/Templates/_comp/MT/Page.Settings.Packaged/ViewModels/Param_ItemNameViewModel_postaction.cs deleted file mode 100644 index 383d11c82..000000000 --- a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Page.Settings.Packaged/ViewModels/Param_ItemNameViewModel_postaction.cs +++ /dev/null @@ -1,13 +0,0 @@ -//{[{ -using Windows.ApplicationModel; -//}]} - - private static string GetVersionDescription() - { - //{[{ - var appName = "AppDisplayName".GetLocalized(); - var version = Package.Current.Id.Version; - - return $"{appName} - {version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; - //}]} - } diff --git a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Page.Settings.Unpackaged/.template.config/template.json b/code/TemplateStudioForWinUICs/Templates/_comp/MT/Page.Settings.Unpackaged/.template.config/template.json deleted file mode 100644 index 6ead27e82..000000000 --- a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Page.Settings.Unpackaged/.template.config/template.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/template", - "author": "Microsoft Community", - "classifications": [ - "Universal" - ], - "name": "ts.WinUI.Page.Settings.Unpackaged", - "shortName": "ts.WinUI.Page.Settings.Unpackaged", - "identity": "ts.WinUI.Page.Settings.Unpackaged", - "tags": { - "language": "C#", - "type": "item", - "ts.type": "composition", - "ts.platform": "WinUI", - "ts.version": "1.0.0", - "ts.compositionFilter": "$frontendframework == MVVMToolkit & groupidentity == ts.WinUI.Page.Settings & $feature != ts.WinUI.Feat.MSIXPackaging" - }, - "sourceName": "Param_ItemName", - "preferNameDirectory": true, - "PrimaryOutputs": [ - ], - "symbols": { - "ts.rootNamespace": { - "type": "parameter", - "replaces": "Param_RootNamespace" - } - } -} diff --git a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Page.Settings.Unpackaged/ViewModels/Param_ItemNameViewModel_postaction.cs b/code/TemplateStudioForWinUICs/Templates/_comp/MT/Page.Settings.Unpackaged/ViewModels/Param_ItemNameViewModel_postaction.cs deleted file mode 100644 index d3e465460..000000000 --- a/code/TemplateStudioForWinUICs/Templates/_comp/MT/Page.Settings.Unpackaged/ViewModels/Param_ItemNameViewModel_postaction.cs +++ /dev/null @@ -1,13 +0,0 @@ -//{[{ -using System.Reflection; -//}]} - - private static string GetVersionDescription() - { - //{[{ - var appName = "AppDisplayName".GetLocalized(); - var version = Assembly.GetExecutingAssembly().GetName().Version; - - return $"{appName} - {version?.Major}.{version?.Minor}.{version?.Build}.{version?.Revision}"; - //}]} - }