dotnet/BenchmarkDotNet · error · ArgumentException
Property name must be non-empty.
Error message
Property name must be non-empty.
What it means
MsBuildProperty's constructor requires a non-empty property name; CreateArgumentTextRepresentation throws ArgumentException ("Property name must be non-empty.") when name is null, empty, or whitespace. The name becomes part of the /p:NAME=value MSBuild argument and must be a real identifier.
Source
Thrown at src/BenchmarkDotNet/Jobs/Argument.cs:123
}
/// <summary>
/// An MSBuild property argument (<c>/p:name=value</c>).
/// It escapes MSBuild special characters in the value (for example, semicolons) so that
/// list-like values can be passed without manual encoding.
/// </summary>
[PublicAPI]
public class MsBuildProperty : MsBuildArgument
{
public MsBuildProperty(string name, params string[] values)
: base(CreateArgumentTextRepresentation(name, values), escapeSpecialCharacters: true)
{
}
private static string CreateArgumentTextRepresentation(string name, string[] values)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentException("Property name must be non-empty.", nameof(name));
if (values is null)
throw new ArgumentNullException(nameof(values));
for (int i = 0; i < values.Length; i++)
if (values[i] is null)
throw new ArgumentException("Property values can not contain null.", nameof(values));
string value = values.Length switch
{
0 => string.Empty,
1 => values[0],
_ => string.Join(";", values)
};
return $"/p:{name}={value}";
}
}View on GitHub (pinned to b515068b61)
Solutions
- Provide a concrete non-empty property name, e.g. new MsBuildProperty("MyCustomSetting", "123").
- Validate with !string.IsNullOrWhiteSpace(name) before constructing the MsBuildProperty.
- If the name is optional, skip adding the property entirely rather than passing empty.
Example fix
// before
job.WithArgument(new MsBuildProperty("", "123"));
// after
job.WithArgument(new MsBuildProperty("MyCustomSetting", "123")); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("name required");
job.WithArgument(new MsBuildProperty(name, value)); Prevention
- Always supply a concrete property name to MsBuildProperty.
- Validate names when building them dynamically.
- Skip adding the property when the name would be empty.
When it happens
Trigger: Calling new MsBuildProperty("", ...) or new MsBuildProperty(" ", ...) (or null name) when adding an MSBuild property to a benchmark job.
Common situations: Building property names dynamically from config/variables that may be unset, whitespace from trimmed input, or copy-paste leaving an empty name.
Related errors
- String cannot be empty.
- Value cannot be null. (Parameter 'values')
- The value {value} is not assignable to {characteristic} prop
- String cannot be empty or whitespace.
- Runtime Moniker not supported
AI-assisted analysis of dotnet/BenchmarkDotNet@b515068b61 (2026-08-13).
Data as JSON: /api/errors/fdd983dbaae2a8fc.
Report an issue: GitHub.