Skip to content

Add Registry Adapter and Microsoft.Windows/Personalization resource#1550

Open
SteveL-MSFT wants to merge 16 commits into
PowerShell:mainfrom
SteveL-MSFT:registry-adapter
Open

Add Registry Adapter and Microsoft.Windows/Personalization resource#1550
SteveL-MSFT wants to merge 16 commits into
PowerShell:mainfrom
SteveL-MSFT:registry-adapter

Conversation

@SteveL-MSFT
Copy link
Copy Markdown
Member

PR Summary

  • Fix DSC engine to use adapted resource schema instead of validate function of adapter
  • Refactor DSC engine to pass the DscResource instead of a different struct CommandResourceInfo when invoking a native resource as information for specific arg types comes from the resource properties, this simplifies the code and future extensibility (basically all the command_resource changes are this which was needed to add the new adaptedContentArg type
  • Add new content property that can be used in adapted resource manifest instead of path to have inline structured content for an adapter
  • Add new adapter mode to Registry resource that uses this content property
  • Add new Microsoft.Windows/Personalization resource that uses the registry adapter
  • The adapter itself has helpers for converting fron JSON to registry and vice versa. Note that not all types were implemented, only ones used by the Personalization resource. More conversions will be added if we have real use cases for them.

The Microsoft.Windows/Personalization adapted resource manifest best shows how to use this adapter:

# Adapted Registry resource for personalization settings defined in:
# https://learn.microsoft.com/en-us/windows/apps/develop/settings/settings-common#personalization---colors

$schema: https://aka.ms/dsc/schemas/v3/bundled/adaptedresource/manifest.json
type: Microsoft.Windows/Personalization
kind: resource
version: 1.0.0
capabilities:
- get
- set
description: Controls Windows personalization settings such as accent color, light/dark mode, and transparency effects.
author: Microsoft Corporation
requireAdapter: Microsoft.Windows.Adapter/Registry
content:
  appsUseLightTheme:
    keyPath: HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize
    valueType: REG_DWORD
    valueName: AppsUseLightTheme
    jsonType: boolean
    defaultValueIfNotFound: 0
    mapJsonToRegistry:
      'false': 0
      'true': 1
schema:
  embedded:
    $schema: http://json-schema.org/draft-07/schema#
    $id: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/resources/Adapted/Three/v0.1.0/schema.json
    title: Microsoft.Windows/Personalization
    description: Windows personalization settings such as accent color, light/dark mode, and transparency effects as described in https://learn.microsoft.com/windows/apps/develop/settings/settings-common
    type: object
    required: []
    additionalProperties: false
    properties:
      appsUseLightTheme:
        type: boolean
        title: App Uses Light Theme
        description: Indicates whether the app uses the light theme.

The content is used by the registry adapter to map the JSON to registry key path/value/valueName/type. There is also a default value used if the key or value doesn't exist in the registry. The JSONSchema is used to enforce what is allowed.

PR Context

@SteveL-MSFT SteveL-MSFT requested review from Copilot and tgauth May 30, 2026 00:00
@SteveL-MSFT SteveL-MSFT added Doc-Impact Schema-Impact Change requires updating a canonical schema for configs or manifests labels May 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Windows Registry adapter (Microsoft.Windows.Adapter/Registry) plus an inline content shape for adapted resource manifests so adapters can receive structured mapping data directly. Uses the new mechanism to ship a Microsoft.Windows/Personalization adapted resource, and refactors command invocation in dsc-lib to pass DscResource directly instead of a separate CommandResourceInfo struct.

Changes:

  • New manifest enum AdaptedPathOrContent (path or inline content), plumbed through discovery and stored on DscResource.adapted_content; new adaptedContentArg arg kind for get/set/delete; Adapter.list made optional.
  • New registry adapter (adapter.rs, adapter subcommand, locale strings, manifest entry, error type) with JSON↔registry conversions for a subset of value types.
  • New Microsoft.Windows/Personalization adapted YAML manifest, project data, and Pester get/set/export tests; refactor of command_resource.rs / extensions/discover.rs to drop CommandResourceInfo; get_schema now prefers the target resource’s schema.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
lib/dsc-lib/src/dscresources/adapted_resource_manifest.rs Adds AdaptedPathOrContent enum and flattens into manifest.
lib/dsc-lib/src/dscresources/dscresource.rs Adds adapted_content field to DscResource.
lib/dsc-lib/src/dscresources/resource_manifest.rs Adds AdaptedContent arg kinds; makes Adapter.list optional.
lib/dsc-lib/src/dscresources/command_resource.rs Drops CommandResourceInfo, threads DscResource directly; handles new arg kinds; reworks get_schema.
lib/dsc-lib/src/discovery/command_discovery.rs Loads content vs path; gates list invocation on optional list.
lib/dsc-lib/src/extensions/discover.rs Switches to passing a DscResource for arg processing.
lib/dsc-lib/locales/en-us.toml Adds noAdaptedContent localization string.
lib/dsc-lib-jsonschema/.versions.json Bumps latest patch to V3_2_1.
tools/test_group_resource/src/main.rs Initializes new adapted_content field.
resources/registry/Cargo.toml, Cargo.lock Version bump to 1.1.0.
resources/registry/src/main.rs Wires up new adapter subcommand.
resources/registry/src/args.rs Adds AdapterSubCommand and SubCommand::Adapter.
resources/registry/src/adapter.rs New adapter implementation and JSON↔registry conversions.
resources/registry/src/error.rs New RegistryResourceError type.
resources/registry/registry.dsc.manifests.json Adds Microsoft.Windows.Adapter/Registry adapter manifest.
resources/registry/locales/en-us.toml Adds adapter localization strings.
resources/windows_personalization/windows_personalization.dsc.adaptedResource.yaml New Personalization adapted resource with content map and embedded schema.
resources/windows_personalization/.project.data.json Build copy-files entry for Windows.
resources/windows_personalization/personalization_{get,set,export}.tests.ps1 New Pester tests for the Personalization resource.

Comment thread resources/windows_personalization/personalization_set.tests.ps1
Comment thread resources/registry/src/adapter.rs
Comment thread lib/dsc-lib/src/dscresources/command_resource.rs Outdated
Comment thread lib/dsc-lib/src/dscresources/command_resource.rs
Comment thread resources/windows_personalization/.project.data.json Outdated
Comment thread resources/registry/src/adapter.rs Outdated
@SteveL-MSFT SteveL-MSFT marked this pull request as draft May 30, 2026 00:23
@SteveL-MSFT SteveL-MSFT marked this pull request as ready for review May 30, 2026 05:36
@SteveL-MSFT SteveL-MSFT changed the title Add Registry Adapter Add Registry Adapter and Microsoft.Windows/Personalization resource May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Doc-Impact Schema-Impact Change requires updating a canonical schema for configs or manifests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants