False auto-implemented property warning on certain classes
2394425147 opened this issue · 1 comments
I was using Medicine's Inject.Single
on abstract MonoBehaviours
today, and it warned me about it not being an auto-implemented property. I did compare that line with other Inject.Single
properties elsewhere in the project but I wasn't able to tell the difference. Maybe there's something wrong with using it in abstract classes (?)
Code:
ItemBehaviour.cs:
public abstract class ItemBehaviour<TReference> : MonoBehaviour where TReference : Item
{
[Inject.Single] // << warning Property RenderManager RenderManager needs to be an auto-implemented property to use injection. For example: (No example given)
protected RenderManager RenderManager { get; }
}
RenderManager.cs:
[Register.Single]
public class RenderManager : MonoBehaviour
Thank you!
Hey, thanks for taking the time to report this issue! I've managed to narrow it down to a few issues with the way generics were handled in the codegen. Dealing with generics in Cecil is a bit of a headache, but I've managed to fix it at least for some simple cases. I also threw together a quick test to make sure that handling of this case doesn't break in the future.
I also noticed that the error message was truncated - turns out Unity skips the rest of the error message after the newline char. I'm pretty sure this worked fine earlier... anyway, I stripped the newlines, that should cover it.
Let me know if you find any other edge cases with the codegen, I'd really like it to be as reliable as possible.