Cmdpal extension: Powertoys extension for cmdpal (#44006)

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Installer built, and every command works as expected,
Now use sparse app deployment, so we don't need an extra msix

---------

Co-authored-by: kaitao-ms <kaitao1105@gmail.com>
This commit is contained in:
Kai Tao
2025-12-23 21:07:44 +08:00
committed by GitHub
parent 534c411fd8
commit d87dde132d
206 changed files with 8800 additions and 691 deletions

View File

@@ -78,24 +78,24 @@ namespace FancyZonesEditorCommon.Data
public JsonElement ToJsonElement(CanvasInfoWrapper info)
{
string json = JsonSerializer.Serialize(info, this.JsonOptions);
string json = JsonSerializer.Serialize(info, FancyZonesJsonContext.Default.CanvasInfoWrapper);
return JsonSerializer.Deserialize<JsonElement>(json);
}
public JsonElement ToJsonElement(GridInfoWrapper info)
{
string json = JsonSerializer.Serialize(info, this.JsonOptions);
string json = JsonSerializer.Serialize(info, FancyZonesJsonContext.Default.GridInfoWrapper);
return JsonSerializer.Deserialize<JsonElement>(json);
}
public CanvasInfoWrapper CanvasFromJsonElement(string json)
{
return JsonSerializer.Deserialize<CanvasInfoWrapper>(json, this.JsonOptions);
return JsonSerializer.Deserialize(json, FancyZonesJsonContext.Default.CanvasInfoWrapper);
}
public GridInfoWrapper GridFromJsonElement(string json)
{
return JsonSerializer.Deserialize<GridInfoWrapper>(json, this.JsonOptions);
return JsonSerializer.Deserialize(json, FancyZonesJsonContext.Default.GridInfoWrapper);
}
}
}

View File

@@ -4,6 +4,7 @@
using System;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
using FancyZonesEditorCommon.Utils;
@@ -16,28 +17,20 @@ namespace FancyZonesEditorCommon.Data
return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
}
protected JsonSerializerOptions JsonOptions
{
get
{
return new JsonSerializerOptions
{
PropertyNamingPolicy = new DashCaseNamingPolicy(),
WriteIndented = true,
};
}
}
protected static JsonSerializerOptions JsonOptions => FancyZonesJsonContext.Default.Options;
protected static JsonTypeInfo<T> TypeInfo => (JsonTypeInfo<T>)FancyZonesJsonContext.Default.GetTypeInfo(typeof(T));
public T Read(string file)
{
IOUtils ioUtils = new IOUtils();
string data = ioUtils.ReadFile(file);
return JsonSerializer.Deserialize<T>(data, JsonOptions);
return JsonSerializer.Deserialize(data, TypeInfo);
}
public string Serialize(T data)
{
return JsonSerializer.Serialize(data, JsonOptions);
return JsonSerializer.Serialize(data, TypeInfo);
}
}
}

View File

@@ -0,0 +1,38 @@
// 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.
using System.Text.Json.Serialization;
using FancyZonesEditorCommon.Utils;
namespace FancyZonesEditorCommon.Data
{
/// <summary>
/// JSON serialization context for AOT-compatible serialization of FancyZones data types.
/// </summary>
[JsonSourceGenerationOptions(
PropertyNamingPolicy = JsonKnownNamingPolicy.KebabCaseLower,
WriteIndented = true)]
[JsonSerializable(typeof(AppliedLayouts.AppliedLayoutsListWrapper))]
[JsonSerializable(typeof(AppliedLayouts.AppliedLayoutWrapper))]
[JsonSerializable(typeof(AppliedLayouts.AppliedLayoutWrapper.DeviceIdWrapper))]
[JsonSerializable(typeof(AppliedLayouts.AppliedLayoutWrapper.LayoutWrapper), TypeInfoPropertyName = "AppliedLayoutLayoutWrapper")]
[JsonSerializable(typeof(CustomLayouts.CustomLayoutListWrapper))]
[JsonSerializable(typeof(CustomLayouts.CustomLayoutWrapper))]
[JsonSerializable(typeof(CustomLayouts.CanvasInfoWrapper))]
[JsonSerializable(typeof(CustomLayouts.CanvasInfoWrapper.CanvasZoneWrapper))]
[JsonSerializable(typeof(CustomLayouts.GridInfoWrapper))]
[JsonSerializable(typeof(LayoutTemplates.TemplateLayoutsListWrapper))]
[JsonSerializable(typeof(LayoutTemplates.TemplateLayoutWrapper))]
[JsonSerializable(typeof(LayoutHotkeys.LayoutHotkeysWrapper))]
[JsonSerializable(typeof(LayoutHotkeys.LayoutHotkeyWrapper))]
[JsonSerializable(typeof(EditorParameters.ParamsWrapper))]
[JsonSerializable(typeof(EditorParameters.NativeMonitorDataWrapper))]
[JsonSerializable(typeof(DefaultLayouts.DefaultLayoutsListWrapper))]
[JsonSerializable(typeof(DefaultLayouts.DefaultLayoutWrapper))]
[JsonSerializable(typeof(DefaultLayouts.DefaultLayoutWrapper.LayoutWrapper), TypeInfoPropertyName = "DefaultLayoutLayoutWrapper")]
public partial class FancyZonesJsonContext : JsonSerializerContext
{
}
}