How can we help you today? How can we help you today?

-- Edited title -- Net Reflector v6.10.11

Source code:
public static bool IsValidIdentifierName2(string name)
{
	for (var num = 0; num < name.Length; num++)
	{
		var category = char.GetUnicodeCategory(name[num]);
		var flag = category == UnicodeCategory.UppercaseLetter
			|| category == UnicodeCategory.LetterNumber
			|| category == UnicodeCategory.TitlecaseLetter
			|| category == UnicodeCategory.OtherLetter
			|| category == UnicodeCategory.LetterNumber
			|| name[num] == '_';
		var flag2 = category == UnicodeCategory.NonSpacingMark
			|| category == UnicodeCategory.SpacingCombiningMark
			|| category == UnicodeCategory.ModifierLetter
			|| category == UnicodeCategory.DecimalDigitNumber;
		if (num == 0 && !flag) return false;
		if (!flag && !flag2) return false;
	}
	return true;
}
Decompiled code:
public static bool IsValidIdentifierName2(string name)
{
    int num;
    UnicodeCategory category;
    bool flag;
    bool flag2;
    bool CS$1$0000;
    bool CS$4$0001;
    num = 0;
    goto Label_0074;
Label_0005:
    category = char.GetUnicodeCategory(name[num]);
    flag = ((((category == null) || (category == 9)) || ((category == 2) || (category == 4))) || (category == 9)) ? 1 : (name[num] == 0x5f);
    flag2 = (((category == 5) || (category == 6)) || (category == 3)) ? 1 : (category == 8);
    if (((num != null) ? 1 : flag) != null)
    {
        goto Label_005D;
    }
    CS$1$0000 = 0;
    goto Label_0088;
Label_005D:
    if (((flag != null) ? 1 : flag2) != null)
    {
        goto Label_006F;
    }
    CS$1$0000 = 0;
    goto Label_0088;
Label_006F:
    num += 1;
Label_0074:
    if ((num < name.Length) != null)
    {
        goto Label_0005;
    }
    CS$1$0000 = 1;
Label_0088:
    return CS$1$0000;
}

How come this: if (num == 0 && !flag) turn into this: if (((num != null) ? 1 : flag) != null) ???
fuckred_gate
0

Comments

5 comments

  • StephenC
    I've edited your post due to the obscenity included in it. Posting that sort of language in a public forum is unconstructive, especially when you are seeking technical help.

    Any further posting with either a title or message content that includes offensive or abusive language will automatically be deleted from now on.

    Someone will now look into your question and respond shortly,

    Stephen
    StephenC
    0
  • Clive Tong
    Hi.

    If you don't turn the optimization off, then the code is much more like you expected.

    What were you hoping to get out of the unoptimised code? It might be more informative to simply look at the IL.
    public static bool IsValidIdentifierName2(string name)
    {
        for (int i = 0; i < name.Length; i++)
        {
            UnicodeCategory unicodeCategory = char.GetUnicodeCategory(name[i]);
            bool flag = ((((unicodeCategory == UnicodeCategory.UppercaseLetter) || (unicodeCategory == UnicodeCategory.LetterNumber)) || ((unicodeCategory == UnicodeCategory.TitlecaseLetter) || (unicodeCategory == UnicodeCategory.OtherLetter))) || (unicodeCategory == UnicodeCategory.LetterNumber)) || (name[i] == '_');
            bool flag2 = (((unicodeCategory == UnicodeCategory.NonSpacingMark) || (unicodeCategory == UnicodeCategory.SpacingCombiningMark)) || (unicodeCategory == UnicodeCategory.ModifierLetter)) || (unicodeCategory == UnicodeCategory.DecimalDigitNumber);
            if (!((i != 0) || flag))
            {
                return false;
            }
            if (!(flag || flag2))
            {
                return false;
            }
        }
        return true;
    }
    
    Clive Tong
    0
  • fuckred_gate
    I'm sorry for my offensive and abusive language, I thought that the decompiler was degraded deliberately. I wonder why neither devs nor lots of users noted that before me. I have one of the previous versions of .Net Reflector so why I can't use it? When I run it it says that the version is outdated and asks me for update, if I press the button "No" it just exits.
    fuckred_gate
    0
  • fuckred_gate
    Turning optimisation to .Net 3.5 settles the matter. Thank you, Clive Tong.
    fuckred_gate
    0
  • StephenC
    Regarding the previous version exiting - Reflector has done this for years and performs the update.

    You can read this blog post for more information:

    http://www.simple-talk.com/community/bl ... 90624.aspx

    Regards,

    Stephen
    StephenC
    0

Add comment

Please sign in to leave a comment.