Skip to content

HardenedThe wiring is written during the build

Mark a method with a route or a function name, and a source generator emits the routing table, the parameter binding and the registration code before the assembly is written.

Attributed handlers on the left becoming a generated route table on the right

A handler and an application

Attribute the method. The routing table, the parameter binding and the registration code are emitted during the build.

csharp
[HardenedModule]
[KestrelRuntime]
public partial class Application;

public class GreetingController {
    [Get("/hello/{name}")]
    public string Hello(string name) => $"Hello, {name}!";
}
csharp
// Program.cs
var services = new ServiceCollection();

services.AddLogging(logging => logging.AddSimpleConsole(options => options.SingleLine = true));
services.AddHardenedEnvironment(args);

new Application().PopulateServiceCollection(services);

await using var app = HardenedKestrelApplication.Create(
    services, kestrel => kestrel.ListenAnyIP(5080));

await app.RunAsync();

Or skip the wiring — dotnet new hardened-web writes all of it, with tests:

bash
dotnet new install Hardened.Templates
dotnet new hardened-web -n Greeter

Set EmitCompilerGeneratedFiles in the project file and the routing table, the handler and the binding code are all under obj/ as ordinary C#.

Two repositories, one framework

The core framework and the AWS integrations version and ship separately, so an application only carries what it uses.

RepositoryWhat it holds
Hardened.FrameworkModules, DI, configuration, routing, binding, templates, testing
Hardened.AmzLambda runtimes, DynamoDB and SQS clients, CDK constructs

Released under the MIT License.