VOOZH about

URL: https://www.nuget.org/packages/Carter.Analyzers/

⇱ NuGet Gallery | Carter.Analyzers 10.0.0




👁 Image
Carter.Analyzers 10.0.0

dotnet add package Carter.Analyzers --version 10.0.0
 
 
NuGet\Install-Package Carter.Analyzers -Version 10.0.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Carter.Analyzers" Version="10.0.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Carter.Analyzers" Version="10.0.0" />
 
Directory.Packages.props
<PackageReference Include="Carter.Analyzers" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Carter.Analyzers --version 10.0.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Carter.Analyzers, 10.0.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Carter.Analyzers@10.0.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Carter.Analyzers&version=10.0.0
 
Install as a Cake Addin
#tool nuget:?package=Carter.Analyzers&version=10.0.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Carter

Carter is a framework that is a thin layer of extension methods and functionality over ASP.NET Core allowing the code to be more explicit and most importantly more enjoyable.

For a better understanding, take a good look at the samples inside this repo. The samples demonstrate usages of elegant extensions around common ASP.NET Core types as shown below.

Other extensions include:

  • Validate<T> / ValidateAsync<T> - FluentValidation extensions to validate incoming HTTP requests which is not available with ASP.NET Core Minimal APIs.
  • BindFile/BindFiles/BindFileAndSave/BindFilesAndSave - Allows you to easily get access to a file/files that has been uploaded. Alternatively you can call BindFilesAndSave and this will save it to a path you specify.
  • MapPost<T>/MapPut<T> - Allows Carter to validate T and if it fails it returns a 422 Problem Details response.
  • MapFormPost<T> - Allows Carter to model bind T when submitting a form to the route.
  • IResponseNegotiators allow you to define how the response should look on a certain Accept header(content negotiation). Handling JSON is built in the default response but implementing an interface allows the user to choose how they want to represent resources.
  • Routes to use in common ASP.NET Core middleware e.g., app.UseExceptionHandler("/errorhandler");.
  • All interface implementations for Carter components are registered into ASP.NET Core DI automatically. Implement the interface and off you go.

Releases

Join our Slack Channel

👁 Join our slack channel

Routing

Carter uses IEndpointRouteBuilder routing and all the extensions IEndpointConventionBuilder offers also known as Minimal APIs. For example you can define a route with authorization required like so:

app.MapGet("/", () => "There's no place like 127.0.0.1").RequireAuthorization();

Where does the name "Carter" come from?

I have been a huge fan of, and core contributor to Nancy, the best .NET web framework, for many years, and the name "Nancy" came about due to it being inspired from Sinatra the Ruby web framework. Frank Sinatra had a daughter called Nancy and so that's where it came from.

I was also trying to think of a derivative name, and I had recently listened to the song Empire State of Mind where Jay-Z declares he is the new Sinatra. His real name is Shaun Carter so I took Carter and here we are!

CI Builds

If you'd like to try the latest builds from the master branch add https://f.feedz.io/carter/carter/nuget/index.json to your NuGet.config and pick up the latest and greatest version of Carter.

Getting Started

You can get started using either the template or by adding the package manually to a new or existing application.

Template

https://www.nuget.org/packages/CarterTemplate/

  1. Install the template - dotnet new install CarterTemplate

  2. Create a new application using template - dotnet new carter -n MyCarterApp -o MyCarterApp

  3. Go into the new directory created for the application cd MyCarterApp

  4. Run the application - dotnet run

Package

https://www.nuget.org/packages/Carter

  1. Create a new empty ASP.NET Core application - dotnet new web -n MyCarterApp

  2. Change into the new project location - cd ./MyCarterApp

  3. Add Carter package - dotnet add package carter

  4. Modify your Program.cs to use Carter

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCarter();

var app = builder.Build();

app.MapCarter();
app.Run();
  1. Create a new Module
 public class HomeModule : ICarterModule
 {
 public void AddRoutes(IEndpointRouteBuilder app)
 {
 app.MapGet("/", () => "Hello from Carter!");
 }
 }
  1. Run the application - dotnet run

Sample

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton<IActorProvider, ActorProvider>();
builder.Services.AddCarter();

var app = builder.Build();

app.MapCarter();
app.Run();

public class HomeModule : ICarterModule
{
 public void AddRoutes(IEndpointRouteBuilder app)
 {
 app.MapGet("/", () => "Hello from Carter!");
 app.MapGet("/qs", (HttpRequest req) =>
 {
 var ids = req.Query.AsMultiple<int>("ids");
 return $"It's {string.Join(",", ids)}";
 });
 app.MapGet("/conneg", (HttpResponse res) => res.Negotiate(new { Name = "Dave" }));
 app.MapPost("/validation", HandlePost);
 app.MapFormPost("/formpost", (Person model) => TypedResults.Ok(model)).DisableAntiforgery();
 }

 private IResult HandlePost(HttpContext ctx, Person person, IDatabase database)
 {
 var result = ctx.Request.Validate(person);

 if (!result.IsValid)
 {
 return Results.UnprocessableEntity(result.GetFormattedErrors());
 }

 var id = database.StorePerson(person);

 ctx.Response.Headers.Location = $"/{id}";
 return Results.StatusCode(201);
 }
}

public record Person(string Name);

public interface IDatabase
{
 int StorePerson(Person person);
}

public class Database : IDatabase
{
 public int StorePerson(Person person)
 {
 //db stuff
 }
}

More samples

Configuration

As mentioned earlier Carter will scan for implementations in your app and register them for DI. However, if you want a more controlled app, Carter comes with a CarterConfigurator that allows you to register modules, validators and response negotiators manually and configure validator lifetimes.

Carter will use a response negotiator based on System.Text.Json, though it provides for custom implementations via the IResponseNegotiator interface. To use your own implementation of IResponseNegotiator (say, CustomResponseNegotiator), add the following line to the initial Carter configuration, in this case as part of Program.cs:


 builder.Services.AddCarter(configurator: c =>
 {
 c.WithResponseNegotiator<CustomResponseNegotiator>();
 c.WithModule<MyModule>();
 c.WithValidator<TestModelValidator>();
 c.WithDefaultValidatorLifetime(ServiceLifetime.Singleton);
 c.WithValidatorServiceLifetimeFactory(t => {if t is PersonValidator...})
 });

If you wish to use Newtonsoft.Json Carter already ships a response negotiator in the package Carter.ResponseNegotiators.Newtonsoft. Once installed, it will automatically pick it up with no registration needed.

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Carter.Analyzers:

Package Downloads
Carter

Carter is framework that is a thin layer of extension methods and functionality over ASP.NET Core allowing code to be more explicit and most importantly more enjoyable.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.0 345,995 11/13/2025
9.0.0 541,684 11/16/2024
8.2.1 1,062,347 6/6/2024