{"record":{"id":"cf3f5e767cac6b5e","repo":"dotnet/BenchmarkDotNet","slug":"source-cannot-be-null-or-whitespace","errorCode":null,"errorMessage":"'source' cannot be null or whitespace.","messagePattern":"'source' cannot be null or whitespace\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet.TestAdapter/VSTestAdapter.cs","lineNumber":234,"sourceCode":"            // create the AppDomain for .NET Framework are not part of .NET Standard, and so a multi-targeting solution\n            // such as this is required to get this to work. This same approach is also used by other .NET unit testing\n            // libraries as well, further justifying this approach to solving how to get the correct assemblies loaded.\n#if NETFRAMEWORK\n            var appBase = Path.GetDirectoryName(assemblyPath);\n            var setup = new AppDomainSetup { ApplicationBase = appBase };\n            var domainName = $\"Isolated Domain for {type.Name}\";\n            var appDomain = AppDomain.CreateDomain(domainName, null, setup);\n            return appDomain.CreateInstanceAndUnwrap(\n                type.Assembly.FullName, type.FullName, false, BindingFlags.Default, null, null, null, null);\n#else\n            return Activator.CreateInstance(type);\n#endif\n        }\n\n        private static void ValidateSourceIsAssemblyOrThrow(string source)\n        {\n            if (string.IsNullOrEmpty(source))\n                throw new ArgumentException($\"'{nameof(source)}' cannot be null or whitespace.\", nameof(source));\n\n            if (!Path.HasExtension(source))\n                throw new NotSupportedException($\"Missing extension on source '{source}', must have the extension '.dll' or '.exe'.\");\n\n            var extension = Path.GetExtension(source);\n            if (!string.Equals(extension, \".dll\", StringComparison.OrdinalIgnoreCase) && !string.Equals(extension, \".exe\", StringComparison.OrdinalIgnoreCase))\n                throw new NotSupportedException($\"Unsupported extension on source '{source}', must have the extension '.dll' or '.exe'.\");\n        }\n    }\n}\n","sourceCodeStart":216,"sourceCodeEnd":245,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet.TestAdapter/VSTestAdapter.cs#L216-L245","documentation":"ValidateSourceIsAssemblyOrThrow throws ArgumentException when the 'source' passed to the VSTest adapter is null or empty. The adapter must be pointed at a benchmark assembly (.dll/.exe); an empty source gives it nothing to load. Note: the message says 'whitespace' but the check is actually IsNullOrEmpty.","triggerScenarios":"RunBenchmarks/GetVsTestCasesFromAssembly invoked with source = null or \"\". Typically the VSTest host passed an empty source list entry, or the consuming code forwarded a null path.","commonSituations":"Misconfigured .runsettings or test platform passing an empty source; programmatic callers of the adapter that hand in null; build output that failed to copy the benchmark assembly so the resolved path is empty.","solutions":["Verify the benchmark project builds and produces a .dll/.exe that the test platform can locate.","Check .runsettings/test platform configuration for empty source entries.","If invoking the adapter programmatically, guard against null/empty before calling."],"exampleFix":"// before\nadapter.RunBenchmarks(source: path ?? \"\", handle);\n\n// after\nif (string.IsNullOrWhiteSpace(path)) throw new ArgumentException(nameof(path));\nadapter.RunBenchmarks(path, handle);","handlingStrategy":"validation","validationCode":"static string ValidateSource(string source)\n{\n    if (string.IsNullOrWhiteSpace(source))\n        throw new ArgumentException(\"source must be a benchmark assembly path\", nameof(source));\n    return source;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve and pass the actual built assembly path before invoking the adapter.","Validate .runsettings / test platform configuration for empty source entries.","Guard programmatic callers against null/empty source."],"tags":["benchmarkdotnet","testadapter","vstest","validation","source-path"],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}