2 ms·
Analyzers are a first class citizen in C#. You can get access to the AST during compile time and use it to output diagnostics with error or warning level, so it
by latentsea 1y ago
Analyzers are a first class citizen in C#. You can get access to the AST during compile time and use it to output diagnostics with error or warning level, so it's more robust than just regex.
I've not seen teams personally write them because they're abstract and most devs shy away from it, but working in the C# ecosystem the one place I do see them pop up occasionally is from library authors.
For example xunit has some.
https://github.com/xunit/xunit.analyzers https://github.com/xunit/xunit.analyzers
So far I have found the value in them to be they help you constrain the possible valid moves that can be made in a codebase. This is valuable with teams of human engineers, but even more so with LLMs. It just so happens LLMs are really good at helping you write them too given you know what you want to enforce.
I doubt the tooling is as good in other languages as it is in C# in this respect, but at least for devs working in the C# ecosystem LLMs have unlocked access to writing custom analysers on a whole new level, and with that it's now significantly easier to define and enforce rules regarding what constitutes a valid program, such that the set of valid programs matches your intended architecture.