Cannot find HandlesResourceDisposal attribute in JetBrains.Annotation in Unity

Despite the fact that this attribute [HandlesResourceDisposal] is mentioned directly in the editor settings, it simply does not exist in any version of the UPM package for Unity. Literally, it's just missing for no reason, while [MustDisposeResource] exists. However, in the NuGet package installed in our Godot project, this attribute exists perfectly well, so at least it's not my imagination.

Some workarounds for Unity without using NuGet?

Thanks in advance.

0
1 comment

Hello Spiral Black ,

Thank you for reaching Rider Forum.

Unity has its own set of annotations, and they don’t always keep them in sync with the Rider's one. That’s why you see differences between the two. As for workarounds without installing the NuGet, you may do the following:

1.  Copy the JetBrains annotation definitions directly into your Unity project. Head over to Settings | Editor | Inspection Settings | Code Annotations in Rider and hit the Copy C# implementation to clipboard button. 

2. Create a new file in your Unity project and paste it there. 

Fair warning, though—when you do this, you might get some red code. That’s because some classes will clash with Unity's definitions. You'll need to go through and remove the duplicates or any classes that are causing issues.

In the end, you should have the JetBrains attributes available without the conflicts. 

Hope. my reply was helpful.

1

Please sign in to leave a comment.