DSC icon indicating copy to clipboard operation
DSC copied to clipboard

PS Adapter Export does not serialize enums correctly

Open ThomasNieto opened this issue 7 months ago • 1 comments

Prerequisites

  • [x] Write a descriptive title.
  • [x] Make sure you are able to repro it on the latest version
  • [x] 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

ThomasNieto avatar May 08 '25 18:05 ThomasNieto

@ThomasNieto I just submitted a pull request. If you're interested in what was changed, you can always check it out at the above link.

Gijsreyn avatar May 10 '25 13:05 Gijsreyn

@ThomasNieto I think this is fixed in preview.6.

Gijsreyn avatar May 23 '25 13:05 Gijsreyn