This utility class implements helpers to log to the activity log, which will help debug issues with the extension that only our customers can reproduce. The log is only written to if the /log parameter is passed to Visual Studio on startup, other than that writing to the log is a noop.
Ejemplo n.º 1
0
        /// <summary>
        /// Change the text in the status bar. If the status bar is frozen no change is made.
        /// </summary>
        /// <param name="text">The text to display.</param>
        public IDisposable FreezeText(string text)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            try
            {
                Statusbar.IsFrozen(out int frozen);
                if (!Convert.ToBoolean(frozen))
                {
                    Statusbar.GetText(out string existingText);
                    Statusbar.SetText(text);
                    Statusbar.FreezeOutput(Convert.ToInt32(true));

                    void UnfreezeText()
                    {
                        Statusbar.FreezeOutput(Convert.ToInt32(false));
                        Statusbar.SetText(existingText);
                    }

                    return(new Disposable(UnfreezeText));
                }
            }
            catch (Exception ex)
            {
                ActivityLogUtils.LogError($"Failed to write to the status bar: {ex.Message}");
            }

            return(new Disposable());
        }
Ejemplo n.º 2
0
 private static void UnFreeze()
 {
     try
     {
         Statusbar.FreezeOutput(0);
     }
     catch (Exception ex)
     {
         ActivityLogUtils.LogError($"Failed to unfreeze the status bar output: {ex.Message}");
     }
 }
Ejemplo n.º 3
0
 private static void HideDeployAnimation()
 {
     try
     {
         object animation = (short)Constants.SBAI_Deploy;
         Statusbar.Animation(0, ref animation);
     }
     catch (Exception ex)
     {
         ActivityLogUtils.LogError($"Failed to hide animation: {ex.Message}");
     }
 }
Ejemplo n.º 4
0
 private void UnFreeze()
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     try
     {
         Statusbar.FreezeOutput(0);
     }
     catch (Exception ex)
     {
         ActivityLogUtils.LogError($"Failed to unfreeze the status bar output: {ex.Message}");
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Freezes the status bar, which prevents updates from other parts of the VS shell.
 /// </summary>
 /// <returns>An implementation of <seealso cref="IDisposable"/> that will unfreeze the status bar on dispose.</returns>
 public static IDisposable Freeze()
 {
     try
     {
         Statusbar.FreezeOutput(1);
         return(new Disposable(UnFreeze));
     }
     catch (Exception ex)
     {
         ActivityLogUtils.LogError($"Failed to freeze the status bar output: {ex.Message}");
         return(null);
     }
 }
Ejemplo n.º 6
0
 private void HideDeployAnimation()
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     try
     {
         object animation = (short)Constants.SBAI_Deploy;
         Statusbar.Animation(0, ref animation);
     }
     catch (Exception ex)
     {
         ActivityLogUtils.LogError($"Failed to hide animation: {ex.Message}");
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Shows an animation to show that a deploy action is being executed. This animation will only show
 /// if VS is showing all of the visual effects. The result of the method should stored in a variable in a
 /// using statement.
 /// </summary>
 /// <returns>An implementation of <seealso cref="IDisposable"/> that will stop the animation on dispose.</returns>
 public static IDisposable ShowDeployAnimation()
 {
     try
     {
         object animation = (short)Constants.SBAI_Deploy;
         Statusbar.Animation(1, ref animation);
         return(new Disposable(HideDeployAnimation));
     }
     catch (Exception ex)
     {
         ActivityLogUtils.LogError($"Failed to show animation: {ex.Message}");
         return(null);
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Change the text in the status bar. If the status bar is frozen no change is made.
 /// </summary>
 /// <param name="text">The text to display.</param>
 public void SetText(string text)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     try
     {
         Statusbar.IsFrozen(out int frozen);
         if (!Convert.ToBoolean(frozen))
         {
             Statusbar.SetText(text);
         }
     }
     catch (Exception ex)
     {
         ActivityLogUtils.LogError($"Failed to write to the status bar: {ex.Message}");
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Change the text in the status bar. If the status bar is frozen no change is made.
 /// </summary>
 /// <param name="text">The text to display.</param>
 public static void SetText(string text)
 {
     try
     {
         int frozen;
         Statusbar.IsFrozen(out frozen);
         if (frozen != 0)
         {
             return;
         }
         Statusbar.SetText(text);
     }
     catch (Exception ex)
     {
         ActivityLogUtils.LogError($"Failed to write to the status bar: {ex.Message}");
     }
 }