summaryrefslogtreecommitdiff
path: root/build/GObjectIntPtrCtorVerifier.cs
blob: 3c3ba9c2da80ea9ce5b4d3df00d31e51853258aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Reflection;

public static class GObjectIntPtrCtorVerifier
{
    public static void Main (string [] args)
    {
        foreach (var path in args) {
            Verify (path);
        }
    }

    private static void Verify (string path)
    {
        foreach (var type in Assembly.LoadFrom (path).GetTypes ()) {
            if (!type.IsSubclassOf (typeof (GLib.Object))) {
                continue;
            }

            bool safe = false;

            foreach (var ctor in type.GetConstructors (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) {
                var args = ctor.GetParameters ();
                if ((safe = (ctor.Attributes & (MethodAttributes.Public |
                    MethodAttributes.Family)) != 0 &&
                    args != null &&
                    args.Length == 1 &&
                    args[0].ParameterType == typeof (IntPtr))) {
                    break;
                }
            }

            if (!safe) {
                Console.WriteLine (type);
            }
        }
    }
}