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

无法正确反射获取field #702

Closed
JasonXuDeveloper opened this issue May 27, 2022 · 0 comments
Closed

无法正确反射获取field #702

JasonXuDeveloper opened this issue May 27, 2022 · 0 comments

Comments

@JasonXuDeveloper
Copy link
Contributor

Describe the bug
A clear and concise description of what the bug is.
请描述Bug的现象
反射获取field的时候,申明了只获取BindingFlags.DeclaredOnly,却还是会返回父类的字段

To Reproduce
Steps to reproduce the behavior:
请描述重现步骤或上下文

热更工程:

public class Base
{
    public int BaseIntVal;
}

public class Impl : Base
{
    public bool ImplBoolVal;
}

主工程:

AppDomain ad = Domain;//加载ilrt的appdomain
var t = ad.GetType(typename)?.ReflectionType;
var flag = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic |
                           BindingFlags.SetProperty;
var fs = t.GetFields(flag).ToList();
Debug.Log(string.Join(",",fs.Select(f=>f.Name)));

Log结果:

BaseIntVal,ImplBoolVal

Expected behavior
A clear and concise description of what you expected to happen.
请描述应有的行为

Log只应该有ImplBoolVal

Unity Version
Please fill in the version of Unity you're currently using
请填写使用的Unity版本
2019.3.13

ILRuntime Version
Please fill in the version of ILRuntime you're currently using(package version or git commit hash or repository download date)
请填写使用的ILRuntime版本(package版本或Git提交号或下载日期)
d803e3e

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