Repository navigation
Add structured handling for settings - #1690
Draft
Mikey Lombardi (He/Him) (michaeltlombardi) wants to merge 8 commits into
Draft
Mikey Lombardi (He/Him) (michaeltlombardi) wants to merge 8 commits into
Mikey Lombardi (He/Him) (michaeltlombardi) wants to merge 8 commits into
Conversation
Mikey Lombardi (He/Him) (michaeltlombardi)
force-pushed
the
gh-1081/main/settings-schematization
branch
from
October 9, 2026 16:09
1dad35e to
a96b570
Compare
Prior to this change, DSC accepted settings from multiple sources and scopes but retrieved those settings adhoc when needed. The settings were not structured or consistently retrieved and resolved. This change starts the work for PowerShell#1081 by: - Adding a new `settings` module to `dsc-lib` to contain the structured cascading hierarchy of settings. - Defining reusable patterns and guidance for maintaining and extending the settings that DSC recognizes. - Providing stubs for writing rust tests where we need to define fixtures to replicate reading from files and environment variables.
This change adds the rust integration tests for the `settings` module. It also introduces helper macros for validating DSC repo schemas and updates the schema generation tests to cover the newly defined types.
Prior to this change, the implementation for `idiomaticize_string_enum` incorrectly used the `enumMarkdownDescriptions` keyword instead of the correct `markdownEnumDescriptions` keyword. This change fixes the implementation and tests.
Prior to this change, the `schema_i18n` macro only supported passing a single string literal as the input value. This made it impossible to correctly construct calls to the macro when needing to compose the dotpath through a macro or dynamic lookup. This change: - Enables the macro to accept multiple string literals or an arbitrary expression. - Adds documentation to the macro. - Adds the missing header comments to the source file.
Prior to this change, the i18n tests would find any apparent usage of the `t!` macro in a file. This unfortunately also included documentation comments, which raised errors for undefined translation strings that are not expected to be defined. This change strips lines that begin with a comment before searching for the expected patterns.
Mikey Lombardi (He/Him) (michaeltlombardi)
force-pushed
the
gh-1081/main/settings-schematization
branch
from
October 9, 2026 19:25
a96b570 to
8ab7650
Compare
Mikey Lombardi (He/Him) (michaeltlombardi)
requested a balanced review from Copilot
October 9, 2026 20:48
Copilot started reviewing on behalf of
Mikey Lombardi (He/Him) (michaeltlombardi)
October 9, 2026 20:49
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Policy trust validation, source precedence, ignore-file loading, and schema-generation defects remain unresolved.
7 open findings
Enforce policy path trust checks before exposing settings APIs · New Handle missing HOME or APPDATA without panicking · New Allowlist the corrected markdownEnumDescriptions metadata key · New Preserve trace-level-only environment overrides · New Honor ignoreSettingsFile before loading preference files · New Apply policy precedence independently to restricted path leaves · New Use the JSON Schema meta-schema URI for generated boolean schemas · New
What changed in this PR
Adds a public, structured DSC settings model with scoped sources, resolution types, schemas, localization, and tests.
Changes:
- Defines policy, preference, environment, CLI, and default settings structures.
- Adds reusable schema macros, exports, localization, and extensive tests.
- Corrects VS Code enum-description keyword handling.
| File | Description |
|---|---|
xtask/src/schemas/export.rs |
Exports settings schemas. |
lib/dsc-lib/tests/integration/settings/sources/preference_file.rs |
Tests preference schemas and serde. |
lib/dsc-lib/tests/integration/settings/sources/policy_file.rs |
Tests policy schemas and serde. |
lib/dsc-lib/tests/integration/settings/sources/environment.rs |
Tests environment settings. |
lib/dsc-lib/tests/integration/settings/sources/command_line.rs |
Tests CLI settings schemas. |
lib/dsc-lib/tests/integration/settings/sources/code_defaults.rs |
Tests default settings schema. |
lib/dsc-lib/tests/integration/settings/resolved/settings.rs |
Tests resolved settings output. |
lib/dsc-lib/tests/integration/settings/mod.rs |
Registers settings tests. |
lib/dsc-lib/tests/integration/settings/fields/resource_path.rs |
Tests resource-path fields. |
lib/dsc-lib/tests/integration/settings/fields/ignore_settings_file.rs |
Tests ignore-file field. |
lib/dsc-lib/tests/integration/settings/fields/forbid_ignore_settings_file.rs |
Tests policy prohibition field. |
lib/dsc-lib/tests/integration/schemas/schema_for.rs |
Covers settings schema generation. |
lib/dsc-lib/tests/integration/schemas/mod.rs |
Adds schema assertions. |
lib/dsc-lib/tests/integration/main.rs |
Registers macros and settings tests. |
lib/dsc-lib/tests/integration/macros/test_schema_validation.rs |
Adds schema-validation macro. |
lib/dsc-lib/tests/integration/macros/test_schema_docs.rs |
Adds schema-documentation macro. |
lib/dsc-lib/tests/integration/macros/test_meta_schema.rs |
Adds meta-schema macro. |
lib/dsc-lib/src/types/fully_qualified_type_name.rs |
Updates API documentation. |
lib/dsc-lib/src/tests/stubs/mod.rs |
Registers test stubs. |
lib/dsc-lib/src/tests/stubs/fs.rs |
Stubs file reads. |
lib/dsc-lib/src/tests/stubs/env.rs |
Stubs environment variables. |
lib/dsc-lib/src/tests/settings/sources/preference_file.rs |
Tests preference loading. |
lib/dsc-lib/src/tests/settings/sources/policy_file.rs |
Tests policy loading. |
lib/dsc-lib/src/tests/settings/mod.rs |
Organizes settings unit tests. |
lib/dsc-lib/src/tests/mod.rs |
Registers unit-test infrastructure. |
lib/dsc-lib/src/settings/sources/preference_file.rs |
Defines preference-file data. |
lib/dsc-lib/src/settings/sources/policy_file.rs |
Defines policy-file data. |
lib/dsc-lib/src/settings/sources/mod.rs |
Organizes settings sources. |
lib/dsc-lib/src/settings/sources/command_line.rs |
Defines CLI settings data. |
lib/dsc-lib/src/settings/sources/code_defaults.rs |
Defines code defaults. |
lib/dsc-lib/src/settings/resolved/settings.rs |
Defines effective settings. |
lib/dsc-lib/src/settings/resolved/mod.rs |
Exports resolved types. |
lib/dsc-lib/src/settings/resolved/field.rs |
Tracks values and source scopes. |
lib/dsc-lib/src/settings/fields/tracing.rs |
Defines tracing settings. |
lib/dsc-lib/src/settings/fields/resource_path.rs |
Defines resource-path settings. |
lib/dsc-lib/src/settings/fields/mod.rs |
Organizes setting fields. |
lib/dsc-lib/src/settings/fields/macros/utility.rs |
Adds macro utilities. |
lib/dsc-lib/src/settings/fields/macros/tests.rs |
Tests generated field types. |
lib/dsc-lib/src/settings/fields/macros/mod.rs |
Exports field macros. |
lib/dsc-lib/src/settings/fields/macros/define_boolean_field.rs |
Generates boolean fields. |
lib/dsc-lib/src/settings/fields/ignore_settings_file.rs |
Defines ignore-file setting. |
lib/dsc-lib/src/settings/fields/forbid_ignore_settings_file.rs |
Defines policy prohibition. |
lib/dsc-lib/src/settings/constants_and_statics.rs |
Defines settings paths. |
lib/dsc-lib/src/lib.rs |
Exposes the settings API. |
lib/dsc-lib/locales/schemas.settings.test.yaml |
Adds macro-test translations. |
lib/dsc-lib/locales/en-us.toml |
Adds settings messages. |
lib/dsc-lib/Cargo.toml |
Adds serialized-test support. |
lib/dsc-lib-jsonschema/tests/integration/transforms/idiomaticize_string_enum.rs |
Updates enum keyword tests. |
lib/dsc-lib-jsonschema/tests/integration_locales/schemas.yaml |
Expands schema fixtures. |
lib/dsc-lib-jsonschema/src/transforms/idiomaticize_string_enum.rs |
Corrects markdown enum output. |
lib/dsc-lib-jsonschema/src/schema_utility_extensions.rs |
Improves invalid-ID diagnostics. |
lib/dsc-lib-jsonschema/src/dsc_repo/macros.rs |
Documents schema localization macro. |
lib/dsc-lib-jsonschema/src/dsc_repo/dsc_repo_schema.rs |
Refines trait documentation. |
dsc/tests/dsc_i18n.tests.ps1 |
Excludes Rust comments from key discovery. |
Cargo.toml |
Adds shared serial_test. |
Cargo.lock |
Locks the new dependency. |
.vscode/dsc-lib.settings.code-snippets |
Adds settings error snippets. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| pub mod parser; | ||
| pub mod progress; | ||
| pub mod schemas; | ||
| pub mod settings; |
Comment on lines
+60
to
+62
| pub static USER_SETTINGS_FILE_PATH: LazyLock<PathBuf> = LazyLock::new(|| { | ||
| if let Some(xdg_config_home) = std::env::var_os("XDG_CONFIG_HOME") { | ||
| return Path::new(&xdg_config_home) |
Comment on lines
260
to
263
| if enum_markdown_descriptions.iter().any(|e| !e.is_empty()) { | ||
| schema.insert( | ||
| "enumMarkdownDescriptions".to_string(), | ||
| "markdownEnumDescriptions".to_string(), | ||
| serde_json::to_value(enum_markdown_descriptions).unwrap() |
| pub mod parser; | ||
| pub mod progress; | ||
| pub mod schemas; | ||
| pub mod settings; |
| pub mod parser; | ||
| pub mod progress; | ||
| pub mod schemas; | ||
| pub mod settings; |
| pub mod parser; | ||
| pub mod progress; | ||
| pub mod schemas; | ||
| pub mod settings; |
| title = crate::schemas::dsc_repo::schema_i18n!("title"), | ||
| description = crate::schemas::dsc_repo::schema_i18n!("description"), | ||
| extend( | ||
| "$schema" = Self::default_export_schema_id_uri(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


PR Summary
This PR defines the structure and handling for initializing settings from multiple scopes.
Note
Will update PR throughout development but needed draft up to enable discussion.
PR Context