File: GObjectIntPtrCtorVerifier.cs

package info (click to toggle)
hyena 0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,800 kB
  • sloc: cs: 33,411; sh: 733; makefile: 435
file content (39 lines) | stat: -rw-r--r-- 1,081 bytes parent folder | download | duplicates (13)
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);
            }
        }
    }
}