public override RenderResults Render()
 {
     Debug.SetTraceListener(OutputPaneTraceListener);
     RenderWithinTarget();
     return(null); // new RenderResults();
     //"'Because of the way custom tool works a file has to be generated. This file can be safely ignored.");
 }
        /// <summary>
        /// Render within target file, instead of into a separate file
        /// </summary>
        /// <remarks></remarks>
        private void RenderWithinTarget()
        {
            var undoCtx = Dte.UndoContext;

            undoCtx.Open(OptionAttributeType.Name);
            try {
                //render shared library. It has to be created before the interface can be added to the classes. Otherwise EnvDte would throw exception
                RenderLibrary();

                var validClasses = GetValidClasses();

                var sw       = new Stopwatch();
                var hasError = false;
                //!for each class
                foreach (var cc in validClasses)
                {
                    sw.Start();

                    var classWriter = _manager.CreateWriter(cc);

                    //!generate
                    GenerateInClass(classWriter);

                    //!if also doing derivedClasses
                    var applyToSubclasses = classWriter.OptionTag.OptionAttribute.ApplyToDerivedClasses;
                    if (applyToSubclasses)
                    {
                        //!for each subclass
                        foreach (var derivedC in cc.GetSubclasses())
                        {
                            var childInfo = _manager.CreateWriter(cc, derivedC);
                            //generate
                            GenerateInClass(childInfo);
                            //combine status
                            if (childInfo.HasError)
                            {
                                classWriter.HasError = true;
                                classWriter.Status.AppendLine(childInfo.Status.ToString());
                            }
                        }
                    }

                    //if there's error
                    if (classWriter.HasError)
                    {
                        hasError = true;
                        MessageBox.Show(classWriter.Status.ToString());
                    }
                    //finish up
                    sw.Stop();
                    DebugWriteLine(string.Format("Finished {0} in {1}", cc.Name, sw.Elapsed));
                    sw.Reset();
                }


                //if there's error
                if (hasError)
                {
                    //undo everything
                    undoCtx.SetAborted();
                }
                else
                {
                    undoCtx.Close();
                    //automatically save, since we are changing the target file
                    var doc = ProjectItem.DteObject.Document;
                    //if anything is changed, save
                    if (doc != null && !doc.Saved)
                    {
                        doc.Save();
                    }
                }
            }
            catch (Exception ex) {
                Debug.DebugHere(ex);
                if (undoCtx.IsOpen)
                {
                    undoCtx.SetAborted();
                }
            }
        }