From 66fc36fe3c4bf47fddf1a465261b36c212415ed1 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 23 Aug 2024 17:07:24 -0400 Subject: [PATCH] Add runtime error for improperly created artifacts --- CHANGELIST.md | 1 + MPF.Processors/OutputFile.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index bac869f1..35635669 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -50,6 +50,7 @@ - Add unused passable func to OutputFile - Pass in new func for OutputFile - Use new func in Redumper +- Add runtime error for improperly created artifacts ### 3.2.1 (2024-08-05) diff --git a/MPF.Processors/OutputFile.cs b/MPF.Processors/OutputFile.cs index 2d974060..0681dc8e 100644 --- a/MPF.Processors/OutputFile.cs +++ b/MPF.Processors/OutputFile.cs @@ -142,8 +142,6 @@ namespace MPF.Processors /// private readonly Func? _existsFunc; - // TODO: Add validation that a key exists if the artifact flag is present - /// /// Create an OutputFile with a single filename /// @@ -169,6 +167,10 @@ namespace MPF.Processors ArtifactKey = null; _flags = flags; _existsFunc = existsFunc; + + // Ensure artifacts have a key + if (IsArtifact && string.IsNullOrEmpty(ArtifactKey)) + throw new InvalidDataException($"{flags} should not contain the Artifact or Binary flag"); } /// @@ -180,6 +182,10 @@ namespace MPF.Processors ArtifactKey = artifactKey; _flags = flags; _existsFunc = existsFunc; + + // Ensure artifacts have a key + if (IsArtifact && string.IsNullOrEmpty(ArtifactKey)) + throw new InvalidDataException($"{flags} should not contain the Artifact or Binary flag"); } ///