troet.cafe ist Teil eines dezentralisierten sozialen Netzwerks, angetrieben von Mastodon.
Hallo im troet.cafe! Dies ist die derzeit größte deutschsprachige Mastodon Instanz zum tröten, neue Leute kennenlernen, sich auszutauschen und Spaß zu haben.

Verwaltet von:

Serverstatistik:

7,1 Tsd.
aktive Profile

Mehr erfahren

#csharp

47 Beiträge34 Beteiligte3 Beiträge heute

I find C#'s features to always somehow be incomplete. For example, I can declare a class without a constructor, like below, and use new HandInfo{... to create with names. However, it doesn't work nullable: enable, thus I have to revert back to manually creating a constructor.

Played a few hours of Palworld with Child.0.

Also worked on my C# CLI parsing library. Mostly I worked out some ideas and patterns to make sure they fit. One implementation I'm doing is based on C#'s XElement pattern:

var root = new ComponentCliCommand(
  new ValueCliOption<string>("option"),
  new ValueCliOption<int>('n', "number"),
  new SwitchCliOption("help"),
  new CliHandler(_ => Console.WriteLine("I ran a command!"));

Since the entire purpose is to make this DI-friendly and also Autofac-module friendly, all of the classes and subclasses can be extended and then added into the service provider.

public RootCommand(IEnumerable<IMyLocalVerbs> verbList, CurrentDateOption currentDateOption)
  : base(currentDateOption)
{
  this.AddRange(verbList);
}

So far, the pattern seems "reasonable"?

I can also easily convert a reflection-based version of the command and convert them into components, which would let me do a CommandLineParser-style command object. And the handler (CliHandler) doesn't have to be in the same class (though I prefer it does).

Today, I implemented the #async / #await pattern (as known from #csharp and meanwhile quite some other languages) ...

... in good old #C! 😎

Well, at least sort of.

* It requires some standard library support, namely #POSIX user context switching with #getcontext and friends, which was deprecated in POSIX-1.2008. But it's still available on many systems, including #FreeBSD, #NetBSD, #Linux (with #glibc). It's NOT available e.g. on #OpenBSD, or Linux with some alternative libc.

* I can't do anything about the basic language syntax, so some boilerplate comes with using it.

* It has some overhead (room for extra stacks, even extra syscalls as getcontext unfortunately also always saves/restores the signal mask)

But then ... async/await in C! 🥳

Here are the docs:
zirias.github.io/poser/api/lat

zirias.github.ioposer: PSC_AsyncTask Class Reference

SpacetimeDB is an interesting new type of relational database that I haven't quite wrapped my head around yet.

It is designed for real time massive multiplayer games and uses some sort event sourcing (CRDTs?) but has many more potential use cases than just games.

It works particularly well with .NET and C#. So I have cleaned up and simplified the C# quickstart sample.

github.com/bitbonk/spacetime-q

A quickstart chat demo for SpacetimeDB. Contribute to bitbonk/spacetime-quickstart-chat development by creating an account on GitHub.
GitHubGitHub - bitbonk/spacetime-quickstart-chat: A quickstart chat demo for SpacetimeDBA quickstart chat demo for SpacetimeDB. Contribute to bitbonk/spacetime-quickstart-chat development by creating an account on GitHub.
#spacetimedb#sql#dotnet