예제 #1
0
        public static NamespaceInfo[] Create(AssemblyDefinition[] targetAssemblies)
        {
            var garbageTypeList = new[]
            {
                "AVPlayerItemLegibleOutputPushDelegate"
                // NB: Aparrently this used to break "build on device because of reasons". We don't know what these reasons are and this may not be needed anymore.
            };

            var publicDelegateTypes = targetAssemblies
                                      .SelectMany(x => SafeTypes.GetSafeTypes(x))
                                      .Where(x => x.IsPublic && !x.IsInterface && !x.HasGenericParameters && IsCocoaDelegateName(x.Name))
                                      .Where(x => x.BaseType == null || !x.BaseType.FullName.Contains("MulticastDelegate"))
                                      .Where(x => !garbageTypeList.Any(y => x.FullName.Contains(y)))
                                      .Select(x => new { Type = x, Delegates = GetPublicDelegateMethods(x) })
                                      .Where(x => x.Delegates.Length > 0)
                                      .ToArray();

            var namespaceData = publicDelegateTypes
                                .GroupBy(x => x.Type.Namespace)
                                //.Where(x => !garbageNamespaceList.Contains(x.Key))    // NB: We don't know why this is disabled.
                                .Select(x => new NamespaceInfo
            {
                Name  = x.Key,
                Types = x.Select(y => new PublicTypeInfo
                {
                    Name                 = y.Type.Name,
                    Type                 = y.Type,
                    Abstract             = y.Type.IsAbstract ? "abstract" : "",
                    ZeroParameterMethods =
                        y.Delegates.Where(z => z.Parameters.Count == 0).Select(z => new ParentInfo
                    {
                        Name = z.Name
                    }).ToArray(),
                    SingleParameterMethods =
                        y.Delegates.Where(z => z.Parameters.Count == 1).Select(z => new SingleParameterMethod
                    {
                        Name          = z.Name,
                        ParameterType = z.Parameters[0].ParameterType.FullName,
                        ParameterName = z.Parameters[0].Name
                    }).ToArray(),
                    MultiParameterMethods =
                        y.Delegates.Where(z => z.Parameters.Count > 1).Select(z => new MultiParameterMethod
                    {
                        Name          = z.Name,
                        ParameterList =
                            string.Join(", ",
                                        z.Parameters.Select(
                                            a => string.Format("{0} {1}", a.ParameterType.FullName, a.Name))),
                        ParameterTypeList =
                            string.Join(", ", z.Parameters.Select(a => a.ParameterType.FullName)),
                        ParameterNameList = string.Join(", ", z.Parameters.Select(a => a.Name))
                    }).ToArray()
                }).ToArray()
            }).ToArray();

            return(namespaceData);
        }
예제 #2
0
        public static NamespaceInfo[] Create(AssemblyDefinition[] targetAssemblies)
        {
            var publicTypesWithEvents = targetAssemblies
                                        .SelectMany(x => SafeTypes.GetSafeTypes(x))
                                        .Where(x => x.IsPublic && !x.HasGenericParameters)
                                        .Select(x => new { Type = x, Events = GetPublicEvents(x) })
                                        .Where(x => x.Events.Length > 0)
                                        .ToArray();

            var garbageNamespaceList = new[]
            {
                "Windows.UI.Xaml.Data",
                "Windows.UI.Xaml.Interop",
                "Windows.UI.Xaml.Input",
                "MonoTouch.AudioToolbox",
                "MonoMac.AudioToolbox",
                "ReactiveUI.Events"
            };

            var namespaceData = publicTypesWithEvents
                                .GroupBy(x => x.Type.Namespace)
                                .Where(x => !garbageNamespaceList.Contains(x.Key))
                                .Select(x => new NamespaceInfo
            {
                Name  = x.Key,
                Types = x.Select(y => new PublicTypeInfo
                {
                    Name   = y.Type.Name,
                    Type   = y.Type,
                    Events = y.Events.Select(z => new PublicEventInfo
                    {
                        Name              = z.Name,
                        EventHandlerType  = GetRealTypeName(z.EventType),
                        EventArgsType     = GetEventArgsTypeForEvent(z),
                        ObsoleteEventInfo = GetObsoleteInfo(z)
                    }).ToArray()
                }).ToArray()
            }).ToArray();

            foreach (var type in namespaceData.SelectMany(x => x.Types))
            {
                var parentWithEvents = GetParents(type.Type).FirstOrDefault(x => GetPublicEvents(x).Any());
                if (parentWithEvents == null)
                {
                    continue;
                }

                type.Parent = new ParentInfo {
                    Name = parentWithEvents.FullName
                };
            }

            return(namespaceData);
        }
예제 #3
0
        public static NamespaceInfo[] Create(AssemblyDefinition[] targetAssemblies)
        {
            var publicTypesWithEvents = targetAssemblies
                                        .SelectMany(x => SafeTypes.GetSafeTypes(x))
                                        .Where(x => x.IsPublic && !x.HasGenericParameters)
                                        .Select(x => new { Type = x, Events = GetPublicEvents(x) })
                                        .Where(x => x.Events.Length > 0)
                                        .ToArray();

            var garbageNamespaceList = new[]
            {
                "Windows.UI.Xaml.Data",
                "Windows.UI.Xaml.Interop",
                "Windows.UI.Xaml.Input",
                "MonoTouch.AudioToolbox",
                "MonoMac.AudioToolbox",
                "ReactiveUI.Events",
                // Winforms
                "System.Collections.Specialized",
                "System.Configuration",
                "System.ComponentModel.Design",
                "System.ComponentModel.Design.Serialization",
                "System.CodeDom",
                "System.Data.SqlClient",
                "System.Data.OleDb",
                "System.Data.Odbc",
                "System.Data.Common",
                "System.Drawing.Design",
                "System.Media",
                "System.Net",
                "System.Net.Mail",
                "System.Net.NetworkInformation",
                "System.Net.Sockets",
                "System.ServiceProcess.Design",
                "System.Windows.Input",
                "System.Windows.Forms.ComponentModel.Com2Interop",
                "System.Windows.Forms.Design",
                "System.Timers"
            };

            var namespaceData = publicTypesWithEvents
                                .GroupBy(x => x.Type.Namespace)
                                .Where(x => !garbageNamespaceList.Contains(x.Key))
                                .Select(x => new NamespaceInfo
            {
                Name  = x.Key,
                Types = x.Select(y => new PublicTypeInfo
                {
                    Name   = y.Type.Name,
                    Type   = y.Type,
                    Events = y.Events.Select(z => new PublicEventInfo
                    {
                        Name              = z.Name,
                        EventHandlerType  = GetRealTypeName(z.EventType),
                        EventArgsType     = GetEventArgsTypeForEvent(z),
                        ObsoleteEventInfo = GetObsoleteInfo(z)
                    }).ToArray()
                }).ToArray()
            }).ToArray();

            foreach (var type in namespaceData.SelectMany(x => x.Types))
            {
                var parentWithEvents = GetParents(type.Type).FirstOrDefault(x => GetPublicEvents(x).Any());
                if (parentWithEvents == null)
                {
                    continue;
                }

                type.Parent = new ParentInfo {
                    Name = parentWithEvents.FullName
                };
            }

            return(namespaceData);
        }