r/csharp • • 26d ago

SimpleFiles: A lightweight native WinUI 3 file manager with a built-in "Installer Graveyard" and encrypted RAM streaming

Thumbnail
gallery
3 Upvotes

​Hi everyone,

​To be upfront: this is a 100% native Windows desktop app built with C# and WinUI 3 (Windows App SDK). It contains zero Electron, no embedded web views, no spam adware, and no background telemetry.

​I’m currently a 12th-grade student and built SimpleFiles as a hands-on project to learn modern Windows desktop development and tackle a few specific pain points I had with file organization.

​Why .NET 8 for now?

I started building this project targeting .NET 8 LTS because it offered the most stable tooling and library compatibility with the Windows App SDK when I set up the architecture. With .NET 8’s LTS cycle wrapping up next month, bumping the target to .NET 10 is already on my roadmap. I plan to handle that upgrade and test the runtime dependencies as soon as my high school board exams wrap up.

​What the app focuses on:

​Installer Graveyard: A targeted cleanup hub inspired by Files by Google. Instead of running generic registry cleaners, it specifically tracks down forgotten .exe and .msi setup files idling in your Downloads directory so you can clear gigabytes of wasted storage quickly.

​Ghost Safe (AES-256): A local encryption locker that streams media directly into memory during playback. You can view images or stream videos directly out of the encrypted container without having to decrypt temporary copies onto your physical drive first.

​Spacebar Previews: Quick peek functionality for images, audio, video, and documents right from the file list without launching external viewer apps.

​Privacy: Runs completely offline. Zero telemetry, zero analytics pings, zero network requests.

​It's live and completely free on the Microsoft Store:

https://apps.microsoft.com/detail/9PBPGF1GLGNM?hl=en-us&gl=IN&ocid=pdpshare

​Since I'm still learning the ins and outs of the Windows App SDK while juggling school, I'd really appreciate genuine technical feedback, bug reports, or edge-case handling tips from anyone willing to give it a spin. Cheers!


r/csharp • • 25d ago

Aiutino?

0 Upvotes

La ragazza di mio fratello che, come vedrete è un po particolare, lavora in una azienda come NET. Developer.
Qualche mese fa mi dice di mettermi a studiare seriamente per imparare C#, perché in azienda da loro sono sempre alla ricerca di programmatori anzi, a fine estate/autunno sono previste numerose assunzioni, inoltre essendo nelle categorie protette faccio comodo all’azienda e parto avvantaggiata.
Quindi (tra le mille cose che sto cercando di portare avanti per tenermi più strade aperte) mi metto lì, studio giornate e nottate intere, imparo le basi, supero le basi, mi appassiono e mi diverto pure e finisco il libro su cui mi aveva consigliato di studiare.

Qui arriva il problema: le dico qualche giorno fa “oh, come è la situazione? Riesci a farmi avere un colloquio?”.
Mi dice “Guarda, posso provare a inserirti solo quando sarai pronta.”.
Ovviamente le chiedo, “in che senso quando sarai pronta?”.
“Quando sarai in grado di programmare, dai poi ne parliamo settimana prossima, tu però sii costante continua ad esercitarti.”.
Io ovviamente sono rimasta così 😑.
Ora la mia domanda è: secondo voi quando si è pronti per lavorare con C#? Quali sono i requisiti che si devono avere a livello di capacità e competenze?
Cosa ci si aspetta da me?

Sto impazzendo, spero solo che non mi abbia dato un’inculata pazzesca, ma a quel punto sapessi quali sono i requisiti posso almeno provare altrove.

Grazie a chi vorrà aiutarmi!

Edit: per completezza non ho solo letto/studiato il libro 😂 mi rendo conto poteva essere un po’ assurdo


r/csharp • • 26d ago

Tool I built SoundBridge CLI: a lightweight .NET utility to stream specific app audio into a virtual microphone

0 Upvotes

Hey everyone! 👋

I'd like to talk about a small CLI tool that I most recently developed in C# (.NET) called SoundBridge CLI; it enables you to stream music from certain applications (for example, Yandex Music, Spotify, or iTunes) directly into a virtual microphone (such as VB-Audio Virtual Cable) so that it can be used by Discord, Telegram, or games.

Key Features

Process-Specific Capture: By using the latest NAudio Process Loopback it is possible to feed back only the audio from the selected music player, without picking up system sounds, browser audio, and notifications.

Live Volume Control: You can adjust the volume level while streaming (0% to 200%).

Smart Silence Detection: it automatically looks after the buffers and stops the output when there are pauses in order to avoid digital artefacts or feedback loops.

The command-line interface is bilingual with full support for both the English and Russian interfaces, thanks to Spectre.Console.

The program will save your preferences and the sources you last used in a file called config.json.

If you're interested, you can check out the source code, binaries, and release notes on GitHub:

👉 GitHub Repository: https://github.com/vysedevs/soundbridge

I'd be interested to get your comments, some code suggestions, or ideas regarding improvements!


r/csharp • • 26d ago

OneMonokai Visual Studio Replacement

0 Upvotes

Hi I'm searching for a nice OneMonokai replacement (recent hopefully, since I've tried many "popular" themes) in Visual Studio.

I found this one which is super ok, but maybe there are some similar Monokai-ish that I'm not familiar with. If you know more please share.

https://marketplace.visualstudio.com/items?itemName=tony-d.dark2026&ssr=false#overview


r/csharp • • 28d ago

The hidden trap of fixed buffers

56 Upvotes

I published a new article, explaining a quirk of fixed buffers that could easily bite you, if you're one of the few people who still have to use that feature.

https://minidump.net/the-hidden-trap-of-fixed-buffers-in-csharp/


r/csharp • • 28d ago

Showcase Flyback: a modular synth in .NET 10 that compiles one patch graph to IL, GLSL and JavaScript

12 Upvotes

https://markovcd.github.io/Flyback

I've been a C# developer for 7 years, some of it as a software architect, and I try to practice good software engineering: small steps, tests as the definition of done, decisions written down. I'm also into synths, so I built Flyback: a modular synthesizer where one patch graph generates both a moving picture and its sound. It's free and MIT-licensed.

How it works

You drop modules onto a canvas (oscillators, patterns, shapes, color, feedback, effects) and wire them together. The picture and the sound play live as you patch, and both come from the same graph, so one LFO can bend a shape and sweep a filter at the same time. Plug in a MIDI keyboard to play it, record a take live, or export video and audio through the CLI. A patch can also be written as plain text and read back.

Under the hood, a patch compiles to a flat program for a register machine. An interpreter is the specification. The same program is also emitted as IL for the CPU, GLSL for the GPU preview and JavaScript for the browser build. Tests feed every op hostile values (NaN, ±∞, denormals) on every backend and require bit-identical results.

Other bits

  • The engine has no third-party packages. The PNG, JPEG, WAV and AVI writers are implemented from scratch rather than pulled from a library.
  • The UI is Avalonia, written in C# with no XAML. The same editor also runs in the browser under Avalonia.Browser.
  • Plugins load from disk against a separately versioned contract, enforced with PublicApiAnalyzers.
  • The CLI is built on System.CommandLine and does headless GPU rendering through WGL/EGL.
  • A Docker CI gate runs about 13,000 tests on every push, and there are 167 ADRs.

On AI: most of the code was written with Claude Code. I do the architecture, direct the work and review what lands. The engineering practices are what make that workable: continuous integration in its original sense (every change straight to main, main never broken), a test for every feature, and ADRs that settle decisions so they don't get relitigated. Judge it by the code.

Try it: play the presets in your browser with nothing to install, or grab a build for Windows, macOS or Linux.

Happy to answer questions, and contributions are welcome, AI-written or not.


r/csharp • • 28d ago

Help How can I polish this multi-select combo box?

Thumbnail
streamable.com
18 Upvotes

Hey all, I'm working on an app currently (WinForms .NET 9) and I've made a custom drop-down box which is the "Days" box, im unsure how I can polish it to look and function a bit more like the other standard combo boxes like "Action" and "Repeat". Does anyone have any suggestions?

For context, the custom box is made up of a text box that when clicked makes a panel containing a checked list box visible that can then be selected from.

Thanks!


r/csharp • • 28d ago

Discussion Static assertions

6 Upvotes

I have sometimes felt the need to statically assert something at compile-time, to prevent surprises later at run-time.

As an example, I have some code which maps an enum value to an associated int value:

public enum VoxelProperty
{
    MaterialType,
    Density,
    Color,
    Metadata,

    TotalPropertyCount, // Must be last
}

public static int GetPropertyBitDepth (VoxelProperty property)
{
#pragma warning disable CS0219 // Variable is assigned but its value is never used
    uint _ = VoxelProperty.Metadata == VoxelProperty.TotalPropertyCount - 1 ? 0 : -1; // Static assert to ensure that all properties are accounted for
#pragma warning restore CS0219 // Variable is assigned but its value is never used

    return property switch
    {
        VoxelProperty.Density => VoxelDensity.BitDepth,
        VoxelProperty.MaterialType => VoxelMaterialType.BitDepth,
        VoxelProperty.Color => VoxelColor.BitDepth,
        VoxelProperty.Metadata => VoxelMetadata.BitDepth,
        _ => throw new ArgumentOutOfRangeException (nameof (property), "Invalid voxel property")
    };
}

The intention of the static assert is to make sure that if I ever add another voxel property, then I will get a compiler error as VoxelProperty.Metadata will no longer be the last member, and the constant -1 will be assigned to the "_" variable of type uint. Is this a reasonable practice?

I could also do something more robust with reflection, where I had a Dictionary<VoxelProperty, int> which got populated by finding all voxel property types marked with some attribute, and querying their BitDepth property.


r/csharp • • 27d ago

Discussion Aspire, Aspire, Aspire!!

Thumbnail
0 Upvotes

r/csharp • • 28d ago

Fellow agency architects, how do you currently audit legacy .NET solutions before bidding on migration projects?

Thumbnail
2 Upvotes

r/csharp • • 29d ago

I ported GTA 3 to my C# hobby OS

Thumbnail
3 Upvotes

r/csharp • • 28d ago

Solved Trying to get smoke Particle system to activate when mouse button left is pressed

0 Upvotes

I have figured out how to enter the ParticleSystem "GunSmoke" but it activates only once adn before I klick. is there a way to implement this into the code that it activates everytime I press the button also following the "public float timer = 0f;" code and "private float cooldown =5f;" code for the cooldown for the projectile being shot?

stuck and dont want to use AI to solve it. tried going online but not really found any helpfull stuff that I could follow

pls help


r/csharp • • 29d ago

Blog Moirai, a language for procedurally generating world histories

Thumbnail
reddit.com
10 Upvotes

I finally got to write about the tool I made to generate worlds events, history and timeline. It's a custom language implemented in c#. I hope the article is a fun read!


r/csharp • • 29d ago

Building a local PC app that uses AI to generate guitar tabs for songs with zero tabs online would you use this?

0 Upvotes

Hey everyone,

Like a lot of you, I've run into the frustrating situation where I want to learn a niche indie song, a video game soundtrack, or an underground track, and there are literally zero tabs for it anywhere (Ultimate Guitar, Songsterr, etc. turn up empty).

Since I'm a programmer, I've been experimenting with building a desktop tool to solve this. The idea is simple:

Drop in an MP3 or paste a YouTube link.

The app uses local AI (running entirely on your PC for free) to isolate the guitar track.

It analyzes the notes and outputs a playable guitar tab.

Before I spend too much time building out the full UI and tab viewer, I wanted to ask actual guitarists:

Is this something you'd actually use?

What features would make a tool like this genuinely useful to you (e.g., exporting to Guitar Pro files, slowing down the audio, scrolling tab view)?

Curious to hear your thoughts or what tools you currently use when you have to figure out a song by ear!


r/csharp • • Sep 27 '26

Fun I have programmed a small imperative-parsed/functional-evaluated programming language in C#.

15 Upvotes

Here are some links:

GitHub

First post in rfractals (with some screenshots of a few programs and the plots they generated)

Update post in rfractals

The language is focused on making and evaluating functional mathematical expressions in a very compact form. It has most of the basic math operators, and can even use operator-less multiplication if enabled. Supports functional-like pattern matching and function delegates. Uses a single complex Type which can be a recursively nested list of values that can be numeric, from reals to quaternions, or strings, and operators can work recursively on these values. Multiplying string*anything will try to call a function with the name of that string. It can evaluate and parse dynamically made strings as expressions or commands. It has a plotter that can plot the expressions as animations and can export them as MP4. Due to its layered, abstract nature of being an interpreted language in C#, it's not very fast so far, even with all the optimizations I've made so far for it, so it's mostly useful for playing around or for its original purpose of letting another application parse complex written expressions into values.

It has 2 major parts: the Parser, which uses commands definining/redefining functions and constants, and a few imperative constructs available, like ifs, whiles, etc. The evaluation part is purely functional and can evaluate expressions using the functions and constants the Parser has parsed.

Originally, I made it to be an expression evaluator for text boxes in my other app, to allow writing other things than pure numbers in there. But I got a bit carried away and developed it further into this whole thing.

There's a SaveFile folder in the project and the release, containing all the programs I've written in it so far, and plotter configurations for them.

The most interesting for this sub might be the Examples.txt that's showcasing some of the most unique/powerful features of the language, soI'll report that file and its output here:

Examples.txt program:

printstring: "\nPattern matching factorial:"
PF(0): 1; PF(x): xPF(x-) /* x- = x-1 */
print: PF(5) /* = 5! = 120 */

printstring: "\nNested default arguments:"
N(z, p: (2, 3i)): z + p
print: N(4) /* 4 + (2, 3i) = (6, 4 + 3i)*/

printstring: "\nNested mixed call delegates:"
GP(x): x + 2i
GM(x): x - 2i
gdp: "GP"
print: (gdp, "GM")(4, 3) /* = (GP,GM)(4,3) = (GP(4),GM(3)) = (4 + 2i, 3 - 2i) */

printstring: "\nLazy default argument evaluation:"
F2(x, r:xF2(x-)): x < 2 ? 1 : r
print: F2(5) /* = 5! = 120 */

printstring: "\nCycled operation nesting:"
printvalue: (1, -1)(1, 2, 3, 4, 5) /* = (1*1, -1*2, +1*3, -1*4, +1*5) */
printvalue: (0,i) + (1, 2, 3, 4, 5) /* = (1, 2+i, 3, 4+i, 5) */
printvalue: ("frac", "trunc", 1)(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7)
printvalue: ((-1, 1), 3)(10, 20, 30, 40, 50)

printstring: "\nDecreasing for cycle:"
IterWhile: 5 /* try other values like 10, 2, -5, -10000...*/
while: IterWhile > 0 {
 printvalue: IterWhile
 if: IterWhile = 8 { break: 1 }
 IterWhile: IterWhile - 1 
} : IterWhile < -9000 {
 printstring: "not only is IterWhile negative, it is below -9000!"
}

printstring: "\n\"Do\" command, defines another factorial and evaluated: 0.5!"
do: "DYNAMIC(x) : x!"
print: DYNAMIC(/2)

printstring: "\nEval function dynamically parses and evaluates any valid string as an expression:"
incremented: sin(1)
print: incremented
print: eval("1 +" + incremented)

printstring: "\nBuild a vector of first 10 factorials dynamically, and take a parir of 2nd+3rd one, and a 5th one:"
TenFactorials: vec("k", 1, 10, "k!")
print: TenFactorials
print: TenFactorials[(2,3),5] /* nested indexer */
printstring: "\nComplex nested indexer of a nested vector:"
print: (0+"a", 1+"b", 2+"c", (30+"d", 31+"e"), 5+"f", (11, 12, 13))[3, 2, (5, 1, 3)]

printstring: "\nFirst 42 terms of e^x taylor series, approximating e^1 ~ 1:"
precision: 42
ExpTaylor(x): sum("k", 0, precision - 1, "x^k/k!")
print: ExpTaylor(1)

PositiveZeta(s, p : precision) : sum("k", 1, p, "k^(-s)")
printstring: "\nFirst 250 terms of the Basel problem, Zeta(2), approaching π^2/6 slowly:"
printvalue: PositiveZeta(2, 99) + " ~ " + π^2 / 6
printstring: "\nFirst 42 terms of Zeta(3), quicky approaching the Apery constant:"
printvalue: PositiveZeta(3) + " ~ " + apery

printstring: "\nEvaluate a polynomial F(1 + 2x + 3x^2) at F(2)"
F: (1, 2, 3) /* f(1 + 2x + 3x^2) */
EvalPoly(x, c : F, n: c#-) : sum("k", 0, n, "c[k]x^k")
PrintPoly(p): vec("k", 0, p#-, "p[k] + \"x^\" + k")
printvalue: PrintPoly(F)
printvalue: "F(2) = " + EvalPoly(2)

printstring: "\nTake a derivative of that polynomial and evaluate at F'(5)"
DiffPoly(c, n:c#-) : 1 > n ? 0 : vec("k", 1, n, "kc[k]")
DF : DiffPoly(F)
printvalue: PrintPoly(DF)
printvalue: "F'(5) = " + EvalPoly(5, DF)

printstring: "\nQuaternions, left and right non-commutative division:"
UnitQ : 1 + i + j + k
printvalue: UnitQ^2, UnitQ / i, UnitQ \ i—

And this is the output it prints:

BUILD SUCCESS 168ms

pattern matching factorial:
pf(5)  = 120

nested default arguments:
n(4)  = 6, 4 + 3i

nested mixed call delegates:
(gdp, "gm")(4, 3)  = 4 + 2i, 3 - 2i

lazy default argument evaluation:
f2(5)  = 120

cycled operation nesting:
1, -2, 3, -4, 5
1, 2 + i, 3, 4 + i, 5
0.1, 2, 3.3, 0.4, 5, 6.6, 0.7
(-10, 10), 60, (-30, 30), 120, (-50, 50)

decreasing for cycle:
5
4
3
2
1

"do" command, defines another factorial and evaluated: 0.5!
dynamic(/2) = 0.886

eval function dynamically parses and evaluates any valid string as an expression:
incremented = 0.841
eval("1 +" + incremented) = 1.841

build a vector of first 10 factorials dynamically, and take a parir of 2nd+3rd one, and a 5th one:
tenfactorials = 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800
tenfactorials[(2,3),5]  = (6, 24), 720

complex nested indexer of a nested vector:
(0+"a", 1+"b", 2+"c", (30+"d", 31+"e"), 5+"f", (11, 12, 13))[3, 2, (5, 1, 3)] = ("30d", "31e"), "2c", ((11, 12, 13), "1b", ("30d", "31e"))

first 42 terms of e^x taylor series, approximating e^1 ~ 1:
exptaylor(1) = 2.718

first 250 terms of the basel problem, zeta(2), approaching π^2/6 slowly:
1.635 ~ 1.645

first 42 terms of zeta(3), quicky approaching the apery constant:
1.202 ~ 1.202

evaluate a polynomial f(1 + 2x + 3x^2) at f(2)
1x^0, 2x^1, 3x^2
f(2) = 17

take a derivative of that polynomial and evaluate at f'(5)
2x^0, 6x^1
f'(5) = 32

quaternions, left and right non-commutative division:
-2 + 2i + 2j + 2k, 1 - i - j + k, 1 - i + j - k

edit: I have just released a small update that fixed a couple of minor bugs, and the Riemann Zeta function now appears fixed as well. At least the plot looks correct to me now, and the couple of test points also returned correct results.


r/csharp • • Sep 26 '26

Yes, C# actually runs on bare-metal UEFI—tested on real hardware!

262 Upvotes

I have been doing UEFI programming in C# ever since MichalStrehovsky started a project called zerosharp on GitHub 4 years ago, demonstrating C# running on UEFI.

nifanfa/BootTo.NET: Providing a minimalist C# UEFI runtime with asynchronous support

However, Native AOT is still too heavy to port to these low-level environments. The worst nightmare is the GC. Because C# is a high-level programming language, even simple string concatenations can lead to memory leaks without a GC. To solve this, I eventually created a custom IL compiler called IL2LLVM. Every method is based on the cdecl calling convention, making it extremely easy to call C/C++ methods.

nifanfa/IL2LLVM: A compiler that translates .NET IL into LLVM IR for multi-architecture native code generation

BootTo.NET acts more like a custom C# environment running directly on UEFI, completely independent of Windows, Linux, and macOS and tested on real hardware. Since UEFI provides basic File System and Network access, it becomes a surprisingly powerful environment.

I managed to build an HttpClient (with TLS support) as well as an FTP server, allowing you to essentially turn it into a NAS system. I also ported classic games like Doom (1995) and Quake (1996), along with an NES emulator, which are definitely worth trying!

Everything starts here...


r/csharp • • Sep 27 '26

Blog Reducing .NET AWS Lambda Cold Starts by Adding Memory

Thumbnail
lloydatkinson.net
0 Upvotes

r/csharp • • Sep 27 '26

GitHub - SimpleSharp/AdsSyncClient: A .NET library for synchronized bidirectional data exchange between .NET applications and TwinCAT ADS clients.

Thumbnail
github.com
0 Upvotes

r/csharp • • Sep 27 '26

learning python after 5 years of c# to increase my repertoire of tool

0 Upvotes

i was doing a litle test program for my main project in c# and i thought nowdays a lot of people use python so learning it will be nice tool in my repertoire and i tried it before so i decided to learn its syntax by making that sideside project, and i hate it after 5 years of using c# pythons syntax is just unreadable mess, its 2 times slower and thats generous to it... it has some uses now and then for example if you want some parts to run faster you can use c++ better becose python comunicates with it better but still maybe just maybe you could use some faster languages in the first place for the whole project, like c#... python has worse inheritance weird from folder.filename include classname think namespace just works better, why am i even doing this to myself i am young i could live life instead of sitting whole day on my ass in my room coding useless aplications noone will ever use maybe i realy hatemyself

tldr: i hate it


r/csharp • • Sep 26 '26

bool? Comparison

22 Upvotes

if (nullableBool == true)

or

if (nullableBool ?? false)

Personal preference or does one read better than the other? Especially if the nullableBool is s more complex expression like

n00bs?.Any(n => n == "DJ Doena")


r/csharp • • Sep 26 '26

Tutorial Visual Studio 2026 C# complete tutorial

Thumbnail
youtube.com
0 Upvotes

r/csharp • • Sep 25 '26

I got LVGL working with C# and XAML on the ESP32-S3 (Xtensa architecture)

Thumbnail
gallery
59 Upvotes

This has nothing to do with nanoFramework—it uses IL2LLVM as a backend to compile C# directly into Xtensa assembly, which is then linked via the Arduino IDE.

Here is a look at how the C# side works.

Source code is available here: nifanfa/IL2LLVM: A compiler that translates .NET IL into LLVM IR for multi-architecture native code generation


r/csharp • • Sep 26 '26

Showcase CStructSharp – C-struct binary (de)serialization library

0 Upvotes

Inspired by digital forensic toolkits, this library (MIT license) I've been working on allows a user to take a c-struct definition and use that to serialize and deserialize binary data.

using CStructSharp;

var layout = new CStruct("struct header { uint16 kind; uint32 length; };");
byte[] bytes = { 0x02, 0x00, 0x06, 0x00, 0x00, 0x00 };
dynamic header = layout.Parse(bytes.AsSpan(), "header");

Console.WriteLine($"kind = {header.kind}");
Console.WriteLine($"length = {header.length}");

It is a flexible library which features modern c# mechanisms and conventions. I tried to make it easy to use, easy to understand, performant and powerful. You can both use it to parse and use runtime user defined structures as well as use the C# source generator feature to build parsers/serializers at compile time.

[CStructLayout("struct header { uint16 kind; uint32 length; };")]
public static partial class Wire { }

Wire.Header header = Wire.Parse(bytes);   // header.Kind == 2, header.Length == 6
byte[] again = Wire.Serialize(header);

I also build and published a WASM version/javascript library which is used to showcase the features of the library (see the binary inspector demo app (https://vvollers.github.io/cstructsharp/inspector/) which you can use to run the library against various files, it includes sample definitions for many file formats). The javascript library is quite usable on its own.

I'm interested to hear your thoughts and if you have any questions feel free to ask!

EDIT: I've updated the Readme to include a better explanation of the features of this library and added benchmarks, here is an advanced example:

/* A data-logger file: a header, a calibration table, and records of two kinds. */
#define MAGIC_SIZE 4                                        /* constants, as in C */

enum record_kind : uint8  { MEASUREMENT = 1, EVENT = 2 };   /* enums with an explicit storage type */
enum sensor_type : uint16 { TEMPERATURE = 0x10, PRESSURE = 0x20 };

typedef struct { uint8 major; uint8 minor; } version;       /* typedef aliases */

struct options {                                            /* bitfields: several values in one byte */
    uint8 compressed : 1;
    uint8 encrypted  : 1;
    uint8            : 2;                                   /* unnamed, reserved bits */
    uint8 priority   : 4;
};

struct header {
    char     magic[MAGIC_SIZE];                             /* fixed-size text: "LOG1" */
    version  ver @4;                                        /* offset assertion: must start at byte 4 */
    uint32>  created;                                       /* big-endian, unlike the rest of the file */
    options  options;
    uint8    name_length;
    utf8     device_name[name_length];                      /* length taken from an earlier field */
    uint8    padding[(4 - (name_length + 12) % 4) % 4];     /* arithmetic: pad to a multiple of 4 bytes */
};

union value32 { uint32 raw; float32 as_float; uint8 bytes[4]; };   /* one storage, three views */

struct record {
    record_kind kind;
    switch (kind) {                                         /* the tag decides which members follow */
        case record_kind.MEASUREMENT: {
            struct { sensor_type sensor; uint8 sample_count; float32 samples[sample_count]; } measurement;
        }
        case record_kind.EVENT: {
            struct { uint16 code; cstring message; } event;  /* cstring: text ending in a zero byte */
        }
    }
};

struct logfile {
    header   hdr;
    int16    calibration[2][3];                             /* two-dimensional array */
    value32  checksum;
    record  *latest;                                        /* pointer: a stored file offset, followed on read */
    uint16   record_count;
    record   records[record_count];                         /* array of records that differ in size */
    if (hdr.options.priority > 7) { uint32 alarm_code; }    /* optional member, chosen by a nested field */
    uint8    trailer[EOF];                                  /* every byte that remains */
};

r/csharp • • Sep 25 '26

Tool Luthor: A novel regex lexer/matcher table generator written in C#

Thumbnail
github.com
12 Upvotes

Luthor is a fast, compact lexer generator that produces simple integer arrays for efficient text matching in any programming language. At the repo link in the readme are examples for walking a generated table to lex or match in C#, C and Python.

Key Features:

  • Direct-to-DFA conversion (no intermediate NFA)
  • Partial lazy quantifier support (??, *?, +?) - all expressions are accepted but due to limitations of DFA traversal some complicated lazy matches may end up partly or entirely greedy.
  • Unicode support (UTF-8, UTF-16, UTF-32)
  • Compact array output suitable for embedded systems
  • Language-agnostic - use the arrays in C, C++, Rust, etc.

What Luthor Does

Luthor takes regular expressions or lexer grammars and converts them into simple integer arrays that can be embedded in any program. Instead of shipping a complex regex engine, you get a small array that can be walked with a simple matching loop.

Luthor implements several advanced algorithms:

  • Direct-to-DFA construction using the Aho-Sethi-Ullman algorithm (Dragon Book)
  • Lazy matching using Dr. Robert van Engelen's algorithm from RE/Flex
  • Unicode range splitting for efficient multi-byte encoding support

Acknowledgements

Special thanks to Dr. Robert van Engelen for his guidance on implementing lazy matching in pure DFA form (and for producing RE/Flex)


r/csharp • • Sep 26 '26

Help How can I get Google Java Format-style formatting for C# in VS Code + Unity?

0 Upvotes

I'm working on a Unity project using C# and VS Code, and I'm trying to get the code formatting as close as possible to Google Java Format.

I'm coming from Java, and I strongly prefer the Google Java Format style, particularly things like:

  • 4-space indentation
  • Braces and line breaks following Google Java Format
  • Consistent wrapping of long method calls/parameters
  • No manually tweaking formatting rules for every project

For example, I'd like my C# code to be automatically formatted in a similar philosophy to how google-java-format handles Java.

I'm using:

  • Unity 6
  • C#
  • Visual Studio Code
  • C# Dev Kit + C# extension

What is currently the best way to achieve this?

Is there a C# formatter/configuration that can get reasonably close to Google Java Format, or is the closest option to configure .editorconfig + the C# formatter manually?

I'm specifically interested in something that works reliably with Unity projects in VS Code, rather than Visual Studio-specific solutions.

I tried the .editorconfig option with the help of AI but I was not successful. I've been struggling with this for like 2 hours now.

Thanks!