Support for Unity Shaders in Rider 2017.2

The last couple of builds of Rider 2017.2 EAP have seen a number of under-the-hood and foundational fixes and updates to the Unity support.

Firstly, Rider will now read options such as the unsafe flag and pre-processor symbols from the mcs.rsp mono compiler response file, so Rider will now know what symbols you have defined, and analyze the correct branch in #ifdef‘d code blocks. This change is exciting to us because it came from the community – yes, the Unity support is open source, and we accept pull requests!

Secondly, we’ve made significant improvements to the ShaderLab parser. We’re not just doing syntax highlighting of .shader files, but we also parse the file and build syntax trees which we can use for syntax error highlighting, and going forward, inspections and analysis. Unfortunately, our parser wasn’t complete, and could highlight correct code as a syntax error. The parser now understands the file format a whole lot better and you should no longer see incorrect code (barring the occasional bug of course). We also highlight pre-processor errors and warnings correctly.
Highlight warning preprocessor directives

If you’ve previously disabled “advanced ShaderLab parsing” in options due to incorrect errors, please re-enable and restart (we’ll be removing this option soon, so the more testing and feedback we can get first, the better). And we’d like to thank the nice folks at Unity for their help with making sure we’ve got the whole file format covered.

Speaking of parsing, we’ve put a lot of effort into foundational work on parsing CGPROGRAM blocks and .cginc files, too. Up until now, our syntax highlighting was based on keywords, but we’re now parsing the Cg/HLSL language directly. We’re not yet complete with the language parsing, so we’re not yet showing error highlighting for syntax errors, but we now have much more accurate syntax highlighting, especially around handling pre-processor directives. This is the first step towards full support of Cg/HLSL, such as rich code completion, navigation, and inspections.

And finally, a nice little feature to end on. ShaderLab files now highlight color values in the editor, and hitting Alt+Enter will allow editing, with a color palette picker.
Colour picker in shader files

Please download Rider 2017.2 EAP and give the new build a try!

image description