Unity-Technologies / ProjectAuditor

Project Auditor is an experimental static analysis tool for Unity Projects.
Other
822 stars 68 forks source link

Mono Cecil code compilation error #120

Closed Belgi07 closed 2 years ago

Belgi07 commented 2 years ago

Hi, I'm part of one of Electronic Arts mobile teams, trying to develop a new game. We were using this package for a while now and everything was ok until we decided to upgrade the Unity version from 2020.3 to 2021.3.9f8 both LTS versions. There is a compile error when using 2021.3 and we wonder if you can do a quick fix for this one. This error is present in both the official version and in our modified version

"Library\PackageCache\com.unity.project-auditor@b19edc002e\Editor\InstructionAnalyzers\BoxingAnalyzer.cs(51,41): error CS1061: 'GenericParameterConstraint' does not contain a definition for 'IsValueType' and no accessible extension method 'IsValueType' accepting a first argument of type 'GenericParameterConstraint' could be found (are you missing a using directive or an assembly reference?)"

Thank you cbelghiru@ea.com

mtrive commented 2 years ago

Hi, Sorry for the inconvenience. What version of Project Auditor are you using?

Belgi07 commented 2 years ago

We were using 0.7.0-preview before, didn't worked with 2021.3, then I tried with 0.8.3-preview and I got the above error.

In Editor\InstructionAnalyzers\BoxingAnalyzer.cs:37, there is a macro #if UNITY_2022_2_OR_NEWER. I believe we should use 2021_3_OR_NEWER

mtrive commented 2 years ago

I suspect there is something else that might be causing this. Does your project depend on com.unity.nuget.mono-cecil ? If so, what version?

Belgi07 commented 2 years ago

"com.unity.nuget.mono-cecil": { "version": "1.11.4", "depth": 2, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" },

Referenced by: "com.unity.collections", "com.unity.entities","com.unity.properties"

mtrive commented 2 years ago

I pushed a fix in the mono-cecil branch. Any chance you could confirm this fixes the compilation error ?

mtrive commented 2 years ago

I pushed 145b0ecc1ea2aaba0b3574fdeb76ee75c88fffe0 which should fix it. Hopefully that works for you too. If not, please reopen this case.