Skip to content

Implement a custom build process for project

No due date 0% complete

The original version of the project and Unity plugin (dll) were built from Windows Terminal with some trial and error, until it worked. I had to use Roslyn, disasm, ILAsm, JetBrains DotPeek and a few others to figure it all out and make it work. I also learned to use Roslyn SDK to write a custom "compiler-as-a-service" program which can build a C# program…

The original version of the project and Unity plugin (dll) were built from Windows Terminal with some trial and error, until it worked. I had to use Roslyn, disasm, ILAsm, JetBrains DotPeek and a few others to figure it all out and make it work. I also learned to use Roslyn SDK to write a custom "compiler-as-a-service" program which can build a C# program or script into an assembly/executable for you and also use modified versions of C# compiler rules! That's right, this isn't exactly following the "law" of C#, we are "breaking the law" to subvert a limitation and gain free performance ... and accomplishing something in the older .NET Framework/Standard 2.X / Mono runtime that didn't appear in C# until much later: until .NET Core 5 and after!

The issue is that List has its inner array set to internal and is thus inaccessible under C# compiler rules, as it lives inside another, signed assembly from Microsoft! So, how do we get around this? Wait ... why do we need to?! Because Span is a "lightweight view" of a collection in memory and can work with "unsafe" code and pointers (best performing memory access usually), and creating one requires an array or pointer! We can't get the _items array inside of List<T> in C# because it was marked as internal, but this project shows how to get around this in more than one way (I've discovered about 9 different ways to "steal" the array from inside of List and "break C# laws").

For this milestone, I would like to create a repeatable build process to include in the repo for users and contributors to make their own builds and hacks! And I want to provide at least one good build step to start with, if not multiple. Later, when we add more "hacks" and plugins, they will come in handy!

Note that I just founded a new company, Arkaen Solutions, and have been very short on time! But the company also values this project and intends to use it in commercial projects, so we will have it prioritized and updated ASAP!

Your support (and any contributions/suggestions/feedback) are HUGELY appreciated, and I hope this helps make people's games in Unity perform better and also teaches people more about performance and optimizations! ❤️‍🔥

Aaron Carter
Arkaen Solutions