OnBase 16 contains a new feature to help you write correct and well-performing Unity Scripts: Code Analysis. This feature, available through OnBase Studio, uses OnBase's custom rules we’ve written through Microsoft's code analysis engine to examine your Unity scripts and libraries for common mistakes.
Code analysis, specifically for managed code, is a feature that allows the definition and use of various rules that can be used to check code for various consistencies, or inconsistencies. Most newer versions of msbuild and Visual Studio ship natively with code analysis tools already built in, only needing a quick toggle or selection of rules to run before build operations.
More information can be found through an MSDN article; Microsoft has a pretty great breakdown of the feature and how it works.
After upgrading to OnBase 16, Code Analysis is run on every Unity script and library when you build it in OnBase Studio. In Studio, you can also run a report to analyze some or all of your existing scripts in bulk. These features are not available in Unity API Project Configuration available through the Configuration module.
Yes, you can (although Code Analysis only generates warnings, not errors, and will not prevent your scripts from building). In the Studio Options dialog, under Script Editors, deselect the "Run code analysis on build" option. You can also suppress individual warnings for a method by tagging the method with the [SuppressRule] attribute.
At the release of OnBase 16, Code Analysis will attempt to find the following patterns that we have determined are likely to cause unwanted results:
The Code Analysis feature is new, but it's expandable. We hope to have more rules to find other problems in future versions of OnBase. If you have suggestions for other rules we could add, please let us know! Like all of our enhancements, we love to pull from what customers actually want and what they're actually doing in their current solutions.
Our Unity API scripting platform [and editor] have continually improved from release to release ever since we unleashed it in version 8. Our hope is that features like code analysis continue to strengthen our customers ability to build great solutions with it, propelling us forward into a future of OnBase that allows your code to be even better than ever. For any questions, comments, or even feedback, hit us up in the comments or our forums. Like we mentioned earlier as well, any suggestions to build upon our analysis rules that you would find useful would be greatly appreciated. Check back on our blog next week to learn about something else in our framework that we recently added: support for LINQ statements in Unity scripts.