Skip to content

Preserve and diagnose malformed BenchmarkDotNet parameter fragments #16

Description

@AamiriYouness

BdnParameterStringParser.Parse currently silently skips parameter
fragments that do not contain =, for example:

N1000000

instead of:

N=1000000

By the time observation validation runs, the malformed fragment has
already been discarded. The validator therefore cannot report the
problem without reparsing the original parameter string or guessing
what was lost.

Required parser change

Change the parameter parser so that it preserves both successfully
parsed parameters and any issues encountered during parsing.

For example:

internal sealed record ParameterParseResult(
    IReadOnlyList<ParsedParameter> Parameters,
    IReadOnlyList<ParameterParseIssue> Issues);

Using a list rather than immediately returning a dictionary may also
preserve duplicate parameter names for future diagnostics. The result
can be converted into the canonical parameter representation only
after parsing succeeds or the issues have been evaluated.

A parse issue should retain enough context to produce a useful
diagnostic, such as:

internal sealed record ParameterParseIssue(
    int FragmentIndex,
    string Fragment,
    ParameterParseIssueKind Kind);

Diagnostic integration

Once malformed fragments are preserved, add:

BGV306 — malformed BenchmarkDotNet parameter fragment

Suggested path convention:

/Benchmarks/{index}/Parameters

The diagnostic message should identify the malformed fragment and,
where available, its position within the original parameter string.

Do not add BGV306 before the parser retains this information.
Reporting it after the fragment has already been discarded would
require reparsing or unreliable inference.

Correctness investigation

After preserving parse issues, determine using real BenchmarkDotNet
fixtures whether malformed fragments can cause two otherwise distinct
benchmarks to collapse into the same canonical identity.

Possible consequences include:

  • false BGV304 duplicate-identity diagnostics within one file
  • false BGV305 duplicate-identity diagnostics across files
  • incorrect baseline matching
  • two observations being treated as the same benchmark

Do not assume this behavior in advance merely to justify including
the change in ObservationValidator issue #6. Confirm it with
representative fixture data.

If identity collisions are possible, malformed identity-affecting
parameters should likely prevent observation compilation rather than
being treated as cosmetic warnings.

Acceptance criteria

  • BdnParameterStringParser no longer silently loses malformed fragments
  • Parsing returns both successfully parsed parameters and structured parse issues
  • Existing valid parameter parsing behavior remains unchanged
  • A focused test covers a fragment without =
  • A focused test covers mixed valid and malformed fragments
  • BGV306 is emitted with path /Benchmarks/{index}/Parameters
  • Tests determine whether malformed fragments can alter or collapse canonical benchmark identity
  • No duplicate parsing logic is added to ObservationValidator

Activity

  1. added
    area:adapter
    type:design
    on Aug 2, 2026
  2. removed this from the v0.3.0 — Validation milestone on Aug 2, 2026
  3. added a commit that references this issue on Aug 17, 2026
    027cf78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:adaptertype:design

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions