Skip to content

Commit

Permalink
Merge pull request dotnet#46183 from CyrusNajmabadi/exceptionInfo
Browse files Browse the repository at this point in the history
Add the name of the current type to the exception we throw in an unsupported case.
  • Loading branch information
CyrusNajmabadi authored Jul 22, 2020
2 parents 6af3aa7 + df15b41 commit 41bcbef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;

Expand Down Expand Up @@ -46,5 +49,20 @@ public SuggestedActionWithNestedActions(

public sealed override Task<IEnumerable<SuggestedActionSet>> GetActionSetsAsync(CancellationToken cancellationToken)
=> Task.FromResult<IEnumerable<SuggestedActionSet>>(NestedActionSets);

protected override void InnerInvoke(IProgressTracker progressTracker, CancellationToken cancellationToken)
{
// A code action with nested actions is itself never invokable. So just do nothing if this ever gets asked.
// Report a message in debug and log a watson exception so that if this is hit we can try to narrow down how
// this happened.
Debug.Fail("InnerInvoke should not be called on a SuggestedActionWithNestedActions");
try
{
throw new InvalidOperationException("Invoke should not be called on a SuggestedActionWithNestedActions");
}
catch (Exception e) when (FatalError.ReportWithoutCrash(e))
{
}
}
}
}
2 changes: 1 addition & 1 deletion src/Workspaces/Core/Portable/CodeActions/CodeAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ protected virtual Task<IEnumerable<CodeActionOperation>> ComputePreviewOperation
/// </remarks>
/// <exception cref="NotSupportedException">If this code action does not support changing a single document.</exception>
protected virtual Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
=> throw new NotSupportedException();
=> throw new NotSupportedException(GetType().FullName);

/// <summary>
/// used by batch fixer engine to get new solution
Expand Down

0 comments on commit 41bcbef

Please sign in to comment.