简体   繁体   中英

c# compiler ILSpy on WP7

I use ILSpy and .NET Reflector to see code, and I found code I don't understand it, I serach in the web and I don't found any1 can help how to resolve it. This code with ILSpy (.NET Reflector show the same)

private void Item_Clicked(object sender, EventArgs e)
    {
        switch (0)
        {
        case 0:
            {
                IL_0E:
                FileSystemItem fileSystemItem;
                while (true)
                {
                    fileSystemItem = (sender as FileSystemItem);
                    int num = 1;
                    while (true)
                    {
                        switch (num)
                        {
                        case 0:
                            if (<PrivateImplementationDetails>{4E2292E7-C82C-431F-9529-B0045F4C1457}.$$method0x60003e4-1 != null)
                            {
                                goto IL_25F;
                            }
                            if (true)
                            {
                                IL_163:
                                num = 3;
                                continue;
                            }
                            goto IL_163;

                        case 1:
                            if (fileSystemItem != null)
                            {
                                num = 11;
                                continue;
                            }
                            return;

                        case 2:
                            goto IL_3B8;

                        case 3:
                            {
                                Dictionary<string, int> expr_1B9 = new Dictionary<string, int>(9);
                                expr_1B9.Add(".mp3", 0);
                                expr_1B9.Add(".wav", 1);
                                expr_1B9.Add(".wma", 2);
                                expr_1B9.Add(".wmv", 3);
                                expr_1B9.Add(".avi", 4);
                                expr_1B9.Add(".jpg", 5);
                                expr_1B9.Add(".png", 6);
                                expr_1B9.Add(".txt", 7);
                                expr_1B9.Add(".inf", 8);
                                <PrivateImplementationDetails>{4E2292E7-C82C-431F-9529-B0045F4C1457}.$$method0x60003e4-1 = expr_1B9;
                                num = 15;
                                continue;
                            }

                        case 4:
                            {
                                string ext;
                                if ((ext = fileSystemItem.Ext) != null)
                                {
                                    num = 8;
                                    continue;
                                }
                                return;
                            }

                        case 5:
                            goto IL_2C9;

                        case 6:
                            num = 12;
                            continue;

                        case 7:
                            {
                                string ext;
                                int num2;
                                if (<PrivateImplementationDetails>{4E2292E7-C82C-431F-9529-B0045F4C1457}.$$method0x60003e4-1.TryGetValue(ext, ref num2))
                                {
                                    num = 6;
                                    continue;
                                }
                                return;
                            }

                        case 8:
                            num = 0;
                            continue;

                        case 9:
                            goto IL_25A;

                        case 10:
                            goto IL_36A;

                        case 11:
                            num = 14;
                            continue;

                        case 12:
                            {
                                int num2;
                                switch (num2)
                                {
                                case 0:
                                case 1:
                                case 2:
                                    num = 16;
                                    continue;

                                case 3:
                                case 4:
                                    goto IL_171;

                                case 5:
                                case 6:
                                    goto IL_1A4;

                                case 7:
                                case 8:
                                    this.ShowText(fileSystemItem.Path);
                                    num = 9;
                                    continue;

                                default:
                                    num = 13;
                                    continue;
                                }
                                break;
                            }

                        case 13:
                            return;

                        case 14:
                            if (fileSystemItem.IsFolder)
                            {
                                switch ((1 == 1) ? 1 : 0)
                                {
                                case 0:
                                case 2:
                                    goto IL_36F;

                                case 1:
                                    IL_2B7:
                                    if (false)
                                    {
                                        IL_2BD:
                                        num = 5;
                                        continue;
                                    }
                                    goto IL_2BD;
                                }
                                goto IL_2B7;
                            }
                            num = 4;
                            continue;

                        case 15:
                            goto IL_25F;

                        case 16:
                            if (fileSystemItem.IsPlaying)
                            {
                                num = 10;
                                continue;
                            }
                            goto IL_36F;
                        }
                        break;
                        IL_25F:
                        num = 7;
                        continue;
                        IL_36F:
                        BackgroundAudioPlayer.get_Instance().set_Track(new AudioTrack(new Uri(fileSystemItem.Path, 2), "Unknown", "Unknown", "Unknown", null));
                        IEnumerator<object> enumerator = this.filesListBox.get_Items().GetEnumerator();
                        num = 2;
                    }
                }
                IL_131:
                BackgroundAudioPlayer.get_Instance().Stop();
                fileSystemItem.IsPlaying = false;
                return;
                IL_171:
                MediaPlayerLauncher mediaPlayerLauncher = new MediaPlayerLauncher();
                mediaPlayerLauncher.set_Media(new Uri(fileSystemItem.Path, 2));
                mediaPlayerLauncher.set_Location(2);
                mediaPlayerLauncher.Show();
                return;
                IL_1A4:
                this.ShowImage(fileSystemItem.Path);
                return;
                IL_25A:
                return;
                IL_2C9:
                this.ShowFolderContents(fileSystemItem.Path);
                return;
                IL_36A:
                goto IL_131;
                IL_3B8:
                try
                {
                    int num = 2;
                    while (true)
                    {
                        switch (num)
                        {
                        case 0:
                            num = 1;
                            continue;

                        case 1:
                            goto IL_EC;

                        case 3:
                            {
                                IEnumerator<object> enumerator;
                                if (!enumerator.MoveNext())
                                {
                                    num = 0;
                                    continue;
                                }
                                FileSystemItem fileSystemItem2 = (FileSystemItem)enumerator.get_Current();
                                fileSystemItem2.IsPlaying = false;
                                num = 4;
                                continue;
                            }
                        }
                        IL_A7:
                        num = 3;
                        continue;
                        goto IL_A7;
                    }
                    IL_EC:
                    goto IL_23A;
                }
                finally
                {
                    int num = 2;
                    while (true)
                    {
                        IEnumerator<object> enumerator;
                        switch (num)
                        {
                        case 0:
                            goto IL_12E;

                        case 1:
                            enumerator.Dispose();
                            num = 0;
                            continue;
                        }
                        if (enumerator == null)
                        {
                            break;
                        }
                        num = 1;
                    }
                    IL_12E:;
                }
                goto IL_131;
                IL_23A:
                fileSystemItem.IsPlaying = true;
                return;
            }
        }
        goto IL_0E;
    }

the error of this dictionnary show me this error

<PrivateImplementationDetails>{4E2292E7-C82C-431F-9529-B0045F4C1457}.$$method0x60003e4-1

So, this what? and how Can I resolve that? I need to replace it with another variable or what?

<PrivateImplementationDetails>{4E2292E7-C82C-431F-9529-B0045F4C1457} is not a proper C# construct. This is perhaps a substitute name which ILSpy issues to some internal framework function, which is not supposed to be used by ordinary developers.

So you need to reverse-engineer the code and understand what does it really do. And implement it by some other means. You cannot just take it and use it :)

By the way, the code seems to be an obfuscated one, while there are lots of unnecessary instructions there. In your case, the whole loop/switch codes a state machine in a fancy way. (It could be that its execution is always sequential, so you ought to try tracing it manually -- with paper and pencil. Try it, it's fun!)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM