Do you know public C# code that you would recommend to look at it because it is well designed or very well readable?
C# is VERY different from even just what things were 2 years ago. You can now build a full-on app with the same number of lines that a Node/Express/Flask app. Except the .NET runtime is about 5-10x faster than those runtimes.
For a random example, here is the analyzer finding variable swaps of the form
tmp = a;
a = b;
b = tmp;
that can better be done using tuples:
https://github.com/dotnet/roslyn/blob/main/src/Analyzers/CSh...And here is the code fix that automatically performs the substitution: https://github.com/dotnet/roslyn/blob/main/src/Analyzers/CSh...
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.
Also PathogenDavid, that guy is a wizard
The above are example of production code. I use these as references all the time
Awesome c# https://github.com/quozd/awesome-dotnet
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.
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/microsoft/calculator
if you go on github you can browse C# repositories, there are good examples there https://github.com/topics/csharp