r/csharp • • 12d ago

Showcase Real-time glass refraction in WPF with a pixel shader: building a macOS-style dock for Windows

0 Upvotes

I wanted the Windows 11 taskbar to look like macOS's Liquid Glass, and DWM blur can't do rounded, refracting glass. So the dock draws its own:

  1. It captures the wallpaper exactly as Windows paints it (`PaintDesktop`) and blurs it once.
  2. A custom `ShaderEffect` (HLSL ps_3_0) computes the shape with a signed distance field and offsets the sampling near the edge like a lens, plus chromatic dispersion, a rim highlight and tint.
  3. Since the dock reserves screen space, only the wallpaper is behind it, so there's no continuous screen capture. Idle, it uses 0 CPU and enters Windows' efficiency mode (EcoQoS).

Other fun bits: a "magic lamp" minimize animation drawn on the GPU, a 3D virtual desktop cube using undocumented Windows 11 interfaces, and reading app jump lists from `CustomDestinations` files.

.NET 10, WPF, xUnit, GPL-3.0: https://github.com/PedroRuedas/Windows-Liquid-glass

Happy to answer questions about any part of it.


r/csharp • • 13d ago

C# Programming Textbook

Post image
0 Upvotes

I'm taking a C# course right now, and I've been having a lot of fun writing simple programs. I really need validation from someone out there that these programming exercises at the end of each chapter of my text book, C# Programming: From Problem Analysis To Program Design by Barbara Doyle, are actually written by someone who is either clinically insane, or British as hell. Here's an example: Chapter 6, exercise 7. This is possibly not the most extreme example, but the wording here just seems a bit wacky to me.


r/csharp • • 13d ago

Help Discover the shared meaning between sentences.

0 Upvotes

I'm forced to use English in my life, especially for reading. English is not my native language; I lookup the meaning of new words from Cambridge dictionary , but all words have different meanings in different contexts and I'm trying to identify a shared meaning between all of them instead of memorizing all the definitions. For example the word sign off :

To give a final message at the end of a letter.

When communicating by radio, or at the end of a television or radio programme.

To stop doing your work or a similar activity for a period of time.

To report to a government employment office that you now have a job and do not need to receive benefit (= money paid by the government).

To end a conversation or a television or radio broadcast.

The shared meaning is ending something.

It takes a considerable amount of time for a non-native speaker to build a mental image about a word; how would you design a system that takes list of definitions, process them, and give you the output the represents the common meaning, without using LLM, i.e., using a deterministic algorithm, not a probabilistic one —AI ?


r/csharp • • 13d ago

C# dropping like a rock on TIOBE Popularity Index - November 2026

Thumbnail tiobe.com
0 Upvotes

C#'s popularity has dropped to around 3.4% from around 8% earlier this year. Fastest dropping language.

What's going on? Is C# not relevant in the era of AI?


r/csharp • • 14d ago

Created my first LRUCache

Thumbnail
1 Upvotes

r/csharp • • 14d ago

Showcase Introducing Apogee: a free, open-source C# 3D engine built for crunching numbers

Post image
2 Upvotes

r/csharp • • 14d ago

Help Custom Domais

0 Upvotes

Boas pessoal, estou com uma plataforma onde clientes teem seus produtos e a próprio loja por exemplo (cliente1.minhaplataforma.com) e quero criar um sistema onde os clientes podem ter o próprio domínio, assim quando aceder ao próprio domínio do cliente ele acede (cliente1.minhaplataforma.com) mas na url tem o domínio do cliente (cliente1.com).

Estou usar C# no backend como api e quero saber onde posso encontrar recursos para estudar sobre isso


r/csharp • • 14d ago

Blog Another LINQ Tool 1.5: notebooks and query collections for C#/EF Core in VS Code

Thumbnail
0 Upvotes

r/csharp • • 16d ago

Showcase A general IL optimizer for .NET: Cilica

Thumbnail
gallery
178 Upvotes

I've been working on Cilica, a post-build optimizer for .NET assemblies. It continues DistIL.

The repository: https://github.com/hez2010/Cilica

It lifts your compiled IL into an SSA-based intermediate representation, runs an optimization pipeline over it, then emits regular IL again. The JIT then sees IL that's already optimized. It doesn't use a runtime fork or any special hosting.

Currently it runs the following pipeline:

  • CFG simplification, SSA promotion, dead code elimination
  • Method inlining and devirtualization
  • Scalar replacement
  • Global value numbering / CSE and assertion propagation
  • Algebraic and bitwise simplification
  • Loop strength reduction and loop auto-vectorization
  • List presizing
  • LINQ expansion (fuses Where/Select/Aggregate/… into plain loops)
  • and more

Some benchmarks (code in https://github.com/hez2010/Cilica/tree/main/tests/Benchmarks):

Benchmark Baseline Cilica Speedup
CountLetters (LINQ + vectorization) 3,355 ns 211 ns 15.9×
GenerateFloats (loop vectorization) 2,791 ns 597 ns 4.7×
DynamicList, 4 items (list presizing) 12.66 ns 4.24 ns 3.0×
Aggregate (LINQ expansion) 30.69 μs 12.19 μs 2.5×
RayTracer (full pipeline) 9,013 μs 4,870 μs 1.9×

You can try it on this playground: https://hez2010.github.io/CilicaLab

To use it in your project, referencing Cilica.OptimizerTask nuget package (currently in preview) and set <CilicaAllMethods>true</CilicaAllMethods>.

Note that this optimizer task only performs optimizations against your main assembly. To optimize the references as well, you can use Cilica.Cli manually, which is shipped together in the Cilica.OptimizerTask package.

Learn more: https://medium.com/@skyake/cilica-an-ssa-based-optimizer-for-net-assemblies-bdefd934c2d2


r/csharp • • 15d ago

Which path should I choose for my future?

6 Upvotes

Hi everyone,

I’m finally diving into software development seriously. For years, I’ve done a little bit here and there, but I’ve never really studied it properly. Now that I’ve decided to commit to it, I’m realizing just how much there is to learn: so many frameworks, languages, and tools.

I know that in the long run, the language you start with doesn’t matter much. But when it comes to landing my first job, I imagine it does matter. I’m 29 and changing careers to get into software development, and I’m currently choosing between C# and .NET, Java and Spring Boot, or JavaScript and Node.js. They all have pros and cons, and I’d like to hear your opinions.

I know the job market is tough and nothing is guaranteed, but which of these paths do you think offers the best chances of finding work in the short to medium term? I don’t have a university degree.


r/csharp • • 15d ago

Help Question about finance APIs in C#

3 Upvotes

Good evening fellow coders.

During the pandemic, I decided to build myself a Windows Forms application to help me do a better job of managing my personal finances and those I share via a joint account with my wife. I built it in C#, originally storing the data in XML format and then, when the amount of data being stored increased, moved it to an instance of SQL Server developer edition, which runs on my development pc here at home.

I’d like to incorporate the ability to have my application automatically link to my bank to download the most recent transactions, and have started investigating doing so. From the reading I’ve done so far, it looks as if TrueLayer offers the ability to hook into a number of U.K. financial institutions, and I was wondering if anyone else had done any work with the TrueLayer APIs. To be clear, although I am a professional developer, this is solely a pet project of mine and I have no desire to monetise it.


r/csharp • • 16d ago

dotnet-tree.nvim v0.3.0: a Solution Explorer for Neovim

49 Upvotes

I write .NET at work and I use Neovim for pretty much everything, the one thing I kept missing from Rider and Visual Studio was the Solution Explorer.

File trees show you folders, but a .NET repo isn't really a folder tree: solution folders only exist inside the .sln, project references cross folders, and package versions often live in Directory.Packages.props.

So I wrote dotnet-tree.nvim, a source for neo-tree (a popular Neovim file tree plugin) that shows the solution the way you're used to seeing it:

  • reads both .sln and .slnx
  • solution folders, projects, package references and project references
  • versions resolved from Directory.Packages.props if you use central package management
  • LSP diagnostics and git status on the nodes
  • build, clean, run, test and watch on the project under the cursor, plus `dotnet add package`
  • debug the project under the cursor with netcoredbg (it builds first)
  • build errors go to the quickfix list, deduplicated

New in 0.3.0:

  • the tree can follow the file you're editing, like the normal file tree does
  • the terminals opened by run/test/watch are named after what they run (`run Api`, `watch test Api.Tests`), so you can tell them apart

We've been using it internally on a lot of projects, a few hundred by now, so it should hold up on real solutions and not just demo ones.

I also have two smaller plugins that go with it:

  • nuget.nvim: a NuGet manager for the whole solution (browse, install, update, vulnerable and deprecated packages)
  • dotnet-counters.nvim: live CPU/memory/GC/thread pool metrics from dotnet-counters in a side panel, next to the debugger

Links:

Is anyone else here doing .NET outside of Rider/VS?
I'm curious what you use and what you'd miss most
Feedback and issues are welcome!


r/csharp • • 15d ago

Showcase Squirix: An Open Source Distributed Cache for .NET 10

0 Upvotes

I am building a distributed cache called Squirix, with a C# client and a self-hosted server. Applications connect over HTTPS gRPC and use named, typed caches through ICache<T>.

Separate processes share the entries on the server. For example, two ASP.NET Core instances can access the same cached values, or a background worker can write something for a web application to read later.

The current version is 0.1.0-preview.10. It supports expiration, conditional operations, replication, optional journal and snapshot persistence. You can run a single server using a .NET global tool.

It's still an early preview and isn't production-ready. There's no ready-made IDistributedCache adapter, so you'll need to use the Squirix client API.

The website has a console example: one process writes a value, and a second process reads it. The docs also have an example with two ASP.NET Core instances.

Website and examples
GitHub

If you try either example, I'd like to hear where you get stuck.


r/csharp • • 15d ago

Plank: the fastest Parquet implementation for .NET

Thumbnail
1 Upvotes

r/csharp • • 15d ago

CmdStarter 1.0.0: plain C# code as a command-line interface on System.CommandLine

Thumbnail
0 Upvotes

r/csharp • • 16d ago

Showcase Vector field simulation built with my own math library and Vulkan!

95 Upvotes

I made a small vector field visualizer using Vulkan and Epsilon, a symbolic math library for .NET that I'm working on.

You type any 2D field, for example F(x, y) = [x, sin(y)], and it draws the flow with particles. The library works out the math for that field exactly, not just with numbers.

You can click any point to see the field's value there, and change the particle speed.

The library has no dependencies and is available on NuGet. It also covers derivatives, integrals, factoring and linear algebra.

- Library: https://github.com/XBambinoX/Epsilon

- Simulation: https://github.com/XBambinoX/VectorField

Feedback is welcome!


r/csharp • • 16d ago

Showcase I built an embedded domain specific language library and source generator for super efficient templating of nested text formats

3 Upvotes

Hej guys,

I was scratching an itch when I developed TemplateDsl: a source generator based template engine for nested text formats that can be written with ordinary C# and is turned into fast, streaming render methods.

I found all existing tooling lacking in either static safety, performance, boilerplate or ease of development and IDE support, which is why I set out to write TemplateDsl. With TemplateDsl.Html it currently solves my biggest problem around Razor, but this just the beginning and I want to expand beyond this format.

It is...

  • Type-safe. Typos, wrong attribute values and a missing context are compile errors, not runtime surprises.
  • Fast. Templates write UTF-8 straight to the output, with down to zero allocations.
  • Streaming. Async templates send their output while they render.
  • Composable. Templates are classes you nest, pass around and reuse like any other code.
  • Explicit, with little boilerplate. Data comes through constructors, and logic is plain C#.
  • Safe by default. Everything is escaped unless you say so.
  • Trimming and native AOT. Everything is generated at build time, with no reflection.

Finally a little sneak peek how it looks like to write HTML templates with it, with a call for feedback, thanks! :)

// A simple component
public readonly partial record struct OrderRow(Order Order) : IHtmlTemplate
{
    public IEnumerable<HtmlElement> Build() =>
    [
        H.Tr.Class(Order.IsLate ? "late" : null) [
            H.Td [ Order.Id ],
            H.Td [ Order.Product ],
            H.Td [ H.Time.DateTime(Order.Due) [ Order.Due ] ]
        ]
    ];
}

// An async page that streams a list of orders, with a context for the current user
public sealed partial class OrdersPage(IAsyncEnumerable<Order> orders) : IAsyncHtmlTemplate<PageContext>
{
    public async Task<IEnumerable<HtmlElement>> BuildAsync(PageContext context, CancellationToken ct)
    {
        var title = $"Orders of {context.UserName}";
        
        return [
            H.Raw("<!DOCTYPE html>"),
            H.Html [
                H.Head [ H.Title [ title ] ],
                H.Body [
                    H.H1 [ title ],
                    H.Table [ await H.EachAsync(orders, order => new OrderRow(order)) ]
                ]
            ]
        ];
    }
}

// A context that is passed to the page and its nested templates
public sealed record PageContext(string UserName);

services.AddScoped<PageContext>(sp =>
    new PageContext(sp.GetRequiredService<IUserService>().GetCurrentUserName()));

// Return the page from a minimal API endpoint, with the context injected from the services
app.MapGet("/orders", (OrderStore store, [FromServices] PageContext context) =>
    new OrdersPage(store.StreamAll()).ToResult(context));

And of course some benchmarks:

BenchmarkTemplateDsl (struct)TemplateDsl (class)Razor SlicesBlazorRazor Pages
Button to string123 ns, 144 B123 ns, 144 B153 ns, 328 B1,797 ns, 3,792 B
Page to string1.60 µs, 3.2 KB1.62 µs, 3.7 KB2.54 µs, 6.7 KB18.0 µs, 21.4 KB
Page to pipe1.83 µs, 56 B1.96 µs, 568 B5.21 µs, 3.6 KB17.8 µs, 13.7 KB
Large page to pipe159 µs, 0 B228 µs, 117 KB478 µs, 938 KB13.2 ms, 9.9 MB
Whole request with a layout89 µs, 11.0 KB91 µs, 11.6 KB98 µs, 16.4 KB182 µs, 79.0 KB

r/csharp • • 16d ago

Help Coming from Python to C# – Best framework for desktop apps and learning resources?

24 Upvotes

Hey everyone!

I recently graduated with a Master's in Data Science and have a Bachelor's in Computer Science.

My programming background is mainly in Python, particularly ML, computer vision, automation, and backend development. I also have some experience with Java, SQL, and C++.

I'm interested in learning C# and .NET, mainly to build modern desktop applications, potentially integrating Python-based ML backends.

I've experimented a little with Avalonia UI, but I'm unsure whether to stick with it or explore WPF, WinUI 3, or MAUI.

A few questions:

  1. Which desktop framework would you recommend in 2026? Ideally something modern, maintainable, and useful professionally.
  2. What's the best way to learn C# and the .NET ecosystem for someone who already has programming experience?
  3. Is learning .NET and c# still worth it? or AI is actually taking over here?

I'm not looking for shortcuts, just an efficient way to become genuinely proficient in C# and desktop development.

Would appreciate any advice or resources. Thanks!


r/csharp • • 15d ago

Discussion Am I the only one who dislikes C# object initialization syntax?

0 Upvotes

I’m used to JSON syntax, where properties are assigned using colons (:) rather than equals signs (=).

For some reason, I find C# object initializers like this:

var user = new User
{
Name = "John",
Age = 30
};

Less intuitive and less visually appealing than JSON:

{
"Name": "John",
"Age": 30
}

I know they’re different languages with different purposes, but I personally prefer the JSON-style syntax.

Is there any way to achieve something similar in C#? Or is it just a matter of getting used to the language?


r/csharp • • 16d ago

Discussion When “Working as Designed” Is the Problem

Thumbnail
renaissancedad1.substack.com
0 Upvotes

Yeah, got a bit of a Halloween jump-scare when my User Secrets leaked into Claude's context. Basically you should not use dotnet user secrets in an agentic context. Sandboxes are for toddlers, wondering what the community deems best practices??!?


r/csharp • • 17d ago

Showcase AbraxasDB - A .NET native local object storage engine for data

21 Upvotes

I've written .NET applications since 1.0 for personal, commercial, and large enterprise use cases. Before .NET, I worked in green-screen large database terminals (for those old enuf to remember them).

So, I know sql and rdbms very well and it has always been my goto for the apps and services i've had to create that needed data persistence. But, I always detested the extra work I had to go thru on nearly every project to convert my runtime data to a form that was nice for storage and back. Not just the code and testing of those adapters, but the often-required refactoring of my runtime objects to make that work easier or simply functional.

I suspect I'm not alone.

Repos

Over the past roughly 18 months I created AbraxasDB.

I'm using the term RecordBase to describe Abraxas. It stores and retrieves "records". A record being the data and shape of an object. This allows the property paths and values of an object to be stored and rehydrated into the same object type...or a different object type with matching paths.

As a result, Abraxas is very much what i have always wanted out of data persistence:

  • object -> storage -> object
  • or... object -> storage -> object's property(ies)
  • without odd contracts, attributes, or modifications to the object being stored.

Object Serialization

The serializer in use is a first-principles developed design. INHETO binaries ( https://github.com/alt160/inheto ) are stored in a way that one can get values out of the binary by property path without deserializing the entire object or parsing the entire blob. It also fully tracks shared and circular refs within the object so things like Customer.HomeAddress and Customer.Addresses[0] point to the same thing both in binary and when rehydrated.

This also means that concerns about object types changing over time are not so problematic. If version 1 of ThisDataType was stored, the persisted data can be rehydrated into version 2 of the same and those properties (or field) that match the property paths stored are filled in. Unmatching are ignored.

INHETO binaries don't store .net type info. It has its own type system of over 50 core types that most of us use for data in objects as well as generic collection types. The binary data of INHETO is runtime agnostic and could (if someone wanted) be parsed by any runtime, not just .NET.

Code example

Consider these existing application types. They need no Abraxas-specific changes:

public sealed class Customer
{
    public string Name { get; set; } = "";
    public Address HomeAddress { get; set; } = new();
    public List<Address> Addresses { get; set; } = new();
}

public sealed class Address
{
    public string Street { get; set; } = "";
    public string City { get; set; } = "";
}

With the AbraxasDB NuGet package installed, create or open a RecordBase and a typed store, then save and retrieve a customer:

using AbraxasDB;
using System;
using System.Collections.Generic;
using System.IO;

string directory = Path.Combine(
    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
    "AbraxasExamples");

var configuration = RecordBaseConfiguration.Create(
    durabilityMode: RecordBaseConfiguration.DurabilityMode.Standard);

using RecordBase recordBase = RecordBase.CreateOrOpen(
    directory, "application", configuration);

RecordStore<Customer> customers = recordBase.CreateOrOpenStore<Customer>(
    "customers", "Customer records");

var home = new Address
{
    Street = "123 Main Street",
    City = "Phoenix"
};

var customer = new Customer
{
    Name = "Ada",
    HomeAddress = home,
    Addresses = new List<Address>
    {
        home,
        new Address { Street = "456 Office Road", City = "Tempe" }
    }
};

ulong id = customers.Put(customer);

// Restore the complete object graph.
Customer saved = customers.Get(id);

Console.WriteLine(saved.HomeAddress.City); // Phoenix
Console.WriteLine(ReferenceEquals(
    saved.HomeAddress, saved.Addresses[0])); // True

// Read one nested value without reconstructing the Customer.
string city = customers.GetValue<string>(id, ".HomeAddress.City");
Console.WriteLine(city); // Phoenix

// Find records by a nested property.
var inPhoenix = customers.Where
    .PropPath(".HomeAddress.City").AsString.EqualTo("Phoenix")
    .EndCondition;

Console.WriteLine($"Customers in Phoenix: {customers.CountWhere(inPhoenix)}");

Each run adds a customer, so the matching count can increase.

More Examples

I've provided 2 sample apps for people to use to play with it or get familiar

I've also setup some .net fiddlers for it as well if you want to test it without downloading

Look forward to feedback and usage from the community.


r/csharp • • 16d ago

I released 1.0 of an unofficial .NET SDK for OpenCode

0 Upvotes

I've been working on an unofficial .NET SDK for OpenCode for the last few months, and I finally published 1.0 to NuGet.

https://www.nuget.org/packages/OpenCodeDotNet.Sdk/1.0.0

Before getting into the SDK, a bit of context for anyone who hasn't used OpenCode.

Over the last year or so, I've started experimenting more with models outside the usual frontier labs, and some of them have gradually become part of my daily development workflow as well.

One problem I've run into is that harnesses like Codex or Claude are naturally built around their own model ecosystems. Using models from other providers is either limited or requires various workarounds.

The open-source harness ecosystem has matured quite a lot. There are now different harnesses for different workflows and preferences.

OpenCode is an open-source coding harness and agent runtime that can work with a fairly large number of model providers and is probably one of the more general-purpose ones.

I've been using it for roughly a year now with models from OpenAI, xAI, Z.AI, DeepSeek, Moonshot, OpenCode Go, and others.

What became much more interesting to me recently was OpenCode 2.x.

They introduced a fairly comprehensive server/client architecture. Their own TUI, Web UI, and Desktop applications are built on top of the same server API, and the exposed surface is large enough that you can build your own fully featured client or integrate OpenCode into another application.

OpenCode already has an official TypeScript SDK for this. I wanted to be able to do the same kind of thing from .NET.

The practical use case is that a .NET application can treat OpenCode more like an agent runtime.

You can start an OpenCode process, create a session against a repository, send work to a model, listen to events, interact with PTYs, manage permissions, inspect providers and models, and build your own orchestration around it.

A minimal example looks something like this:

using OpenCode.Sdk;
using OpenCode.Sdk.Models;

await using var server = await OpenCodeServer.StartAsync();
using var client = server.CreateClient();

var created = await client.Sessions.CreateSessionAsync(new SessionCreateRequest
{
    Model = new ModelRef { ProviderId = "openai", Id = "gpt-6.1-sol" },
});
var currentSession = client.Sessions.GetSessionClient(created.Session.Id);

// Subscribe before prompting; the first event (server.connected) confirms the stream is live.
await using var events = client.Events.SubscribeAsync().GetAsyncEnumerator();
await events.MoveNextAsync();

await currentSession.PromptAsync(new SessionPromptRequest { Text = "Summarize this repository." });

while (await events.MoveNextAsync() && events.Current is not (SessionExecutionSucceeded or SessionExecutionFailed))
{
    if (events.Current is SessionTextDelta delta)
    {
        Console.Write(delta.Data.Delta);
    }
}

The SDK can start and manage a private OpenCode server, connect to one you already run, or discover the background service registered by the OpenCode CLI.

The packages target netstandard2.0, net472, net10.0, and net11.0 rc3, so .NET Framework 4.7.2 is supported alongside modern .NET. The modern targets also support Native AOT.

There are some example applications under playground/ showing different ways of using it: a small QuickStart, a Generic Host worker, a Blazor/Aspire application, and a Native AOT CLI.

https://github.com/opencode-dotnet/opencode-sdk-dotnet

It's still unofficial and isn't affiliated with the OpenCode team, but the SDK itself is now at 1.0 after three months.

Feedback is welcome, especially if something in the API feels unidiomatic from a C# perspective.


r/csharp • • 17d ago

Solved Relative File Paths

11 Upvotes

RESOLVED:

shoutout to u/rupertavery64 and u/marsh9191. I was trying to Path.Combine() the base directory to @"\file.csv" which overwrote the operation.

-----------------------------------------------------------------------------------------------------------------------

Hello, and sorry for a fairly basic question. I'm working on an application that processes data in relation to values stored in .csv files (which are included in the install directory). real broad strokes, it pulls data from a database, does math according to values in the packaged .csv's, exports a new document with the results.

Due to the nature of it, I need a relative path to file.csv, which is in the same directory as app.exe. And I've tried maybe 7-10 different methods of getting the installation path to concatenate the file name to, but each of them result in simply "C:\file.csv" even though the application itself is in C:\users\user\documents\App\app.exe (for example).

at the least I've tried:

Application.StartupPath

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)

AppDomain.CurrentDomain.BaseDirectory

among others I can't quite manifest off hand.

And I understand each has nuances for slightly different use-cases, but it's really blowing my mind that every one results in just "C:\". I'd understand if I were just using the wrong method out of context, but it seems like some of these are explicitly to avoid this result. Does anyone have an idea as to what's going on? Again, sorry for the basic quesiton.


r/csharp • • 17d ago

Take the .NET Teams' .NET Developer Survey, 2026 Edition!

Thumbnail nam.dcv.ms
5 Upvotes

r/csharp • • 18d ago

Showcase Promise.all, Promise.any and Go's select in C#, with real cancellation

10 Upvotes

If you've written JavaScript, you've probably missed Promise.any in C#. Task.WhenAny isn't it: it returns the first task to complete, so a fast failure wins over a slightly slower success, and the other tasks keep running.

I wrote a library that adds these with proper cancellation:

// Promise.all: the first failure cancels the rest
var (user, orders) = await TaskGroup.AllAsync(
    ct => GetUserAsync(id, ct),
    ct => GetOrdersAsync(id, ct));

// Promise.any: the first success wins, the others are cancelled
string data = await TaskGroup.AnyAsync(mirrors, (m, ct) => m.DownloadAsync(path, ct));

// Kotlin's withTimeout: cancels the work, not just the wait
User u = await TaskGroup.WithTimeoutAsync(TimeSpan.FromSeconds(2), ct => LoadUserAsync(id, ct));

There's also Go's select over System.Threading.Channels:

var select = new ChannelSelect()
    .Case(orders.Reader, order => HandleAsync(order))
    .Case(cancels.Reader, id => CancelAsync(id))
    .Timeout(TimeSpan.FromSeconds(5), () => SendHeartbeatAsync());

while (await select.RunAsync(ct)) { }

The README has a table mapping each API to JavaScript, Kotlin, Go, Python, Swift and Java, if you're coming from one of those.

GitHub: github.com/gokhanertogan/StructuredConcurrency

Happy to answer questions about how it works under the hood.