-
Notifications
You must be signed in to change notification settings - Fork 134
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
Add custom attribute to mark method as expensive #1030
Comments
See also RIDER-22807 |
I second this. I have an external dll that does implement some kind of frequently called Update method which I'd love being able to tag as "expensive" without having to resort to a hack: Putting a fake call to it in an Unity Update method to trick it seems the wrong way to achieve this. |
Implemented, from now you can add |
Add a new
JetBrains.Annotations
attribute to mark a method as expensive. Any usage of this method inside a performance critical context would be highlighted as usage of an expensive method, in the same was asGetComponent
,Find
, etc. are currently handled.This would be useful for third party assemblies that indirectly call the known Unity APIs that are expensive (e.g.
Camera.main
callsFindObjectWithTag
internally) and could be included as external annotations, or compiled directly into the code. We should add features to make it easy to create or add a reference/package to use the attribute.Another option is to ship a public attribute in the plugin, or as a package. We can mark it as
[Conditional]
to prevent a binary dependency, or maybe[Conditional("UNITY_EDITOR")]
so the dependency is only there for the editor, which would help if the project was being distributed on the Asset Store or as a package.We should also think carefully about choosing a name - expensive might not be expressive enough. Maybe something like "performance sensitive"? And it would be worth co-ordinating with R# team to see if it could be shared, or just something with a Unity specific name.
The text was updated successfully, but these errors were encountered: