Problem
When running InspectCode.exe on Unity code, one can notice that the tool can treat [Serializable] fields as [SerializeField]
Environment
- Tool:
InspectCode.exe - Project Type: Unity project
- Rule Defined: for Unity serialized fields
Root Cause
The issue is likely caused by running InspectCode.exe against a .csproj file instead of the solution file ({unity_project}.sln). Unity generates project-specific .csproj files, but these files do not always fully represent the project's context or adhere to custom rules configured for the solution. When InspectCode scans the .csproj file alone, it may produce unpredictable results, including unexpected warnings such as the one observed for FooVar.
Resolution
To resolve this issue, ensure you pass the path to the Unity solution file {unity_project}.sln instead of individual .csproj files when running InspectCode.exe. This approach provides InspectCode with the full project context, including all configurations and custom rules, which should eliminate the unexpected behavior.
Steps
-
Identify the location of your Unity solution file
{unity_project}.sln. This file is typically found in your Unity project directory. -
Run
InspectCode.exeusing the.slnfile instead of.csproj. For instance:InspectCode.exe {path_to_unity_project}/{unity_project}.sln\ -
Verify the results to ensure that warnings are appropriately flagged based on your custom rules.
Note: Always ensure that you are using the latest version of InspectCode.exe
Comments
0 comments
Please sign in to leave a comment.