You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does anyone remember what use cases ProxyTypes are for and how they are supposed to be used?
I for example have these, but actually I no longer directly code PixImages for quite a while:
Aardvark.Base.Coder.TypeInfo.Add(new Aardvark.Base.Coder.TypeInfo(typeof(PixImage<float>), () => new PixImageProxy<float>())
{
Object2ProxyFun = x => ((PixImage)x).ToFieldCoderProxy(),
Proxy2ObjectFun = x => ((PixImageProxy)x).ToPixImage(),
ProxyType = typeof(PixImageProxy<float>)
});
I believe they were necessary because there was some restriction with generics. I would need to create an example with PixImage to see how this would have worked, but actually, a see some flaws in the coder when proxies are used.
The creator of the TypeInfo "() => new PixImageProxy()" creates this proxy object. When this is used in the coder during deserialization the Line:
stores a ref to the proxy object and when the ref is used later you get an InvalidCastException.
Note: Within CodeFields, a ref to the parent object may also already be used, but the Proxy2ObjectFun would only be invoked after this, so the actual object to where these refs should point to does not exist yet.
I don't see how this could be fixed, only by redefining how proxies work (decode):
The creator would need to create an object of the TargetType
"obj" would then immediately have the proper target type and the proper ref could be recorded
additional an instance of ProxyType needs to be created and used for serialization (CodeFields)
The Proxy2ObjectFun would then also get passed the already created instance and could initialize it with the data from the proxy object
Todo: Review encode
A ran into this issue because I currently somehow need to convert an object from an old type to a new type. The new type however is not actually new so when I would simply redirect the types (decode "OldType" as "NewType"), I cannot distinguish between data from "OldType Version=X" and "NewType, Version=X".
(Since I actually do not have refs to the parent object that I want to convert with a proxy, we could simply store the objRef index and overwrite it after Proxy2ObjectFun is invoked.)
The next thing I tried to is register Converters, starting with "Aardvark.Base.Coder.TypeInfoVersion.Add", but I did not manage to register them property yet. When I look at the code here:
is then the OldType but should actually be NewType. Since Name actually a string, I maybe can somehow create such a custom type info... Then I "only" need to register the converter properly, TypeInfoVersion.Add does not do this (does not run into the proper cases), or I just have not figured out how.
Does anyone still have Converters around? Any help is appreciated!
The text was updated successfully, but these errors were encountered:
I somehow managed to use the convertes, but they (of course) have the same issue as proxies with references. In order to solve this for now (me), I have implemented that the references are replaced after proxy or converter conversions. So they can be used as long as references to converted objects are not coded in their sub-objects.
Does anyone remember what use cases ProxyTypes are for and how they are supposed to be used?
I for example have these, but actually I no longer directly code PixImages for quite a while:
I believe they were necessary because there was some restriction with generics. I would need to create an example with PixImage to see how this would have worked, but actually, a see some flaws in the coder when proxies are used.
The creator of the TypeInfo "() => new PixImageProxy()" creates this proxy object. When this is used in the coder during deserialization the Line:
aardvark.base/src/Aardvark.Base.IO/BinaryReadingCoder.cs
Line 226 in 4eb7b47
stores a ref to the proxy object and when the ref is used later you get an InvalidCastException.
Note: Within CodeFields, a ref to the parent object may also already be used, but the Proxy2ObjectFun would only be invoked after this, so the actual object to where these refs should point to does not exist yet.
I don't see how this could be fixed, only by redefining how proxies work (decode):
A ran into this issue because I currently somehow need to convert an object from an old type to a new type. The new type however is not actually new so when I would simply redirect the types (decode "OldType" as "NewType"), I cannot distinguish between data from "OldType Version=X" and "NewType, Version=X".
(Since I actually do not have refs to the parent object that I want to convert with a proxy, we could simply store the objRef index and overwrite it after Proxy2ObjectFun is invoked.)
The next thing I tried to is register Converters, starting with "Aardvark.Base.Coder.TypeInfoVersion.Add", but I did not manage to register them property yet. When I look at the code here:
aardvark.base/src/Aardvark.Base.IO/BinaryReadingCoder.cs
Line 192 in 4eb7b47
newTypeInfo would always be the TypeInfo that was retrieved using the coded type name (OldType). The Name used here:
aardvark.base/src/Aardvark.Base.IO/BinaryReadingCoder.cs
Line 290 in 4eb7b47
is then the OldType but should actually be NewType. Since Name actually a string, I maybe can somehow create such a custom type info... Then I "only" need to register the converter properly, TypeInfoVersion.Add does not do this (does not run into the proper cases), or I just have not figured out how.
Does anyone still have Converters around? Any help is appreciated!
The text was updated successfully, but these errors were encountered: