Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"PrivateImplementationDetails" function when decompiling a C #

I'm rebuilding a library programmed in C # and need help with a Switch statement, I have the following code snippet using the <PrivateImplementationDetails> .ComputeStringHash () function generated during compilation. My question is, what is the function that I should use? Will I get the same result using sss.GetHashCode()?

Currently the error that is presented to me is Can not resolve symbol 'PrivateImplementationDetails'.

 switch (<PrivateImplementationDetails>.ComputeStringHash(sss)) {
    case 0x1315fc:
        if (sss == "ASD") {
            break;
        }
        goto Label_0105;

    case 0x15c3dc:
        if (sss == "JKL") {
            break;
        }
        goto Label_0105;
 }
like image 284
Joseph Avatar asked Jun 02 '17 23:06

Joseph


1 Answers

At the time the question was asked, the generated IL was relatively new, so the decompilers hadn't been updated to support it. Essentially the decompiler revealed some of the underlying .NET framework code and the hash function used to support string switch statements.

Now, a year or so later, the decompilers have been updated so they should just show a switch statement like this:

switch (sss)
{
    case "ASD":
    // do something
    break;
    case "JKL":
    // do something
    break
}

I've tested this with DotPeek and can confirm it shows this correctly.

like image 170
2 revs, 2 users 88% Avatar answered Oct 18 '22 18:10

2 revs, 2 users 88%