hhu-mahmoud / ExceptionalReSharper

Extension for ReSharper which analyzes thrown and documented C# exceptions and suggests improvements
Microsoft Public License
5 stars 2 forks source link

VS 2019 hangs on quick fix #4

Closed raubv0gel closed 2 years ago

raubv0gel commented 3 years ago

Many times VS 2019 hangs if I want to quick fix (Alt + Enter) a missing <exception …/> in XML doc. Seems there is heavy load on CPU. Is there any option to track/trace this issue?

VS 2019: 16.10.4 ReSharper: 2021.1.5 Exceptional: 2021.1.1

Great plugin btw.!

hhu-mahmoud commented 3 years ago

@raubv0gel Sorry for to delay by answering .. i was too busy and i have not seen the issue.

I tested it now with the same version of VS Community 16.10.4 with Resharper 2021.2.0 and Exceptional 2021.2.0 .. it works fine by me!

See pls the gif =>

12-08-_2021_08-51-33

Can you please test it again with the same versions and tell me again if it works?

raubv0gel commented 3 years ago

Thank you! It seems that for some types of exceptions only there is hang. For ArgumentException it worked, for ArgumentOutOfRangeException it hangs. Visual Studio then shows a „Visual Studio is busy“ ballon massage.

Example Code:

using Net.Pkcs11Interop.Common;
using System;

namespace Test
{
    /// <summary>
    /// </summary>
    internal static class Utilities
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hash">Hash value.</param>
        /// <param name="hashAlgorithm">Hash algorithm.</param>
        /// <returns></returns>
        public static byte[] CreatePkcs1DigestInfo(byte[] hash, CKM hashAlgorithm)
        {
            if (hash == null || hash.Length == 0)
                throw new ArgumentNullException(nameof(hash));

            byte[] pkcs1DigestInfo;
            switch (hashAlgorithm)
            {
                case CKM.CKM_MD5 when hash.Length != 16:
                    throw new ArgumentException("Invalid length of hash value.");
                case CKM.CKM_MD5:
                    pkcs1DigestInfo = new byte[] { 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                    Array.Copy(hash, 0, pkcs1DigestInfo, pkcs1DigestInfo.Length - hash.Length, hash.Length);
                    break;
                case CKM.CKM_SHA_1 when hash.Length != 20:
                    throw new ArgumentException("Invalid length of hash value.");
                case CKM.CKM_SHA_1:
                    pkcs1DigestInfo = new byte[] { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                    Array.Copy(hash, 0, pkcs1DigestInfo, pkcs1DigestInfo.Length - hash.Length, hash.Length);
                    break;
                case CKM.CKM_SHA256 when hash.Length != 32:
                    throw new ArgumentException("Invalid length of hash value.");
                case CKM.CKM_SHA256:
                    pkcs1DigestInfo = new byte[] { 0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                    Array.Copy(hash, 0, pkcs1DigestInfo, pkcs1DigestInfo.Length - hash.Length, hash.Length);
                    break;
                case CKM.CKM_SHA384 when hash.Length != 48:
                    throw new ArgumentException("Invalid length of hash value.");
                case CKM.CKM_SHA384:
                    pkcs1DigestInfo = new byte[] { 0x30, 0x41, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                    Array.Copy(hash, 0, pkcs1DigestInfo, pkcs1DigestInfo.Length - hash.Length, hash.Length);
                    break;
                case CKM.CKM_SHA512 when hash.Length != 64:
                    throw new ArgumentException("Invalid length of hash value.");
                case CKM.CKM_SHA512:
                    pkcs1DigestInfo = new byte[] { 0x30, 0x51, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                    Array.Copy(hash, 0, pkcs1DigestInfo, pkcs1DigestInfo.Length - hash.Length, hash.Length);
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(hashAlgorithm), hashAlgorithm, null);
            }

            return pkcs1DigestInfo;
        }
    }
}

Currently I have (all latest): VS 2019: 16.11.1 ReSharper: 2021.2 Exceptional: 2021.2.0

misterorlov commented 3 years ago

VS 2019: 16.11.3 hangs too

hhu-mahmoud commented 3 years ago

@raubv0gel @misterorlov Thanks for your report. I will take a look

Christian-GB-DE commented 3 years ago

Still a problem with VS 16.11.5 ReSharper: 2021.2.2 Exceptional: 2021.2.0

hhu-mahmoud commented 3 years ago

@Christian-GB-DE Sorry Cus of lot of works .. I did not have time to fix it. I will try as soon as possible to fix it.

Christian-GB-DE commented 2 years ago

@hhu-mahmoud - thanks für your replay. And also thanks for this great plugin. Because of this helpful plugin it's hard to wait for the fix 😉But of course, I understand your situation.

Thnaks for your work.

hhu-mahmoud commented 2 years ago

@raubv0gel @misterorlov @Christian-GB-DE I have fixed the bug. You can try it now. Exceptional Version 2021.2.2

Christian-GB-DE commented 2 years ago

@hhu-mahmoud - many thanks for that. Works for me. Great job.

raubv0gel commented 2 years ago

@hhu-mahmoud, perfect! Works. Thank you very much!