-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
private standard Unity MonoBehaviour methods generate IDE0051 #170
Comments
Hello @WarpedPixel, we already have a dedicated suppressor to handle that: here is the documentation: here is the related test: So my guess is that the issue is perhaps on your side ?
Thanks! |
You have indeed. Running vscode latest on Mac Catalina latest. Unity 2019.4.23f1. I had to patch my csproj files to limit LangVersion to 8.0 since that is what Unity supports. I definitely see other UNTxxxx warnings. For example, I see UNT0001 if the Update body in my example above is empty. I'll test a few things. EDIT: I also had to manually install the NuGet package following these instructions (but I did not disable IDE0051): https://code.visualstudio.com/docs/other/unity#_enabling-unity-warnings |
Ah that's why: vscode (omnisharp in fact) is not yet able to use suppressors (USPxxxx), only regular analyzers (UNTxxxx) are working so far. The original issue is tracked here: The good news, a PR seems to fix that: |
@WarpedPixel here are directions on how to setup an .editorconfig file and then turn off IDE0051. @sailro sweet, I've been waiting for this to be addressed. Thanks! |
I have the same issue, looks like something broke again. VStudio 2022 marks Monobehaviour methods - Start, Update, etc - as unused methods, after creating a new Monobehaviour inside Unity Editor. |
(Hopefully this is the right way to report what looks like a bug to me. Love the analyzers and trying to get to zero warning in my code, thanks!)
Bug description
This code generates IDE0051 with analyzer 1.10.2:
Expected behavior
These methods are not "unused" since, when derived from MonoBehaviour, they are actually invoked by Unity.
This is regardless if they are public or private.
So the expected behavior is for all these methods with standard Unity MonoBehavior signatures (Start, Awake, Update, etc.) to never flag IDE0051. While other private methods continue to flag that normally.
Workaround
Just make sure all your standard MonoBehaviour methods are declared public
The text was updated successfully, but these errors were encountered: