🌟 [Major]: TOML 1.0.0 reading and writing now available in PowerShell#15
🌟 [Major]: TOML 1.0.0 reading and writing now available in PowerShell#15Marius Storhaug (MariusStorhaug) wants to merge 10 commits into
Conversation
- Add ConvertFrom-Toml, ConvertTo-Toml, Import-Toml, Export-Toml public commands - Add TomlDocument class with Data (OrderedDictionary) and FilePath properties - Add private helpers: ConvertFrom-TomlDateTime, ConvertFrom-TomlynTable, ConvertFrom-TomlynValue, ConvertTo-TomlynArray, ConvertTo-TomlynTable, ConvertTo-TomlynValue - Back with Tomlyn v2.0.0 (.NET TOML library) via src/assemblies/Tomlyn.dll - Enforce TOML 1.0.0 duplicate key and table redefinition rules via SyntaxParser.ParseStrict before deserializing - Map all 8 TOML types to PowerShell types (string, long, double, bool, DateTimeOffset, DateTime, TimeSpan, OrderedDictionary/object[]) - Add 116 Pester tests covering spec compliance, round-trips, file I/O, error handling, and all TOML 1.0.0 type categories - Add build.ps1 for local module assembly and test running - Add tests/bootstrap.ps1 for test module import - Add tests/data/ with 9 TOML fixture files - Update README.md with type mapping table, command reference, usage examples - Update examples/General.ps1 with comprehensive usage examples - Remove template placeholder files (LsonLib.dll, format/type XMLs, sample modules/scripts/variables) - Fix PSScriptAnalyzer warnings: UTF-8 BOM, indentation consistency PSScriptAnalyzer: 0 errors, 0 warnings Tests: 116/116 pass Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter MARKDOWNPOWERSHELL |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…dvanced fixtures - Replace Tomlyn (.NET) dependency with pure PowerShell parser/serializer - Add 19 private helper functions covering all TOML token types - Fix: sub-tables inside array-of-tables entries no longer falsely fail as redefinitions - Fix: space-separator datetimes (e.g. '1987-07-05 17:45:00Z') now parsed correctly - Add 5 advanced TOML fixture files covering deep AoT nesting, all numeric bases, all datetime forms, Unicode escapes, multi-line strings, and heterogeneous arrays - Remove src/assemblies/Tomlyn.dll and all Tomlyn* helpers - Set PowerShellVersion = 7.6 in manifest - 116 tests pass, PSScriptAnalyzer clean Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- src/functions/public/Toml/ -> src/functions/public/ - src/functions/private/Toml/ -> src/functions/private/ - Remove template placeholder sections from README.md Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter MARKDOWNPOWERSHELL |
Remove header.ps1, finally.ps1, init/initializer.ps1, manifest.psd1, and src/README.md — none are needed by the pure-PowerShell module. Build and 116 tests remain green. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter MARKDOWNPOWERSHELL |
- One file with Describe/Context hierarchy per command - Remove bootstrap.ps1 — module is pre-imported by the test runner - Add advanced fixture tests covering AoT sub-tables, space-separator datetimes, deep nesting, and all numeric forms - 120 tests, 0 failures Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter MARKDOWNPOWERSHELL |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter MARKDOWNPOWERSHELL |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter MARKDOWNPOWERSHELL |
Code violations fixed: - [bool] parameters replaced with [switch] in Add-TomlTableText and Get-TomlBareToken; callers updated (-StopAtEquals) - \Continue = 'Stop' injected into built psm1 via build.ps1 - Skip-TomlWhitespace gains [OutputType([void])] Comment-based help: - ConvertFrom-Toml and ConvertTo-Toml: add .DESCRIPTION, .EXAMPLE x2, .INPUTS, .OUTPUTS, .NOTES to match required section order - All 20 private helpers: add .DESCRIPTION, .EXAMPLE, .INPUTS, .OUTPUTS - Add Write-Verbose to all four public functions Structure: - Add tests/BeforeAll.ps1 (shared setup entry-point per PSModule standard) Examples: - Add examples/data/ with three comment-free TOML fixtures 120/120 tests pass. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter MARKDOWNPOWERSHELL |
The Toml module now provides complete TOML 1.0.0 read and write support in pure PowerShell 7.6+. Scripts and tools can parse TOML configuration files into typed PowerShell objects, modify them in memory, and write them back — with no external dependencies required.
New: Parse TOML text into PowerShell objects
ConvertFrom-Tomlparses any valid TOML 1.0.0 document into aTomlDocument. TheDataproperty is an ordered dictionary that preserves source key order. All TOML scalar types map to native PowerShell types.[string][long][double][bool][System.DateTimeOffset][System.DateTime][System.TimeSpan][object[]][System.Collections.Specialized.OrderedDictionary]New: Serialize PowerShell objects to TOML text
ConvertTo-Tomlconverts ordered dictionaries and hashtables into valid TOML text. Nested tables emit[header]sections and arrays of tables emit[[header]]sections in the correct order.New: Import and export TOML files directly
Import-Tomlreads a.tomlfile from disk and returns aTomlDocumentwith the resolved file path attached.Export-Tomlwrites any object orTomlDocumentto disk as UTF-8 without BOM.Technical Details
StringBuilderfor output assembly,OrderedDictionaryfor key ordering,ArrayListfor array-of-tables growth.tests/data/advanced/cover deep nesting, all integer/float/datetime forms, Unicode escapes, multi-line strings, and heterogeneous arrays.Related issues