[Unity] Bug: FileStream Wrapper Class Error
前置阅读 | Pre-reading
Puer的版本 | Puer Version
master 6c22bf42d2a673acd8f76f4191c2085b66f72b0e
Unity的版本 | Unity Version
unity 2021.3.17f1
发生在哪个平台 | Platform
Editor(win)
错误信息 | Error Message
Assets\Gen\System_IO_FileStream_Wrap.cs(198,446): error CS0234: The type or namespace name 'FileSystemRights' does not exist in the namespace 'System.Security.AccessControl' (are you missing an assembly reference?)
Assets\Gen\System_IO_FileStream_Wrap.cs(207,93): error CS1503: Argument 6: cannot convert from 'System.IO.FileOptions' to 'bool'
问题重现 | Bug reproduce
[Binding]
public static List<Type> binding {
get {
return new List<Type>{
typeof(System.IO.FileStream),
};
}
}
An error occurs when the Wrapper Class of System.IO.FileStream is extracted.
When I checked the C# definition of System.IO.FileStream The commented-out function seems to be converted.
============================================================================= 提取 System.IO.FileStream 的包装类时发生错误。
当我检查 System.IO.FileStream 的 C# 定义时 注释掉的函数似乎被转换了。
//ACLS public FileStream(string path, System.IO.FileMode mode, System.Security.AccessControl.FileSystemRights rights, System.IO.FileShare share, int bufferSize, System.IO.FileOptions options) { } //ACLS public FileStream(string path, System.IO.FileMode mode, System.Security.AccessControl.FileSystemRights rights, System.IO.FileShare share, int bufferSize, System.IO.FileOptions options, System.Security.AccessControl.FileSecurity fileSecurity ) { }
-> Wrappers
string arg0 = (string)PuertsDLL.GetStringFromValue(isolate, v8Value0, false);
System.IO.FileMode arg1 = (System.IO.FileMode)StaticTranslate
typeof(System.MarshalByRefObject), //REMOTING public virtual System.Runtime.Remoting.ObjRef CreateObjRef(System.Type requestedType) { throw null; }
Assets\Gen\System_MarshalByRefObject_Wrap.cs(40,42): error CS1061: 'MarshalByRefObject' does not contain a definition for 'CreateObjRef' and no accessible extension method 'CreateObjRef' accepting a first argument of type 'MarshalByRefObject' could be found (are you missing a using directive or an assembly reference?)
The same annotated function in the corresponding type is extracted to the Wrapper Class.
===============================================================================
该类型的相同带注释函数被提取到 Wrapper 类中。
Did you try to use Filter? https://puerts.github.io/en/docs/puerts/unity/wrapper/filter
I know how to use filters. However, sometimes an error occurs in Constructor. FileStream throws an error in Constructor. Can I apply filters in Constructor as well? Should I remove the Type as a filter?
==============================================================================
我知道如何使用过滤器。然而,Consturctor有时会出现错误。 FileStream 在构造函数中抛出错误。 我也可以在构造函数中应用过滤器吗? 我应该删除类型作为过滤器吗?
Yes of course, you can use filter to ignore some constructor overloads.
here is an example, I can generate a wrapper of FileStream without Error:
if (
mb.DeclaringType == typeof(System.IO.FileStream) &&
(
mb.Name == "GetAccessControl" ||
mb.Name == "SetAccessControl" ||
(
mb is System.Reflection.ConstructorInfo &&
(
(mb as System.Reflection.ConstructorInfo).GetParameters().Length == 7 ||
(mb as System.Reflection.ConstructorInfo).GetParameters().Length == 6
)
)
)
) {
return true;
}
When comparing only the number of parameters, there is an issue that even normal constructors are unintentionally processed in the filter. If you check the type of the parameter, it seems that there is a limit that cannot be handled in common in other cases. Is there any way to check annotated functions in common?
===============================================================================
当仅比较参数数量时,存在一个问题,即即使是正常的构造函数也会在过滤器中无意中进行处理。 如果检查参数的类型,似乎存在其他情况下无法通用处理的限制。 有什么方法可以检查注释函数的共同点吗?
Yes you can check the type of the parameter. The code above is just for example.
I had never use those kind of method, but I think that you can find some special for those function in MemberInfo. If you find that, maybe I can builtin a filter for those methods.
The issue seems to have become clear. It seems that the dll used when importing with type.GetConstructor and the dll of the wrapper class are different.
How can I check the dll referenced when creating the wrapper class?.
=========================================================================== 问题似乎已经很清楚了。 看来用type.GetConstructor导入时使用的dll和包装类的dll是不同的。
如何检查创建包装类时引用的 dll?