Beispiel #1
0
        IOsbideEvent IOsbideEvent.FromDict(Dictionary <string, object> values)
        {
            BuildEvent evt = new BuildEvent();

            if (values.ContainsKey("Id"))
            {
                evt.Id = (int)values["Id"];
            }
            if (values.ContainsKey("EventLogId"))
            {
                evt.EventLogId = (int)values["EventLogId"];
            }
            if (values.ContainsKey("EventLog"))
            {
                evt.EventLog = (EventLog)values["EventLog"];
            }
            if (values.ContainsKey("EventDate"))
            {
                evt.EventDate = (DateTime)values["EventDate"];
            }
            if (values.ContainsKey("SolutionName"))
            {
                evt.SolutionName = values["SolutionName"].ToString();
            }
            if (values.ContainsKey("ErrorItems"))
            {
                evt.ErrorItems = values["ErrorItems"] as List <BuildEventErrorListItem>;
            }
            if (values.ContainsKey("Breakpoints"))
            {
                evt.Breakpoints = values["Breakpoints"] as List <BuildEventBreakPoint>;
            }
            if (values.ContainsKey("Documents"))
            {
                evt.Documents = values["LineNumber"] as List <BuildDocument>;
            }
            return(evt);
        }
        public override void OnBuildDone(vsBuildScope Scope, vsBuildAction Action)
        {
            base.OnBuildDone(Scope, Action);

            //this might take a while, so throw it in its own thread
            //System.Threading.Tasks.Task.Factory.StartNew(
            //    () =>
            //    {
            BuildEvent    build           = new BuildEvent();
            List <string> filesWithErrors = new List <string>();

            build.SolutionName = dte.Solution.FullName;
            build.EventDate    = DateTime.UtcNow;

            //start at 1 when iterating through Error List
            for (int i = 1; i <= dte.ToolWindows.ErrorList.ErrorItems.Count; i++)
            {
                ErrorItem item = dte.ToolWindows.ErrorList.ErrorItems.Item(i);
                BuildEventErrorListItem beli = new BuildEventErrorListItem();
                beli.BuildEvent    = build;
                beli.ErrorListItem = ErrorListItem.FromErrorItem(item);

                //only worry about critical errors
                if (beli.ErrorListItem.CriticalErrorName.Length > 0)
                {
                    build.ErrorItems.Add(beli);

                    //add the file with the error to our list of items that have errors
                    if (filesWithErrors.Contains(beli.ErrorListItem.File.ToLower()) == false)
                    {
                        filesWithErrors.Add(beli.ErrorListItem.File.ToLower());
                    }
                }
            }

            //add in breakpoint information
            for (int i = 1; i <= dte.Debugger.Breakpoints.Count; i++)
            {
                BreakPoint           bp   = new BreakPoint(dte.Debugger.Breakpoints.Item(i));
                BuildEventBreakPoint bebp = new BuildEventBreakPoint();
                bebp.BreakPoint = bp;
                bebp.BuildEvent = build;
                build.Breakpoints.Add(bebp);
            }

            //get all files in the solution
            List <CodeDocument> files = build.GetSolutionFiles(dte.Solution);

            //add in associated documents
            foreach (CodeDocument file in files)
            {
                BuildDocument bd = new BuildDocument();
                bd.Build    = build;
                bd.Document = file;
                build.Documents.Add(bd);
            }

            byte[] data = EventFactory.ToZippedBinary(build);

            //let others know that we have created a new event
            NotifyEventCreated(this, new EventCreatedArgs(build));
            //}
            //);
        }