Skip to content

ADR-0105: Code convention baseline

Field Value
Status Accepted
Date 2026-12-01
Deciders ConnectSoft Architecture Team (owner decisions of 2026-12-01)
Supersedes The conflicting statements listed under "Documents corrected"

Context

The engineering standards (ADR-0104) need one answer for each convention before any rule text is written. On several conventions the ConnectSoft documentation pages, the BaseTemplate AGENTS.md, the StyleCop configuration files and the code disagree.

The counts below come from the engineering standards inventory. They cover 195 ConnectSoft repositories (21,518 C# files) and 12 consumer services generated from the templates (8,067 files).

Decision

1. Private fields and this. qualification

Measured ConnectSoft Consumer services
name fields 11,750 4,408
_name fields 474 402
Repositories where _name is the majority 0 0

Decision.

  1. Private instance fields use camelCase without a prefix and are accessed with this.. Example: private readonly ILogger logger;, used as this.logger.
  2. Constants and static readonly fields use PascalCase.
  3. The _camelCase rule in the BaseTemplate AGENTS.md is withdrawn.

This matches the StyleCop defaults SA1101 (prefix local calls with this) and SA1309 (field names must not begin with an underscore).

2. Namespace style and using placement

Measured ConnectSoft files Consumer files
Block-scoped namespace 20,239 7,808
File-scoped namespace 200 6
Usings inside the namespace 17,546 6,855
Usings outside the namespace 701 415

Decision.

  1. Files use a block-scoped namespace, and using directives go inside it.
  2. This matches the StyleCop default for SA1200.
  3. Five repositories that mostly use the other style are listed in the findings register. They are converted only during the enforcement phase.

3. Test method names

Measured ConnectSoft Consumer services
Test names without an underscore 15,803 8,357
Test names with an underscore 11,740 72
Repositories where underscores are the majority 52 0

Underscore names are concentrated in the Blazor UI kits and component library, the MAUI repositories and about ten API clients.

Decision.

  1. Test method names are PascalCase without underscores.
  2. A test name states the behaviour under test and the expected outcome, for example CreateOrderReturnsCreatedWhenRequestIsValid.
  3. No CA1707 suppression is needed in test projects.

4. Test coverage target

Measured Repositories
No coverage gate (threshold 0) 77
Threshold 10 to 79 78
Threshold 80 or more 16

The shared pipeline step defaults to 80, BaseTemplate passes 72, its AGENTS.md states 74, and CompanyDocumentation requires 80.

Decision.

  1. The line coverage target for services and libraries is 80%.
  2. Ratchet rule: a repository's coverage threshold is never lowered. A repository below the target raises its threshold toward 80 whenever its measured coverage allows. A new repository starts at 80.
  3. Coverage is collected by one collector per test run. See the testing standard.

Pipeline thresholds are not changed by this record; the gap is tracked in the findings register.

5. Message type names

Measured ConnectSoft Consumer services
Messaging types ending in Event 114 62
Messaging types ending in Command 23 6

Decision.

  1. Events are named in the past tense with the Event suffix, for example OrderCreatedEvent.
  2. Commands are named in the imperative with the Command suffix, for example CreateOrderCommand.
  3. Other contract types (DTOs, results, enumerations) keep their own suffixes.

6. REST route casing

Measured ConnectSoft routes Consumer routes
Lowercase 343 126
With an uppercase letter (mostly api/[controller]) 55 319

Decision.

  1. New REST contracts use lowercase, hyphen-separated, plural resource paths, for example /api/orders/{orderId}/line-items.
  2. Existing paths are not changed, because a path change is a breaking contract change.
  3. A new controller in an existing service follows this rule unless it extends an existing resource family that already uses another casing.

7. StyleCop configuration

The StyleCop configuration that follows from sections 1 and 2 is: - usingDirectivesPlacement: insideNamespace; - SA1101 enabled; - SA1309 enabled.

The ten stylecop.json variants found in the estate are reconciled to this configuration during the enforcement phase.

Documents corrected

These statements are superseded by this record and are rewritten in the standards program:

  • BaseTemplate AGENTS.md: _camelCase private fields, Method_Scenario_Expected test names, and coverage 74%.
  • Testing pages: Method_Scenario_Expected examples in architecture/testing.md and architecture/testing/unit-testing.md.
  • CompanyDocumentation: underscore test names and the 80% coverage wording in docs/engineering-process/testing-strategy.md, which is moved into the canonical site.
  • Naming pages: the "either this.field or _field" option in technology/coding-standards.md and cross-cutting-concerns/code-quality-standards/naming-conventions.md.
  • SoftwareFactory naming: event names without a suffix and the REST path examples in ConnectSoft.AI.SoftwareFactory.Documentation/docs/reference/naming-conventions.md, which receives a superseded notice.

Alternatives considered

Option Outcome
_camelCase fields without this. Rejected. It would mean renaming about 16,000 fields, and no repository uses it as its main style.
File-scoped namespaces with usings outside Rejected for now. It would mean rewriting about 28,000 files for indentation only.
Method_Scenario_Expected test names Rejected. The majority uses PascalCase without underscores, and underscores need a CA1707 suppression.
One 85% target everywhere Rejected. 155 repositories are below 80 today; the ratchet rule moves them up without breaking builds.
Separate targets per repository family Rejected. One number is easier to state and check.
Events without a suffix Rejected. The suffix is used in the code and in the canonical documentation.
PascalCase routes from api/[controller] Rejected for new contracts. Lowercase routes follow the common REST guidelines and most templates.

Consequences

  • Rules in the code, naming and testing standards cite this record.
  • Code that already follows another style is not rewritten by the standards program. Deviating repositories are listed in the findings register for the enforcement phase.
  • Code review flags new code that breaks these conventions. It does not flag untouched existing code.
  • New controllers in services that use PascalCase routes may mix casing within one service until the resource family is versioned.