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
GObject.Internal.ObjectWrapper.WrapHandle needs to create a new instance of a class if the given handle is not known. It uses reflection to find the correct constructor.
With dotnet 7 it is possible to define static methods in interfaces. This allows all classes to implement a certain interface (e.g. CreateableClass) which defines a method like Create(ptr, owned). The WrapHandle method can check if the given T implements this interface and then call the Create method which in turns calls the constructor. In this way reflection can be avoided. If the interface is not implemented throw an exception.
Create a fallback implementation for dotnet 6 which relies on reflection (similar to GTypeProviderHelper).
Verify if this can be applied to interfaces and records, too.
The text was updated successfully, but these errors were encountered:
GObject.Internal.ObjectWrapper.WrapHandle
needs to create a new instance of a class if the given handle is not known. It uses reflection to find the correct constructor.With dotnet 7 it is possible to define static methods in interfaces. This allows all classes to implement a certain interface (e.g.
CreateableClass
) which defines a method likeCreate(ptr, owned)
. TheWrapHandle
method can check if the givenT
implements this interface and then call theCreate
method which in turns calls the constructor. In this way reflection can be avoided. If the interface is not implemented throw an exception.Create a fallback implementation for dotnet 6 which relies on reflection (similar to GTypeProviderHelper).
Verify if this can be applied to interfaces and records, too.
The text was updated successfully, but these errors were encountered: