Exemplo n.º 1
0
        // Forces the error toggle "on", so that errors are visible in the list.  Warnings and
        // informational messages are not affected.
        /// <include file='doc\TaskProvider.uex' path='docs/doc[@for="ErrorListProvider.ForceShowErrors"]/*' />
        public void ForceShowErrors()
        {
            IVsTaskList tasklist = this.VsTaskList;

            NativeMethods.ThrowOnFailure(errorList.ForceShowErrors());
            tasklist = null;
        }
Exemplo n.º 2
0
 public void ForceShowErrors()
 {
     if (!Shell.VsShellUtilities.ShellIsShuttingDown)
     {
         _errorList.ForceShowErrors();
     }
 }
 protected virtual void AfterCodeGenerated(bool error)
 {
     if (error)
     {
         IVsErrorList errorList = ErrorList;
         if (errorList != null)
         {
             errorList.BringToFront();
             errorList.ForceShowErrors();
         }
     }
 }
        /*
         * private void SetTargetNamespace()
         * {
         *  if (!string.IsNullOrEmpty(this.CodeFileNameSpace))
         *  {
         *      TargetNamespace = CodeFileNameSpace;
         *      return;
         *  }
         *
         *  DTE dte = Dte;
         *  if (dte == null)
         *      return;
         *  IEnumerable activeProjects = dte.ActiveSolutionProjects as IEnumerable;
         *  if (activeProjects == null)
         *      return;
         *  Project project = activeProjects.OfType<Project>().First();
         *  if (project == null)
         *      return;
         *  var defaultNamespace = project.Properties.Item("DefaultNamespace");
         *  if (defaultNamespace != null && defaultNamespace.Value is string)
         *  {
         *      string targetNamespace = (string)defaultNamespace.Value;
         *      string projectFolder = Path.GetDirectoryName(project.FullName);
         *      string sourceFileFolder = Path.GetDirectoryName(this.CodeFilePath);
         *      if (sourceFileFolder.StartsWith(sourceFileFolder, StringComparison.InvariantCultureIgnoreCase))
         *      {
         *          string extraFolders = sourceFileFolder.Substring(projectFolder.Length);
         *          if (extraFolders.Length > 0)
         *          {
         *              string[] parts = extraFolders.TrimStart('\\').Split('\\');
         *              targetNamespace += "." + string.Join(".",
         *                  parts.Select(p => p.ToIdentifier()).ToArray());
         *          }
         *          targetNamespace += extraFolders.Replace("\\", ".");
         *      }
         *      TargetNamespace = targetNamespace;
         *  }
         * }
         */

        protected override void AfterCodeGenerated(bool error)
        {
            base.AfterCodeGenerated(error);

            if (error)
            {
                IVsErrorList errorList = ErrorList;
                if (errorList != null)
                {
                    errorList.BringToFront();
                    errorList.ForceShowErrors();
                }
            }
        }
Exemplo n.º 5
0
        protected override byte[] GenerateCode(string inputFileName, string inputFileContent)
        {
            if (this.ShowWarningDialog())
            {
                return(new byte[0]);
            }
            base.SetWaitCursor();
            this.errors = false;
            this.encodingSetFromOutputDirective = false;
            this.outputEncoding = null;
            ITextTemplating textTemplating = this.TextTemplating;
            string          s = string.Empty;

            CallContext.LogicalSetData("NamespaceHint", base.FileNamespace);
            try
            {
                if (textTemplating == null)
                {
                    throw new InvalidOperationException(Resources.TextTemplatingUnavailable);
                }
                textTemplating.BeginErrorSession();
                IVsHierarchy service = base.GetService(typeof(IVsHierarchy)) as IVsHierarchy;
                s            = this.ProcessTemplate(inputFileName, inputFileContent, textTemplating, service);
                this.errors |= textTemplating.EndErrorSession();
                MarkProjectForTextTemplating(service);
            }
            finally
            {
                CallContext.FreeNamedDataSlot("NamespaceHint");
            }
            if (this.errors)
            {
                IVsErrorList errorList = base.ErrorList;
                if (errorList != null)
                {
                    try
                    {
                        errorList.BringToFront();
                        errorList.ForceShowErrors();
                    }
                    catch
                    {
                    }
                }
            }
            if (this.outputEncoding == null)
            {
                this.outputEncoding = EncodingHelper.GetEncoding(inputFileName);
            }
            if (this.outputEncoding == null)
            {
                this.outputEncoding = Encoding.UTF8;
            }
            byte[] bytes    = this.outputEncoding.GetBytes(s);
            byte[] preamble = this.outputEncoding.GetPreamble();
            if ((preamble != null) && (preamble.Length > 0))
            {
                bool flag2 = false;
                if (bytes.Length >= preamble.Length)
                {
                    flag2 = true;
                    for (int i = 0; i < preamble.Length; i++)
                    {
                        if (preamble[i] != bytes[i])
                        {
                            flag2 = false;
                            break;
                        }
                    }
                }
                if (!flag2)
                {
                    byte[] array = new byte[preamble.Length + bytes.Length];
                    preamble.CopyTo(array, 0);
                    bytes.CopyTo(array, preamble.Length);
                    bytes = array;
                }
            }
            return(bytes);
        }