Skip to content

Screenplay generation: separator-carrying constraint names are sanitized into unreadable identifiers #2398

Description

@woksin

Summary

Constraint names that carry separators in their runtime name (kebab-case is idiomatic for Chronicle constraint names) are sanitized by deleting the separator characters, producing unreadable all-lowercase run-together identifiers in the generated document.

Evidence (real application)

Ada declares:

public class UniqueTimesheetStartConstraint : IConstraint
{
    public const string Name = "unique-timesheet-start";

    public void Define(IConstraintBuilder builder) => builder
        .Unique<TimesheetStarted>(name: Name);
}

The generated document emits:

constraint uniquetimesheetstart
  unique event TimesheetStarted

All 31 constraints in the document look like this (uniqueinvitationemail, uniqueengagementonboardingcompletion, uniquetimesheetoverduereminder, …). The Screenplay identifier rules ([A-Za-z_]\w*) force some transformation, but deleting separators is the least readable choice, and it discards word boundaries that were present in the source.

Suggested fix

When sanitizing a name for an identifier position, treat separator characters (-, _, spaces, dots) as word boundaries and PascalCase the segments: unique-timesheet-startUniqueTimesheetStart. Where a declaring type exists (as with IConstraint implementations), the type name minus a Constraint suffix is an even better candidate (UniqueTimesheetStartConstraintUniqueTimesheetStart).

Round-trip note: the constraint's runtime name is the string, and a future .play→code path would regenerate a different string from the PascalCase identifier. If that matters, the mapping convention (PascalCase ↔ kebab-case) should be stated in the docs.

Environment

  • Cratis.Arc.Screenplay 20.65.0 (Emission/Naming/ScreenplayNaming.cs sanitization)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions