{"record":{"id":"08d15e587f338adb","repo":"dotnet/BenchmarkDotNet","slug":"string-cannot-be-empty","errorCode":null,"errorMessage":"String cannot be empty.","messagePattern":"String cannot be empty\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet/Extensions/Polyfills/ArgumentExceptionExtensions.cs","lineNumber":19,"sourceCode":"#if NET6_0 || NETSTANDARD2_0\nusing System.Diagnostics.CodeAnalysis;\nusing System.Runtime.CompilerServices;\n\nnamespace System;\n\ninternal static partial class ArgumentExceptionExtensions\n{\n    extension(ArgumentException)\n    {\n        public static void ThrowIfNullOrEmpty(\n            string? argument,\n            [CallerArgumentExpression(nameof(argument))] string? paramName = null)\n        {\n            if (argument is null)\n                throw new ArgumentNullException(paramName);\n\n            if (argument.Length == 0)\n                throw new ArgumentException(\"String cannot be empty.\", paramName);\n        }\n\n        public static void ThrowIfNullOrWhiteSpace([NotNull] string? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null)\n        {\n            if (argument is null)\n            {\n                throw new ArgumentNullException(paramName);\n            }\n\n            if (string.IsNullOrWhiteSpace(argument))\n            {\n                throw new ArgumentException(\"String cannot be empty or whitespace.\", paramName);\n            }\n        }\n    }\n}\n#endif\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet/Extensions/Polyfills/ArgumentExceptionExtensions.cs#L1-L37","documentation":"Thrown by the ThrowIfNullOrEmpty polyfill in BenchmarkDotNet.Extensions.ArgumentExceptionExtensions. It mirrors ArgumentException.ThrowIfNullOrEmpty: a null argument raises ArgumentNullException first, then a zero-length string raises this ArgumentException (\"String cannot be empty.\"). The library uses it to validate string-shaped configuration and identifier arguments internally.","triggerScenarios":"Any internal BenchmarkDotNet call site invokes ArgumentException.ThrowIfNullOrEmpty(value) and the supplied string has Length == 0 (e.g. an empty artifacts path, empty job id, or empty column name passed into a validated API).","commonSituations":"Empty ArtifactsPath or output template, empty argument/property names, programmatic config that defaults an optional string to \"\" instead of null, or reading an unset environment/config value that resolves to an empty string.","solutions":["Supply a non-empty, meaningful string value to the configuration property that triggered it.","If the value is optional, pass null (most validated APIs accept nullable) rather than an empty string.","Trace the stack trace to the BenchmarkDotNet call site and pre-validate the originating config field with string.IsNullOrEmpty before assignment."],"exampleFix":"// before\nconfig.ArtifactsPath = \"\";\n\n// after\nconfig.ArtifactsPath = \"./benchmark-results\";","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(value)) throw new InvalidOperationException(\"value must be non-empty\");\n// or: guard the assignment to the BenchmarkDotNet config field","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default optional config strings to null rather than empty.","Add a string.IsNullOrEmpty check at the boundary where config is read into BenchmarkDotNet.","Unit-test config construction with representative inputs."],"tags":["validation","argument","string","config"],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}