Repository navigation
ConvertTo-SplatExpression: Cannot find type for custom attribute 'EditorCommand' #42
Description
Activity
- pinned this issue
on Nov 11, 2019 I've made some changes to the v0.5.0 branch to accommodate the new PowerShellEditorServices architecture. That version is a complete overhaul of the module and isn't where I want it to be for release yet, but it's currently functional and should serve as a drop in replacement.
You can grab a daily here
Edit 2020/02/08: Updated for PowerShellEditorServices 2.0.0-preview.8
Edit 2020/02/22: Updated for PowerShellEditorServices 2.0.0-preview.9There's a few new editor commands in there, some fixes to old ones, and a lot more configuration options. There's also a context based refactor system similar to "quick fixes" or "code actions". To use that, put something like this in your
keybindings.json:{ "key": "ctrl+.", "command": "PowerShell.InvokeRegisteredEditorCommand", "args": { "commandName": "Invoke-DocumentRefactor" }, "when": "editorLangId == 'powershell'", },And then press Ctrl + . on whatever you want to refactor.
There's also configuration options scoped to machine, user, or project levels. To create a new settings file, use
New-CommandSuiteSettingsFilewith either-Scope Machine(or User) or-Pathfor project. (@markekraus this includes the splat variable name config)Reacted by Nate Ferrell, Adam Cook and Przemysław KłysDaily works great @SeeminglyScience - thank you so much for publishing the link as a temporary workaround!
Reacted by Patrick Meinecke and Przemysław KłysAny chance the v 0.5.0 can be pushed to the Gallery as a prelease?
@kilasuit Not yet, PowerShellEditorServices is currently changing too rapidly to steadily release previews atm.
Once PowerShell/PowerShellEditorServices#1183 makes it into a vscode-powershell preview release then I'll get something up.
After today's update to Preview 0.5 stopped working again.
Import-Module -Name EditorServicesCommandSuite 149,03ms Add-Type : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. At C:\Program Files\WindowsPowerShell\Modules\EditorServicesCommandSuite\0.5.0\EditorServicesCommandSuite.psm1:15 char:9 + Add-Type -Path "$PSScriptRoot/EditorServicesCommandSuite.Edit ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Add-Type], ReflectionTypeLoadException + FullyQualifiedErrorId : System.Reflection.ReflectionTypeLoadException,Microsoft.PowerShell.Commands.AddTypeCommand The following exception occurred while retrieving member "GetCommandSuite": "Could not load type 'Microsoft.PowerShell.EditorServices.Servic es.PowerShellContext.EditorObject' from assembly 'Microsoft.PowerShell.EditorServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null '." At C:\Program Files\WindowsPowerShell\Modules\EditorServicesCommandSuite\0.5.0\EditorServicesCommandSuite.psm1:19 char:5 + $CommandSuite = $type::GetCommandSuite( + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException + FullyQualifiedErrorId : CatchFromBaseGetMember Get-RefactorOption : No existing CommandSuite instance was found. Initialization with the host editor may have failed. At C:\Program Files\WindowsPowerShell\Modules\EditorServicesCommandSuite\0.5.0\EditorServicesCommandSuite.psm1:53 char:9 + Get-RefactorOption | ForEach-Object { + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (:) [Get-RefactorOption], NoCommandSuiteInstanceException + FullyQualifiedErrorId : NoCommandSuiteInstance,EditorServicesCommandSuite.Commands.GetRefactorOptionCommandImport-EditorCommand -Module EditorServicesCommandSuite Unable to find type [Microsoft.PowerShell.EditorServices.Services.PowerShellContext.EditorCommand]. At C:\Users\przemyslaw.klys\.vscode\extensions\ms-vscode.powershell-preview-2020.2.0\modules\PowerShellEditorServices\Commands\Public\Import -EditorCommand.ps1:10 char:17 + ... [OutputType([Microsoft.PowerShell.EditorServices.Services.PowerShellC ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (Microsoft.Power...t.EditorCommand:TypeName) [], RuntimeException + FullyQualifiedErrorId : TypeNotFoundThanks @PrzemyslawKlys! Yeah, some more big changes. I'll get another build ready this weekend.
Reacted by Przemysław KłysFix for preview 9 here. Also updated the link above.
Unable to find type [Microsoft.PowerShell.EditorServices.Services.PowerShellContext.EditorCommand]. At C:\Users\przemyslaw.klys\.vscode\extensions\ms-vscode.powershell-preview-2020.2.0\modules\PowerShellEditorServices\Commands\Public\Import -EditorCommand.ps1:10 char:17 + ... [OutputType([Microsoft.PowerShell.EditorServices.Services.PowerShellC ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (Microsoft.Power...t.EditorCommand:TypeName) [], RuntimeException + FullyQualifiedErrorId : TypeNotFoundOne error still remains.
@PrzemyslawKlys That error isn't coming from ESCS, can you file that on PowerShellEditorServices? Also you can remove
Import-EditorCommandfrom your profile, it's no longer required for this module (and that'll bypass that error).I can, but does it still matter if I'm not supposed to use it?
This module just doesn't require it anymore, other modules still can. I'll take submitting the issue, thanks for the report 🙂
Fixed with v1.0.0-beta1
Install-Module EditorServicesCommandSuite -Scope CurrentUser -AllowPrerelease -Force
Reacted by Przemysław KłysReacted by Nate Ferrell

Working with the newest Powershell Preview extension (tested on v2019.11.0),
ConvertTo-SplatExpressionfails with the following error. Non-preview powershell extension works as intended.Exception : ErrorRecord : Exception : Message : Cannot find the type for custom attribute 'EditorCommand'. Make sure that the assembly that contains this type is loaded. HResult : -2146233087 TargetObject : [EditorCommand(DisplayName='Convert Command to Splat Expression')] CategoryInfo : InvalidOperation: ([EditorCommand(Disp…Splat Expression')]:AttributeAst) [], ParentContainsErrorRecordException FullyQualifiedErrorId : CustomAttributeTypeNotFound InvocationInfo : ScriptLineNumber : 10 OffsetInLine : 5 HistoryId : -1 ScriptName : C:\Users\ntwebb\Documents\PowerShell\Modules\EditorServicesCommandSuite\0.4.0\Public\ConvertTo-SplatExpression.ps1 Line : [EditorCommand(DisplayName='Convert Command to Splat Expression')] PositionMessage : At C:\Users\ntwebb\Documents\PowerShell\Modules\EditorServicesCommandSuite\0.4.0\Public\ConvertTo-SplatExpression.ps1:10 char:5 + [EditorCommand(DisplayName='Convert Command to Splat Expression') … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PSScriptRoot : C:\Users\ntwebb\Documents\PowerShell\Modules\EditorServicesCommandSuite\0.4.0\Public PSCommandPath : C:\Users\ntwebb\Documents\PowerShell\Modules\EditorServicesCommandSuite\0.4.0\Public\ConvertTo-SplatExpression.ps1 CommandOrigin : Internal ScriptStackTrace : at <ScriptBlock>, <No file>: line 1 TargetSite : Name : GetAttribute DeclaringType : System.Management.Automation.Language.Compiler MemberType : Method Module : System.Management.Automation.dll StackTrace : at System.Management.Automation.Language.Compiler.GetAttribute(AttributeAst attributeAst) at System.Management.Automation.Language.ScriptBlockAst.System.Management.Automation.Language.IParameterMetadataProvider.GetScriptBlockAttributes()+MoveNext() at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items) at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source) at System.Management.Automation.CompiledScriptBlockData.InitializeMetadata() at System.Management.Automation.CompiledScriptBlockData.Compile(Boolean optimized) at System.Management.Automation.PSScriptCmdlet..ctor(ScriptBlock scriptBlock, Boolean useNewScope, Boolean fromScriptFile, ExecutionContext context) at System.Management.Automation.CommandProcessor.Init(IScriptCommandInfo scriptCommandInfo) at System.Management.Automation.CommandDiscovery.GetScriptAsCmdletProcessor(IScriptCommandInfo scriptCommandInfo, ExecutionContext context, Boolean useNewScope, Boolean fromScriptFile, SessionStateInternal sessionState) at System.Management.Automation.CommandDiscovery.CreateCommandProcessorForScript(FunctionInfo functionInfo, ExecutionContext context, Boolean useNewScope, SessionStateInternal sessionState) at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(CommandInfo commandInfo, CommandOrigin commandOrigin, Nullable`1 useLocalScope, SessionStateInternal sessionState) at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope) at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource) at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context) at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext) at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) Message : Cannot find the type for custom attribute 'EditorCommand'. Make sure that the assembly that contains this type is loaded. Data : System.Collections.ListDictionaryInternal Source : System.Management.Automation HResult : -2146233087 TargetObject : [EditorCommand(DisplayName='Convert Command to Splat Expression')] CategoryInfo : InvalidOperation: ([EditorCommand(Disp…Splat Expression')]:AttributeAst) [], RuntimeException FullyQualifiedErrorId : CustomAttributeTypeNotFound InvocationInfo : ScriptLineNumber : 10 OffsetInLine : 5 HistoryId : -1 ScriptName : C:\Users\ntwebb\Documents\PowerShell\Modules\EditorServicesCommandSuite\0.4.0\Public\ConvertTo-SplatExpression.ps1 Line : [EditorCommand(DisplayName='Convert Command to Splat Expression')] PositionMessage : At C:\Users\ntwebb\Documents\PowerShell\Modules\EditorServicesCommandSuite\0.4.0\Public\ConvertTo-SplatExpression.ps1:10 char:5 + [EditorCommand(DisplayName='Convert Command to Splat Expression') … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PSScriptRoot : C:\Users\ntwebb\Documents\PowerShell\Modules\EditorServicesCommandSuite\0.4.0\Public PSCommandPath : C:\Users\ntwebb\Documents\PowerShell\Modules\EditorServicesCommandSuite\0.4.0\Public\ConvertTo-SplatExpression.ps1 CommandOrigin : Internal ScriptStackTrace : at <ScriptBlock>, <No file>: line 1