You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a class reference to WNDPROC ( private static WNDPROC WindowProc; )
Initialize it in the Window constructor ( WindowProc = ProcessWindowMessage; )\
Expected Behavior:
This should not report a warning ( CS8618 )
Actual Behavior:
I get the warning:
CS8618 Non-nullable field 'WindowProc' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
The text was updated successfully, but these errors were encountered:
Do you initialize it in an instance constructor or in the static constructor? If you meant an instance constructor, then this behavior seems correct, since the field is static. When the class is initialized, this field has not been assigned a non-null value. You could for example put the initialization in the field declaration (if possible), move the intialization to a static constructor (if possible) or remove the static modifier.
Version Used:
.Net 8.0
Steps to Reproduce:
Expected Behavior:
This should not report a warning ( CS8618 )
Actual Behavior:
I get the warning:
CS8618 Non-nullable field 'WindowProc' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
The text was updated successfully, but these errors were encountered: