Endjin.Assembly.ChangeDetection.Infrastructure.LastException.LastException C# (CSharp) Method

LastException() public method

public LastException ( ) : System
return System
        public LastException()
        {
            if (myThreadPointerFieldInfo == null)
            {
                // Dont read the donĀ“t or you will get scared. 
                // I prefer to read this more like: If you dont know the rules you will
                // get biten by the next .NET Framework update
                myThreadPointerFieldInfo = typeof(Thread).GetField("DONT_USE_InternalThread", BindingFlags.Instance | BindingFlags.NonPublic);
            }

            if (myThreadOffset == -1)
            {
                var context = ClrContext.None;
                context |= (IntPtr.Size == 8) ? ClrContext.Is64Bit : ClrContext.Is32Bit;
                context |= (Environment.Version.Major == 2) ? ClrContext.IsNet2 : ClrContext.None;
                context |= (Environment.Version.Major == 4) ? ClrContext.IsNet4 : ClrContext.None;

                switch (context)
                {
                    case ClrContext.Is32Bit | ClrContext.IsNet2:
                        myThreadOffset = 0x180;
                        break;
                    case ClrContext.Is32Bit | ClrContext.IsNet4:
                        myThreadOffset = 0x188;
                        break;
                    case ClrContext.Is64Bit | ClrContext.IsNet2:
                        myThreadOffset = 0x240;
                        break;
                    case ClrContext.Is64Bit | ClrContext.IsNet4:
                        myThreadOffset = 0x250;
                        break;

                    default: // ups who did install .NET 5?
                        myThreadOffset = -1;
                        break;
                }
            }
        }