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;
        static private extern bool GetLastInputInfo(ref LASTINPUTINFO lii);
        public static TimeSpan InputIdleTimeSpan
                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;
1 comment
Comment actions Permalink

Hello Mathias,

A new ticket was submitted to YouTrack.



Please sign in to leave a comment.