Nullable settings in ctor of BlockGridItem
#14550
Replies: 3 comments
-
Constructor looks like as shown below, so might have been an oversight: public BlockGridItem(Udi contentUdi, IPublishedElement content, Udi settingsUdi, IPublishedElement settings)
{
ContentUdi = contentUdi ?? throw new ArgumentNullException(nameof(contentUdi));
Content = content ?? throw new ArgumentNullException(nameof(content));
SettingsUdi = settingsUdi;
Settings = settings;
} So I agree that it makes sense to make them nullable. Although ideally I suppose It could probably also make sense to add a constructor overload that only takes the two first parameters: public BlockGridItem(Udi contentUdi, IPublishedElement content)
{
ContentUdi = contentUdi ?? throw new ArgumentNullException(nameof(contentUdi));
Content = content ?? throw new ArgumentNullException(nameof(content));
} |
Beta Was this translation helpful? Give feedback.
-
Yeah, I guess the settings should be nullable, maybe @Zeegaan can answer that? I also wonder it we should have an extension like this?
but wouldn't benefits much it the code above. Not sure it we can make rendering a single block item from a composition simpler.
|
Beta Was this translation helpful? Give feedback.
-
I haven't looked into this, but at a quick glance, my best bet would be: yes they should be nullable 👍 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have this following where a Header can be used on its own, but also works as composition on existing blocks, e.g. a few carousel blocks.
I can render the tagline and a heading properties directly, or include a partial view using
IBlockHeader
model in each block inclusive the Header block, but I found the following works to render the block directly.However should SettingsUdi and Settings arguments be nullable as these are not required?
Beta Was this translation helpful? Give feedback.
All reactions