Inspection: False "Field ... is never assigned" error
I'm using R# 8 and the following code produces two false errors:
"Field 'dwTime' is never assigned" and "Field 'cbSize' is assigned but its value is never used".
public static class User32 { private struct LASTINPUTINFO { public uint cbSize; public uint dwTime; } [DllImport("user32.dll")] static private extern bool GetLastInputInfo(ref LASTINPUTINFO lii); public static TimeSpan InputIdleTimeSpan { get { var info = new LASTINPUTINFO(); info.cbSize = Convert.ToUInt32(Marshal.SizeOf(info)); if (!GetLastInputInfo(ref info)) throw new InvalidOperationException("Failed to read the last input time."); var environmentTickCount = Convert.ToUInt32(Environment.TickCount); var lastInputTicks = environmentTickCount - info.dwTime; TimeSpan timeSpanFromTicks = TimeSpan.FromTicks(lastInputTicks * 10000); return timeSpanFromTicks; } } }
Please sign in to leave a comment.
Hello Mathias,
A new ticket http://youtrack.jetbrains.com/issue/RSRP-383520 was submitted to YouTrack.
Thanks!