Help needed on "CS8774 Member must have a non-null value when exiting" #4270
-
Need some help on [MemberNotNull(nameof(dqListCache))]
public async Task InitCacheAsync()
{
using var conn = connFactory.NewConnection();
dqListCache = (await conn.QueryAsync<MyDto>("select * from MyTable")).ToList();
} It generates "CS8774 Member must have a non-null value when exiting." on the last line, and adding null-forgiving |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
It's possible that this is because it's task returning and async. So the method literally can return (giving the caller the task) before the value is actually set. |
Beta Was this translation helpful? Give feedback.
-
What happens if you start the method with |
Beta Was this translation helpful? Give feedback.
What happens if you start the method with
dqListCache = null!
prior to any of the existing code.