Skip to content

Contribution Guide ​

Introduction ​

DotBlaze is developed for internal use first. The repository is the source of truth for the framework, the application template, the sample app, and this documentation. What is planned next is on the roadmap.

Repository Layout ​

src/
  Directory.Build.props            # version and NuGet metadata shared by every package
  DotBlaze/                        # core package: one project, one folder per module
  DotBlaze.Cli/                    # the `dotblaze` .NET tool
  DotBlaze.Database.Postgres/      # driver packages for heavy dependencies
  DotBlaze.Database.MySql/
  DotBlaze.Database.SqlServer/
  DotBlaze.Storage.S3/
  DotBlaze.Redis/
  DotBlaze.Testing/                # HTTP, database, and live component test helpers
  DotBlaze.Tinker/                 # `dotblaze tinker` (brings Roslyn, so it is optional)
  DotBlaze.Image/                  # raster image processing (brings Magick.NET, so it is optional)
  DotBlaze.AI/                     # AI agents, media generation and retrieval (optional)
templates/
  dotblaze-app/                    # the `dotnet new dotblaze-app` template
  DotBlaze.Templates.csproj        # packs the template
samples/
  SampleApp/                       # a blog built with DotBlaze
tests/
  DotBlaze.Tests/                  # framework tests
  DotBlaze.TestPackage/            # a small package, for the package discovery tests
  DotBlaze.Cli.Tests/              # CLI tests
  SampleApp.Tests/                 # end-to-end tests of the sample app
  Browser/                         # Playwright tests of the sample app in Chromium
docs/                              # this documentation
DotBlaze.slnx                      # solution file

Driver packages use the namespace DotBlaze.Drivers (not, for example, DotBlaze.Storage.S3), because a DotBlaze.Storage namespace would hide the Storage facade.

Building and Testing ​

You need the .NET 10 SDK, and Node.js if you want to build the frontend assets of the template or sample app.

shell
dotnet build DotBlaze.slnx
dotnet test tests/DotBlaze.Tests
dotnet test tests/SampleApp.Tests

The tests are executable examples of the API, so they are a good place to look when you change behaviour. tests/DotBlaze.Tests/TestApp.cs builds DotBlaze's services without a web host; tests/SampleApp.Tests boots the sample app with WebApplicationFactory<Program>.

Running Tests on Other Databases ​

Both test projects use SQLite by default. Set DOTBLAZE_TEST_DB to pgsql, mysql, or sqlsrv, and pass the connection settings as environment variables, the same way CI does:

shell
export DOTBLAZE_TEST_DB=pgsql
export database__connections__pgsql__driver=pgsql
export database__connections__pgsql__host=127.0.0.1
export database__connections__pgsql__database=dotblaze
export database__connections__pgsql__username=postgres
export database__connections__pgsql__password=postgres

dotnet test tests/DotBlaze.Tests
dotnet test tests/SampleApp.Tests

WARNING

Run the two test projects one after the other, not in parallel: both reset the same database.

The S3 storage test runs when DOTBLAZE_TEST_S3_ENDPOINT points at an S3-compatible server such as MinIO or moto (CI uses moto; see the workflow for the exact setup). Likewise, the SMTP test runs when DOTBLAZE_TEST_SMTP_HOST names a Mailpit server, and the Redis tests (queue, cache, shared keys, SignalR backplane) when DOTBLAZE_TEST_REDIS names a Redis host:

shell
docker run -d -p 6379:6379 redis:7
DOTBLAZE_TEST_REDIS=127.0.0.1 dotnet test tests/DotBlaze.Tests

tests/Browser/live.e2e.js drives the sample app in Chromium with Playwright. Start the sample with mail:default=log and queue:default=sync, its output in a log file, then run npm install && npx playwright install chromium && SERVER_LOG=<log file> npm test in tests/Browser; the browser job in CI shows the exact steps.

Continuous Integration ​

.github/workflows/ci.yml runs on every push and pull request:

  • sqlite: all test projects on SQLite, the S3 test against moto (an S3-compatible server), the SMTP test against Mailpit, the Redis tests, and a template smoke test. The smoke test packs src/DotBlaze, installs the template, creates an app with dotnet new dotblaze-app, builds it, runs migrate and db:check, and builds its CSS and JavaScript with npm.
  • databases: both test projects against PostgreSQL 17, MySQL 8.4, and SQL Server 2022.
  • browser: the sample app in Chromium (tests/Browser/live.e2e.js), exercising live components end to end.

If you change the template, make sure the smoke test still passes.

templates/Directory.Build.targets makes the template project in this checkout reference the local framework and its Blade build targets. Generated applications use the NuGet reference in templates/dotblaze-app/DotBlazeApp.csproj.

Coding Style ​

Follow these design principles:

  • Use what .NET already has and wrap it in a Laravel-style API. DotBlaze does not rewrite routing, dependency injection, the ORM, or templating.
  • Support both styles. Every facade is a thin static front for a service in the container, so constructor injection always works as well.
  • Testable from day one. A facade that talks to the outside world gets a Fake() with assertions.
  • Convention over configuration. Providers, models, migrations, seeders, jobs, and listeners are discovered from the application assembly.

Keep comments short and use them to explain why, not what. All code, comments, and documentation are written in English.

Shortcuts ​

When code takes a deliberate shortcut with a known limit, it is marked with a comment in this form, so the debt is easy to find:

csharp
// shortcut: simple English pluralization rules (no irregular words), use [Table] for other cases.

Documentation ​

The rules for these pages are in docs/readme.md. In short: one topic per file, a # Title followed by a list of links to the sections, an <a name="..."></a> anchor before every ##/### heading, and only what the code does today. Missing features get a short "Not Yet Available" note; larger gaps are listed on the roadmap. Prefer code samples taken from samples/SampleApp or the tests.

Releasing ​

All packages share one version, set in src/Directory.Build.props. Keep the version in templates/DotBlaze.Templates.csproj and the framework reference in templates/dotblaze-app/DotBlazeApp.csproj aligned when bumping it. The Publish workflow (.github/workflows/publish.yml) overrides these with the release version and does the following:

  1. Runs the tests on SQLite.
  2. Packs every package (.nupkg with a .snupkg symbol package, Source Link, and XML docs) and the template.
  3. Creates a new application from the packed template and builds it against the packed DotBlaze.
  4. Uploads the packages as a build artifact.
  5. For a version tag only: publishes to nuget.org.

Run it by hand (Actions > Publish > Run workflow) to check the packages. A manual run gets a 0.1.0-ci.<run> version and never publishes.

Publishing uses NuGet Trusted Publishing, not a stored API key. The nuget.org policy for the DotBlaze owner trusts the workflow file publish.yml in dotblaze/framework. On a tag, NuGet/login exchanges GitHub's OIDC token for an API key that is valid for one hour. Do not rename the workflow file, because the policy names it.

To publish a new version, push a tag, for example git tag v1.1.0 && git push origin v1.1.0. The version comes from the tag, and new applications created from the template reference that same version.

The one-time setup is done: the repository secret NUGET_USER holds the nuget.org profile name (not the email address) of the account that created the policy, and the DotBlaze organization has a confirmed email address. Without either, NuGet/login fails with HTTP 400 and nothing is pushed.

Still open: choose a license and set PackageLicenseExpression in src/Directory.Build.props and templates/DotBlaze.Templates.csproj. Until then, nuget.org shows the packages as "license not specified".

The packages' README is the repository's README.md. nuget.org does not resolve relative links or images, and shows images only from trusted domains, so links into this private repository do not work there.

A version on nuget.org cannot be replaced, only unlisted, so check the manual run's packages first.

Documenting a Complete Example ​

Use the complete application as the format for a multi-file example:

  1. State the target runtime, application namespace, package requirements, and existing files it depends on.
  2. Show full file contents for new types. For additions to existing classes, name the exact method where the code belongs.
  3. Include route/provider registration, schema changes, configuration, and a form or request that actually invokes the feature.
  4. Give commands and expected output, including one relevant invalid-input or authorization result.
  5. Link the implementation and an executable test. If a check needs an external service, distinguish it from the fake-based check.

For example, the source of the blog's validation rules is PostRequest.cs, while TestingPackageTest.cs demonstrates HTTP validation assertions. From the repository root, run that focused test class:

shell
dotnet test tests/SampleApp.Tests --filter FullyQualifiedName~TestingPackageTest

Do not present pseudocode such as CreateYourClient(), an undeclared user, or ... as a complete application. Such excerpts can remain in API reference sections when the surrounding text identifies the application-owned pieces. Document the current C# API rather than mechanically translating a Laravel example.