-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
False positive inspections. Attribute 'ExecuteInEditMode' and 'SerializeField' is not valid on this declaration type. #322
Comments
Is it only a notification or something else doesn't work? Could you please add a zip with logs from Help - Show logs in Files. Thanks! If you want to submit privately, please use youtrack.jetbrains.com |
Nope for some reason it's having trouble resolving some packages it looks like. |
But we are interested to see the logs, maybe there is a bug, which requires attention of the Rider team. |
I checked and my settings match the above. |
Wen't ahead and tried what you said and still didn't resolve anything. Still getting errors saying certain pieces of code are not allowed when they clearly should be :( |
So far here is what I have tried to resolve this issue.
Quite a few other small things as well :( |
Issue seem related to https://youtrack.jetbrains.com/issue/RIDER-11917 |
Very strange that Rider was working great for the entire time I've been using it. I close it and reopen it and I begin getting errors. Checked the bug you sent along. It does seem like it could be the same thing. |
Try also to remove the mono executable path. |
Removed mono path. Solution builds fine in rider however it reports a few errors on code that shouldn't exist. |
Any red code maybe? |
Yes indeed. I'll go post some pictures of that. |
Yup went ahead and cleared that. |
It is really a weird issue, |
That sounds great to me thanks! |
You may try
2.1. Switch Rider to internal mode 2.2. Call internal Action "Reload project and show logs" If it will not give a clue, I am ready to have a call today. Next week I will be on vacation, so lets do it today. |
Ok wen't ahead a did what you suggested. Should I post the log here? It looks like it wants ToolsVersion="4.0". Maybe that's whats causing the issue. |
Please post it. |
Here you go. Thanks once again for the help. |
If you expand References node in Solution Explorer, are there any yellow unresolved references? |
I have reproduced one of your red-code pieces. public class Class1:UnityEditor.Editor \Assets\Plugins\Editor\JetBrains\Class1.cs:114 Attribute 'UnityEngine.ExecuteInEditMode' is not valid on this declaration type. It is valid on 'Class' declarations only. |
https://docs.unity3d.com/ScriptReference/SerializeField.html
So the error is not a false one. |
Sorry it's been a long day and didn't have time to check this till now. That error should not be displaying there. Hopefully this makes sense. Thanks in advance! For reference check out this http://www.sirenix.net/odininspector/faq/30/why-is-odin-not-serializing-or-showing-my-field-or-property |
@citizenmatt please take a look. The code piece above shows 2 errors, which are implemented in resharper-unity, not Rider itself. using UnityEngine; namespace Assets.Plugins.Editor.JetBrains
} |
This behaviour was added in the last update. Some of Unity's attributes can only be usefully applied to certain targets - classes, fields, methods, etc. - but some of them don't declare these targets, which makes it hard to know if they're applied correctly, and difficult to see why they're not working (e.g. because they're in the wrong place). So this behaviour was added to help show when attributes where applied to the wrong code element, with the aim of helping the user know when something was wrong, and hopefully, why it wasn't working. But it's only an error in the editor. The attributes can be applied to any code element, and the compiler and Unity will allow it. Rider is just trying to help point out that these attributes don't do anything useful in these locations. As far as Unity is concerned, Of course, it's entirely likely I've got this wrong :) Can we just confirm that they are actually working where you've applied them? Then we can look at how best to fix this. I've had a scan through the page you've linked, and don't see an example of And does the |
According to one of there developers as long as Odin Inspector sees the However I do see what you mean by the errors showing up in Rider and yet them not effecting compile time. I would say though, if this is in fact a feature that is meant to be helpful I strongly urge you guys to turn those errors into warnings. This error has caused a great deal of confusion on my part and if Unity still allows the compilation it doesn't feel like it is in fact is an error then. The code where those errors do show up though has been in plugin code rather then my own code so I just assumed that the plugin developers knew what they were doing. ( Photon / Amplify Color are the two plugins to blame ) Hopefully this all makes sense. Thanks in advance! |
Ok some good news here. After @citizenmatt updated me on why Rider was spitting out those errors I went ahead and did some digging into installed plugins. Updated Photon and error went away for all photon scripts. Confirmed it was there error from there changelog. It reads That's one problem fixed. I still stick to my statement earlier though. Not sure these should be errors but warnings 😅 . Now to fix the .Net problem. |
I've been thinking about this, and I think that if it was only user code, I'd leave it as it is - the attributes are in the wrong place, and won't work (usually), so an error is fine. The idea behind the current implementation is that Unity didn't set valid targets on these attributes, so I added them, and this is the standard error that ReSharper displays when an attribute is applied to an incorrect target. However, we also have to deal with code downloaded from the asset store, and I think it's unfair to show an error in code that maybe you didn't write, or that you're not maintaining, especially when the code will compile just fine. So I think it would be a good idea to downgrade this to a warning, most likely greyed out "redundant" code, since it's technically fine to apply to this target, but does nothing. I'll open another issue to track that. |
Sounds like exactly what I was thinking @citizenmatt. Great idea. To give Rider / Resharper-Unity credit I went ahead contacted all the plugin authors where the errors were displaying and told them the attributes were not taking effect. I'm sure they were happy the bug was caught before it became a problem 👍. They all told me they would fix it in the upcoming updates. Thanks once again for the stellar help guys. Kudos @citizenmatt & @van800 |
Lovely feedback, thanks! This is what we're aiming at - helping find issues without having to debug, or switch to Unity or know some weird rules. Thanks for reporting to the plugin authors! |
Seemingly randomly I started getting the above message when opening up a Unity project in Rider.
The text was updated successfully, but these errors were encountered: