From 55d1bd72ff4536f59cc4d7ab00880b48dd611287 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 9 Mar 2026 17:34:17 +0000 Subject: [PATCH 1/2] chore(deps): update dependency tomlyn.signed to v1 --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index dd8034204..870401aed 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -46,7 +46,7 @@ - + From 309110d2d28a7246cec24ae4575e47be4b17797f Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Mon, 9 Mar 2026 10:42:07 -0700 Subject: [PATCH 2/2] Fix build: migrate Tomlyn API from 0.x to 1.x Toml.ToModel was removed in Tomlyn 1.0. Replace with TomlSerializer.Deserialize and drop TomlModelOptions (unmapped properties are ignored by default in the new API). --- .../poetry/PoetryComponentDetector.cs | 6 +----- .../rust/Parsers/RustCargoLockParser.cs | 7 +------ .../rust/RustSbomDetector.cs | 9 ++------- src/Microsoft.ComponentDetection.Detectors/uv/UvLock.cs | 2 +- 4 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.ComponentDetection.Detectors/poetry/PoetryComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/poetry/PoetryComponentDetector.cs index 554ef477c..0a7a98602 100644 --- a/src/Microsoft.ComponentDetection.Detectors/poetry/PoetryComponentDetector.cs +++ b/src/Microsoft.ComponentDetection.Detectors/poetry/PoetryComponentDetector.cs @@ -43,11 +43,7 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID this.Logger.LogDebug("Found Poetry lockfile {PoetryLockFile}", poetryLockFile); var reader = new StreamReader(poetryLockFile.Stream); - var options = new TomlModelOptions - { - IgnoreMissingProperties = true, - }; - var poetryLock = Toml.ToModel(await reader.ReadToEndAsync(cancellationToken), options: options); + var poetryLock = TomlSerializer.Deserialize(await reader.ReadToEndAsync(cancellationToken)); if (poetryLock.Metadata != null && poetryLock.Metadata.TryGetValue("lock-version", out var lockVersion)) { diff --git a/src/Microsoft.ComponentDetection.Detectors/rust/Parsers/RustCargoLockParser.cs b/src/Microsoft.ComponentDetection.Detectors/rust/Parsers/RustCargoLockParser.cs index 87eb1443d..61c05b522 100644 --- a/src/Microsoft.ComponentDetection.Detectors/rust/Parsers/RustCargoLockParser.cs +++ b/src/Microsoft.ComponentDetection.Detectors/rust/Parsers/RustCargoLockParser.cs @@ -25,11 +25,6 @@ internal class RustCargoLockParser : IRustCargoLockParser @"^(?[^ ]+)(?: (?[^ ]+))?(?: \((?[^()]*)\))?$", RegexOptions.Compiled); - private static readonly TomlModelOptions TomlOptions = new TomlModelOptions - { - IgnoreMissingProperties = true, - }; - private readonly ILogger logger; /// @@ -56,7 +51,7 @@ internal class RustCargoLockParser : IRustCargoLockParser { using var reader = new StreamReader(componentStream.Stream); var content = await reader.ReadToEndAsync(cancellationToken); - var cargoLock = Toml.ToModel(content, options: TomlOptions); + var cargoLock = TomlSerializer.Deserialize(content); this.ProcessCargoLock(cargoLock, singleFileComponentRecorder, componentStream); return cargoLock.Version; } diff --git a/src/Microsoft.ComponentDetection.Detectors/rust/RustSbomDetector.cs b/src/Microsoft.ComponentDetection.Detectors/rust/RustSbomDetector.cs index a37f47dd7..1252a47eb 100644 --- a/src/Microsoft.ComponentDetection.Detectors/rust/RustSbomDetector.cs +++ b/src/Microsoft.ComponentDetection.Detectors/rust/RustSbomDetector.cs @@ -26,11 +26,6 @@ internal class RustSbomDetector : FileComponentDetector private const string CargoTomlFileName = "Cargo.toml"; private const string CargoLockFileName = "Cargo.lock"; - private static readonly TomlModelOptions TomlOptions = new TomlModelOptions - { - IgnoreMissingProperties = true, - }; - private readonly IPathUtilityService pathUtilityService; private readonly IRustSbomParser sbomParser; private readonly IRustCliParser cliParser; @@ -561,7 +556,7 @@ private bool IsWorkspaceOnlyToml(string cargoTomlPath) try { var content = this.fileUtilityService.ReadAllText(cargoTomlPath); - var tomlTable = Toml.ToModel(content, options: TomlOptions); + var tomlTable = TomlSerializer.Deserialize(content); // Check if it has a [workspace] section but no [package] section var hasWorkspace = tomlTable.ContainsKey("workspace"); @@ -728,7 +723,7 @@ private void ProcessWorkspaceTables(string cargoTomlPath, string directory) try { var content = this.fileUtilityService.ReadAllText(cargoTomlPath); - var tomlTable = Toml.ToModel(content, options: TomlOptions); + var tomlTable = TomlSerializer.Deserialize(content); if (tomlTable.ContainsKey("workspace") && tomlTable["workspace"] is TomlTable workspaceTable) { diff --git a/src/Microsoft.ComponentDetection.Detectors/uv/UvLock.cs b/src/Microsoft.ComponentDetection.Detectors/uv/UvLock.cs index 61ec1b532..95b22686d 100644 --- a/src/Microsoft.ComponentDetection.Detectors/uv/UvLock.cs +++ b/src/Microsoft.ComponentDetection.Detectors/uv/UvLock.cs @@ -16,7 +16,7 @@ public static UvLock Parse(Stream tomlStream) { using var reader = new StreamReader(tomlStream); var tomlContent = reader.ReadToEnd(); - var model = Toml.ToModel(tomlContent); + var model = TomlSerializer.Deserialize(tomlContent); return new UvLock { Packages = ParsePackagesFromModel(model),