Suppress nullable warnings
Closed this issue · 6 comments
As variables and commands get initialized not in constructor but in seperate methods code analyzer does net recognize it and throw always CS8618 warnings. Partly workaround is adding a MemberNotNull attribute on the OnInitialize method. This is not nice but works at least for all Properties. But it is not possible to do this for the commands as they are in the generated file part. I tried a lot to disable these warning but nothing works, pargam once, SuppressMessage attribute or rules in .editorconfig file for [*.g.cs] files. Could it be an option to add warnings to suppress in the next version ?
Hi @Telespaz , thank you for this issue, and great that you were bringing this topic up.
Yes, indeed, handling nullable reference types in the generated code is still something that need to be improved. Would it be possible for you to create and upload here a small repro project that shows the stuff?
I plan to bring a fix with the next release.
Hi,
thanks for your response. I created a small sample project, hope thats correct, its the first time for me.
https://github.com/Telespaz/mvvmgen-nullable-71
Its generating 2 warnings.
Thank you @Telespaz , that's perfect. I'm on vacation right now, but will look into it in September.
Hi @Telespaz , I'll work on it next week and then let's plan a release in the first week of December.
The command nullable warning will be gone with the next release coming out in the next week.
For the OnInitialize method I don't have any other workaround right now than either set MemberNotNull or declare the field as nullable. But both cases should allow you to create ViewModels without any nullable warnings.
If there's anything else, let's start with a new issue. Hope that's good for you.