GNOME Bugzilla – Bug 788132
DynamicSignal: use NativeType property instead of doing unsafe pointer trickery
Last modified: 2017-09-25 17:34:23 UTC
Created attachment 360354 [details] [review] patch The Microsoft C# (csc) compiler doesn't seem to like the "dereferencing" of managed types very much (I'm using Microsoft (R) Visual C# Compiler version 2.3.2.62019 from VS 2017). It complains with error CS0208 "Cannot take the address of, get the size of, or declare a pointer to a managed type ('Object.GTypeInstance')". Using the GLib.Object.NativeType property should return the same result. However, this property actually has internal protection level, so glib-sharp must be compiled with an [assembly: InternalsVisibleTo("gstreamer-sharp")] directive for it to be accessible to gstreamer-sharp (when compiling with the MS C# compiler). But then again the types references in the previous unsafe-approach (GLib.Object.GTypeInstance etc.) also had internal visibility only.
If adding [assembly: InternalsVisibleTo("gstreamer-sharp")] to glib-sharp's AssemblyInfo.cs is something that will be necessary in general when compiling gstreamer-sharp with the Microsoft C# compiler, is this maybe something we'd want to document? (Or is there maybe an easier way to achieve the same?)
Review of attachment 360354 [details] [review]: ::: sources/custom/DynamicSignal.cs @@ -335,3 @@ - type = (*(IntPtr*) ((GLib.Object.GTypeInstance*) o.Handle)->g_class); - } - GType gtype = new GType (type); Does o.NativeType also get the actual type from the instance, or only the type of the C# wrapper object (e.g. GstPlaybin2 is wrapped in a GstElement C# wrapper object, both having different GTypes and the latter not having all the GstPlaybin2 signals).