Visual Studio 2022 warns "'xxx' may be null here" even when there is no possible way `xxx` could be null

Advertisements I have a C# method (net6.0) similar to this: bool TryDoSomething(out MyObject1? obj1, out MyObject2? obj2) { obj1 = DoSomethingElse(); obj2 = DoAnotherThing(); //Do some other things…. return obj1 != null && obj2 != null; } This is called by another method thusly: bool CallingMethod() { if (!TryDoSomething(out var obj1, out var obj2)) return… Read More Visual Studio 2022 warns "'xxx' may be null here" even when there is no possible way `xxx` could be null

Why do I get CS8601 null pointers warning even I do null check before

Advertisements I have a code piece below which creates an IplImage object from a camera and then creates a bitmap using this iplImage. var iplImage = Globals.ActiveCamera.Acquisition?.IplImage?.ConvertTo(PixelFormatName.BGR8, ConversionMode.Fast); if (iplImage == null) { return; } frame = new Bitmap(Convert.ToInt16(iplImage?.Width()), Convert.ToInt16(iplImage?.Height()), Convert.ToInt16(iplImage?.PixelFormat().CalculateStorageSizeOfPixels(iplImage.Width())), System.Drawing.Imaging.PixelFormat.Format24bppRgb, iplImage.Data()); Even, I check for null and return if it is. I still… Read More Why do I get CS8601 null pointers warning even I do null check before