PowerShell / PowerShell/DSC

PS Adapter Export does not serialize enums correctly

Open
#791 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Bug Need-Review
Dominant language
Rust
Stars
523
Forks
75
Avg merge
3d 16h
Merged PRs (30d)
24

Description

Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.
Summary

I've added the static Export() method to my class-based resources and have Ensure as an enum. When running dsc export the enum gets converted into the numeric value instead of the string value.

$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
contentVersion: 1.0.0
resources:
- type: AnyPackageDsc/Package
  name: AnyPackageDsc/Package-0
  properties:
    result:
    - Version: 3.12.2140.44225
      Prerelease: false
      Provider: AnyPackage.Msi\Msi
      Source: C:\WINDOWS\Installer\3fc3c86b.msi
      Latest: false
      Ensure: 1
      Name: Microsoft Visual Studio Setup WMI Provider
      Reasons: null
      AdditionalParameters: {}
Steps to reproduce

Create DSC class based resource with an enum.

Expected behavior
Enums use the string value
Actual behavior
Enums use the numeric value
Error details

Environment data
7.6-preview 4
Version

3.0.1

Visuals

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with dsc export on a class-based resource containing an enum, using PowerShell 7.6-preview 4 and DSC 3.0.1. Trace the PS Adapter export path and verify that Ensure is serialized as its string value rather than its numeric value; add or update coverage for this scenario if the repository has a matching test location.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.