We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
见OverloadMethodWrap类的Init方法 var defalutValue = paramInfos[i].DefaultValue; if (paramInfos[i].IsOptional) { if (defalutValue != null && defalutValue.GetType() != paramInfos[i].ParameterType) { defalutValue = defalutValue.GetType() == typeof(Missing) ? (paramInfos[i].ParameterType.IsValueType() ? Activator.CreateInstance(paramInfos[i].ParameterType) : Missing.Value) : Convert.ChangeType(defalutValue, paramInfos[i].ParameterType); } HasDefalutValue = true; }
var defalutValue = paramInfos[i].DefaultValue; if (paramInfos[i].IsOptional) { if (defalutValue != null && defalutValue.GetType() != paramInfos[i].ParameterType) { defalutValue = defalutValue.GetType() == typeof(Missing) ? (paramInfos[i].ParameterType.IsValueType() ? Activator.CreateInstance(paramInfos[i].ParameterType) : Missing.Value) : Convert.ChangeType(defalutValue, paramInfos[i].ParameterType); } HasDefalutValue = true; }
如果函数参数支持默认值,则会进入到这段代码,会根据参数类型对默认值做强制转换 但是如果函数参数是被in/out/ref修饰的,假设参数类型是T,则函数参数的实际类型是T&,而默认值参数类型是T,这里做强制转换被失败抛出异常,导致类的后续函数不会被收集。
这里应该再需要加上一条判断语句 defalutValue.GetType().MakeByRefType() != paramInfos[i].ParameterType
The text was updated successfully, but these errors were encountered:
No branches or pull requests
见OverloadMethodWrap类的Init方法
var defalutValue = paramInfos[i].DefaultValue; if (paramInfos[i].IsOptional) { if (defalutValue != null && defalutValue.GetType() != paramInfos[i].ParameterType) { defalutValue = defalutValue.GetType() == typeof(Missing) ? (paramInfos[i].ParameterType.IsValueType() ? Activator.CreateInstance(paramInfos[i].ParameterType) : Missing.Value) : Convert.ChangeType(defalutValue, paramInfos[i].ParameterType); } HasDefalutValue = true; }
如果函数参数支持默认值,则会进入到这段代码,会根据参数类型对默认值做强制转换
但是如果函数参数是被in/out/ref修饰的,假设参数类型是T,则函数参数的实际类型是T&,而默认值参数类型是T,这里做强制转换被失败抛出异常,导致类的后续函数不会被收集。
这里应该再需要加上一条判断语句
defalutValue.GetType().MakeByRefType() != paramInfos[i].ParameterType
The text was updated successfully, but these errors were encountered: