# \[view models / page structuring series\] Warnings flood my markup when I use nullable view models

**URL:** <https://forum.dotvvm.com/t/view-models-page-structuring-series-warnings-flood-my-markup-when-i-use-nullable-view-models/149>\
**Category:** Discussion in English\
**Tags:** vs\
**Created:** [February 19, 2024, 11:34am UTC](https://forum.dotvvm.com/t/view-models-page-structuring-series-warnings-flood-my-markup-when-i-use-nullable-view-models/149 "2024-02-19T11:34:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarianV](https://forum.dotvvm.com/letter_avatar_proxy/v4/letter/m/c0e974/32.png) [@MarianV](https://forum.dotvvm.com/u/MarianV)\
**Post date:** [February 19, 2024, 11:34am UTC](https://forum.dotvvm.com/t/view-models-page-structuring-series-warnings-flood-my-markup-when-i-use-nullable-view-models/149/1 "2024-02-19T11:34:40Z")

</div>

(taken from here: [Simple validation crashing on just one property (+other validation issues)](https://forum.dotvvm.com/t/simple-validation-crashing-on-just-one-property-other-validation-issues/140)

> [@Simple validation crashing on just one property (+other validation issues)](https://forum.dotvvm.com/t/simple-validation-crashing-on-just-one-property-other-validation-issues/140/20):
>
> I’ve switched to sub view models that accept null and bound them to my sections. I get warnings of possible null value in markup in many places. I suspect this is because nullable context is enabled at the project level (it was convenient to leave it like that).  
> ![image](https://forum.dotvvm.com/uploads/default/original/1X/cf5bc67cdf7fa3766b2d3b09179c564714bf8b73.png)
> 
> Do you have any suggestions for getting rid of this?  
> ![image](https://forum.dotvvm.com/uploads/default/original/1X/67480cb0d5bfd8e4b463cf0357c3a5cae56f5db6.png)
> 
> PS:  
> Disabling it at the top of the .cs view model file of the MarkupControl does not resolve this.  
> ![image](https://forum.dotvvm.com/uploads/default/original/1X/c3611413220497503440ec8845572b4288a5847e.png)

PS 2:  
This unfortunately blows up exponentially very easily and a nullable disabled context **is certainly not an option** for us.

 ![fdgdsgsdgfd](https://forum.dotvvm.com/uploads/default/original/1X/ff88692d458777c6aa930c0ccc079c814c63b3a5.png)

---

<div class="post-metadata">

**Author:** ![MarianV](https://forum.dotvvm.com/letter_avatar_proxy/v4/letter/m/c0e974/32.png) [@MarianV](https://forum.dotvvm.com/u/MarianV)\
**Post date:** [February 19, 2024, 12:47pm UTC](https://forum.dotvvm.com/t/view-models-page-structuring-series-warnings-flood-my-markup-when-i-use-nullable-view-models/149/2 "2024-02-19T12:47:54Z")

</div>

UPDATE

I am not able do obtain progress with trying to disable the warnings, even though it is not to be desired to disable them in the view model:

```
#pragma warning disable CS8600
#pragma warning disable CS8602

```

* * *

Putting `[NotNull]` on properties in view model makes the markup warnings disappear but, of course, they also disappear in the view model file.

---

<div class="post-metadata">

**Author:** ![MarianV](https://forum.dotvvm.com/letter_avatar_proxy/v4/letter/m/c0e974/32.png) [@MarianV](https://forum.dotvvm.com/u/MarianV)\
**Post date:** [February 19, 2024, 1:00pm UTC](https://forum.dotvvm.com/t/view-models-page-structuring-series-warnings-flood-my-markup-when-i-use-nullable-view-models/149/3 "2024-02-19T13:00:27Z")

</div>

UPDATE

Progress:  
 ![image](https://forum.dotvvm.com/uploads/default/original/1X/a010581be7051ba083f8552621ce9d9c3fed0dc0.png)

This eliminates all warnings from the MarkupControl markup.

now,  
❓ how do I disable specifically only for .dothtml and .dotcontrol files?

---

<div class="post-metadata">

**Author:** ![MarianV](https://forum.dotvvm.com/letter_avatar_proxy/v4/letter/m/c0e974/32.png) [@MarianV](https://forum.dotvvm.com/u/MarianV)\
**Post date:** [February 19, 2024, 1:39pm UTC](https://forum.dotvvm.com/t/view-models-page-structuring-series-warnings-flood-my-markup-when-i-use-nullable-view-models/149/4 "2024-02-19T13:39:22Z")

</div>

UPDATE on disabling for specific files:

Not able to do anything with the approach posted here: [https://stackoverflow.com/a/70755376/2603874](https://stackoverflow.com/a/70755376/2603874)

![image](https://forum.dotvvm.com/uploads/default/original/1X/3b766e33a8edce7d4b1b66b79cef878930f92dd7.png)

.editorconfig rules look like are ignored for DotVVM specific markup files (I tried various alternatives) while they do have effect on .cs files. So… I don’t know.

---

<div class="post-metadata">

**Author:** ![exyi](https://forum.dotvvm.com/user_avatar/forum.dotvvm.com/exyi/32/9_2.png) [@exyi](https://forum.dotvvm.com/u/exyi)\
**Post date:** [February 19, 2024, 1:41pm UTC](https://forum.dotvvm.com/t/view-models-page-structuring-series-warnings-flood-my-markup-when-i-use-nullable-view-models/149/5 "2024-02-19T13:41:18Z")

</div>

This is essentially the same problem as [[Validation series] Required validation for int? property gives warnings in markup](https://forum.dotvvm.com/t/validation-series-required-validation-for-int-property-gives-warnings-in-markup/146), right?

> [@Simple validation crashing on just one property (+other validation issues)](https://forum.dotvvm.com/t/simple-validation-crashing-on-just-one-property-other-validation-issues/140/20):
>
> Do you have any suggestions for getting rid of this?

I don’t know, I reported it to the VS Extension yesterday. I don’t use Visual Studio, but I doubt you can easily work around it, I think it will have to be fixed by us

---

<div class="post-metadata">

**Author:** ![MarianV](https://forum.dotvvm.com/letter_avatar_proxy/v4/letter/m/c0e974/32.png) [@MarianV](https://forum.dotvvm.com/u/MarianV)\
**Post date:** [February 19, 2024, 1:43pm UTC](https://forum.dotvvm.com/t/view-models-page-structuring-series-warnings-flood-my-markup-when-i-use-nullable-view-models/149/6 "2024-02-19T13:43:21Z")

</div>

> [@exyi](#):
>
> This is essentially the same problem as [[Validation series] Required validation for int? property gives warnings in markup](https://forum.dotvvm.com/t/validation-series-required-validation-for-int-property-gives-warnings-in-markup/146), right?

Yes, they are the same. Good catch! And sorry, I’ve missed that - lots of stuff happening here these days.

---

<div class="post-metadata">

**Author:** ![exyi](https://forum.dotvvm.com/user_avatar/forum.dotvvm.com/exyi/32/9_2.png) [@exyi](https://forum.dotvvm.com/u/exyi)\
**Post date:** [February 19, 2024, 1:44pm UTC](https://forum.dotvvm.com/t/view-models-page-structuring-series-warnings-flood-my-markup-when-i-use-nullable-view-models/149/7 "2024-02-19T13:44:49Z")

</div>

no problem, I was just wondering I should report this one as another issue

---

<div class="post-metadata">

**Author:** ![MarianV](https://forum.dotvvm.com/letter_avatar_proxy/v4/letter/m/c0e974/32.png) [@MarianV](https://forum.dotvvm.com/u/MarianV)\
**Post date:** [March 7, 2024, 3:44pm UTC](https://forum.dotvvm.com/t/view-models-page-structuring-series-warnings-flood-my-markup-when-i-use-nullable-view-models/149/8 "2024-03-07T15:44:22Z")

</div>

UPDATE 😯

In a now decently 300 count of wide-rows markup:

 ![image](https://forum.dotvvm.com/uploads/default/original/1X/6c39699a0c0c60416d4045538cecbf7dad7aef81.png)

While developing I tend to disable the warning for obvious reasons but if I get in the habbit of keeping it disabled, when I enable it again I have surprise work to do in code-behind in many places in a refactor/backtrack kinda way.
