C# Parser Part 2
Recap for anyone who didn't read the posts on the last article. I found Roslyn, an open source project on github by Microsoft, that includes a C# parser. Unfortunately, it did a lot, like also cover VB, compiler abilities, Visual Studio extensions, tools and more; >240K unit tests. I didn't expect all these features to work once pulled into Unity, especially the VS plugins, so I took an approach to start hacking pieces off I didn't think were needed.
Unfortunately, this started me down a long path that in the end I don't trust. I think Roslyn has a good chance of working for me, but not in this way. When I was done axe-wielding a keyboard, I had stripped off dozens of projects, hundreds of files and thousands of lines of code. It had all the precision of a bull in a tea shop, and the end result (8 hours of effort later) resulted in eleven hundred failed test cases. :(
Don't get me wrong, I ended up with only 25% of the test cases left, nearly all focused on C# parsing and nearly all passing. I think that proved that I can at least remove most of the items that are not needed for the game. You can view this failed attempt here: https://github.com/DanVioletSagmiller/roslyn/tree/ParseExtract/AxeWieldingKeyboardApproach
I had at first thought it would be pretty straight forward to just delete projects that were VB direct, but then I also came across test cases that were split to both C# and VB. This started me down the rabbit hole, and with 3 hours invested, I decided to keep following it unless I got to a point where it was clear I was destroying the project's ability to parse.
Unfortunately, I had a few other mistakes along the way. I was also removing projects and files without actually deleting them. This would have made it a pain to port into Unity in the end, which is where it needs to go.
So for my next pass, I'll start by removing only the VB Projects. Then rerunning the test cases. Then as soon as I have a working test pass, I'll commit it. I'll get rid of/modify only the test cases I need to, because they don't compile. I will also be deleting these as soon as I've proven they are invalid for my needs. Hoping to have my next branch shortly.
Unfortunately, this started me down a long path that in the end I don't trust. I think Roslyn has a good chance of working for me, but not in this way. When I was done axe-wielding a keyboard, I had stripped off dozens of projects, hundreds of files and thousands of lines of code. It had all the precision of a bull in a tea shop, and the end result (8 hours of effort later) resulted in eleven hundred failed test cases. :(
Don't get me wrong, I ended up with only 25% of the test cases left, nearly all focused on C# parsing and nearly all passing. I think that proved that I can at least remove most of the items that are not needed for the game. You can view this failed attempt here: https://github.com/DanVioletSagmiller/roslyn/tree/ParseExtract/AxeWieldingKeyboardApproach
![]() |
source https://codeburst.io/git-good-a-practical-introduction-to-git-and-github-in-git-we-trust-f18fa263ec48 |
I had at first thought it would be pretty straight forward to just delete projects that were VB direct, but then I also came across test cases that were split to both C# and VB. This started me down the rabbit hole, and with 3 hours invested, I decided to keep following it unless I got to a point where it was clear I was destroying the project's ability to parse.
Unfortunately, I had a few other mistakes along the way. I was also removing projects and files without actually deleting them. This would have made it a pain to port into Unity in the end, which is where it needs to go.
So for my next pass, I'll start by removing only the VB Projects. Then rerunning the test cases. Then as soon as I have a working test pass, I'll commit it. I'll get rid of/modify only the test cases I need to, because they don't compile. I will also be deleting these as soon as I've proven they are invalid for my needs. Hoping to have my next branch shortly.
This is proving difficult. Much of the Unit tests test the same thing in VB and C#, by passing an example of the code principal for each language into their associated code parser/compiler. This means that I either have to just kill a huge portion of the C# test cases, or I still have to delete line by line sections of code.
ReplyDeleteAt least this time, I'm deleting the files as well. I've started with Remotes, VisualBasic Workspaces, and Visual Studio focused projects, none of those should be part of my project.
While continuing with this mode of deletion, I'm also trying to reach out to people on the roslyn project/online forums to ask about which project/projects in specific I can use to just get C# parsing abilities, and nothing else. It might work better just to copy the necessities out, and ignore the rest. I'm going to need to figure out where that project(s) is in specific anyway.