예제 #1
0
        void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
        {
            ErrorData.AppendLine(e.Data);
            LastLine = e.Data;
            Action <string> ErrorLineHandler = ErrorLine;

            if (ErrorLineHandler != null)
            {
                EditorMainThread.Run(() => {
                    ErrorLineHandler(e.Data);
                });
            }
        }
예제 #2
0
        public void Start()
        {
            try {
                Process.Start();

                Process.BeginOutputReadLine();
                Process.BeginErrorReadLine();

                BackgroundProcessManager.Add(this);
            } catch (Exception ex) {
                string err = string.Format("Could not start process: {0}", ex.ToString());
                ErrorData.AppendLine(err);
                Action <string> ErrorLineHandler = ErrorLine;
                if (ErrorLineHandler != null)
                {
                    EditorMainThread.Run(() => {
                        ErrorLineHandler(err);
                    });
                }
            }
        }
예제 #3
0
        public void AsyncCandidates()
        {
            int n = 0;

            Errors = 0;
            ErrorData.Clear();

            foreach (Type t in Assembly.GetTypes())
            {
                // e.g. delegates used for events
                if (t.IsNested)
                {
                    continue;
                }

                if (!NSObjectType.IsAssignableFrom(t))
                {
                    continue;
                }

                if (t.GetCustomAttribute <ProtocolAttribute> () != null)
                {
                    continue;
                }
                if (t.GetCustomAttribute <ModelAttribute> () != null)
                {
                    continue;
                }

                // let's not encourage the use of some API
                if (IsDiscouraged(t))
                {
                    continue;
                }

                CurrentType = t;

                var methods = t.GetMethods(Flags);
                foreach (MethodInfo m in methods)
                {
                    if (m.DeclaringType != t)
                    {
                        continue;
                    }

                    // skip properties / events
                    if (m.IsSpecialName)
                    {
                        continue;
                    }

                    if (IgnoreAsync(m))
                    {
                        continue;
                    }

                    // some calls are "natively" async
                    if (m.Name.IndexOf("Async", StringComparison.Ordinal) != -1)
                    {
                        continue;
                    }

                    // let's not encourage the use of some API
                    if (IsDiscouraged(m))
                    {
                        continue;
                    }

                    // is it a candidate ?
                    var p = m.GetParameters();
                    if (p.Length == 0)
                    {
                        continue;
                    }
                    var last = p [p.Length - 1];
                    // trying to limit false positives and the need for large ignore lists to maintain
                    // unlike other introspection tests a failure does not mean a broken API
                    switch (last.Name)
                    {
                    case "completionHandler":
                    case "completion":
                        break;

                    default:
                        continue;
                    }
                    if (!last.ParameterType.IsSubclassOf(typeof(Delegate)))
                    {
                        continue;
                    }

                    // did we provide a async wrapper ?
                    string ma = m.Name + "Async";
                    if (methods.Where((mi) => mi.Name == ma).FirstOrDefault() != null)
                    {
                        continue;
                    }

                    var name = m.ToString();
                    var i    = name.IndexOf(' ');
                    ErrorData.AppendLine(name.Insert(i + 1, m.DeclaringType.Name + "::"));
                    Errors++;
                }
            }
            AssertIfErrors("{0} errors found in {1} signatures validated{2}", Errors, n, Errors == 0 ? string.Empty : ":\n" + ErrorData.ToString() + "\n");
        }