Skip to content

1 January 2025 - The Conservatory Analysis Tools

<<< Previous Post Next Post >>>


  Before I start this blog post, obligatory messages: Happy new year! I can't believe it's already 2007.

  Anyway... It's another blog post about the analyzer - but rest assured, this time, I have good news.

  As a brief recap, I wanted to make a Roslyn Analyzer + Code Fix combo for my future modders. Roslyn is the system that compiles C# for .NET, and analyzers are tools that operate within this space to create compiler warnings and errors.

  Using this, I have created many special, custom diagnostics that show up in modded code (or even my code!) for The Conservatory.

  Here's some little examples of the helpful redirects the tool gives you:

This warning is used to indicate that a <code>VoxelMaterialProperties</code> instance has nonsensical data for its durability. Replaceable voxels are replaced when a voxel is placed on them, so having durability makes no sense when it can just be deleted this way.

<code>AbstractSpeciesEntity</code> is a convenience layer that provides species validation to an entity. It's meant to be a utility and extends the <code>AbstractLivingEntity</code> type. Methods that work on entities that have a species should use the living type - not the species type.

  And as a matter of fact, there's a lot of little helpful goodies in here. You may have noticed each warning is a clickable link. That's right - even the diagnostics are documented!

  You may need to press on the following images to zoom in.

The documentation website has an index of all analyzer diagnostics. This image is the documentation page for the <code>TC_ENTITY_000</code> diagnostic. It shows off a description of exactly what the warning means and why it's happening, and then provides a fix including with example code.

  You can see there's a lot of assorted diagnostics that make sure your code stays functional and mistakes are caught before you get into your testing phase. Every page for every diagnostic has as much detail as it needs to make it abundantly clear exactly why a warning/error is raised, and how to fix it, including multiple ways to fix it if the fix is not straightforward.

  To crank this up to 11, though, I will add that the code keywords in that second image for the game types AbstractLivingEntity and AbstractSpeciesEntity will be clickable links in the future, leading to the game's online documentation. So if you were going to ask "What's the difference", that question is answered too via the game's documentation.1

  As you can see, my give-a-shit for my modding community is not broken, and my field of fucks is most certainly not barren.


  1. AbstractSpeciesEntity is a convenience layer that shunts in a call to EntityValidation.AssertSpeciesIs(...) into the constructor. This way, you can't construct an AbstractGaianEntity (which extends this type) using Species.Novan, for example. This will raise an exception.

    This is an entirely optional convenience layer however, and it's more than valid to skip it and just call the assertion yourself. This is why it's not a good idea to limit by AbstractSpeciesEntity - an entity may not even be using it in the first place!