Skip to content

Repository files navigation

UnityEngineAnalyzer

UnityEngineAnalyzer is a set of Roslyn analyzers that aim to detect common problems in Unity3D C# code. Unity3D makes it easy for us to make cross platform games, but there are hidden rules about performance and AOT, which might only come with experience, testing or reading the forums. It is hoped that such problems can be caught before compilation.

Analyzers

AnalyzerNameGategorySeverity
UEA0001DoNotUseOnGUIGCInfo
UEA0002DoNotUseStringMethodsGCInfo
UEA0003EmptyMonoBehaviourMethodMiscellaneousWarning
UEA0004UseCompareTagGCWarning
UEA0005DoNotUseFindMethodsInUpdatePerformanceWarning
UEA0006DoNotUseCoroutinesGCInfo
UEA0007DoNotUseForEachInUpdatePerformanceWarning
UEA0008UnsealedDerivedClassPerformanceWarning
UEA0009InvokeFunctionMissingPerformanceWarning
UEA0010DoNotUseStateNameInAnimatorPerformanceWarning
UEA0011DoNotUseStringPropertyNamesPerformanceWarning
UEA0012CameraMainIsSlowGCWarning
UEA0013UseNonAllocMethodsGCWarning
UEA0014AudioSourceMuteUsesCPUPerformanceInfo
UEA0015InstantiateTakeParentPerformanceWarning
--------------------------------------------------------------------------------------------
AOT0001DoNotUseRemotingAOTInfo
AOT0002DoNotUseReflectionEmitAOTInfo
AOT0003TypeGetTypeAOTInfo

Building CLI executable

CLI requires .NET Core 2.1

dotnet publish -c Release -r win10-x64

or

dotnet publish -c Release -r ubuntu.16.10-x64

Command Line Interface

In order to use the Command Line Interface (CLI), download the latest release of UnityEngineAnalyzer then unzip the archive (https://github.com/vad710/UnityEngineAnalyzer/releases).

  1. Open a Command Prompt or Powershell Window
  2. Run Linty.CLI.exe <project path>
  3. Observe the analysis results
  4. (Optional) In the same location as the project file are report.json and UnityReport.html files containing the results of the analysis
    • Use command -e customexporter exporter2 ... to load custom exporters
  5. (Optional) configuration file path.
    • Use command -c configureFilePath.json to load custom configurations
    • Configuration json, allows to enable / disable analyzers
  6. (Optional) minimal severity for reports
    • Use command -s Info/Warning/Error to defined used minimal severity for reporting
    • Default is Warning
  7. (Optional) Unity version for check
    • Use command -v UNITY_2017_1/UNITY_5_5/UNITY_4_0/... to Unity version
    • For default analyzer will try to find ProjectVersion.txt file and parse version automatically.

Example:

> Linty.CLI.exe C:\Code\MyGame.CSharp.csproj

Visual Studio Integration

In Visual Studio 2017, go to Tools > Nuget Package Manager > Manage Nuget Packages for Solution.... Search for and install UnityEngineAnalyzer

Configuration

Under projects right-click Analyzers to modify the severity or to disable the rule completely.

Limitations

  • HTML Report requires FireFox or XOR (Corss Origin Request) enabled in other browsers
  • It doesn't have rules for all of Mono's AOT Limitations
  • IL2CPP might change the limitations of AOT compilation

License

See LICENSE

About

Roslyn Analyzer for Unity3D

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages