SeeminglyScience / EditorServicesCommandSuite

Collection of editor commands for use in PowerShell Editor Services.
Other
151 stars 13 forks source link

Remove cancelation message? #52

Closed PrzemyslawKlys closed 4 years ago

PrzemyslawKlys commented 4 years ago

If you open Splat menu then cancel is straight away i get error message.

image

I believe there should be no message to not confuse users?

Type                        : System.Management.Automation.MethodInvocationException
ErrorRecord                 : 
    Exception             : 
        Type    : System.Management.Automation.ParentContainsErrorRecordException
        Message : Exception calling "ProcessRecord" with "1" argument(s): "The operation was canceled."
        HResult : -2146233087
    CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    FullyQualifiedErrorId : OperationCanceledException
    InvocationInfo        : 
        ScriptLineNumber : 337
        OffsetInLine     : 7
        HistoryId        : -1
        Line             : $__cmdletization_objectModelWrapper.ProcessRecord($__cmdletization_methodInvocationInfo)

        PositionMessage  : At line:337 char:7
                           +       $__cmdletization_objectModelWrapper.ProcessRecord($__cmdletizat …
                           +       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        CommandOrigin    : Internal
    ScriptStackTrace      : at ConvertTo-SplatExpression<Process>, <No file>: line 337
                            at <ScriptBlock>, <No file>: line 1
WasThrownFromThrowStatement : True
TargetSite                  : 
    Name          : Invoke
    DeclaringType : System.Management.Automation.Runspaces.PipelineBase, System.Management.Automation, Version=7.0.0.0, Culture=neu
tral, PublicKeyToken=31bf3856ad364e35
    MemberType    : Method
    Module        : System.Management.Automation.dll
StackTrace                  : 
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvoca 
tionSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSe 
ttings settings)
   at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, IList`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, PSInvocationSettings settings)
   at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.<>c__DisplayClass89_0`1.<ExecuteCommandAsync>b__0() in D:\a\1\s\ 
src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 764
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCal
lback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCal 
lback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.ExecuteCommandAsync[TResult](PSCommand psCommand, StringBuilder  
errorMessages, ExecutionOptions executionOptions) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextServi 
ce.cs:line 764
   at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.ExecuteCommandAsync[TResult](PSCommand psCommand, StringBuilder  
errorMessages, ExecutionOptions executionOptions) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextServi
ce.cs:line 809
Message                     : Exception calling "ProcessRecord" with "1" argument(s): "The operation was canceled."
Data                        : System.Collections.ListDictionaryInternal
InnerException              : 
    Type              : System.OperationCanceledException
    CancellationToken : System.Threading.CancellationToken
    TargetSite        : 
        Name          : MoveNext
        DeclaringType : EditorServicesCommandSuite.EditorServices.UIService+<ShowChoicePromptAsync>d__8`1[TItem]
        MemberType    : Method
        Module        : EditorServicesCommandSuite.EditorServices.dll
    StackTrace        : 
   at EditorServicesCommandSuite.EditorServices.UIService.ShowChoicePromptAsync[TItem](String caption, String message, TItem[] items, Func`2 
 labelSelector, Func`2 helpMessageSelector)
   at EditorServicesCommandSuite.EditorServices.UIService.ShowChoicePromptAsync[TItem](String caption, String message, TItem[] items, Func`2 
 labelSelector) in D:\a\1\s\src\EditorServicesCommandSuite.EditorServices\UIService.cs:line 77
   at EditorServicesCommandSuite.CodeGeneration.Refactors.RefactorProvider.Invoke(DocumentContextBase context) in D:\a\1\s\src\EditorService
sCommandSuite\CodeGeneration\Refactors\RefactorProvider.cs:line 46
   at EditorServicesCommandSuite.Internal.RefactorCmdletAdapter.<>c__DisplayClass12_0.<<InvokeRefactor>b__0>d.MoveNext() in D:\a\1\s\src\Edi 
torServicesCommandSuite\Internal\RefactorCmdletAdapter.cs:line 146
--- End of stack trace from previous location where exception was thrown ---
   at EditorServicesCommandSuite.Utility.ThreadController.GiveControl(Task requestTask, CancellationToken cancellationToken) in D:\a\1\s\src 
\EditorServicesCommandSuite\Utility\ThreadController.cs:line 58
   at EditorServicesCommandSuite.Internal.RefactorCmdletAdapter.InvokeRefactor(String className, PSCmdlet psCmdlet) in D:\a\1\s\src\EditorSe 
rvicesCommandSuite\Internal\RefactorCmdletAdapter.cs:line 150
   at EditorServicesCommandSuite.Internal.RefactorCmdletAdapter.ProcessRecord(MethodInvocationInfo methodInvocationInfo) in D:\a\1\s\src\Edi 
torServicesCommandSuite\Internal\RefactorCmdletAdapter.cs:line 77
   at CallSite.Target(Closure , CallSite , Object , Object )
    Message           : The operation was canceled.
    Source            : EditorServicesCommandSuite.EditorServices
    HResult           : -2146233029
Source                      : System.Management.Automation
HResult                     : -2146233087
SeeminglyScience commented 4 years ago

Included the fix for this in 1.0.0-beta2. I changed the behavior to not prompt, it just assumes you want a basic splat.

PrzemyslawKlys commented 4 years ago

What if I wanted the advanced ones?