I am trying the new nullable reference types C# 8.0. I have come to one tiny issue:
foreach(FileSystemAccessRule rule in directorySecurity.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount)))
{
// do something with rule
}
This shows a warning since the compiler thinks the rule could be null, which it never will be.
My current fix is this:
foreach(FileSystemAccessRule? rule in directorySecurity.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount)))
{
if (rule == null) continue;
// do something with rule
}
But I would be much happier with a fix, like [NeverNull]FileSystemAccessRule rule or something like that. Is there a way to achieve this?