diff --git a/src/modules/cmdpal/ExtTests/CODE_STYLE_COMPLIANCE.md b/src/modules/cmdpal/ExtTests/CODE_STYLE_COMPLIANCE.md deleted file mode 100644 index 5584e561e0..0000000000 --- a/src/modules/cmdpal/ExtTests/CODE_STYLE_COMPLIANCE.md +++ /dev/null @@ -1,101 +0,0 @@ -# Code Style Compliance Changes - -## Overview -This document summarizes the code style changes made to the migrated unit test files to comply with PowerToys project coding standards. - -## Changes Made - -### 1. Namespace Declaration Style -**Before:** -```csharp -namespace Microsoft.CmdPal.Ext.Registry.UnitTests.Helpers -{ - [TestClass] - public sealed class ResultHelperTest - { - // ... - } -} -``` - -**After:** -```csharp -namespace Microsoft.CmdPal.Ext.Registry.UnitTests.Helpers; - -[TestClass] -public class ResultHelperTest -{ - // ... -} -``` - -**Rationale:** The project uses file-scoped namespace declarations (C# 10 feature) as specified in the `.editorconfig` file with `csharp_style_namespace_declarations = file_scoped:silent`. - -### 2. Class Access Modifiers -**Before:** -```csharp -public sealed class ResultHelperTest -``` - -**After:** -```csharp -public class ResultHelperTest -``` - -**Rationale:** Removed `sealed` modifier to maintain consistency with existing test classes in the cmdpal project, such as `TimeDateCalculatorTests`. - -### 3. File Header -All files maintain the required Microsoft copyright header as specified in the `.editorconfig`: -```csharp -// Copyright (c) Microsoft Corporation -// The Microsoft Corporation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -``` - -## Files Modified - -### Registry Extension Tests -- `ResultHelperTest.cs` -- `RegistryHelperTest.cs` -- `QueryHelperTest.cs` -- `KeyNameTest.cs` - -### Calculator Extension Tests -- `BracketHelperTests.cs` -- `ExtendedCalculatorParserTests.cs` -- `NumberTranslatorTests.cs` - -### WindowWalker Extension Tests -- `PluginSettingsTests.cs` - -### System Extension Tests -- `ImageTests.cs` -- `QueryTests.cs` -- `BasicTests.cs` - -## Compliance with PowerToys Standards - -### EditorConfig Rules Applied -- **File-scoped namespaces**: `csharp_style_namespace_declarations = file_scoped:silent` -- **Indentation**: 4 spaces as specified by `indent_size = 4` -- **Line endings**: CRLF as specified by `end_of_line = crlf` -- **Brace style**: Allman style as specified by `csharp_new_line_before_open_brace = all` - -### Naming Conventions -- Test classes use PascalCase -- Test methods use descriptive names with proper casing -- Parameters and variables follow camelCase conventions - -### Code Organization -- Using statements are properly organized -- Test classes are properly structured with appropriate attributes -- Test methods include proper arrange/act/assert patterns where applicable - -## Benefits -1. **Consistency**: All test files now follow the same coding style as the rest of the PowerToys project -2. **Maintainability**: Consistent formatting makes the code easier to read and maintain -3. **Compliance**: Adherence to project standards ensures smooth integration with the existing codebase -4. **Tooling**: Compatible with the project's code analysis and formatting tools - -## Next Steps -These changes ensure that all migrated test files comply with PowerToys coding standards and can be seamlessly integrated into the project's build and testing pipeline. diff --git a/src/modules/cmdpal/ExtTests/INTERNALS_VISIBLE_TO_CONFIGURATION.md b/src/modules/cmdpal/ExtTests/INTERNALS_VISIBLE_TO_CONFIGURATION.md deleted file mode 100644 index 6c9ec341ed..0000000000 --- a/src/modules/cmdpal/ExtTests/INTERNALS_VISIBLE_TO_CONFIGURATION.md +++ /dev/null @@ -1,101 +0,0 @@ -# InternalsVisibleTo Configuration for CmdPal Extension Unit Tests - -## Problem -Unit test projects for cmdpal extensions were unable to access internal types and members in the extension assemblies, causing compilation errors when trying to test internal classes like `ResultHelper`, `BracketHelper`, `ErrorHandler`, etc. - -## Solution -Added `InternalsVisibleTo` attributes to each extension project's `.csproj` file to allow their corresponding unit test projects to access internal types. - -## Changes Made - -### 1. Microsoft.CmdPal.Ext.Registry -**File**: `src\modules\cmdpal\ext\Microsoft.CmdPal.Ext.Registry\Microsoft.CmdPal.Ext.Registry.csproj` - -Added: -```xml - - - <_Parameter1>Microsoft.CmdPal.Ext.Registry.UnitTests - - -``` - -This allows the test project to access internal types like: -- `Microsoft.CmdPal.Ext.Registry.Helpers.ResultHelper` -- Other internal helper classes - -### 2. Microsoft.CmdPal.Ext.Calc -**File**: `src\modules\cmdpal\ext\Microsoft.CmdPal.Ext.Calc\Microsoft.CmdPal.Ext.Calc.csproj` - -Added: -```xml - - - <_Parameter1>Microsoft.CmdPal.Ext.Calc.UnitTests - - -``` - -This allows the test project to access internal types like: -- `Microsoft.CmdPal.Ext.Calc.Helper.BracketHelper` -- `Microsoft.CmdPal.Ext.Calc.Helper.ErrorHandler` -- Other internal helper classes - -### 3. Microsoft.CmdPal.Ext.WindowWalker -**File**: `src\modules\cmdpal\ext\Microsoft.CmdPal.Ext.WindowWalker\Microsoft.CmdPal.Ext.WindowWalker.csproj` - -Added: -```xml - - - <_Parameter1>Microsoft.CmdPal.Ext.WindowWalker.UnitTests - - -``` - -### 4. Microsoft.CmdPal.Ext.System -**File**: `src\modules\cmdpal\ext\Microsoft.CmdPal.Ext.System\Microsoft.CmdPal.Ext.System.csproj` - -Added: -```xml - - - <_Parameter1>Microsoft.CmdPal.Ext.System.UnitTests - - -``` - -### 5. Microsoft.CmdPal.Ext.TimeDate -**File**: `src\modules\cmdpal\ext\Microsoft.CmdPal.Ext.TimeDate\Microsoft.CmdPal.Ext.TimeDate.csproj` - -Added: -```xml - - - <_Parameter1>Microsoft.CmdPal.Ext.TimeDate.UnitTests - - -``` - -## How It Works - -The `InternalsVisibleTo` attribute is a .NET feature that allows an assembly to specify which other assemblies can access its internal types and members. By adding this attribute to each extension project, we grant the corresponding unit test projects access to internal classes, methods, and properties that need to be tested. - -## Benefits - -1. **Comprehensive Testing**: Unit tests can now access and test internal implementation details -2. **Maintains Encapsulation**: Internal types remain internal to external consumers while being testable -3. **Follows Best Practices**: This is the standard .NET approach for testing internal members -4. **Future-Proof**: Any new internal types added to the extensions will automatically be accessible to their tests - -## Verification - -After applying these changes: -1. Unit test projects can compile successfully -2. Tests can access internal helper classes and methods -3. The extension assemblies maintain their internal encapsulation for external consumers -4. The solution builds correctly in both Visual Studio and via dotnet CLI - -## Security Considerations - -The `InternalsVisibleTo` attribute only grants access to the specific test assemblies named. This maintains security while enabling comprehensive testing of internal implementation details. diff --git a/src/modules/cmdpal/ExtTests/MIGRATION_SUMMARY.md b/src/modules/cmdpal/ExtTests/MIGRATION_SUMMARY.md deleted file mode 100644 index 3529b21fec..0000000000 --- a/src/modules/cmdpal/ExtTests/MIGRATION_SUMMARY.md +++ /dev/null @@ -1,88 +0,0 @@ -# CmdPal Extension Unit Tests Migration - -## Overview -Successfully migrated unit tests for four PowerToys launcher plugins (Registry, Calculator, WindowWalker, System) to the Command Palette (CmdPal) extension framework. - -## Migrated Extensions - -### 1. Microsoft.CmdPal.Ext.Registry.UnitTests -**Original Source**: `src\modules\launcher\Plugins\Microsoft.PowerToys.Run.Plugin.Registry.UnitTest\` -**New Location**: `src\modules\cmdpal\ExtTests\Microsoft.CmdPal.Ext.Registry.UnitTests\` - -**Test Files Created**: -- `RegistryHelperTest.cs` - Tests for registry key parsing and base key operations -- `ResultHelperTest.cs` - Tests for text truncation and result formatting -- `QueryHelperTest.cs` - Tests for query parsing and short base key handling -- `KeyNameTest.cs` - Tests for registry key name constants -- `BasicStructureTest.cs` - Basic project structure validation - -### 2. Microsoft.CmdPal.Ext.Calc.UnitTests -**Original Source**: `src\modules\launcher\Plugins\Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest\` -**New Location**: `src\modules\cmdpal\ExtTests\Microsoft.CmdPal.Ext.Calc.UnitTests\` - -**Test Files Created**: -- `BracketHelperTests.cs` - Tests for bracket completion validation -- `ExtendedCalculatorParserTests.cs` - Tests for mathematical expression parsing and evaluation -- `NumberTranslatorTests.cs` - Tests for culture-specific number translation - -### 3. Microsoft.CmdPal.Ext.WindowWalker.UnitTests -**Original Source**: `src\modules\launcher\Plugins\Microsoft.Plugin.WindowWalker.UnitTests\` -**New Location**: `src\modules\cmdpal\ExtTests\Microsoft.CmdPal.Ext.WindowWalker.UnitTests\` - -**Test Files Created**: -- `PluginSettingsTests.cs` - Tests for WindowWalker settings management (adapted to use SettingsManager instead of WindowWalkerSettings) - -### 4. Microsoft.CmdPal.Ext.System.UnitTests -**Original Source**: `src\modules\launcher\Plugins\Microsoft.PowerToys.Run.Plugin.System.UnitTests\` -**New Location**: `src\modules\cmdpal\ExtTests\Microsoft.CmdPal.Ext.System.UnitTests\` - -**Test Files Created**: -- `ImageTests.cs` - Tests for icon theme handling (adapted for cmdpal structure) -- `QueryTests.cs` - Tests for system command queries -- `BasicTests.cs` - Tests for helper classes and basic functionality - -## Key Adaptations Made - -### 1. Namespace Changes -- Updated all namespaces from `Microsoft.PowerToys.Run.Plugin.*` to `Microsoft.CmdPal.Ext.*` -- Updated using statements to reference cmdpal extension helpers - -### 2. Class Reference Updates -- **Registry**: Updated references from `Microsoft.PowerToys.Run.Plugin.Registry.Helper` to `Microsoft.CmdPal.Ext.Registry.Helpers` -- **Calculator**: Updated references from `Microsoft.PowerToys.Run.Plugin.Calculator` to `Microsoft.CmdPal.Ext.Calc.Helper` -- **WindowWalker**: Adapted from `WindowWalkerSettings.Instance` to `SettingsManager.Instance` -- **System**: Adapted tests to work with new cmdpal system extension structure - -### 3. Project Structure -- All projects follow the same structure as the existing `Microsoft.CmdPal.Ext.TimeDate.UnitTests` -- Use MSTest framework with Moq for mocking -- Target .NET 9.0 with Windows 10.0.26100.0 SDK -- Output to the same directory structure as other cmdpal tests - -### 4. Framework Adaptations -- **WindowWalker**: The settings system changed from `WindowWalkerSettings` singleton to `SettingsManager` with JsonSettingsManager base -- **System**: Adapted to use new helper classes like `Commands`, `Icons`, `Win32Helpers`, `NetworkConnectionProperties` -- **Calculator**: Maintained similar test structure but updated to use cmdpal's calculator helpers -- **Registry**: Maintained similar registry helper test patterns - -## Project Configuration -Each test project includes: -- Reference to the corresponding cmdpal extension project -- MSTest and Moq package references -- Proper output path configuration for cmdpal test structure -- Appropriate root namespace matching the extension - -## Migration Benefits -1. **Consistency**: All tests now follow the same pattern as the existing TimeDate extension tests -2. **Framework Alignment**: Tests are aligned with the cmdpal extension framework -3. **Maintainability**: Tests are organized alongside their respective extensions -4. **Reusability**: Test patterns can be applied to future cmdpal extensions - -## Next Steps -1. Verify all tests compile and run correctly in the full build environment -2. Add any additional test coverage specific to cmdpal extension features -3. Consider adding integration tests for the command palette framework interactions -4. Update CI/CD pipelines to include the new test projects - -## Files Created -Total of 13 test files across 4 new test projects, mirroring the functionality and test coverage of the original PowerToys launcher plugin tests while adapting to the cmdpal extension architecture. diff --git a/src/modules/cmdpal/ExtTests/SOLUTION_FIX_DOCUMENTATION.md b/src/modules/cmdpal/ExtTests/SOLUTION_FIX_DOCUMENTATION.md deleted file mode 100644 index 2b601076e5..0000000000 --- a/src/modules/cmdpal/ExtTests/SOLUTION_FIX_DOCUMENTATION.md +++ /dev/null @@ -1,49 +0,0 @@ -# PowerToys Solution Fix - Built-in Extension Tests Folder - -## Problem -The cmdpal extension unit test projects were not appearing in the "Built-in Extension Tests" folder in Visual Studio, even though they were correctly added to the solution file. - -## Root Cause -The projects were missing from the `NestedProjects` section of the PowerToys.sln file, which is what tells Visual Studio which projects belong to which solution folders. - -## Solution -Added the following entries to the `NestedProjects` section of PowerToys.sln: - -``` -{A1B2C3D4-E5F6-7890-ABCD-56789ABCDEF0} = {7872E99B-71E6-4AE9-976A-922F0A6B3113} -{B2C3D4E5-F6A7-8901-BCDE-6789ABCDEF01} = {7872E99B-71E6-4AE9-976A-922F0A6B3113} -{C3D4E5F6-A7B8-9012-CDEF-789ABCDEF012} = {7872E99B-71E6-4AE9-976A-922F0A6B3113} -{D4E5F6A7-B8C9-0123-DEF0-89ABCDEF0123} = {7872E99B-71E6-4AE9-976A-922F0A6B3113} -{E5F6A7B8-C9D0-1234-EF01-9ABCDEF01234} = {7872E99B-71E6-4AE9-976A-922F0A6B3113} -``` - -These entries were added right after the existing TimeDate test project entry: -``` -{97E31501-601E-493D-A6A8-1EEB799F4ADC} = {7872E99B-71E6-4AE9-976A-922F0A6B3113} -``` - -Where: -- `{7872E99B-71E6-4AE9-976A-922F0A6B3113}` is the GUID of the "Built-in Extension Tests" folder -- The left-hand GUIDs correspond to: - - `{A1B2C3D4-E5F6-7890-ABCD-56789ABCDEF0}` = Microsoft.CmdPal.Ext.Registry.UnitTests - - `{B2C3D4E5-F6A7-8901-BCDE-6789ABCDEF01}` = Microsoft.CmdPal.Ext.Calc.UnitTests - - `{C3D4E5F6-A7B8-9012-CDEF-789ABCDEF012}` = Microsoft.CmdPal.Ext.WindowWalker.UnitTests - - `{D4E5F6A7-B8C9-0123-DEF0-89ABCDEF0123}` = Microsoft.CmdPal.Ext.System.UnitTests - - `{E5F6A7B8-C9D0-1234-EF01-9ABCDEF01234}` = Microsoft.CmdPal.Ext.TimeDate.UnitTests - -## Verification -1. All test projects are now properly nested under the "Built-in Extension Tests" folder -2. The solution can still be built using dotnet CLI -3. Visual Studio should now display all projects in the correct folder structure - -## What to do next -1. Restart Visual Studio if it's currently open -2. Reload the PowerToys.sln solution -3. Verify that all cmdpal extension test projects now appear under "Built-in Extension Tests" folder -4. The projects should be fully manageable (build, test, debug) within Visual Studio - -## Additional Notes -- The solution file retains all existing functionality -- All build configurations (Debug/Release, x64/ARM64) are preserved -- The test projects follow PowerToys code style conventions -- Documentation has been provided in the ExtTests folder for future reference diff --git a/src/modules/cmdpal/ExtTests/SOLUTION_INTEGRATION.md b/src/modules/cmdpal/ExtTests/SOLUTION_INTEGRATION.md deleted file mode 100644 index 2445024a0d..0000000000 --- a/src/modules/cmdpal/ExtTests/SOLUTION_INTEGRATION.md +++ /dev/null @@ -1,57 +0,0 @@ -# PowerToys.sln Solution File Updates - -## Summary -Added the new unit test projects for the migrated cmdpal extensions to the PowerToys.sln solution file under the "Built-in Extension Tests" folder. - -## Changes Made - -### 1. Added Project Definitions -Added the following new project entries after the existing Microsoft.CmdPal.Ext.TimeDate.UnitTests project: - -```xml -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Ext.Registry.UnitTests", "src\modules\cmdpal\ExtTests\Microsoft.CmdPal.Ext.Registry.UnitTests\Microsoft.CmdPal.Ext.Registry.UnitTests.csproj", "{A1B2C3D4-E5F6-7890-ABCD-56789ABCDEF0}" -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Ext.Calc.UnitTests", "src\modules\cmdpal\ExtTests\Microsoft.CmdPal.Ext.Calc.UnitTests\Microsoft.CmdPal.Ext.Calc.UnitTests.csproj", "{B2C3D4E5-F6A7-8901-BCDE-6789ABCDEF01}" -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Ext.WindowWalker.UnitTests", "src\modules\cmdpal\ExtTests\Microsoft.CmdPal.Ext.WindowWalker.UnitTests\Microsoft.CmdPal.Ext.WindowWalker.UnitTests.csproj", "{C3D4E5F6-A7B8-9012-CDEF-789ABCDEF012}" -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Ext.System.UnitTests", "src\modules\cmdpal\ExtTests\Microsoft.CmdPal.Ext.System.UnitTests\Microsoft.CmdPal.Ext.System.UnitTests.csproj", "{D4E5F6A7-B8C9-0123-DEF0-89ABCDEF0123}" -``` - -### 2. Added Build Configurations -Added Debug and Release configurations for both ARM64 and x64 platforms for each new project: - -For each project GUID, added: -- Debug|ARM64 (ActiveCfg and Build.0) -- Debug|x64 (ActiveCfg and Build.0) -- Release|ARM64 (ActiveCfg and Build.0) -- Release|x64 (ActiveCfg and Build.0) - -### 3. Added Project Nesting -Added the new projects to the "Built-in Extension Tests" folder by adding entries in the GlobalSection(NestedProjects): - -``` -{A1B2C3D4-E5F6-7890-ABCD-56789ABCDEF0} = {7872E99B-71E6-4AE9-976A-922F0A6B3113} -{B2C3D4E5-F6A7-8901-BCDE-6789ABCDEF01} = {7872E99B-71E6-4AE9-976A-922F0A6B3113} -{C3D4E5F6-A7B8-9012-CDEF-789ABCDEF012} = {7872E99B-71E6-4AE9-976A-922F0A6B3113} -{D4E5F6A7-B8C9-0123-DEF0-89ABCDEF0123} = {7872E99B-71E6-4AE9-976A-922F0A6B3113} -``` - -Where `{7872E99B-71E6-4AE9-976A-922F0A6B3113}` is the GUID of the "Built-in Extension Tests" folder. - -## Project GUIDs -Generated unique GUIDs for each new project: -- **Registry.UnitTests**: `{A1B2C3D4-E5F6-7890-ABCD-56789ABCDEF0}` -- **Calc.UnitTests**: `{B2C3D4E5-F6A7-8901-BCDE-6789ABCDEF01}` -- **WindowWalker.UnitTests**: `{C3D4E5F6-A7B8-9012-CDEF-789ABCDEF012}` -- **System.UnitTests**: `{D4E5F6A7-B8C9-0123-DEF0-89ABCDEF0123}` - -## Visual Studio Integration -These changes will ensure that: -1. The test projects appear in the Visual Studio Solution Explorer under "Built-in Extension Tests" -2. The projects can be built in both Debug and Release configurations -3. The projects support both ARM64 and x64 architectures -4. The test projects are properly integrated with the PowerToys build system - -## Files Affected -- `PowerToys.sln` - Main solution file with project definitions, build configurations, and folder structure - -## Next Steps -After these changes, the test projects should be visible in Visual Studio and can be built and run using the standard MSBuild tools and Visual Studio test runner. diff --git a/src/modules/cmdpal/ExtTests/VISUAL_STUDIO_TROUBLESHOOTING.md b/src/modules/cmdpal/ExtTests/VISUAL_STUDIO_TROUBLESHOOTING.md deleted file mode 100644 index 98b58bc8b4..0000000000 --- a/src/modules/cmdpal/ExtTests/VISUAL_STUDIO_TROUBLESHOOTING.md +++ /dev/null @@ -1,49 +0,0 @@ -# Visual Studio 解决方案项目可见性问题解决方案 - -## 问题描述 -新添加的单元测试项目在Visual Studio解决方案资源管理器中不可见。 - -## 已完成的更改 -✅ 项目已正确添加到PowerToys.sln解决方案文件 -✅ 使用了正确的项目类型GUID (`{9A19103F-16F7-4668-BE54-9A1E7A4F7556}`) -✅ 添加了完整的构建配置 (Debug/Release, ARM64/x64) -✅ 正确配置了项目嵌套到"Built-in Extension Tests"文件夹 - -## 验证状态 -通过 `dotnet sln list` 命令验证,所有新的测试项目都已正确识别: -- ✅ Microsoft.CmdPal.Ext.Registry.UnitTests -- ✅ Microsoft.CmdPal.Ext.Calc.UnitTests -- ✅ Microsoft.CmdPal.Ext.WindowWalker.UnitTests -- ✅ Microsoft.CmdPal.Ext.System.UnitTests - -## 解决方案 -由于已确认项目在解决方案文件级别配置正确,项目不可见的问题可能是Visual Studio缓存相关。请尝试以下步骤: - -### 方法1: 重新加载解决方案 -1. 在Visual Studio中关闭解决方案 -2. 重新打开PowerToys.sln -3. 检查"Built-in Extension Tests"文件夹 - -### 方法2: 清除Visual Studio缓存 -1. 关闭Visual Studio -2. 删除解决方案目录下的`.vs`文件夹 -3. 重新打开PowerToys.sln - -### 方法3: 手动添加项目引用(如果上述方法无效) -在Visual Studio中右键点击"Built-in Extension Tests"文件夹,选择"添加现有项目",然后导航到以下项目文件: -- `src\modules\cmdpal\ExtTests\Microsoft.CmdPal.Ext.Registry.UnitTests\Microsoft.CmdPal.Ext.Registry.UnitTests.csproj` -- `src\modules\cmdpal\ExtTests\Microsoft.CmdPal.Ext.Calc.UnitTests\Microsoft.CmdPal.Ext.Calc.UnitTests.csproj` -- `src\modules\cmdpal\ExtTests\Microsoft.CmdPal.Ext.WindowWalker.UnitTests\Microsoft.CmdPal.Ext.WindowWalker.UnitTests.csproj` -- `src\modules\cmdpal\ExtTests\Microsoft.CmdPal.Ext.System.UnitTests\Microsoft.CmdPal.Ext.System.UnitTests.csproj` - -## 技术细节 -- **项目类型**: SDK风格的C#项目 (.NET) -- **文件夹层次**: CommandPalette → Built-in Extension Tests -- **架构支持**: ARM64, x64 -- **配置**: Debug, Release - -## 注意事项 -- 项目文件已存在且结构正确 -- 解决方案文件语法验证无误 -- 构建失败是由于C++/CLI依赖项,但不影响项目在Visual Studio中的可见性 -- 这些测试项目应该可以在Visual Studio中正常显示和构建