Repository: Elfocrash/DotnetDocsShow.MinimalApis
Branch: main
Commit: 9513e4f6b511
Files: 76
Total size: 61.0 KB
Directory structure:
gitextract_9kootkau/
├── .gitignore
├── DotnetDocsShow.Extensions.Validation/
│ ├── Customers/
│ │ ├── Customer.cs
│ │ ├── CustomerEndpoints.cs
│ │ ├── CustomerService.cs
│ │ ├── CustomerValidation.cs
│ │ └── ICustomerService.cs
│ ├── DotnetDocsShow.Extensions.Validation.csproj
│ ├── IAssemblyMarker.cs
│ ├── Program.cs
│ └── ValidationExtensions.cs
├── DotnetDocsShow.Intro.MinimalApi/
│ ├── DotnetDocsShow.Intro.MinimalApi.csproj
│ └── Program.cs
├── DotnetDocsShow.MinimalApiTests.Structured/
│ ├── DotnetDocsShow.MinimalApiTests.Structured.csproj
│ ├── EndpointDefinitionExtensions.cs
│ ├── EndpointDefinitions/
│ │ ├── CustomerEndpointDefinition.cs
│ │ └── SwaggerEndpointDefinition.cs
│ ├── IEndpointDefinition.cs
│ ├── Models/
│ │ └── Customer.cs
│ ├── Program.cs
│ └── Services/
│ ├── CustomerService.cs
│ └── ICustomerService.cs
├── DotnetDocsShow.NewWebApi/
│ ├── Controllers/
│ │ └── WeatherForecastController.cs
│ ├── DotnetDocsShow.NewWebApi.csproj
│ ├── Program.cs
│ ├── Properties/
│ │ └── launchSettings.json
│ ├── WeatherForecast.cs
│ ├── appsettings.Development.json
│ └── appsettings.json
├── DotnetDocsShow.OldWebApi/
│ ├── Controllers/
│ │ └── WeatherForecastController.cs
│ ├── DotnetDocsShow.OldWebApi.csproj
│ ├── Program.cs
│ ├── Properties/
│ │ └── launchSettings.json
│ ├── Startup.cs
│ ├── WeatherForecast.cs
│ ├── appsettings.Development.json
│ └── appsettings.json
├── DotnetDocsShow.PerformanceTests/
│ ├── DotnetDocsShow.PerformanceTests.csproj
│ └── Program.cs
├── DotnetDocsShow.Structured.Extensions/
│ ├── Customers/
│ │ ├── Customer.cs
│ │ ├── CustomerEndpoints.cs
│ │ ├── CustomerService.cs
│ │ └── ICustomerService.cs
│ ├── DotnetDocsShow.Structured.Extensions.csproj
│ └── Program.cs
├── DotnetDocsShow.Structured.Mediator/
│ ├── DotnetDocsShow.Structured.Mediator.csproj
│ ├── Handlers/
│ │ ├── CreateCustomerRequestHandler.cs
│ │ ├── DeleteCustomerByIdRequestHandler.cs
│ │ ├── GetAllCustomersRequestHandler.cs
│ │ └── GetCustomerByIdRequestHandler.cs
│ ├── Models/
│ │ └── Customer.cs
│ ├── Program.cs
│ └── Services/
│ ├── CustomerService.cs
│ └── ICustomerService.cs
├── DotnetDocsShow.Structured.Scanning/
│ ├── DotnetDocsShow.Structured.Scanning.csproj
│ ├── EndpointDefinitionExtensions.cs
│ ├── EndpointDefinitions/
│ │ ├── CustomerEndpointDefinition.cs
│ │ ├── PaymentsEndpointDefinition.cs
│ │ └── SwaggerEndpointDefinition.cs
│ ├── IEndpointDefinition.cs
│ ├── Models/
│ │ └── Customer.cs
│ ├── Program.cs
│ └── Services/
│ ├── CustomerService.cs
│ └── ICustomerService.cs
├── DotnetDocsShow.Tests.Integration/
│ ├── BroadCustomerEndpointsTests.cs
│ ├── DotnetDocsShow.Tests.Integration.csproj
│ ├── NarrowCustomerEndpointsTests.cs
│ └── TestApplicationFactory.cs
├── DotnetDocsShow.Tests.Unit/
│ ├── CustomerEndpointDefinitionTests.cs
│ ├── DotnetDocsShow.Tests.Unit.csproj
│ └── ResultExtensions.cs
├── DotnetDocsShow.Weather.MinimalApi/
│ ├── DotnetDocsShow.Weather.MinimalApi.csproj
│ ├── Program.cs
│ ├── WeatherEndpoints.cs
│ ├── WeatherForecast.cs
│ └── appsettings.json
└── DotnetDocsShow.sln
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
/obj/
================================================
FILE: DotnetDocsShow.Extensions.Validation/Customers/Customer.cs
================================================
namespace DotnetDocsShow.Extensions.Validation.Customers;
public class Customer
{
public Guid Id { get; } = Guid.NewGuid();
public string FullName { get; init; } = default!;
}
================================================
FILE: DotnetDocsShow.Extensions.Validation/Customers/CustomerEndpoints.cs
================================================
using FluentValidation;
namespace DotnetDocsShow.Extensions.Validation.Customers;
public static class CustomerEndpoints
{
public static void MapCustomerEndpoints(this WebApplication app)
{
app.MapGet("/customers", GetAllCustomers);
app.MapGet("/customers/{id}", GetCustomerById);
app.MapPost("/customers", CreateCustomer).WithValidator<Customer>();
app.MapPut("/customers/{id}", UpdateCustomer);
app.MapDelete("/customers/{id}", DeleteCustomerById);
}
public static void AddCustomerServices(this IServiceCollection services)
{
services.AddSingleton<ICustomerService, CustomerService>();
}
internal static List<Customer> GetAllCustomers(ICustomerService service)
{
return service.GetAll();
}
internal static IResult GetCustomerById(ICustomerService service, Guid id)
{
var customer = service.GetById(id);
return customer is not null ? Results.Ok(customer) : Results.NotFound();
}
internal static async Task<IResult> CreateCustomerWithValidation(
ICustomerService service, Customer customer,
IValidator<Customer> validator)
{
var validate = await validator.ValidateAsync(customer);
if (!validate.IsValid)
{
return Results.BadRequest(validate.Errors);
}
service.Create(customer);
return Results.Created($"/customers/{customer.Id}", customer);
}
internal static IResult CreateCustomer(
ICustomerService service, Customer customer)
{
service.Create(customer);
return Results.Created($"/customers/{customer.Id}", customer);
}
internal static IResult UpdateCustomer(ICustomerService service, Guid id, Customer updatedCustomer)
{
var customer = service.GetById(id);
if (customer is null)
{
return Results.NotFound();
}
service.Update(updatedCustomer);
return Results.Ok(updatedCustomer);
}
internal static IResult DeleteCustomerById(ICustomerService service, Guid id)
{
service.Delete(id);
return Results.Ok();
}
}
================================================
FILE: DotnetDocsShow.Extensions.Validation/Customers/CustomerService.cs
================================================
namespace DotnetDocsShow.Extensions.Validation.Customers;
public class CustomerService : ICustomerService
{
private readonly Dictionary<Guid, Customer> _customers = new();
public void Create(Customer? customer)
{
if (customer is null)
{
return;
}
_customers[customer.Id] = customer;
}
public Customer? GetById(Guid id)
{
return _customers.GetValueOrDefault(id);
}
public List<Customer> GetAll()
{
return _customers.Values.ToList();
}
public void Update(Customer customer)
{
var existingCustomer = GetById(customer.Id);
if (existingCustomer is null)
{
return;
}
_customers[customer.Id] = customer;
}
public void Delete(Guid id)
{
_customers.Remove(id);
}
}
================================================
FILE: DotnetDocsShow.Extensions.Validation/Customers/CustomerValidation.cs
================================================
using FluentValidation;
namespace DotnetDocsShow.Extensions.Validation.Customers;
public class CustomerValidation : AbstractValidator<Customer>
{
public CustomerValidation()
{
RuleFor(x => x.Id).NotEmpty();
RuleFor(x => x.FullName).NotEmpty();
}
}
================================================
FILE: DotnetDocsShow.Extensions.Validation/Customers/ICustomerService.cs
================================================
namespace DotnetDocsShow.Extensions.Validation.Customers;
public interface ICustomerService
{
void Create(Customer? customer);
Customer? GetById(Guid id);
List<Customer> GetAll();
void Update(Customer customer);
void Delete(Guid id);
}
================================================
FILE: DotnetDocsShow.Extensions.Validation/DotnetDocsShow.Extensions.Validation.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="10.3.4" />
</ItemGroup>
</Project>
================================================
FILE: DotnetDocsShow.Extensions.Validation/IAssemblyMarker.cs
================================================
namespace DotnetDocsShow.Extensions.Validation;
public interface IAssemblyMarker{}
================================================
FILE: DotnetDocsShow.Extensions.Validation/Program.cs
================================================
using DotnetDocsShow.Extensions.Validation;
using DotnetDocsShow.Extensions.Validation.Customers;
using FluentValidation;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCustomerServices();
builder.Services.AddValidatorsFromAssemblyContaining(typeof(IAssemblyMarker));
var app = builder.Build();
app.MapCustomerEndpoints();
app.Run();
================================================
FILE: DotnetDocsShow.Extensions.Validation/ValidationExtensions.cs
================================================
using FluentValidation;
namespace DotnetDocsShow.Extensions.Validation;
public static class ValidationExtensions
{
public static RouteHandlerBuilder WithValidator<TType>(
this RouteHandlerBuilder builder) where TType : class
{
builder.Add(endpointBuilder =>
{
var originalRequestDelegate = endpointBuilder.RequestDelegate;
endpointBuilder.RequestDelegate = async context =>
{
var validator = context.RequestServices.GetService<IValidator<TType>>();
if (validator is null)
{
await originalRequestDelegate!(context);
return;
}
context.Request.EnableBuffering();
var model = await context.Request.ReadFromJsonAsync<TType>();
if (model is null)
{
context.Response.StatusCode = 400;
await context.Response.WriteAsJsonAsync(new
{
error = "Couldn't map the model from the request body"
});
return;
}
var result = await validator.ValidateAsync(model);
if (!result.IsValid)
{
context.Response.StatusCode = 400;
await context.Response.WriteAsJsonAsync(new { errors = result.Errors });
return;
}
context.Request.Body.Position = 0;
await originalRequestDelegate!(context);
};
});
return builder;
}
}
================================================
FILE: DotnetDocsShow.Intro.MinimalApi/DotnetDocsShow.Intro.MinimalApi.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
================================================
FILE: DotnetDocsShow.Intro.MinimalApi/Program.cs
================================================
var app = WebApplication.Create();
app.MapGet("helloworld", () => "Hello world!");
app.Run();
================================================
FILE: DotnetDocsShow.MinimalApiTests.Structured/DotnetDocsShow.MinimalApiTests.Structured.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="DotnetDocsShow.Tests.Integration" />
<InternalsVisibleTo Include="DotnetDocsShow.Tests.Unit" />
</ItemGroup>
</Project>
================================================
FILE: DotnetDocsShow.MinimalApiTests.Structured/EndpointDefinitionExtensions.cs
================================================
namespace DotnetDocsShow.MinimalApiTests.Structured;
public static class EndpointDefinitionExtensions
{
public static void AddEndpointDefinitions(
this IServiceCollection services, params Type[] scanMarkers)
{
var endpointDefinitions = new List<IEndpointDefinition>();
foreach (var marker in scanMarkers)
{
endpointDefinitions.AddRange(
marker.Assembly.ExportedTypes
.Where(x => typeof(IEndpointDefinition).IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract)
.Select(Activator.CreateInstance).Cast<IEndpointDefinition>()
);
}
foreach (var endpointDefinition in endpointDefinitions)
{
endpointDefinition.DefineServices(services);
}
services.AddSingleton(endpointDefinitions as IReadOnlyCollection<IEndpointDefinition>);
}
public static void UseEndpointDefinitions(this WebApplication app)
{
var definitions = app.Services.GetRequiredService<IReadOnlyCollection<IEndpointDefinition>>();
foreach (var endpointDefinition in definitions)
{
endpointDefinition.DefineEndpoints(app);
}
}
}
================================================
FILE: DotnetDocsShow.MinimalApiTests.Structured/EndpointDefinitions/CustomerEndpointDefinition.cs
================================================
using DotnetDocsShow.MinimalApiTests.Structured.Models;
using DotnetDocsShow.MinimalApiTests.Structured.Services;
namespace DotnetDocsShow.MinimalApiTests.Structured.EndpointDefinitions;
public class CustomerEndpointDefinition : IEndpointDefinition
{
public void DefineEndpoints(WebApplication app)
{
app.MapGet("/customers", GetAllCustomers);
app.MapGet("/customers/{id}", GetCustomerById);
app.MapPost("/customers", CreateCustomer);
app.MapPut("/customers/{id}", UpdateCustomer);
app.MapDelete("/customers/{id}", DeleteCustomerById);
}
internal List<Customer> GetAllCustomers(ICustomerService service)
{
return service.GetAll();
}
internal IResult GetCustomerById(ICustomerService service, Guid id)
{
var customer = service.GetById(id);
return customer is not null ? Results.Ok(customer) : Results.NotFound();
}
internal IResult CreateCustomer(ICustomerService service, Customer customer)
{
service.Create(customer);
return Results.Created($"/customers/{customer.Id}", customer);
}
internal IResult UpdateCustomer(ICustomerService service, Guid id, Customer updatedCustomer)
{
var customer = service.GetById(id);
if (customer is null)
{
return Results.NotFound();
}
service.Update(updatedCustomer);
return Results.Ok(updatedCustomer);
}
internal IResult DeleteCustomerById(ICustomerService service, Guid id)
{
service.Delete(id);
return Results.Ok();
}
public void DefineServices(IServiceCollection services)
{
services.AddSingleton<ICustomerService, CustomerService>();
}
}
================================================
FILE: DotnetDocsShow.MinimalApiTests.Structured/EndpointDefinitions/SwaggerEndpointDefinition.cs
================================================
using Microsoft.OpenApi.Models;
namespace DotnetDocsShow.MinimalApiTests.Structured.EndpointDefinitions;
public class SwaggerEndpointDefinition : IEndpointDefinition
{
public void DefineEndpoints(WebApplication app)
{
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "DotnetDocsShow.MinimalApiTests.Structured v1"));
}
public void DefineServices(IServiceCollection services)
{
services.AddEndpointsApiExplorer();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "DotnetDocsShow.MinimalApiTests.Structured", Version = "v1" });
});
}
}
================================================
FILE: DotnetDocsShow.MinimalApiTests.Structured/IEndpointDefinition.cs
================================================
namespace DotnetDocsShow.MinimalApiTests.Structured;
public interface IEndpointDefinition
{
void DefineServices(IServiceCollection services);
void DefineEndpoints(WebApplication app);
}
================================================
FILE: DotnetDocsShow.MinimalApiTests.Structured/Models/Customer.cs
================================================
using System.Text.Json.Serialization;
namespace DotnetDocsShow.MinimalApiTests.Structured.Models;
public class Customer
{
[JsonPropertyName("id")]
public Guid Id { get; init; } = Guid.NewGuid();
[JsonPropertyName("fullName")]
public string FullName { get; init; } = default!;
}
================================================
FILE: DotnetDocsShow.MinimalApiTests.Structured/Program.cs
================================================
using DotnetDocsShow.MinimalApiTests.Structured;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointDefinitions(typeof(IEndpointDefinition));
var app = builder.Build();
app.UseEndpointDefinitions();
app.Run();
================================================
FILE: DotnetDocsShow.MinimalApiTests.Structured/Services/CustomerService.cs
================================================
using DotnetDocsShow.MinimalApiTests.Structured.Models;
namespace DotnetDocsShow.MinimalApiTests.Structured.Services;
public class CustomerService : ICustomerService
{
private readonly Dictionary<Guid, Customer> _customers = new();
public void Create(Customer? customer)
{
if (customer is null)
{
return;
}
_customers[customer.Id] = customer;
}
public Customer? GetById(Guid id)
{
return _customers.GetValueOrDefault(id);
}
public List<Customer> GetAll()
{
return _customers.Values.ToList();
}
public void Update(Customer customer)
{
var existingCustomer = GetById(customer.Id);
if (existingCustomer is null)
{
return;
}
_customers[customer.Id] = customer;
}
public void Delete(Guid id)
{
_customers.Remove(id);
}
}
================================================
FILE: DotnetDocsShow.MinimalApiTests.Structured/Services/ICustomerService.cs
================================================
using DotnetDocsShow.MinimalApiTests.Structured.Models;
namespace DotnetDocsShow.MinimalApiTests.Structured.Services;
public interface ICustomerService
{
void Create(Customer? customer);
Customer? GetById(Guid id);
List<Customer> GetAll();
void Update(Customer customer);
void Delete(Guid id);
}
================================================
FILE: DotnetDocsShow.NewWebApi/Controllers/WeatherForecastController.cs
================================================
using Microsoft.AspNetCore.Mvc;
namespace DotnetDocsShow.NewWebApi.Controllers;
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly Random Random = new(489);
private static readonly string[] Summaries = {
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Next(-20, 55),
Summary = Summaries[Random.Next(Summaries.Length)]
})
.ToArray();
}
}
================================================
FILE: DotnetDocsShow.NewWebApi/DotnetDocsShow.NewWebApi.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.5"/>
</ItemGroup>
</Project>
================================================
FILE: DotnetDocsShow.NewWebApi/Program.cs
================================================
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
================================================
FILE: DotnetDocsShow.NewWebApi/Properties/launchSettings.json
================================================
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:56176",
"sslPort": 44384
}
},
"profiles": {
"DotnetDocsShow.NewWebApi": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7256;http://localhost:5256",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
================================================
FILE: DotnetDocsShow.NewWebApi/WeatherForecast.cs
================================================
namespace DotnetDocsShow.NewWebApi;
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
================================================
FILE: DotnetDocsShow.NewWebApi/appsettings.Development.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
================================================
FILE: DotnetDocsShow.NewWebApi/appsettings.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
================================================
FILE: DotnetDocsShow.OldWebApi/Controllers/WeatherForecastController.cs
================================================
using Microsoft.AspNetCore.Mvc;
namespace DotnetDocsShow.OldWebApi.Controllers;
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly Random Random = new(489);
private static readonly string[] Summaries = {
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Next(-20, 55),
Summary = Summaries[Random.Next(Summaries.Length)]
})
.ToArray();
}
}
================================================
FILE: DotnetDocsShow.OldWebApi/DotnetDocsShow.OldWebApi.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3"/>
</ItemGroup>
</Project>
================================================
FILE: DotnetDocsShow.OldWebApi/Program.cs
================================================
namespace DotnetDocsShow.OldWebApi;
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
}
================================================
FILE: DotnetDocsShow.OldWebApi/Properties/launchSettings.json
================================================
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:17516",
"sslPort": 44325
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"DotnetDocsShow.OldWebApi": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
================================================
FILE: DotnetDocsShow.OldWebApi/Startup.cs
================================================
using Microsoft.OpenApi.Models;
namespace DotnetDocsShow.OldWebApi;
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "DotnetDocsShow.OldWebApi", Version = "v1" });
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "DotnetDocsShow.OldWebApi v1"));
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
}
}
================================================
FILE: DotnetDocsShow.OldWebApi/WeatherForecast.cs
================================================
namespace DotnetDocsShow.OldWebApi;
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string Summary { get; set; }
}
================================================
FILE: DotnetDocsShow.OldWebApi/appsettings.Development.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
================================================
FILE: DotnetDocsShow.OldWebApi/appsettings.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
================================================
FILE: DotnetDocsShow.PerformanceTests/DotnetDocsShow.PerformanceTests.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NBomber" Version="2.1.1" />
<PackageReference Include="NBomber.Http" Version="2.0.1" />
</ItemGroup>
</Project>
================================================
FILE: DotnetDocsShow.PerformanceTests/Program.cs
================================================
using NBomber.Contracts;
using NBomber.CSharp;
using NBomber.Plugins.Http.CSharp;
var httpFactory = HttpClientFactory.Create();
var oldWebApiStep = CreateStep("old_web_api_step", httpFactory, "https://localhost:5001/weatherforecast");
var newWebApiStep = CreateStep("new_web_api_step", httpFactory, "https://localhost:7256/weatherforecast");
var minimalApiStep = CreateStep("minimal_api_step", httpFactory, "https://localhost:1337/weatherforecast");
var oldWebApiScenario = CreateScenario("old_web_api", oldWebApiStep, 10, TimeSpan.FromSeconds(60));
var newWebApiScenario = CreateScenario("new_web_api", newWebApiStep, 10, TimeSpan.FromSeconds(60));
var minimalApiScenario = CreateScenario("minimal_api", minimalApiStep, 10, TimeSpan.FromSeconds(60));
NBomberRunner
.RegisterScenarios(oldWebApiScenario, newWebApiScenario, minimalApiScenario)
.Run();
IStep CreateStep(string stepName, IClientFactory<HttpClient> httpClientFactory, string endpoint) =>
Step.Create(stepName, httpClientFactory, async context =>
{
var response = await context.Client.GetAsync(endpoint, context.CancellationToken);
return response.IsSuccessStatusCode
? Response.Ok(statusCode: (int)response.StatusCode)
: Response.Fail(statusCode: (int)response.StatusCode);
});
Scenario CreateScenario(string scenarioName, IStep step, int copies, TimeSpan duration) =>
ScenarioBuilder
.CreateScenario(scenarioName, step)
.WithWarmUpDuration(TimeSpan.FromSeconds(5))
.WithLoadSimulations(Simulation.KeepConstant(copies, duration));
================================================
FILE: DotnetDocsShow.Structured.Extensions/Customers/Customer.cs
================================================
namespace DotnetDocsShow.Structured.Extensions.Customers;
public class Customer
{
public Guid Id { get; } = Guid.NewGuid();
public string FullName { get; init; } = default!;
}
================================================
FILE: DotnetDocsShow.Structured.Extensions/Customers/CustomerEndpoints.cs
================================================
namespace DotnetDocsShow.Structured.Extensions.Customers;
public static class CustomerEndpoints
{
public static void MapCustomerEndpoints(this WebApplication app)
{
app.MapGet("/customers", GetAllCustomers);
app.MapGet("/customers/{id}", GetCustomerById);
app.MapPost("/customers", CreateCustomer);
app.MapPut("/customers/{id}", UpdateCustomer);
app.MapDelete("/customers/{id}", DeleteCustomerById);
}
public static void AddCustomerServices(this IServiceCollection services)
{
services.AddSingleton<ICustomerService, CustomerService>();
}
internal static List<Customer> GetAllCustomers(ICustomerService service)
{
return service.GetAll();
}
internal static IResult GetCustomerById(ICustomerService service, Guid id)
{
var customer = service.GetById(id);
return customer is not null ? Results.Ok(customer) : Results.NotFound();
}
internal static IResult CreateCustomer(ICustomerService service, Customer customer)
{
service.Create(customer);
return Results.Created($"/customers/{customer.Id}", customer);
}
internal static IResult UpdateCustomer(ICustomerService service, Guid id, Customer updatedCustomer)
{
var customer = service.GetById(id);
if (customer is null)
{
return Results.NotFound();
}
service.Update(updatedCustomer);
return Results.Ok(updatedCustomer);
}
internal static IResult DeleteCustomerById(ICustomerService service, Guid id)
{
service.Delete(id);
return Results.Ok();
}
}
================================================
FILE: DotnetDocsShow.Structured.Extensions/Customers/CustomerService.cs
================================================
namespace DotnetDocsShow.Structured.Extensions.Customers;
public class CustomerService : ICustomerService
{
private readonly Dictionary<Guid, Customer> _customers = new();
public void Create(Customer? customer)
{
if (customer is null)
{
return;
}
_customers[customer.Id] = customer;
}
public Customer? GetById(Guid id)
{
return _customers.GetValueOrDefault(id);
}
public List<Customer> GetAll()
{
return _customers.Values.ToList();
}
public void Update(Customer customer)
{
var existingCustomer = GetById(customer.Id);
if (existingCustomer is null)
{
return;
}
_customers[customer.Id] = customer;
}
public void Delete(Guid id)
{
_customers.Remove(id);
}
}
================================================
FILE: DotnetDocsShow.Structured.Extensions/Customers/ICustomerService.cs
================================================
namespace DotnetDocsShow.Structured.Extensions.Customers;
public interface ICustomerService
{
void Create(Customer? customer);
Customer? GetById(Guid id);
List<Customer> GetAll();
void Update(Customer customer);
void Delete(Guid id);
}
================================================
FILE: DotnetDocsShow.Structured.Extensions/DotnetDocsShow.Structured.Extensions.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
================================================
FILE: DotnetDocsShow.Structured.Extensions/Program.cs
================================================
using DotnetDocsShow.Structured.Extensions.Customers;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCustomerServices();
var app = builder.Build();
app.MapCustomerEndpoints();
app.Run();
================================================
FILE: DotnetDocsShow.Structured.Mediator/DotnetDocsShow.Structured.Mediator.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
</ItemGroup>
</Project>
================================================
FILE: DotnetDocsShow.Structured.Mediator/Handlers/CreateCustomerRequestHandler.cs
================================================
using System.Text.Json.Serialization;
using DotnetDocsShow.Structured.Mediator.Models;
using DotnetDocsShow.Structured.Mediator.Services;
using MediatR;
namespace DotnetDocsShow.Structured.Mediator.Handlers;
public record CreateCustomerRequest : IRequest<IResult>
{
[JsonPropertyName("id")]
public Guid Id { get; init; } = Guid.NewGuid();
[JsonPropertyName("fullName")]
public string FullName { get; init; } = default!;
}
public class CreateCustomerRequestHandler
: IRequestHandler<CreateCustomerRequest, IResult>
{
private readonly ICustomerService _customerService;
public CreateCustomerRequestHandler(ICustomerService customerService)
{
_customerService = customerService;
}
public Task<IResult> Handle(CreateCustomerRequest request, CancellationToken cancellationToken)
{
var customer = new Customer
{
FullName = request.FullName,
Id = request.Id
};
_customerService.Create(customer);
var response = Results.Created($"/customers/{customer.Id}", customer);
return Task.FromResult(response);
}
}
================================================
FILE: DotnetDocsShow.Structured.Mediator/Handlers/DeleteCustomerByIdRequestHandler.cs
================================================
using System.Text.Json.Serialization;
using DotnetDocsShow.Structured.Mediator.Services;
using MediatR;
namespace DotnetDocsShow.Structured.Mediator.Handlers;
public record DeleteCustomerByIdRequest : IRequest<IResult>
{
[JsonPropertyName("id")]
public Guid Id { get; init; }
public DeleteCustomerByIdRequest(Guid id)
{
Id = id;
}
}
public class DeleteCustomerByIdRequestHandler
: IRequestHandler<DeleteCustomerByIdRequest, IResult>
{
private readonly ICustomerService _customerService;
public DeleteCustomerByIdRequestHandler(ICustomerService customerService)
{
_customerService = customerService;
}
public Task<IResult> Handle(DeleteCustomerByIdRequest request, CancellationToken cancellationToken)
{
_customerService.Delete(request.Id);
return Task.FromResult(Results.Ok());
}
}
================================================
FILE: DotnetDocsShow.Structured.Mediator/Handlers/GetAllCustomersRequestHandler.cs
================================================
using DotnetDocsShow.Structured.Mediator.Services;
using MediatR;
namespace DotnetDocsShow.Structured.Mediator.Handlers;
public record GetAllCustomersRequest : IRequest<IResult>;
public class GetAllCustomersRequestHandler
: IRequestHandler<GetAllCustomersRequest, IResult>
{
private readonly ICustomerService _customerService;
public GetAllCustomersRequestHandler(ICustomerService customerService)
{
_customerService = customerService;
}
public Task<IResult> Handle(
GetAllCustomersRequest request, CancellationToken cancellationToken)
{
var customers = _customerService.GetAll();
var response = Results.Ok(customers);
return Task.FromResult(response);
}
}
================================================
FILE: DotnetDocsShow.Structured.Mediator/Handlers/GetCustomerByIdRequestHandler.cs
================================================
using System.Text.Json.Serialization;
using DotnetDocsShow.Structured.Mediator.Services;
using MediatR;
namespace DotnetDocsShow.Structured.Mediator.Handlers;
public record GetCustomerByIdRequest : IRequest<IResult>
{
[JsonPropertyName("id")]
public Guid Id { get; init; }
public GetCustomerByIdRequest(Guid id)
{
Id = id;
}
}
public class GetCustomerByIdRequestHandler
: IRequestHandler<GetCustomerByIdRequest, IResult>
{
private readonly ICustomerService _customerService;
public GetCustomerByIdRequestHandler(ICustomerService customerService)
{
_customerService = customerService;
}
public Task<IResult> Handle(GetCustomerByIdRequest request, CancellationToken cancellationToken)
{
var customer = _customerService.GetById(request.Id);
var response = customer is not null ? Results.Ok(customer) : Results.NotFound();
return Task.FromResult(response);
}
}
================================================
FILE: DotnetDocsShow.Structured.Mediator/Models/Customer.cs
================================================
namespace DotnetDocsShow.Structured.Mediator.Models;
public class Customer
{
public Guid Id { get; init; } = Guid.NewGuid();
public string FullName { get; init; } = default!;
}
================================================
FILE: DotnetDocsShow.Structured.Mediator/Program.cs
================================================
using DotnetDocsShow.Structured.Mediator;
using DotnetDocsShow.Structured.Mediator.Handlers;
using DotnetDocsShow.Structured.Mediator.Models;
using DotnetDocsShow.Structured.Mediator.Services;
using MediatR;
var builder = WebApplication.CreateBuilder();
builder.Services.AddSingleton<ICustomerService, CustomerService>();
builder.Services.AddMediatR(typeof(Customer));
var app = builder.Build();
app.MapGet("customers", async (IMediator mediator) => await mediator.Send(new GetAllCustomersRequest()));
app.MapGet("/customers/{id}", async (IMediator mediator, Guid id) => await mediator.Send(new GetCustomerByIdRequest(id)));
app.MapPost("/customers", async (IMediator mediator, CreateCustomerRequest request) => await mediator.Send(request));
app.MapDelete("/customers/{id}", async (IMediator mediator, Guid id) => await mediator.Send(new DeleteCustomerByIdRequest(id)));
app.Run();
================================================
FILE: DotnetDocsShow.Structured.Mediator/Services/CustomerService.cs
================================================
using DotnetDocsShow.Structured.Mediator.Models;
namespace DotnetDocsShow.Structured.Mediator.Services;
public class CustomerService : ICustomerService
{
private readonly Dictionary<Guid, Customer> _customers = new();
public void Create(Customer? customer)
{
if (customer is null)
{
return;
}
_customers[customer.Id] = customer;
}
public Customer? GetById(Guid id)
{
return _customers.GetValueOrDefault(id);
}
public List<Customer> GetAll()
{
return _customers.Values.ToList();
}
public void Update(Customer customer)
{
var existingCustomer = GetById(customer.Id);
if (existingCustomer is null)
{
return;
}
_customers[customer.Id] = customer;
}
public void Delete(Guid id)
{
_customers.Remove(id);
}
}
================================================
FILE: DotnetDocsShow.Structured.Mediator/Services/ICustomerService.cs
================================================
using DotnetDocsShow.Structured.Mediator.Models;
namespace DotnetDocsShow.Structured.Mediator.Services;
public interface ICustomerService
{
void Create(Customer? customer);
Customer? GetById(Guid id);
List<Customer> GetAll();
void Update(Customer customer);
void Delete(Guid id);
}
================================================
FILE: DotnetDocsShow.Structured.Scanning/DotnetDocsShow.Structured.Scanning.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
</Project>
================================================
FILE: DotnetDocsShow.Structured.Scanning/EndpointDefinitionExtensions.cs
================================================
namespace DotnetDocsShow.Structured.Scanning;
public static class EndpointDefinitionExtensions
{
public static void AddEndpointDefinitions(
this IServiceCollection services, params Type[] scanMarkers)
{
var endpointDefinitions = new List<IEndpointDefinition>();
foreach (var marker in scanMarkers)
{
endpointDefinitions.AddRange(
marker.Assembly.ExportedTypes
.Where(x => typeof(IEndpointDefinition).IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract)
.Select(Activator.CreateInstance).Cast<IEndpointDefinition>()
);
}
foreach (var endpointDefinition in endpointDefinitions)
{
endpointDefinition.DefineServices(services);
}
services.AddSingleton(endpointDefinitions as IReadOnlyCollection<IEndpointDefinition>);
}
public static void UseEndpointDefinitions(this WebApplication app)
{
var definitions = app.Services.GetRequiredService<IReadOnlyCollection<IEndpointDefinition>>();
foreach (var endpointDefinition in definitions)
{
endpointDefinition.DefineEndpoints(app);
}
}
}
================================================
FILE: DotnetDocsShow.Structured.Scanning/EndpointDefinitions/CustomerEndpointDefinition.cs
================================================
using DotnetDocsShow.Structured.Scanning.Models;
using DotnetDocsShow.Structured.Scanning.Services;
namespace DotnetDocsShow.Structured.Scanning.EndpointDefinitions;
public class CustomerEndpointDefinition : IEndpointDefinition
{
public void DefineEndpoints(WebApplication app)
{
app.MapGet("/customers", GetAllCustomers);
app.MapGet("/customers/{id}", GetCustomerById);
app.MapPost("/customers", CreateCustomer);
app.MapPut("/customers/{id}", UpdateCustomer);
app.MapDelete("/customers/{id}", DeleteCustomerById);
}
internal List<Customer> GetAllCustomers(ICustomerService service)
{
return service.GetAll();
}
internal IResult GetCustomerById(ICustomerService service, Guid id)
{
var customer = service.GetById(id);
return customer is not null ? Results.Ok(customer) : Results.NotFound();
}
internal IResult CreateCustomer(ICustomerService service, Customer customer)
{
service.Create(customer);
return Results.Created($"/customers/{customer.Id}", customer);
}
internal IResult UpdateCustomer(ICustomerService service, Guid id, Customer updatedCustomer)
{
var customer = service.GetById(id);
if (customer is null)
{
return Results.NotFound();
}
service.Update(updatedCustomer);
return Results.Ok(updatedCustomer);
}
internal IResult DeleteCustomerById(ICustomerService service, Guid id)
{
service.Delete(id);
return Results.Ok();
}
public void DefineServices(IServiceCollection services)
{
services.AddSingleton<ICustomerService, CustomerService>();
}
}
================================================
FILE: DotnetDocsShow.Structured.Scanning/EndpointDefinitions/PaymentsEndpointDefinition.cs
================================================
namespace DotnetDocsShow.Structured.Scanning.EndpointDefinitions;
public class PaymentsEndpointDefinition : IEndpointDefinition
{
public void DefineServices(IServiceCollection services)
{
}
public void DefineEndpoints(WebApplication app)
{
}
}
================================================
FILE: DotnetDocsShow.Structured.Scanning/EndpointDefinitions/SwaggerEndpointDefinition.cs
================================================
using Microsoft.OpenApi.Models;
namespace DotnetDocsShow.Structured.Scanning.EndpointDefinitions;
public class SwaggerEndpointDefinition : IEndpointDefinition
{
public void DefineEndpoints(WebApplication app)
{
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "DotnetDocsShow.Structured.Custom v1"));
}
public void DefineServices(IServiceCollection services)
{
services.AddEndpointsApiExplorer();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "DotnetDocsShow.Structured.Custom", Version = "v1" });
});
}
}
================================================
FILE: DotnetDocsShow.Structured.Scanning/IEndpointDefinition.cs
================================================
namespace DotnetDocsShow.Structured.Scanning;
public interface IEndpointDefinition
{
void DefineServices(IServiceCollection services);
void DefineEndpoints(WebApplication app);
}
================================================
FILE: DotnetDocsShow.Structured.Scanning/Models/Customer.cs
================================================
namespace DotnetDocsShow.Structured.Scanning.Models;
public class Customer
{
public Guid Id { get; init; } = Guid.NewGuid();
public string FullName { get; init; } = default!;
}
================================================
FILE: DotnetDocsShow.Structured.Scanning/Program.cs
================================================
using DotnetDocsShow.Structured.Scanning;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointDefinitions(typeof(IEndpointDefinition));
var app = builder.Build();
app.UseEndpointDefinitions();
app.Run();
================================================
FILE: DotnetDocsShow.Structured.Scanning/Services/CustomerService.cs
================================================
using DotnetDocsShow.Structured.Scanning.Models;
namespace DotnetDocsShow.Structured.Scanning.Services;
public class CustomerService : ICustomerService
{
private readonly Dictionary<Guid, Customer> _customers = new();
public void Create(Customer? customer)
{
if (customer is null)
{
return;
}
_customers[customer.Id] = customer;
}
public Customer? GetById(Guid id)
{
return _customers.GetValueOrDefault(id);
}
public List<Customer> GetAll()
{
return _customers.Values.ToList();
}
public void Update(Customer customer)
{
var existingCustomer = GetById(customer.Id);
if (existingCustomer is null)
{
return;
}
_customers[customer.Id] = customer;
}
public void Delete(Guid id)
{
_customers.Remove(id);
}
}
================================================
FILE: DotnetDocsShow.Structured.Scanning/Services/ICustomerService.cs
================================================
using DotnetDocsShow.Structured.Scanning.Models;
namespace DotnetDocsShow.Structured.Scanning.Services;
public interface ICustomerService
{
void Create(Customer? customer);
Customer? GetById(Guid id);
List<Customer> GetAll();
void Update(Customer customer);
void Delete(Guid id);
}
================================================
FILE: DotnetDocsShow.Tests.Integration/BroadCustomerEndpointsTests.cs
================================================
using System;
using System.Net;
using System.Net.Http.Json;
using System.Text.Json;
using System.Threading.Tasks;
using DotnetDocsShow.MinimalApiTests.Structured.Models;
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Xunit;
namespace DotnetDocsShow.Tests.Integration;
public class BroadCustomerEndpointsTests
{
[Fact]
public async Task GetCustomerById_ReturnCustomer_WhenCustomerExists()
{
//Arrange
var id = Guid.NewGuid();
var customer = new Customer{ Id = id, FullName = "Nick Chapsas"};
using var app = new TestApplicationFactory();
var httpClient = app.CreateClient();
await httpClient.PostAsJsonAsync("/customers", customer);
//Act
var response = await httpClient.GetAsync($"/customers/{id}");
var responseText = await response.Content.ReadAsStringAsync();
var customerResult = JsonSerializer.Deserialize<Customer>(responseText);
//Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
customerResult.Should().BeEquivalentTo(customer);
}
[Fact]
public async Task GetCustomerById_ReturnNotFound_WhenCustomerDoesNotExists()
{
//Arrange
using var app = new TestApplicationFactory();
var guid = Guid.NewGuid();
var httpClient = app.CreateClient();
//Act
var response = await httpClient.GetAsync($"/customers/{guid}");
//Assert
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
}
}
================================================
FILE: DotnetDocsShow.Tests.Integration/DotnetDocsShow.Tests.Integration.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.0-rc.2.21480.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DotnetDocsShow.MinimalApiTests.Structured\DotnetDocsShow.MinimalApiTests.Structured.csproj" />
</ItemGroup>
</Project>
================================================
FILE: DotnetDocsShow.Tests.Integration/NarrowCustomerEndpointsTests.cs
================================================
using System;
using System.Net;
using System.Text.Json;
using System.Threading.Tasks;
using DotnetDocsShow.MinimalApiTests.Structured.Models;
using DotnetDocsShow.MinimalApiTests.Structured.Services;
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Xunit;
namespace DotnetDocsShow.Tests.Integration;
public class NarrowCustomerEndpointsTests
{
private readonly ICustomerService _customerService =
Substitute.For<ICustomerService>();
[Fact]
public async Task GetCustomerById_ReturnCustomer_WhenCustomerExists()
{
//Arrange
var id = Guid.NewGuid();
var customer = new Customer{ Id = id, FullName = "Nick Chapsas"};
_customerService.GetById(Arg.Is(id)).Returns(customer);
using var app = new TestApplicationFactory(x =>
{
x.AddSingleton(_customerService);
});
var httpClient = app.CreateClient();
//Act
var response = await httpClient.GetAsync($"/customers/{id}");
var responseText = await response.Content.ReadAsStringAsync();
var customerResult = JsonSerializer.Deserialize<Customer>(responseText);
//Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
customerResult.Should().BeEquivalentTo(customer);
}
[Fact]
public async Task GetCustomerById_ReturnNotFound_WhenCustomerDoesNotExists()
{
//Arrange
_customerService.GetById(Arg.Any<Guid>()).Returns((Customer?)null);
using var app = new TestApplicationFactory(x =>
{
x.AddSingleton(_customerService);
});
var guid = Guid.NewGuid();
var httpClient = app.CreateClient();
//Act
var response = await httpClient.GetAsync($"/customers/{guid}");
//Assert
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
}
}
================================================
FILE: DotnetDocsShow.Tests.Integration/TestApplicationFactory.cs
================================================
using System;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace DotnetDocsShow.Tests.Integration;
internal class TestApplicationFactory : WebApplicationFactory<Program>
{
private readonly Action<IServiceCollection>? _serviceOverride;
public TestApplicationFactory(Action<IServiceCollection>? serviceOverride = null)
{
_serviceOverride = serviceOverride;
}
protected override IHost CreateHost(IHostBuilder builder)
{
if (_serviceOverride is not null)
{
builder.ConfigureServices(_serviceOverride);
}
return base.CreateHost(builder);
}
}
================================================
FILE: DotnetDocsShow.Tests.Unit/CustomerEndpointDefinitionTests.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using DotnetDocsShow.MinimalApiTests.Structured.EndpointDefinitions;
using DotnetDocsShow.MinimalApiTests.Structured.Models;
using DotnetDocsShow.MinimalApiTests.Structured.Services;
using FluentAssertions;
using NSubstitute;
using Xunit;
namespace DotnetDocsShow.Tests.Unit;
public class CustomerEndpointDefinitionTests
{
private readonly ICustomerService _customerService =
Substitute.For<ICustomerService>();
private readonly CustomerEndpointDefinition _sut = new();
[Fact]
public void GetAllCustomers_ReturnEmptyList_WhenNoCustomersExist()
{
//Arrange
_customerService.GetAll().Returns(new List<Customer>());
//Act
var result = _sut.GetAllCustomers(_customerService);
//Assert
result.Should().BeEmpty();
}
[Fact]
public void GetAllCustomers_ReturnsCustomer_WhenCustomerExists()
{
//Arrange
var id = Guid.NewGuid();
var customer = new Customer { Id = id, FullName = "Nick Chapsas" };
_customerService.GetAll().Returns(new List<Customer> { customer });
//Act
var result = _sut.GetAllCustomers(_customerService);
//Assert
result.Should().ContainSingle(x => x.Id == id && x.FullName == "Nick Chapsas");
}
}
================================================
FILE: DotnetDocsShow.Tests.Unit/DotnetDocsShow.Tests.Unit.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DotnetDocsShow.MinimalApiTests.Structured\DotnetDocsShow.MinimalApiTests.Structured.csproj" />
</ItemGroup>
</Project>
================================================
FILE: DotnetDocsShow.Tests.Unit/ResultExtensions.cs
================================================
using System;
using Microsoft.AspNetCore.Http;
namespace DotnetDocsShow.Tests.Unit;
public static class ResultExtensions
{
public static T? GetOkObjectResultValue<T>(this IResult result)
{
return (T?)Type.GetType("Microsoft.AspNetCore.Http.Result.OkObjectResult, Microsoft.AspNetCore.Http.Results")?
.GetProperty("Value",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?
.GetValue(result);
}
public static int? GetOkObjectResultStatusCode(this IResult result)
{
return (int?)Type.GetType("Microsoft.AspNetCore.Http.Result.OkObjectResult, Microsoft.AspNetCore.Http.Results")?
.GetProperty("StatusCode",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?
.GetValue(result);
}
public static int? GetNotFoundResultStatusCode(this IResult result)
{
return (int?)Type.GetType("Microsoft.AspNetCore.Http.Result.NotFoundObjectResult, Microsoft.AspNetCore.Http.Results")?
.GetProperty("StatusCode",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?
.GetValue(result);
}
}
================================================
FILE: DotnetDocsShow.Weather.MinimalApi/DotnetDocsShow.Weather.MinimalApi.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.5" />
</ItemGroup>
</Project>
================================================
FILE: DotnetDocsShow.Weather.MinimalApi/Program.cs
================================================
using DotnetDocsShow.Weather.MinimalApi;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddAuthorization();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapWeatherEndpoints();
app.Run("https://localhost:1337");
================================================
FILE: DotnetDocsShow.Weather.MinimalApi/WeatherEndpoints.cs
================================================
namespace DotnetDocsShow.Weather.MinimalApi;
public static class WeatherEndpoints
{
private static Random Random = new(489);
private static string[] Summaries = {
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
public static void MapWeatherEndpoints(this WebApplication app)
{
app.MapGet("weatherforecast", () =>
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Next(-20, 55),
Summary = Summaries[Random.Next(Summaries.Length)]
})
.ToArray();
})
.Produces(200, typeof(IEnumerable<WeatherForecast>))
.AllowAnonymous();
}
}
================================================
FILE: DotnetDocsShow.Weather.MinimalApi/WeatherForecast.cs
================================================
namespace DotnetDocsShow.Weather.MinimalApi;
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
================================================
FILE: DotnetDocsShow.Weather.MinimalApi/appsettings.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
================================================
FILE: DotnetDocsShow.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "1. Comparision", "1. Comparision", "{6FB66046-57C1-4669-84E1-0905DADC000E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4. Structuring", "4. Structuring", "{8618805B-A0E5-4B0A-B52D-FF5429D814E2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "5. Testing", "5. Testing", "{1E5E6DC2-39AE-4B52-83A7-46B28FEF72C3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2. Performance", "2. Performance", "{A18A5368-4F83-428C-ABA5-838FE467A581}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetDocsShow.NewWebApi", "DotnetDocsShow.NewWebApi\DotnetDocsShow.NewWebApi.csproj", "{6CA5CC96-0678-4723-B5B3-E2464516C277}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetDocsShow.PerformanceTests", "DotnetDocsShow.PerformanceTests\DotnetDocsShow.PerformanceTests.csproj", "{71788840-6B85-42A5-9D52-D51A802A21BE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetDocsShow.OldWebApi", "DotnetDocsShow.OldWebApi\DotnetDocsShow.OldWebApi.csproj", "{5EB40414-02BE-44A5-A14C-E619914A0F4A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetDocsShow.Weather.MinimalApi", "DotnetDocsShow.Weather.MinimalApi\DotnetDocsShow.Weather.MinimalApi.csproj", "{AD793B6C-DF05-458E-854B-ECFCAF7167AD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetDocsShow.Tests.Unit", "DotnetDocsShow.Tests.Unit\DotnetDocsShow.Tests.Unit.csproj", "{96598D5F-199D-45E7-9F80-98FD10DCD24A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetDocsShow.Tests.Integration", "DotnetDocsShow.Tests.Integration\DotnetDocsShow.Tests.Integration.csproj", "{0D8831BD-6C91-49ED-9BE7-AEA7A6DA821F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetDocsShow.MinimalApiTests.Structured", "DotnetDocsShow.MinimalApiTests.Structured\DotnetDocsShow.MinimalApiTests.Structured.csproj", "{E6AFFD49-C560-4947-8076-48E3F87AACAC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetDocsShow.Structured.Scanning", "DotnetDocsShow.Structured.Scanning\DotnetDocsShow.Structured.Scanning.csproj", "{D7F4582E-2A51-4BCA-A4D6-A11B92EDAA2F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetDocsShow.Structured.Extensions", "DotnetDocsShow.Structured.Extensions\DotnetDocsShow.Structured.Extensions.csproj", "{020FC895-5E41-41A6-9C10-E2BCEBE40842}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetDocsShow.Structured.Mediator", "DotnetDocsShow.Structured.Mediator\DotnetDocsShow.Structured.Mediator.csproj", "{DCFF64BC-6B91-4121-BB4B-0A34AD3A6C84}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0. Intro", "0. Intro", "{8975828E-1794-41B6-8F82-41F70F52C270}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3. Extensions", "3. Extensions", "{6BD6DACA-80E0-4683-A6B3-649D79F8994C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetDocsShow.Extensions.Validation", "DotnetDocsShow.Extensions.Validation\DotnetDocsShow.Extensions.Validation.csproj", "{12E1D11E-6E0E-4F40-91BB-996E71CC15C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetDocsShow.Intro.MinimalApi", "DotnetDocsShow.Intro.MinimalApi\DotnetDocsShow.Intro.MinimalApi.csproj", "{A3ECA132-FE31-46DF-8715-285B41409A1D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6CA5CC96-0678-4723-B5B3-E2464516C277} = {6FB66046-57C1-4669-84E1-0905DADC000E}
{71788840-6B85-42A5-9D52-D51A802A21BE} = {A18A5368-4F83-428C-ABA5-838FE467A581}
{5EB40414-02BE-44A5-A14C-E619914A0F4A} = {6FB66046-57C1-4669-84E1-0905DADC000E}
{AD793B6C-DF05-458E-854B-ECFCAF7167AD} = {6FB66046-57C1-4669-84E1-0905DADC000E}
{96598D5F-199D-45E7-9F80-98FD10DCD24A} = {1E5E6DC2-39AE-4B52-83A7-46B28FEF72C3}
{0D8831BD-6C91-49ED-9BE7-AEA7A6DA821F} = {1E5E6DC2-39AE-4B52-83A7-46B28FEF72C3}
{E6AFFD49-C560-4947-8076-48E3F87AACAC} = {1E5E6DC2-39AE-4B52-83A7-46B28FEF72C3}
{D7F4582E-2A51-4BCA-A4D6-A11B92EDAA2F} = {8618805B-A0E5-4B0A-B52D-FF5429D814E2}
{020FC895-5E41-41A6-9C10-E2BCEBE40842} = {8618805B-A0E5-4B0A-B52D-FF5429D814E2}
{DCFF64BC-6B91-4121-BB4B-0A34AD3A6C84} = {8618805B-A0E5-4B0A-B52D-FF5429D814E2}
{12E1D11E-6E0E-4F40-91BB-996E71CC15C3} = {6BD6DACA-80E0-4683-A6B3-649D79F8994C}
{A3ECA132-FE31-46DF-8715-285B41409A1D} = {8975828E-1794-41B6-8F82-41F70F52C270}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6CA5CC96-0678-4723-B5B3-E2464516C277}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CA5CC96-0678-4723-B5B3-E2464516C277}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CA5CC96-0678-4723-B5B3-E2464516C277}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CA5CC96-0678-4723-B5B3-E2464516C277}.Release|Any CPU.Build.0 = Release|Any CPU
{71788840-6B85-42A5-9D52-D51A802A21BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71788840-6B85-42A5-9D52-D51A802A21BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71788840-6B85-42A5-9D52-D51A802A21BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71788840-6B85-42A5-9D52-D51A802A21BE}.Release|Any CPU.Build.0 = Release|Any CPU
{5EB40414-02BE-44A5-A14C-E619914A0F4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5EB40414-02BE-44A5-A14C-E619914A0F4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5EB40414-02BE-44A5-A14C-E619914A0F4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5EB40414-02BE-44A5-A14C-E619914A0F4A}.Release|Any CPU.Build.0 = Release|Any CPU
{AD793B6C-DF05-458E-854B-ECFCAF7167AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD793B6C-DF05-458E-854B-ECFCAF7167AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD793B6C-DF05-458E-854B-ECFCAF7167AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD793B6C-DF05-458E-854B-ECFCAF7167AD}.Release|Any CPU.Build.0 = Release|Any CPU
{96598D5F-199D-45E7-9F80-98FD10DCD24A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96598D5F-199D-45E7-9F80-98FD10DCD24A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96598D5F-199D-45E7-9F80-98FD10DCD24A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96598D5F-199D-45E7-9F80-98FD10DCD24A}.Release|Any CPU.Build.0 = Release|Any CPU
{0D8831BD-6C91-49ED-9BE7-AEA7A6DA821F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D8831BD-6C91-49ED-9BE7-AEA7A6DA821F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D8831BD-6C91-49ED-9BE7-AEA7A6DA821F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D8831BD-6C91-49ED-9BE7-AEA7A6DA821F}.Release|Any CPU.Build.0 = Release|Any CPU
{E6AFFD49-C560-4947-8076-48E3F87AACAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6AFFD49-C560-4947-8076-48E3F87AACAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6AFFD49-C560-4947-8076-48E3F87AACAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6AFFD49-C560-4947-8076-48E3F87AACAC}.Release|Any CPU.Build.0 = Release|Any CPU
{D7F4582E-2A51-4BCA-A4D6-A11B92EDAA2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D7F4582E-2A51-4BCA-A4D6-A11B92EDAA2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7F4582E-2A51-4BCA-A4D6-A11B92EDAA2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7F4582E-2A51-4BCA-A4D6-A11B92EDAA2F}.Release|Any CPU.Build.0 = Release|Any CPU
{020FC895-5E41-41A6-9C10-E2BCEBE40842}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{020FC895-5E41-41A6-9C10-E2BCEBE40842}.Debug|Any CPU.Build.0 = Debug|Any CPU
{020FC895-5E41-41A6-9C10-E2BCEBE40842}.Release|Any CPU.ActiveCfg = Release|Any CPU
{020FC895-5E41-41A6-9C10-E2BCEBE40842}.Release|Any CPU.Build.0 = Release|Any CPU
{DCFF64BC-6B91-4121-BB4B-0A34AD3A6C84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DCFF64BC-6B91-4121-BB4B-0A34AD3A6C84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DCFF64BC-6B91-4121-BB4B-0A34AD3A6C84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DCFF64BC-6B91-4121-BB4B-0A34AD3A6C84}.Release|Any CPU.Build.0 = Release|Any CPU
{12E1D11E-6E0E-4F40-91BB-996E71CC15C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12E1D11E-6E0E-4F40-91BB-996E71CC15C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12E1D11E-6E0E-4F40-91BB-996E71CC15C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12E1D11E-6E0E-4F40-91BB-996E71CC15C3}.Release|Any CPU.Build.0 = Release|Any CPU
{A3ECA132-FE31-46DF-8715-285B41409A1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3ECA132-FE31-46DF-8715-285B41409A1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3ECA132-FE31-46DF-8715-285B41409A1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3ECA132-FE31-46DF-8715-285B41409A1D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
gitextract_9kootkau/ ├── .gitignore ├── DotnetDocsShow.Extensions.Validation/ │ ├── Customers/ │ │ ├── Customer.cs │ │ ├── CustomerEndpoints.cs │ │ ├── CustomerService.cs │ │ ├── CustomerValidation.cs │ │ └── ICustomerService.cs │ ├── DotnetDocsShow.Extensions.Validation.csproj │ ├── IAssemblyMarker.cs │ ├── Program.cs │ └── ValidationExtensions.cs ├── DotnetDocsShow.Intro.MinimalApi/ │ ├── DotnetDocsShow.Intro.MinimalApi.csproj │ └── Program.cs ├── DotnetDocsShow.MinimalApiTests.Structured/ │ ├── DotnetDocsShow.MinimalApiTests.Structured.csproj │ ├── EndpointDefinitionExtensions.cs │ ├── EndpointDefinitions/ │ │ ├── CustomerEndpointDefinition.cs │ │ └── SwaggerEndpointDefinition.cs │ ├── IEndpointDefinition.cs │ ├── Models/ │ │ └── Customer.cs │ ├── Program.cs │ └── Services/ │ ├── CustomerService.cs │ └── ICustomerService.cs ├── DotnetDocsShow.NewWebApi/ │ ├── Controllers/ │ │ └── WeatherForecastController.cs │ ├── DotnetDocsShow.NewWebApi.csproj │ ├── Program.cs │ ├── Properties/ │ │ └── launchSettings.json │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── DotnetDocsShow.OldWebApi/ │ ├── Controllers/ │ │ └── WeatherForecastController.cs │ ├── DotnetDocsShow.OldWebApi.csproj │ ├── Program.cs │ ├── Properties/ │ │ └── launchSettings.json │ ├── Startup.cs │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── DotnetDocsShow.PerformanceTests/ │ ├── DotnetDocsShow.PerformanceTests.csproj │ └── Program.cs ├── DotnetDocsShow.Structured.Extensions/ │ ├── Customers/ │ │ ├── Customer.cs │ │ ├── CustomerEndpoints.cs │ │ ├── CustomerService.cs │ │ └── ICustomerService.cs │ ├── DotnetDocsShow.Structured.Extensions.csproj │ └── Program.cs ├── DotnetDocsShow.Structured.Mediator/ │ ├── DotnetDocsShow.Structured.Mediator.csproj │ ├── Handlers/ │ │ ├── CreateCustomerRequestHandler.cs │ │ ├── DeleteCustomerByIdRequestHandler.cs │ │ ├── GetAllCustomersRequestHandler.cs │ │ └── GetCustomerByIdRequestHandler.cs │ ├── Models/ │ │ └── Customer.cs │ ├── Program.cs │ └── Services/ │ ├── CustomerService.cs │ └── ICustomerService.cs ├── DotnetDocsShow.Structured.Scanning/ │ ├── DotnetDocsShow.Structured.Scanning.csproj │ ├── EndpointDefinitionExtensions.cs │ ├── EndpointDefinitions/ │ │ ├── CustomerEndpointDefinition.cs │ │ ├── PaymentsEndpointDefinition.cs │ │ └── SwaggerEndpointDefinition.cs │ ├── IEndpointDefinition.cs │ ├── Models/ │ │ └── Customer.cs │ ├── Program.cs │ └── Services/ │ ├── CustomerService.cs │ └── ICustomerService.cs ├── DotnetDocsShow.Tests.Integration/ │ ├── BroadCustomerEndpointsTests.cs │ ├── DotnetDocsShow.Tests.Integration.csproj │ ├── NarrowCustomerEndpointsTests.cs │ └── TestApplicationFactory.cs ├── DotnetDocsShow.Tests.Unit/ │ ├── CustomerEndpointDefinitionTests.cs │ ├── DotnetDocsShow.Tests.Unit.csproj │ └── ResultExtensions.cs ├── DotnetDocsShow.Weather.MinimalApi/ │ ├── DotnetDocsShow.Weather.MinimalApi.csproj │ ├── Program.cs │ ├── WeatherEndpoints.cs │ ├── WeatherForecast.cs │ └── appsettings.json └── DotnetDocsShow.sln
SYMBOL INDEX (172 symbols across 46 files)
FILE: DotnetDocsShow.Extensions.Validation/Customers/Customer.cs
class Customer (line 3) | public class Customer
FILE: DotnetDocsShow.Extensions.Validation/Customers/CustomerEndpoints.cs
class CustomerEndpoints (line 5) | public static class CustomerEndpoints
method MapCustomerEndpoints (line 7) | public static void MapCustomerEndpoints(this WebApplication app)
method AddCustomerServices (line 16) | public static void AddCustomerServices(this IServiceCollection services)
method GetAllCustomers (line 21) | internal static List<Customer> GetAllCustomers(ICustomerService service)
method GetCustomerById (line 26) | internal static IResult GetCustomerById(ICustomerService service, Guid...
method CreateCustomerWithValidation (line 32) | internal static async Task<IResult> CreateCustomerWithValidation(
method CreateCustomer (line 46) | internal static IResult CreateCustomer(
method UpdateCustomer (line 53) | internal static IResult UpdateCustomer(ICustomerService service, Guid ...
method DeleteCustomerById (line 65) | internal static IResult DeleteCustomerById(ICustomerService service, G...
FILE: DotnetDocsShow.Extensions.Validation/Customers/CustomerService.cs
class CustomerService (line 3) | public class CustomerService : ICustomerService
method Create (line 7) | public void Create(Customer? customer)
method GetById (line 17) | public Customer? GetById(Guid id)
method GetAll (line 22) | public List<Customer> GetAll()
method Update (line 27) | public void Update(Customer customer)
method Delete (line 38) | public void Delete(Guid id)
FILE: DotnetDocsShow.Extensions.Validation/Customers/CustomerValidation.cs
class CustomerValidation (line 5) | public class CustomerValidation : AbstractValidator<Customer>
method CustomerValidation (line 7) | public CustomerValidation()
FILE: DotnetDocsShow.Extensions.Validation/Customers/ICustomerService.cs
type ICustomerService (line 3) | public interface ICustomerService
method Create (line 5) | void Create(Customer? customer);
method GetById (line 7) | Customer? GetById(Guid id);
method GetAll (line 9) | List<Customer> GetAll();
method Update (line 11) | void Update(Customer customer);
method Delete (line 13) | void Delete(Guid id);
FILE: DotnetDocsShow.Extensions.Validation/IAssemblyMarker.cs
type IAssemblyMarker (line 3) | public interface IAssemblyMarker{}
FILE: DotnetDocsShow.Extensions.Validation/ValidationExtensions.cs
class ValidationExtensions (line 5) | public static class ValidationExtensions
method WithValidator (line 7) | public static RouteHandlerBuilder WithValidator<TType>(
FILE: DotnetDocsShow.MinimalApiTests.Structured/EndpointDefinitionExtensions.cs
class EndpointDefinitionExtensions (line 3) | public static class EndpointDefinitionExtensions
method AddEndpointDefinitions (line 5) | public static void AddEndpointDefinitions(
method UseEndpointDefinitions (line 27) | public static void UseEndpointDefinitions(this WebApplication app)
FILE: DotnetDocsShow.MinimalApiTests.Structured/EndpointDefinitions/CustomerEndpointDefinition.cs
class CustomerEndpointDefinition (line 6) | public class CustomerEndpointDefinition : IEndpointDefinition
method DefineEndpoints (line 8) | public void DefineEndpoints(WebApplication app)
method GetAllCustomers (line 17) | internal List<Customer> GetAllCustomers(ICustomerService service)
method GetCustomerById (line 22) | internal IResult GetCustomerById(ICustomerService service, Guid id)
method CreateCustomer (line 28) | internal IResult CreateCustomer(ICustomerService service, Customer cus...
method UpdateCustomer (line 34) | internal IResult UpdateCustomer(ICustomerService service, Guid id, Cus...
method DeleteCustomerById (line 46) | internal IResult DeleteCustomerById(ICustomerService service, Guid id)
method DefineServices (line 52) | public void DefineServices(IServiceCollection services)
FILE: DotnetDocsShow.MinimalApiTests.Structured/EndpointDefinitions/SwaggerEndpointDefinition.cs
class SwaggerEndpointDefinition (line 5) | public class SwaggerEndpointDefinition : IEndpointDefinition
method DefineEndpoints (line 7) | public void DefineEndpoints(WebApplication app)
method DefineServices (line 13) | public void DefineServices(IServiceCollection services)
FILE: DotnetDocsShow.MinimalApiTests.Structured/IEndpointDefinition.cs
type IEndpointDefinition (line 3) | public interface IEndpointDefinition
method DefineServices (line 5) | void DefineServices(IServiceCollection services);
method DefineEndpoints (line 7) | void DefineEndpoints(WebApplication app);
FILE: DotnetDocsShow.MinimalApiTests.Structured/Models/Customer.cs
class Customer (line 5) | public class Customer
FILE: DotnetDocsShow.MinimalApiTests.Structured/Services/CustomerService.cs
class CustomerService (line 5) | public class CustomerService : ICustomerService
method Create (line 9) | public void Create(Customer? customer)
method GetById (line 19) | public Customer? GetById(Guid id)
method GetAll (line 24) | public List<Customer> GetAll()
method Update (line 29) | public void Update(Customer customer)
method Delete (line 40) | public void Delete(Guid id)
FILE: DotnetDocsShow.MinimalApiTests.Structured/Services/ICustomerService.cs
type ICustomerService (line 5) | public interface ICustomerService
method Create (line 7) | void Create(Customer? customer);
method GetById (line 9) | Customer? GetById(Guid id);
method GetAll (line 11) | List<Customer> GetAll();
method Update (line 13) | void Update(Customer customer);
method Delete (line 15) | void Delete(Guid id);
FILE: DotnetDocsShow.NewWebApi/Controllers/WeatherForecastController.cs
class WeatherForecastController (line 5) | [ApiController]
method Get (line 14) | [HttpGet(Name = "GetWeatherForecast")]
FILE: DotnetDocsShow.NewWebApi/WeatherForecast.cs
class WeatherForecast (line 3) | public class WeatherForecast
FILE: DotnetDocsShow.OldWebApi/Controllers/WeatherForecastController.cs
class WeatherForecastController (line 5) | [ApiController]
method Get (line 14) | [HttpGet]
FILE: DotnetDocsShow.OldWebApi/Program.cs
class Program (line 3) | public class Program
method Main (line 5) | public static void Main(string[] args)
method CreateHostBuilder (line 10) | public static IHostBuilder CreateHostBuilder(string[] args) =>
FILE: DotnetDocsShow.OldWebApi/Startup.cs
class Startup (line 5) | public class Startup
method Startup (line 7) | public Startup(IConfiguration configuration)
method ConfigureServices (line 15) | public void ConfigureServices(IServiceCollection services)
method Configure (line 25) | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
FILE: DotnetDocsShow.OldWebApi/WeatherForecast.cs
class WeatherForecast (line 3) | public class WeatherForecast
FILE: DotnetDocsShow.Structured.Extensions/Customers/Customer.cs
class Customer (line 3) | public class Customer
FILE: DotnetDocsShow.Structured.Extensions/Customers/CustomerEndpoints.cs
class CustomerEndpoints (line 3) | public static class CustomerEndpoints
method MapCustomerEndpoints (line 5) | public static void MapCustomerEndpoints(this WebApplication app)
method AddCustomerServices (line 14) | public static void AddCustomerServices(this IServiceCollection services)
method GetAllCustomers (line 19) | internal static List<Customer> GetAllCustomers(ICustomerService service)
method GetCustomerById (line 24) | internal static IResult GetCustomerById(ICustomerService service, Guid...
method CreateCustomer (line 30) | internal static IResult CreateCustomer(ICustomerService service, Custo...
method UpdateCustomer (line 36) | internal static IResult UpdateCustomer(ICustomerService service, Guid ...
method DeleteCustomerById (line 48) | internal static IResult DeleteCustomerById(ICustomerService service, G...
FILE: DotnetDocsShow.Structured.Extensions/Customers/CustomerService.cs
class CustomerService (line 3) | public class CustomerService : ICustomerService
method Create (line 7) | public void Create(Customer? customer)
method GetById (line 17) | public Customer? GetById(Guid id)
method GetAll (line 22) | public List<Customer> GetAll()
method Update (line 27) | public void Update(Customer customer)
method Delete (line 38) | public void Delete(Guid id)
FILE: DotnetDocsShow.Structured.Extensions/Customers/ICustomerService.cs
type ICustomerService (line 3) | public interface ICustomerService
method Create (line 5) | void Create(Customer? customer);
method GetById (line 7) | Customer? GetById(Guid id);
method GetAll (line 9) | List<Customer> GetAll();
method Update (line 11) | void Update(Customer customer);
method Delete (line 13) | void Delete(Guid id);
FILE: DotnetDocsShow.Structured.Mediator/Handlers/CreateCustomerRequestHandler.cs
type CreateCustomerRequest (line 8) | public record CreateCustomerRequest : IRequest<IResult>
class CreateCustomerRequestHandler (line 17) | public class CreateCustomerRequestHandler
method CreateCustomerRequestHandler (line 22) | public CreateCustomerRequestHandler(ICustomerService customerService)
method Handle (line 27) | public Task<IResult> Handle(CreateCustomerRequest request, Cancellatio...
FILE: DotnetDocsShow.Structured.Mediator/Handlers/DeleteCustomerByIdRequestHandler.cs
type DeleteCustomerByIdRequest (line 7) | public record DeleteCustomerByIdRequest : IRequest<IResult>
class DeleteCustomerByIdRequestHandler (line 18) | public class DeleteCustomerByIdRequestHandler
method DeleteCustomerByIdRequestHandler (line 23) | public DeleteCustomerByIdRequestHandler(ICustomerService customerService)
method Handle (line 28) | public Task<IResult> Handle(DeleteCustomerByIdRequest request, Cancell...
FILE: DotnetDocsShow.Structured.Mediator/Handlers/GetAllCustomersRequestHandler.cs
type GetAllCustomersRequest (line 6) | public record GetAllCustomersRequest : IRequest<IResult>;
class GetAllCustomersRequestHandler (line 8) | public class GetAllCustomersRequestHandler
method GetAllCustomersRequestHandler (line 13) | public GetAllCustomersRequestHandler(ICustomerService customerService)
method Handle (line 18) | public Task<IResult> Handle(
FILE: DotnetDocsShow.Structured.Mediator/Handlers/GetCustomerByIdRequestHandler.cs
type GetCustomerByIdRequest (line 7) | public record GetCustomerByIdRequest : IRequest<IResult>
class GetCustomerByIdRequestHandler (line 18) | public class GetCustomerByIdRequestHandler
method GetCustomerByIdRequestHandler (line 23) | public GetCustomerByIdRequestHandler(ICustomerService customerService)
method Handle (line 28) | public Task<IResult> Handle(GetCustomerByIdRequest request, Cancellati...
FILE: DotnetDocsShow.Structured.Mediator/Models/Customer.cs
class Customer (line 3) | public class Customer
FILE: DotnetDocsShow.Structured.Mediator/Services/CustomerService.cs
class CustomerService (line 5) | public class CustomerService : ICustomerService
method Create (line 9) | public void Create(Customer? customer)
method GetById (line 19) | public Customer? GetById(Guid id)
method GetAll (line 24) | public List<Customer> GetAll()
method Update (line 29) | public void Update(Customer customer)
method Delete (line 40) | public void Delete(Guid id)
FILE: DotnetDocsShow.Structured.Mediator/Services/ICustomerService.cs
type ICustomerService (line 5) | public interface ICustomerService
method Create (line 7) | void Create(Customer? customer);
method GetById (line 9) | Customer? GetById(Guid id);
method GetAll (line 11) | List<Customer> GetAll();
method Update (line 13) | void Update(Customer customer);
method Delete (line 15) | void Delete(Guid id);
FILE: DotnetDocsShow.Structured.Scanning/EndpointDefinitionExtensions.cs
class EndpointDefinitionExtensions (line 3) | public static class EndpointDefinitionExtensions
method AddEndpointDefinitions (line 5) | public static void AddEndpointDefinitions(
method UseEndpointDefinitions (line 27) | public static void UseEndpointDefinitions(this WebApplication app)
FILE: DotnetDocsShow.Structured.Scanning/EndpointDefinitions/CustomerEndpointDefinition.cs
class CustomerEndpointDefinition (line 6) | public class CustomerEndpointDefinition : IEndpointDefinition
method DefineEndpoints (line 8) | public void DefineEndpoints(WebApplication app)
method GetAllCustomers (line 17) | internal List<Customer> GetAllCustomers(ICustomerService service)
method GetCustomerById (line 22) | internal IResult GetCustomerById(ICustomerService service, Guid id)
method CreateCustomer (line 28) | internal IResult CreateCustomer(ICustomerService service, Customer cus...
method UpdateCustomer (line 34) | internal IResult UpdateCustomer(ICustomerService service, Guid id, Cus...
method DeleteCustomerById (line 46) | internal IResult DeleteCustomerById(ICustomerService service, Guid id)
method DefineServices (line 52) | public void DefineServices(IServiceCollection services)
FILE: DotnetDocsShow.Structured.Scanning/EndpointDefinitions/PaymentsEndpointDefinition.cs
class PaymentsEndpointDefinition (line 3) | public class PaymentsEndpointDefinition : IEndpointDefinition
method DefineServices (line 5) | public void DefineServices(IServiceCollection services)
method DefineEndpoints (line 10) | public void DefineEndpoints(WebApplication app)
FILE: DotnetDocsShow.Structured.Scanning/EndpointDefinitions/SwaggerEndpointDefinition.cs
class SwaggerEndpointDefinition (line 5) | public class SwaggerEndpointDefinition : IEndpointDefinition
method DefineEndpoints (line 7) | public void DefineEndpoints(WebApplication app)
method DefineServices (line 13) | public void DefineServices(IServiceCollection services)
FILE: DotnetDocsShow.Structured.Scanning/IEndpointDefinition.cs
type IEndpointDefinition (line 3) | public interface IEndpointDefinition
method DefineServices (line 5) | void DefineServices(IServiceCollection services);
method DefineEndpoints (line 7) | void DefineEndpoints(WebApplication app);
FILE: DotnetDocsShow.Structured.Scanning/Models/Customer.cs
class Customer (line 3) | public class Customer
FILE: DotnetDocsShow.Structured.Scanning/Services/CustomerService.cs
class CustomerService (line 5) | public class CustomerService : ICustomerService
method Create (line 9) | public void Create(Customer? customer)
method GetById (line 19) | public Customer? GetById(Guid id)
method GetAll (line 24) | public List<Customer> GetAll()
method Update (line 29) | public void Update(Customer customer)
method Delete (line 40) | public void Delete(Guid id)
FILE: DotnetDocsShow.Structured.Scanning/Services/ICustomerService.cs
type ICustomerService (line 5) | public interface ICustomerService
method Create (line 7) | void Create(Customer? customer);
method GetById (line 9) | Customer? GetById(Guid id);
method GetAll (line 11) | List<Customer> GetAll();
method Update (line 13) | void Update(Customer customer);
method Delete (line 15) | void Delete(Guid id);
FILE: DotnetDocsShow.Tests.Integration/BroadCustomerEndpointsTests.cs
class BroadCustomerEndpointsTests (line 14) | public class BroadCustomerEndpointsTests
method GetCustomerById_ReturnCustomer_WhenCustomerExists (line 16) | [Fact]
method GetCustomerById_ReturnNotFound_WhenCustomerDoesNotExists (line 38) | [Fact]
FILE: DotnetDocsShow.Tests.Integration/NarrowCustomerEndpointsTests.cs
class NarrowCustomerEndpointsTests (line 14) | public class NarrowCustomerEndpointsTests
method GetCustomerById_ReturnCustomer_WhenCustomerExists (line 19) | [Fact]
method GetCustomerById_ReturnNotFound_WhenCustomerDoesNotExists (line 44) | [Fact]
FILE: DotnetDocsShow.Tests.Integration/TestApplicationFactory.cs
class TestApplicationFactory (line 8) | internal class TestApplicationFactory : WebApplicationFactory<Program>
method TestApplicationFactory (line 12) | public TestApplicationFactory(Action<IServiceCollection>? serviceOverr...
method CreateHost (line 17) | protected override IHost CreateHost(IHostBuilder builder)
FILE: DotnetDocsShow.Tests.Unit/CustomerEndpointDefinitionTests.cs
class CustomerEndpointDefinitionTests (line 13) | public class CustomerEndpointDefinitionTests
method GetAllCustomers_ReturnEmptyList_WhenNoCustomersExist (line 20) | [Fact]
method GetAllCustomers_ReturnsCustomer_WhenCustomerExists (line 33) | [Fact]
FILE: DotnetDocsShow.Tests.Unit/ResultExtensions.cs
class ResultExtensions (line 6) | public static class ResultExtensions
method GetOkObjectResultValue (line 8) | public static T? GetOkObjectResultValue<T>(this IResult result)
method GetOkObjectResultStatusCode (line 16) | public static int? GetOkObjectResultStatusCode(this IResult result)
method GetNotFoundResultStatusCode (line 24) | public static int? GetNotFoundResultStatusCode(this IResult result)
FILE: DotnetDocsShow.Weather.MinimalApi/WeatherEndpoints.cs
class WeatherEndpoints (line 3) | public static class WeatherEndpoints
method MapWeatherEndpoints (line 10) | public static void MapWeatherEndpoints(this WebApplication app)
FILE: DotnetDocsShow.Weather.MinimalApi/WeatherForecast.cs
class WeatherForecast (line 3) | public class WeatherForecast
Condensed preview — 76 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (72K chars).
[
{
"path": ".gitignore",
"chars": 4312,
"preview": "## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n\n# User"
},
{
"path": "DotnetDocsShow.Extensions.Validation/Customers/Customer.cs",
"chars": 187,
"preview": "namespace DotnetDocsShow.Extensions.Validation.Customers;\n\npublic class Customer\n{\n public Guid Id { get; } = Guid.N"
},
{
"path": "DotnetDocsShow.Extensions.Validation/Customers/CustomerEndpoints.cs",
"chars": 2163,
"preview": "using FluentValidation;\n\nnamespace DotnetDocsShow.Extensions.Validation.Customers;\n\npublic static class CustomerEndpoin"
},
{
"path": "DotnetDocsShow.Extensions.Validation/Customers/CustomerService.cs",
"chars": 849,
"preview": "namespace DotnetDocsShow.Extensions.Validation.Customers;\n\npublic class CustomerService : ICustomerService\n{\n privat"
},
{
"path": "DotnetDocsShow.Extensions.Validation/Customers/CustomerValidation.cs",
"chars": 279,
"preview": "using FluentValidation;\n\nnamespace DotnetDocsShow.Extensions.Validation.Customers;\n\npublic class CustomerValidation : A"
},
{
"path": "DotnetDocsShow.Extensions.Validation/Customers/ICustomerService.cs",
"chars": 262,
"preview": "namespace DotnetDocsShow.Extensions.Validation.Customers;\n\npublic interface ICustomerService\n{\n void Create(Customer"
},
{
"path": "DotnetDocsShow.Extensions.Validation/DotnetDocsShow.Extensions.Validation.csproj",
"chars": 398,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <OutputType>Exe</OutputType>\n <TargetFramework"
},
{
"path": "DotnetDocsShow.Extensions.Validation/IAssemblyMarker.cs",
"chars": 85,
"preview": "namespace DotnetDocsShow.Extensions.Validation;\n\npublic interface IAssemblyMarker{}\n"
},
{
"path": "DotnetDocsShow.Extensions.Validation/Program.cs",
"chars": 360,
"preview": "using DotnetDocsShow.Extensions.Validation;\nusing DotnetDocsShow.Extensions.Validation.Customers;\nusing FluentValidatio"
},
{
"path": "DotnetDocsShow.Extensions.Validation/ValidationExtensions.cs",
"chars": 1659,
"preview": "using FluentValidation;\n\nnamespace DotnetDocsShow.Extensions.Validation;\n\npublic static class ValidationExtensions\n{\n "
},
{
"path": "DotnetDocsShow.Intro.MinimalApi/DotnetDocsShow.Intro.MinimalApi.csproj",
"chars": 263,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <OutputType>Exe</OutputType>\n <TargetFramework"
},
{
"path": "DotnetDocsShow.Intro.MinimalApi/Program.cs",
"chars": 97,
"preview": "var app = WebApplication.Create();\n\napp.MapGet(\"helloworld\", () => \"Hello world!\");\n\napp.Run();\n"
},
{
"path": "DotnetDocsShow.MinimalApiTests.Structured/DotnetDocsShow.MinimalApiTests.Structured.csproj",
"chars": 548,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <OutputType>Exe</OutputType>\n <TargetFramework"
},
{
"path": "DotnetDocsShow.MinimalApiTests.Structured/EndpointDefinitionExtensions.cs",
"chars": 1225,
"preview": "namespace DotnetDocsShow.MinimalApiTests.Structured;\n\npublic static class EndpointDefinitionExtensions\n{\n public sta"
},
{
"path": "DotnetDocsShow.MinimalApiTests.Structured/EndpointDefinitions/CustomerEndpointDefinition.cs",
"chars": 1735,
"preview": "using DotnetDocsShow.MinimalApiTests.Structured.Models;\nusing DotnetDocsShow.MinimalApiTests.Structured.Services;\n\nname"
},
{
"path": "DotnetDocsShow.MinimalApiTests.Structured/EndpointDefinitions/SwaggerEndpointDefinition.cs",
"chars": 685,
"preview": "using Microsoft.OpenApi.Models;\n\nnamespace DotnetDocsShow.MinimalApiTests.Structured.EndpointDefinitions;\n\npublic class"
},
{
"path": "DotnetDocsShow.MinimalApiTests.Structured/IEndpointDefinition.cs",
"chars": 197,
"preview": "namespace DotnetDocsShow.MinimalApiTests.Structured;\n\npublic interface IEndpointDefinition\n{\n void DefineServices(IS"
},
{
"path": "DotnetDocsShow.MinimalApiTests.Structured/Models/Customer.cs",
"chars": 298,
"preview": "using System.Text.Json.Serialization;\n\nnamespace DotnetDocsShow.MinimalApiTests.Structured.Models;\n\npublic class Custom"
},
{
"path": "DotnetDocsShow.MinimalApiTests.Structured/Program.cs",
"chars": 241,
"preview": "using DotnetDocsShow.MinimalApiTests.Structured;\n\nvar builder = WebApplication.CreateBuilder(args);\nbuilder.Services.Ad"
},
{
"path": "DotnetDocsShow.MinimalApiTests.Structured/Services/CustomerService.cs",
"chars": 910,
"preview": "using DotnetDocsShow.MinimalApiTests.Structured.Models;\n\nnamespace DotnetDocsShow.MinimalApiTests.Structured.Services;\n"
},
{
"path": "DotnetDocsShow.MinimalApiTests.Structured/Services/ICustomerService.cs",
"chars": 323,
"preview": "using DotnetDocsShow.MinimalApiTests.Structured.Models;\n\nnamespace DotnetDocsShow.MinimalApiTests.Structured.Services;\n"
},
{
"path": "DotnetDocsShow.NewWebApi/Controllers/WeatherForecastController.cs",
"chars": 803,
"preview": "using Microsoft.AspNetCore.Mvc;\n\nnamespace DotnetDocsShow.NewWebApi.Controllers;\n\n[ApiController]\n[Route(\"[controller]\")"
},
{
"path": "DotnetDocsShow.NewWebApi/DotnetDocsShow.NewWebApi.csproj",
"chars": 337,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <TargetFramework>net6.0</TargetFramework>\n <Nu"
},
{
"path": "DotnetDocsShow.NewWebApi/Program.cs",
"chars": 531,
"preview": "var builder = WebApplication.CreateBuilder(args);\n\n// Add services to the container.\n\nbuilder.Services.AddControllers();"
},
{
"path": "DotnetDocsShow.NewWebApi/Properties/launchSettings.json",
"chars": 821,
"preview": "{\n \"$schema\": \"https://json.schemastore.org/launchsettings.json\",\n \"iisSettings\": {\n \"windowsAuthentication\": fals"
},
{
"path": "DotnetDocsShow.NewWebApi/WeatherForecast.cs",
"chars": 260,
"preview": "namespace DotnetDocsShow.NewWebApi;\n\npublic class WeatherForecast\n{\n public DateTime Date { get; set; }\n\n public i"
},
{
"path": "DotnetDocsShow.NewWebApi/appsettings.Development.json",
"chars": 119,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft.AspNetCore\": \"Warning\"\n }\n }\n}\n"
},
{
"path": "DotnetDocsShow.NewWebApi/appsettings.json",
"chars": 142,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft.AspNetCore\": \"Warning\"\n }\n },\n "
},
{
"path": "DotnetDocsShow.OldWebApi/Controllers/WeatherForecastController.cs",
"chars": 775,
"preview": "using Microsoft.AspNetCore.Mvc;\n\nnamespace DotnetDocsShow.OldWebApi.Controllers;\n\n[ApiController]\n[Route(\"[controller]\""
},
{
"path": "DotnetDocsShow.OldWebApi/DotnetDocsShow.OldWebApi.csproj",
"chars": 301,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <TargetFramework>net6.0</TargetFramework>\n <Im"
},
{
"path": "DotnetDocsShow.OldWebApi/Program.cs",
"chars": 363,
"preview": "namespace DotnetDocsShow.OldWebApi;\n\npublic class Program\n{\n public static void Main(string[] args)\n {\n Cre"
},
{
"path": "DotnetDocsShow.OldWebApi/Properties/launchSettings.json",
"chars": 822,
"preview": "{\n \"$schema\": \"http://json.schemastore.org/launchsettings.json\",\n \"iisSettings\": {\n \"windowsAuthentication\": false"
},
{
"path": "DotnetDocsShow.OldWebApi/Startup.cs",
"chars": 1216,
"preview": "using Microsoft.OpenApi.Models;\n\nnamespace DotnetDocsShow.OldWebApi;\n\npublic class Startup\n{\n public Startup(IConfigu"
},
{
"path": "DotnetDocsShow.OldWebApi/WeatherForecast.cs",
"chars": 259,
"preview": "namespace DotnetDocsShow.OldWebApi;\n\npublic class WeatherForecast\n{\n public DateTime Date { get; set; }\n\n public i"
},
{
"path": "DotnetDocsShow.OldWebApi/appsettings.Development.json",
"chars": 159,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft\": \"Warning\",\n \"Microsoft.Hostin"
},
{
"path": "DotnetDocsShow.OldWebApi/appsettings.json",
"chars": 182,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft\": \"Warning\",\n \"Microsoft.Hostin"
},
{
"path": "DotnetDocsShow.PerformanceTests/DotnetDocsShow.PerformanceTests.csproj",
"chars": 423,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <OutputType>Exe</OutputType>\n <TargetFramework>net"
},
{
"path": "DotnetDocsShow.PerformanceTests/Program.cs",
"chars": 1590,
"preview": "using NBomber.Contracts;\nusing NBomber.CSharp;\nusing NBomber.Plugins.Http.CSharp;\n\nvar httpFactory = HttpClientFactory."
},
{
"path": "DotnetDocsShow.Structured.Extensions/Customers/Customer.cs",
"chars": 187,
"preview": "namespace DotnetDocsShow.Structured.Extensions.Customers;\n\npublic class Customer\n{\n public Guid Id { get; } = Guid.N"
},
{
"path": "DotnetDocsShow.Structured.Extensions/Customers/CustomerEndpoints.cs",
"chars": 1650,
"preview": "namespace DotnetDocsShow.Structured.Extensions.Customers;\n\npublic static class CustomerEndpoints\n{\n public static vo"
},
{
"path": "DotnetDocsShow.Structured.Extensions/Customers/CustomerService.cs",
"chars": 849,
"preview": "namespace DotnetDocsShow.Structured.Extensions.Customers;\n\npublic class CustomerService : ICustomerService\n{\n privat"
},
{
"path": "DotnetDocsShow.Structured.Extensions/Customers/ICustomerService.cs",
"chars": 262,
"preview": "namespace DotnetDocsShow.Structured.Extensions.Customers;\n\npublic interface ICustomerService\n{\n void Create(Customer"
},
{
"path": "DotnetDocsShow.Structured.Extensions/DotnetDocsShow.Structured.Extensions.csproj",
"chars": 263,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <OutputType>Exe</OutputType>\n <TargetFramework"
},
{
"path": "DotnetDocsShow.Structured.Extensions/Program.cs",
"chars": 216,
"preview": "using DotnetDocsShow.Structured.Extensions.Customers;\n\nvar builder = WebApplication.CreateBuilder(args);\n\nbuilder.Servi"
},
{
"path": "DotnetDocsShow.Structured.Mediator/DotnetDocsShow.Structured.Mediator.csproj",
"chars": 399,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <OutputType>Exe</OutputType>\n <TargetFramework"
},
{
"path": "DotnetDocsShow.Structured.Mediator/Handlers/CreateCustomerRequestHandler.cs",
"chars": 1133,
"preview": "using System.Text.Json.Serialization;\nusing DotnetDocsShow.Structured.Mediator.Models;\nusing DotnetDocsShow.Structured."
},
{
"path": "DotnetDocsShow.Structured.Mediator/Handlers/DeleteCustomerByIdRequestHandler.cs",
"chars": 873,
"preview": "using System.Text.Json.Serialization;\nusing DotnetDocsShow.Structured.Mediator.Services;\nusing MediatR;\n\nnamespace Dotn"
},
{
"path": "DotnetDocsShow.Structured.Mediator/Handlers/GetAllCustomersRequestHandler.cs",
"chars": 735,
"preview": "using DotnetDocsShow.Structured.Mediator.Services;\nusing MediatR;\n\nnamespace DotnetDocsShow.Structured.Mediator.Handler"
},
{
"path": "DotnetDocsShow.Structured.Mediator/Handlers/GetCustomerByIdRequestHandler.cs",
"chars": 956,
"preview": "using System.Text.Json.Serialization;\nusing DotnetDocsShow.Structured.Mediator.Services;\nusing MediatR;\n\nnamespace Dotn"
},
{
"path": "DotnetDocsShow.Structured.Mediator/Models/Customer.cs",
"chars": 188,
"preview": "namespace DotnetDocsShow.Structured.Mediator.Models;\n\npublic class Customer\n{\n public Guid Id { get; init; } = Guid."
},
{
"path": "DotnetDocsShow.Structured.Mediator/Program.cs",
"chars": 889,
"preview": "using DotnetDocsShow.Structured.Mediator;\nusing DotnetDocsShow.Structured.Mediator.Handlers;\nusing DotnetDocsShow.Struc"
},
{
"path": "DotnetDocsShow.Structured.Mediator/Services/CustomerService.cs",
"chars": 896,
"preview": "using DotnetDocsShow.Structured.Mediator.Models;\n\nnamespace DotnetDocsShow.Structured.Mediator.Services;\n\npublic class "
},
{
"path": "DotnetDocsShow.Structured.Mediator/Services/ICustomerService.cs",
"chars": 309,
"preview": "using DotnetDocsShow.Structured.Mediator.Models;\n\nnamespace DotnetDocsShow.Structured.Mediator.Services;\n\npublic interf"
},
{
"path": "DotnetDocsShow.Structured.Scanning/DotnetDocsShow.Structured.Scanning.csproj",
"chars": 374,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <OutputType>Exe</OutputType>\n <TargetFramework"
},
{
"path": "DotnetDocsShow.Structured.Scanning/EndpointDefinitionExtensions.cs",
"chars": 1218,
"preview": "namespace DotnetDocsShow.Structured.Scanning;\n\npublic static class EndpointDefinitionExtensions\n{\n public static voi"
},
{
"path": "DotnetDocsShow.Structured.Scanning/EndpointDefinitions/CustomerEndpointDefinition.cs",
"chars": 1714,
"preview": "using DotnetDocsShow.Structured.Scanning.Models;\nusing DotnetDocsShow.Structured.Scanning.Services;\n\nnamespace DotnetDo"
},
{
"path": "DotnetDocsShow.Structured.Scanning/EndpointDefinitions/PaymentsEndpointDefinition.cs",
"chars": 273,
"preview": "namespace DotnetDocsShow.Structured.Scanning.EndpointDefinitions;\n\npublic class PaymentsEndpointDefinition : IEndpointD"
},
{
"path": "DotnetDocsShow.Structured.Scanning/EndpointDefinitions/SwaggerEndpointDefinition.cs",
"chars": 660,
"preview": "using Microsoft.OpenApi.Models;\n\nnamespace DotnetDocsShow.Structured.Scanning.EndpointDefinitions;\n\npublic class Swagge"
},
{
"path": "DotnetDocsShow.Structured.Scanning/IEndpointDefinition.cs",
"chars": 190,
"preview": "namespace DotnetDocsShow.Structured.Scanning;\n\npublic interface IEndpointDefinition\n{\n void DefineServices(IServiceC"
},
{
"path": "DotnetDocsShow.Structured.Scanning/Models/Customer.cs",
"chars": 188,
"preview": "namespace DotnetDocsShow.Structured.Scanning.Models;\n\npublic class Customer\n{\n public Guid Id { get; init; } = Guid."
},
{
"path": "DotnetDocsShow.Structured.Scanning/Program.cs",
"chars": 234,
"preview": "using DotnetDocsShow.Structured.Scanning;\n\nvar builder = WebApplication.CreateBuilder(args);\nbuilder.Services.AddEndpoi"
},
{
"path": "DotnetDocsShow.Structured.Scanning/Services/CustomerService.cs",
"chars": 896,
"preview": "using DotnetDocsShow.Structured.Scanning.Models;\n\nnamespace DotnetDocsShow.Structured.Scanning.Services;\n\npublic class "
},
{
"path": "DotnetDocsShow.Structured.Scanning/Services/ICustomerService.cs",
"chars": 309,
"preview": "using DotnetDocsShow.Structured.Scanning.Models;\n\nnamespace DotnetDocsShow.Structured.Scanning.Services;\n\npublic interf"
},
{
"path": "DotnetDocsShow.Tests.Integration/BroadCustomerEndpointsTests.cs",
"chars": 1557,
"preview": "using System;\nusing System.Net;\nusing System.Net.Http.Json;\nusing System.Text.Json;\nusing System.Threading.Tasks;\nusing"
},
{
"path": "DotnetDocsShow.Tests.Integration/DotnetDocsShow.Tests.Integration.csproj",
"chars": 1311,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net6.0</TargetFramework>\n <Nullab"
},
{
"path": "DotnetDocsShow.Tests.Integration/NarrowCustomerEndpointsTests.cs",
"chars": 1905,
"preview": "using System;\nusing System.Net;\nusing System.Text.Json;\nusing System.Threading.Tasks;\nusing DotnetDocsShow.MinimalApiTe"
},
{
"path": "DotnetDocsShow.Tests.Integration/TestApplicationFactory.cs",
"chars": 706,
"preview": "using System;\nusing Microsoft.AspNetCore.Mvc.Testing;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.E"
},
{
"path": "DotnetDocsShow.Tests.Unit/CustomerEndpointDefinitionTests.cs",
"chars": 1344,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing DotnetDocsShow.MinimalApiTests.Structured.Endp"
},
{
"path": "DotnetDocsShow.Tests.Unit/DotnetDocsShow.Tests.Unit.csproj",
"chars": 1210,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net6.0</TargetFramework>\n <Nullab"
},
{
"path": "DotnetDocsShow.Tests.Unit/ResultExtensions.cs",
"chars": 1373,
"preview": "using System;\nusing Microsoft.AspNetCore.Http;\n\nnamespace DotnetDocsShow.Tests.Unit;\n\npublic static class ResultExtensi"
},
{
"path": "DotnetDocsShow.Weather.MinimalApi/DotnetDocsShow.Weather.MinimalApi.csproj",
"chars": 374,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <OutputType>Exe</OutputType>\n <TargetFramework"
},
{
"path": "DotnetDocsShow.Weather.MinimalApi/Program.cs",
"chars": 605,
"preview": "using DotnetDocsShow.Weather.MinimalApi;\n\nvar builder = WebApplication.CreateBuilder(args);\n\n// Add services to the con"
},
{
"path": "DotnetDocsShow.Weather.MinimalApi/WeatherEndpoints.cs",
"chars": 858,
"preview": "namespace DotnetDocsShow.Weather.MinimalApi;\n\npublic static class WeatherEndpoints\n{\n private static Random Random ="
},
{
"path": "DotnetDocsShow.Weather.MinimalApi/WeatherForecast.cs",
"chars": 270,
"preview": "namespace DotnetDocsShow.Weather.MinimalApi;\n\npublic class WeatherForecast\n{\n public DateTime Date { get; set; }\n\n "
},
{
"path": "DotnetDocsShow.Weather.MinimalApi/appsettings.json",
"chars": 182,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft\": \"Warning\",\n \"Microsoft.Hostin"
},
{
"path": "DotnetDocsShow.sln",
"chars": 8689,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\nProject(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"1. Co"
}
]
About this extraction
This page contains the full source code of the Elfocrash/DotnetDocsShow.MinimalApis GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 76 files (61.0 KB), approximately 18.6k tokens, and a symbol index with 172 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.