Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Warn if property is not set as virtual

Vote:
 

If you create a pagetype with new properties it would be neat if we could get a clear indication or warning if the property isn't set as virtual in code = won't work.

That would save some debugging time in most projects. Is it visible in logs maybe already? I haven't checked. Possible to display in edit /admin?

#145155
Feb 25, 2016 22:00
Vote:
 

To me, I get a quite good YSOD with detailed Exception message at site startup if I forget to make a property virtual. Don't you get that?

Don't remember if it only applies when I have the Display attributes though (which to me is essential to add)

#145160
Edited, Feb 25, 2016 22:42
Vote:
 

I haven't tested it lately, it was a few years back now, but I know I forgot it earlier and just got null back. I saw an other user had the same problem the other day so it seems to still be a small problem sometimes...maybe tweak it a little then I guess :)

#145165
Feb 26, 2016 8:37
Vote:
 

+1

It is possible to define the following block:

[ContentType(GUID = "1F8B71EF-4776-4282-A8F0-45A6599FF06F")]
public class MyBlock : BlockData
{
    [UIHint(UIHint.Image)]
    public ContentReference Image { get; set; }
}

Episerver won't throw any exception (ysod), and it will allow editors to store the value in edit mode.

In backend, Image is always null.

#147744
Apr 22, 2016 15:45
Vote:
 

There is a bug in the validation if a property is part of an interface (because it is virtual but also final): http://world.episerver.com/support/Bug-list/bug/CMS-3090

Tested the above code and it seems to throw now.

#155218
Sep 12, 2016 15:57
This thread is locked and should be used for reference only.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.