Ask HN: Examples of Top C# Code?

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • FrameworkBenchmarks

    Source for the TechEmpower Framework Benchmarks project

  • Specifically, comparing Responses per second between C# and javascript web frameworks:

    https://www.techempower.com/benchmarks/#section=data-r21&tes...

    One JS framework smokes, but most of the C# ones are above the JS ones. I don't know what's that "just-js" thing at the top though, I suspect it's not really a framework.

  • Stripe.Net

    Stripe.net is a sync/async .NET 4.6.1+ client, and a portable class library for stripe.com.

  • I like the Stripe API design, and as a follow-on, I tend to like their coding styles and structures. Here's their official Stripe dotnet library - https://github.com/stripe/stripe-dotnet. It's well organized and the code coverage looks good.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • runuo

    RunUO

  • IdentityServer

    The most flexible and standards-compliant OpenID Connect and OAuth 2.x framework for ASP.NET Core

  • calculator

    Windows Calculator: A simple yet powerful calculator that ships with Windows

  • Roslyn

    The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.

  • referencesource

    Source from the Microsoft .NET Reference Source that represent a subset of the .NET Framework

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • dotnet

    This repo is the official home of .NET on GitHub. It's a great starting point to find many .NET OSS projects from Microsoft and the community, including many that are part of the .NET Foundation.

  • UnityCsReference

    Unity C# reference source code.

  • awesome-dotnet

    A collection of awesome .NET libraries, tools, frameworks and software

  • osu

    rhythm is just a *click* away!

  • In my personal opinion, the rhythm game osu! [1] and the related osu!framework [2] are great examples of C# code.

    [1] https://github.com/ppy/osu

  • osu-framework

    A game framework written with osu! in mind.

  • Bitwarden

    The core infrastructure backend (API, database, Docker, etc). (by bitwarden)

  • Not a .NET developer, but even as such, the Bitwarden code was very readable to me https://github.com/bitwarden/server

  • CleanArchitecture

    Clean Architecture Solution Template: A starting point for Clean Architecture with ASP.NET Core (by ardalis)

  • This repository is a good place to start with modern c# code, specifically ASP.NET

    https://github.com/ardalis/CleanArchitecture

  • MySqlConnector

    MySQL Connector for .NET

  • I have had the pleasure of contributing to a couple different networked drivers with very talented maintainers that I like to use as references.

    One supports a wide array of Framework versions and has both Sync and Async I/O, as it must to implement the ADO.NET database driver interfaces. Reading the internals really highlight the way that .NET has evolved over the years and what must be done in each target version to maximize performance:

    https://github.com/mysql-net/MySqlConnector

    The other supports .NET 6 only with Async I/O only. This support policy seems to be the way that "modern" .NET development is headed, as .NET 6 will be the floor for LTS .NET (formerly .NET Core) releases in a few months. Async APIs only greatly simplify development, and make it simpler to remain performant when targeting WASM.

    https://github.com/Cysharp/AlterNats

    As a library maintainer, one thing I often wonder about is how to indicate .NET version support. One option would be for the major version of the library to track the major version of .NET, so if I were to publish a new library today then start with .NET 6 support and start with version number 6.0.0 instead of 1.0.0. This would limit the library to only making breaking changes when the .NET version changes though.

  • AlterNats

    Discontinued An alternative high performance NATS client for .NET.

  • I have had the pleasure of contributing to a couple different networked drivers with very talented maintainers that I like to use as references.

    One supports a wide array of Framework versions and has both Sync and Async I/O, as it must to implement the ADO.NET database driver interfaces. Reading the internals really highlight the way that .NET has evolved over the years and what must be done in each target version to maximize performance:

    https://github.com/mysql-net/MySqlConnector

    The other supports .NET 6 only with Async I/O only. This support policy seems to be the way that "modern" .NET development is headed, as .NET 6 will be the floor for LTS .NET (formerly .NET Core) releases in a few months. Async APIs only greatly simplify development, and make it simpler to remain performant when targeting WASM.

    https://github.com/Cysharp/AlterNats

    As a library maintainer, one thing I often wonder about is how to indicate .NET version support. One option would be for the major version of the library to track the major version of .NET, so if I were to publish a new library today then start with .NET 6 support and start with version number 6.0.0 instead of 1.0.0. This would limit the library to only making breaking changes when the .NET version changes though.

  • Cursively

    A CSV reader for .NET. Fast, RFC 4180 compliant, and fault tolerant. UTF-8 only.

  • I was looking at the CSV parser Cursively recently, and I think it is a good simple example of a high performance C# parser and API design.

    https://github.com/airbreather/Cursively

  • ClassicUO

    ClassicUO - an open source implementation of the Ultima Online Classic Client.

  • Might enjoy taking a look at Classic UO. It's UO, written in .NET, to run in the browser...

    https://github.com/ClassicUO/ClassicUO

    https://www.classicuo.org/

  • dotNext

    Next generation API for .NET

  • "DotNEXT" is a repo that enhances the code from .NET core, and has examples of using new API's that you can't even find tutorials for on the internet/examples from in public code.

    For instance, there's been a class since .NET 6, "RandomAccess", for high-performance random-access file I/O (potentially async), and I couldn't find a single damn use of it on the internet.

    But then this repo had a whole utility class for it, and it's chock full of similar things:

    https://github.com/dotnet/dotNext/blob/d4111528297ff3b6567b9...

    Similarly, I would recommend stuff by the .NET core team.

    I'm particular biased towards the low-level/interop team. Anything by Tanner Gooding is great, stuff by Michal Strehovský, Aaron Robinson, Elinor Fung.

  • NodaTime

    A better date and time API for .NET

  • adventofcode

    :christmas_tree: Advent of Code (2015-2023) in C# (by encse)

  • Solutions to Advent of Code problems that people publish on github tend to be fairly short but readable, and most show off the language.

    This is not "real" production C# code. Real production code would have a lot more checks for edge conditions and error handling that would obfuscate the meaning. But it's good in order to get a feel for the capabilities of the language and its ecosystem, imo.

    There are a couple of repos you can browse, I recommend this one, but only if you have some basic knowledge of LINQ and/or functional programming in general, else this might scare you off. But even if you don't, you could try to figure out how the solution to the first couple of problems in each year work, and learn through that. This guy tries to use the newest features of the language so it can confusing at time. He includes the full text of the problems in the repo so you can try to understand what's he's trying to do.

    https://github.com/encse/adventofcode

    Also solving AOC with C# has its own github topic:

    https://github.com/topics/advent-of-code-csharp

  • js-ts-csharp

    A repository demonstrating functional techniques with C# 10 and the similarities between JavaScript, TypeScript, and C#.

  • > C# is VERY different from even just what things were 2 years ago

    C# and TypeScript are converging (both from Anders Hjelsberg).

    Small repo here showing just how similar they are syntactically: https://github.com/CharlieDigital/js-ts-csharp

    I'm surprised we don't see a bigger uptick in C# usage given the growth of TypeScript and how similar the two languages are. If you know C#, it's pretty easy to pick up TypeScript and vice versa.

  • grpc_bench

    Various gRPC benchmarks

  • Also worth checking out the gRPC benchmarks: https://github.com/LesnyRumcajs/grpc_bench/discussions/284

    dotnet is up there with Rust.

  • eShopOnWeb

    Sample ASP.NET Core 8.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder.

  • NancyFx

    Discontinued Lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono. Note: This project is no longer maintained and has been archived.

  • Nancyfx - sadly dead in the water now but well worth a read of both the code and docs https://github.com/NancyFx/Nancy/tree/master/

  • .NET Runtime

    .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.

  • ReferenceSource is the code from the Windows framework and I'm pretty sure it should be considered deprecated at this point. The runtime and core libraries are now at https://github.com/dotnet/runtime, kinda weird that this is not directly linked in the home page repo.

  • TodoApi

    Todo application with ASP.NET Core Blazor WASM, Minimal APIs and Authentication

  • A basic example looks like: https://github.com/davidfowl/CommunityStandUpMinimalAPI/blob...

    Some more documentation on integration tests: https://learn.microsoft.com/en-us/aspnet/core/test/integrati...

  • oqtane.framework

    CMS & Application Framework for Blazor & .NET MAUI

  • It looks promising

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts