Program by Microsoft
NuGet / site data
Details
Info
Name: Program
Provides APIs for annotating route handler endpoints in ASP.NET Core with OpenAPI annotations.
This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/e77cb01b5529c137130757859f09f892dbdd2436
Author: Microsoft
NuGet: https://www.nuget.org/packages/Microsoft.AspNetCore.OpenApi
You can find more details at https://github.com/dotnet/aspnetcore/blob/70d851104f739fb906aabcd6a07c0935ce2549c9/src/Framework/AspNetCoreAnalyzers/src/SourceGenerators/PublicTopLevelProgramGenerator.cs#L11
Author
Microsoft

Original Readme
ASP.NET Core
ASP.NET Core is an open-source and cross-platform framework for building modern cloud-based internet-connected applications, such as web apps, IoT apps, and mobile backends. ASP.NET Core apps run on .NET, a free, cross-platform, and open-source application runtime. It was architected to provide an optimized development framework for apps that are deployed to the cloud or run on-premises. It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions. You can develop and run your ASP.NET Core apps cross-platform on Windows, Mac, and Linux. Learn more about ASP.NET Core.
Get started
Follow the Getting Started instructions.
Also check out the .NET Homepage for released versions of .NET, getting started guides, and learning resources.
See the Triage Process document for more information on how we handle incoming issues.
How to engage, contribute, and give feedback
Some of the best ways to contribute are to try things out, file issues, join in design conversations, and make pull-requests.
- Download our latest daily builds
- Follow along with the development of ASP.NET Core:
- Community Standup: The community standup is held every week and streamed live on YouTube. You can view past standups in the linked playlist.
- Roadmap: The schedule and milestone themes for ASP.NET Core.
- Build ASP.NET Core source code
- Check out the contributing page to see the best places to log issues and start discussions.
Reporting security issues and bugs
Security issues and bugs should be reported privately to the Microsoft Security Response Center (MSRC) via the MSRC Researcher Portal. You should receive a response within 24 hours. Further information can be found in the MSRC Report an Issue FAQ. You can also find these instructions in this repo's Security doc.
Also see info about related Microsoft .NET Bounty Program.
Related projects
These are some other repos for related projects:
- Documentation - documentation sources for https://learn.microsoft.com/aspnet/core/
- Entity Framework Core - data access technology
- Runtime - cross-platform runtime for cloud, mobile, desktop, and IoT apps
- Razor - the Razor compiler and tooling for working with Razor syntax (.cshtml, .razor)
Code of conduct
See CODE-OF-CONDUCT
Nightly builds
This table includes links to download the latest builds of the ASP.NET Core Shared Framework. Also included are links to download the Windows Hosting Bundle, which includes the ASP.NET Core Shared Framework, the .NET Runtime Shared Framework, and the IIS plugin (ASP.NET Core Module). You can download the latest .NET Runtime builds here, and the latest .NET SDK builds here. If you're unsure what you need, then install the SDK; it has everything except the IIS plugin.
| Platform | Shared Framework (Installer) | Shared Framework (Binaries) | Hosting Bundle (Installer) |
|---|---|---|---|
| Windows x64 | Installer | Binaries | Installer |
| Windows x86 | Installer | Binaries | Installer |
| Windows arm64 | Installer | Binaries | Installer |
| macOS x64 | N/A | Binaries | N/A |
| macOS arm64 | N/A | Binaries | N/A |
| Linux x64 | Deb Installer - RPM Installer | Binaries | N/A |
| Linux arm | N/A | Binaries | N/A |
| Linux arm64 | RPM Installer | Binaries | N/A |
| Linux-musl-x64 | N/A | Binaries | N/A |
| Linux-musl-arm | N/A | Binaries | N/A |
| Linux-musl-arm64 | N/A | Binaries | N/A |
About
Generating Program.cs class for testing purposes
How to use
Example (source csproj, source files)
- CSharp Project
- Program.cs
This is the CSharp Project that references Program
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<PublishAot>true</PublishAot>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
</ItemGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>
This is the use of Program in Program.cs
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Http.HttpResults;
var builder = WebApplication.CreateSlimBuilder(args);
builder.Services.ConfigureHttpJsonOptions(options =>
{
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
});
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
Todo[] sampleTodos =
[
new(1, "Walk the dog"),
new(2, "Do the dishes", DateOnly.FromDateTime(DateTime.Now)),
new(3, "Do the laundry", DateOnly.FromDateTime(DateTime.Now.AddDays(1))),
new(4, "Clean the bathroom"),
new(5, "Clean the car", DateOnly.FromDateTime(DateTime.Now.AddDays(2)))
];
var todosApi = app.MapGroup("/todos");
todosApi.MapGet("/", () => sampleTodos)
.WithName("GetTodos");
todosApi.MapGet("/{id}", Results<Ok<Todo>, NotFound> (int id) =>
sampleTodos.FirstOrDefault(a => a.Id == id) is \{ \} todo
? TypedResults.Ok(todo)
: TypedResults.NotFound())
.WithName("GetTodoById");
app.Run();
public record Todo(int Id, string? Title, DateOnly? DueBy = null, bool IsComplete = false);
[JsonSerializable(typeof(Todo[]))]
internal partial class AppJsonSerializerContext : JsonSerializerContext
{
}
Generated Files
Those are taken from $(BaseIntermediateOutputPath)\GX
- PublicTopLevelProgram.Generated.g.cs
// <auto-generated />
/// <summary>
/// Auto-generated public partial Program class for top-level statement apps.
/// </summary>
public partial class Program \{ }
Useful
Download Example (.NET C#)
Share Program
https://ignatandrei.github.io/RSCG_Examples/v2/docs/Program
Category "EnhancementClass" has the following generators:
5 DudNet
8 Immutype
10 Lombok.NET
13 MemoryPack
15 Microsoft.Extensions.Logging
16 Microsoft.Extensions.Options.Generators.OptionsValidatorGenerator
17 Microsoft.Interop.JavaScript.JSImportGenerator
19 Program
25 System.Runtime.InteropServices
26 System.Text.RegularExpressions
28 ThisClass