Skip to content
Tracon

ContractCoverage

Namespace Tracon.Testing.Contracts · Assembly Tracon.Testing.Contracts.Xunit.dll

Verifies that a test assembly derives every contract class this package ships for one contract family, so a class dropped during a refactor or never picked up for a new implementation is caught at build time instead of silently reducing coverage.

public static class ContractCoverage
Inheritance
object ← ContractCoverage
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Tracon’s own four store implementations (in-memory, PostgreSQL, SQL Server, SQLite) each call ContractCoverage.MissingDerivedTypes from their own test assembly; a third-party implementation can do the same.

Every call names a family — the namespace the contracts live in, such as ContractCoverage.StorageContracts or ContractCoverage.ProviderContracts. There is deliberately no family-less overload: one used to exist, and adding a second family to this package would have made every existing caller fail with contracts that were never theirs to implement. A store implementer’s coverage check must not start failing because Tracon published a model-provider contract.

The namespace holding agent-source contracts.

public const string AgentSourceContracts = "Tracon.Testing.Contracts.AgentSources"

string

The namespace holding run judge contracts.

public const string JudgeContracts = "Tracon.Testing.Contracts.Judges"

string

The namespace holding the model-provider contracts.

public const string ProviderContracts = "Tracon.Testing.Contracts.Providers"

string

The namespace holding job handler contracts.

public const string SchedulingContracts = "Tracon.Testing.Contracts.Scheduling"

string

The namespace holding skill script executor contracts.

public const string ScriptContracts = "Tracon.Testing.Contracts.Scripts"

string

The namespace holding the store contracts (IRunStore and the rest).

public const string StorageContracts = "Tracon.Testing.Contracts.Storage"

string

The namespace holding custom tool contracts.

public const string ToolContracts = "Tracon.Testing.Contracts.Tools"

string

The contract classes this package ships for one family: every non-generic public abstract type in namespaceScope whose name ends in Contract.

[RequiresUnreferencedCode("Reflects over every type in this assembly. Build-time test infrastructure only; never called from application code.")]
public static IReadOnlyList<Type> ContractTypes(string namespaceScope)

namespaceScope string

The contract family, normally ContractCoverage.StorageContracts or ContractCoverage.ProviderContracts.

IReadOnlyList<Type>

The contract types, ordered by name.

ArgumentException

namespaceScope is empty, or names no contract type at all. A namespace that matches nothing is a typo, not an empty family: reporting zero contracts would make a coverage check pass while checking nothing.

MissingDerivedTypes(Assembly, string, IReadOnlyCollection<string>?)

Section titled “ MissingDerivedTypes(Assembly, string, IReadOnlyCollection<string>?)”

The contract classes in one family that consumerAssembly declares no concrete derived type for.

[RequiresUnreferencedCode("Reflects over every type in the consumer assembly. Build-time test infrastructure only; never called from application code.")]
public static IReadOnlyList<string> MissingDerivedTypes(Assembly consumerAssembly, string namespaceScope, IReadOnlyCollection<string>? except = null)

consumerAssembly Assembly

The test assembly to check, typically Assembly.GetExecutingAssembly from the caller.

namespaceScope string

The contract family to check, normally ContractCoverage.StorageContracts or ContractCoverage.ProviderContracts. Contracts outside it are ignored, so a consumer that implements one family is unaffected by the others.

except IReadOnlyCollection<string>?

Contract type names this assembly intentionally does not cover (for example, a contract for a store shape this deployment does not offer). A name that does not match any contract type is itself reported back, the same way TenantCoverageTests.Coverage_list_carries_no_stale_entries catches a stale exemption: an exemption for a contract that no longer exists, or was never spelled correctly, must not silently pass.

IReadOnlyList<string>

The names of the uncovered, non-exempt contract types, ordered by name, followed by any stale except entry (prefixed "stale exemption: "); empty when every contract type is either covered or validly exempted.

ArgumentNullException

consumerAssembly is null.

ArgumentException

namespaceScope names no contract type.