Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

枚举类型值IL和本地行为不一致 #42

Closed
Minamiyama opened this issue May 19, 2017 · 0 comments
Closed

枚举类型值IL和本地行为不一致 #42

Minamiyama opened this issue May 19, 2017 · 0 comments

Comments

@Minamiyama
Copy link
Contributor

Minamiyama commented May 19, 2017

定义一个枚举类型在本地代码里
enum TestEnum
{
One,
Two
}

在热更代码里定义
var testEnum = TestEnum.Two;

Debug.Log($"{testEnum} : {testEnum.ToString()}")
输出的是"Two : 1"

在本地代码中得到的结果是"Two : Two"

在此种用法中热更代码里和本地代码里的结果行为不一致

测试用例:
`
using System;
using LitJson;

namespace TestCases
{
public class EnumTest
{
public enum TestEnum : long
{
Enum1,
Enum2,
Enum4 = 0x123456789,
}

    public static void Test11()
    {
        //热更内定义的枚举
        var testEnum = TestEnum.Enum4;
        var valueDirectly = $"{testEnum}";
        var valueToString = testEnum.ToString();

        Console.WriteLine($"隐式字符值: {valueDirectly}");
        Console.WriteLine($"显式字符值: {valueToString}");
        if (valueDirectly.Equals(valueToString) == false)
        {
            throw new Exception($"字符值不一致: {valueDirectly} vs. {valueToString}");
        }

        //本地定义的枚举
        var jsonType = JsonType.Int;
        valueDirectly = $"{jsonType}";
        valueToString = jsonType.ToString();

        Console.WriteLine($"隐式字符值: {valueDirectly}");
        Console.WriteLine($"显式字符值: {valueToString}");
        if (valueDirectly.Equals(valueToString) == false)
        {
            throw new Exception($"字符值不一致: {valueDirectly} vs. {valueToString}");
        }
    }
}

}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant