Shared patterns
The twelve libraries were written independently but to a shared set of conventions. Knowing them means knowing most of what any one library will do before you open it.
1. Outputs, not exceptions
The defining pattern. Anything that can fail for an expected reason returns an envelope from
ArturRios.Output rather than throwing:
ProcessOutput— success flag plus messages, for operations with no return value.DataOutput<T>— the same, carrying a payload.PaginatedOutput<T>— a page of results plus its paging metadata.
Validation failures, missing records, optimistic-concurrency conflicts and infrastructure errors all
arrive as errors on the result. Exceptions are reserved for genuine defects. This is why Output is the
root of the dependency graph: almost every other library needs it in its signatures.
DataOutput<User> result = await repository.GetById(id);
if (!result.Success)
{
return ResponseResolver.Resolve(result); // 400 with the messages
}
2. One capability, one package
Nothing is bundled “for convenience”. Each concern lives in its own repository and NuGet package, and
where a single repository covers several backends — ArturRios.Data — each backend is
still its own package. Adding SQLite support does not pull in the MongoDB or AWS SDKs.
The cost is a slightly larger dependency list; the benefit is that no application carries code it does not run.
3. A core plus interchangeable providers
Where several implementations of one idea exist, a *.Core package defines the abstraction and the
provider packages supply the implementations:
ArturRios.Data.Relational.Coreholds the repository contracts and envelope handling;PostgreSql,MySql,SqliteandDapperplug into it.ArturRios.Data.Exportdefines the writer abstraction;Export.Exceladds a format.ArturRios.Configurationcomposes providers (EnvironmentProvider,SettingsProvider) overMicrosoft.Extensions.Configuration.
Swapping a database or a file format is a package reference and a registration, not a rewrite.
4. Composition over the built-in container
Registration always uses the standard IServiceCollection; none of the libraries introduce a container
of their own. ArturRios.Mediator is the clearest example — it dispatches each
command or query to a handler resolved from a fresh DI scope, so scoped dependencies such as a
DbContext are isolated per execution rather than shared across a request.
The same instinct shows up as small, overridable hooks: WebApiStartup in
ArturRios.Util.WebApi wires configuration, Swagger and the middleware
pipeline behind virtual methods you override only where you differ.
5. Validation as a first-class result
ArturRios.Validation wraps FluentValidation’s AbstractValidator<T> in a
FluentValidator<T> that returns what an application actually consumes: a string[] of messages, or a
ProcessOutput / DataOutput<T>. Validation results therefore flow through the same envelope as
everything else, and validators are injectable behind IFluentValidator<T>.
6. Configuration from layered sources
Configuration is loaded rather than assumed. ConfigurationLoader composes JSON files, environment
variables and .env files with a single precedence rule — later sources override earlier ones — and the
same loader is used by the web API startup and by the functional test base, so tests and production read
their settings the same way.
7. Diagnostics that cross process boundaries
ArturRios.Logging captures caller file and method automatically via compiler
attributes and carries a trace ID; ArturRios.Util.WebApi propagates a W3C
traceparent through the request and onto outgoing calls with TraceActivityMiddleware and
TracePropagationHandler. Correlation is a convention of the family, not per-service wiring.
8. Testing conventions
Test names follow Given / When / Then, without exception:
GivenSpecial_WhenInspected_ThenContainNoDuplicatesAndNoWhitespace.xUnit throughout, with
ArturRios.Util.Testsupplying extra assertions, in-memory repository and scheduler fakes, and a base class for functional web API tests.Every test class carries a
Categorytrait, eitherUnitorFunctional, so the two kinds can be run and reported separately:dotnet test <solution> --filter "Category=Unit" dotnet test <solution> --filter "Category=Functional"A unit test exercises code in isolation against test doubles. A functional test reaches something real: the file system, a loopback HTTP server, an in-memory ASP.NET Core host, SQLite, an ephemeral MongoDB replica set, DynamoDB Local.
A repository adds a third category,
Integration, when a test needs a server the suite cannot provision itself. Today onlyArturRios.Datahas one: its MySQL tests read a connection string fromARTURRIOS_DATA_MYSQL_TEST_CONNECTIONand skip when it is unset, and CI supplies MySQL as a service container.The
UnitFactAttribute,UnitTheoryAttribute,FunctionalFactAttributeandFunctionalTheoryAttributeinArturRios.Util.Teststamp that sameCategorytrait, and additionally let a suite skip tests per environment or condition. A repository that cannot reference the package — anythingArturRios.Util.Testitself depends on — puts a plain[Trait("Category", "Unit")]on the class instead. Both filter identically.
9. Repository layout
Every repository is laid out the same way:
src/ the library (and its .sln)
tests/ xUnit test projects
docs/ the Hugo + Docsy documentation site
README.md overview, install, usage
LICENSE Artur Rios Attribution License
10. Identical CI
Every repository has a yggdrasil.yml at its root, which Jenkins reads (on Forgejo, with GitHub as a read-only mirror), and the same
scripts under ci/, which run on a developer’s machine too:
| Part | Trigger | What it does |
|---|---|---|
test check (ci/test.sh) | pull requests | Checks the formatting, builds, and runs the Unit and Functional tests one category after the other. A test with no Category trait fails it. ArturRios.Data also runs its Integration tests against a MySQL container. |
coverage check (ci/coverage.sh) | pull requests | Runs the tests with coverage collected and makes the HTML coverage report. |
| The docs site | a push to main | Builds the Hugo site together with the coverage report into an image, served at docs.artur-rios.tech/<library>/ (the report at /coverage-report/). |
publish.nuget (ci/pack.sh) | the owner pushes an annotated tag on main | Packs the package at the tag’s version and pushes it to nuget.org. The tag is the bare <version>, or <PackageId>@<version> for ArturRios.Data, whose packages each have a version of their own. Packing fails when the csproj’s <Version> is not the tag’s. |
On top of them, the branch policy requires a release/<version> pull request into main to carry that version in
the csproj (the release-version gate; ArturRios.Data has none, since each package is versioned apart), and
Renovate, not Dependabot, opens the dependency-update pull requests.
Documentation is therefore never stale relative to main, and a release is a tag.
Splitting the run into separate checks rather than steps means the run shows which half failed before anything is opened, and it lets both be required independently.
12. Protected main
Every repository’s main is protected the same way:
- a pull request is required — nothing is pushed to
maindirectly; - the test and coverage checks and the branch policy must pass;
- only
release/*branches can be merged into it; - force pushes and branch deletion are refused.
11. Consistent packaging metadata
Every package targets net10.0, is licensed under the Artur Rios Attribution License (packed as a LICENSE file), ships XML documentation
(<DocumentationFile>), and carries a <PackageId> under the ArturRios.* prefix with a
<Description> that matches the README’s opening line. Versions move independently per package —
there is no lockstep family version.