Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Empty, unreferenced arrays are not being serialized #10

Open
heaths opened this issue Feb 27, 2025 · 1 comment · May be fixed by #11
Open

Empty, unreferenced arrays are not being serialized #10

heaths opened this issue Feb 27, 2025 · 1 comment · May be fixed by #11

Comments

@heaths
Copy link

heaths commented Feb 27, 2025

We are using PSToml for some Rust release pipelines and found that empty, unreferenced[^unref] arrays are not being serialized.

You can observe this with the latest version of PSToml:

$crate = @'
[package]
name = "example"
version = "0.1.0"

[features]
default = ["foo"]
foo = []
bar = []
'@ | ConvertFrom-Toml

$obj
# Name                           Value
# ----                           -----
# package                        {[name, example], [version, 0.1.0]}
# features                       {[default, System.Object[]], [foo, System.Object[]], [bar, System.Object[]]}

$obj | ConvertTo-Toml -Depth 10
# [package]
# name = "example"
# version = "0.1.0"
# [features]
# default = ["foo"]
# foo = []

Notice that bar is missing. What's odd is that foo is serialized, despite it being referenced by name as a string, as if Cargo.toml has special handling, or perhaps that is a common enough pattern to warrant forcing serialization. But as is also common in Cargo.toml, not ever feature would be refenced.

Deserialized serialized an empty array and that's what should be serialized. I could see if an array is $null, but this may require specific handling apart from PowerShell's "emptyness" (like its "falsy" behavior) such that $null != empty for collections.

heaths added a commit to heaths/PSToml that referenced this issue Feb 27, 2025
@heaths heaths linked a pull request Feb 27, 2025 that will close this issue
@jborean93
Copy link
Owner

Looks like a pretty gnarly bug, hopefully they can figure out the cause and push a new version. Happy to push out a release of this module when they've got a fix ready.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants