Home > Back-end >  Can you make a global rule that `virtual` properties are automatically nullable?
Can you make a global rule that `virtual` properties are automatically nullable?

Time:01-26

With how the virtual keyword interacts with EPiServer CMS's implementation of EntityFramework, where empty properties will be read as null, is there a way to define at a project-level that all virtual properties are nullable?

These properties are inherently & quietly nullable in any case, and we need to directly check if these properties are null or not when working on them in EPiServer projects. As I understand it, it makes more sense to designate that virtual implicitly means that the property is nullable than to have every single property on any CMS Page, Block, Media asset (image, video, audio, file) explicitly add ? to give that context & clarity.

The Null-state analysis itself is desired, however due to the overall quantity of properties that would need to be individually denoted as nullable, some way to effectively bulk-define propeties as nullable would be ideal.

CodePudding user response:

No, but you can simply disable Null-state analysis for the code or whole project. Nullable reference types

  • Related