-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersBugFeature - Interpolated String ImprovementsInterpolated string improvementsInterpolated string improvements
Milestone
Description
Description
After building PowerShell against .NET 6 Preview 7 SDK, tab completion in PowerShell throws TypeLoadException:
PS:4> $er.Exception.InnerException
Message : The generic type '<>A{00000002}`3' was used with an invalid instantiation in assembly 'System.Management.Automation,
Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
TypeName : <>A{00000002}`3
TargetSite : Void NativeCompletionProcessCommands(System.Management.Automation.CompletionContext, System.String,
System.Collections.Generic.List`1[System.Management.Automation.CompletionResult])
Data : {}
InnerException :
HelpLink :
Source : System.Management.Automation
HResult : -2146233054
StackTrace : at System.Management.Automation.CompletionCompleters.NativeCompletionProcessCommands(CompletionContext context, String
paramName, List`1 result)
at System.Management.Automation.CompletionCompleters.NativeCommandArgumentCompletion(String commandName,
CompiledCommandParameter parameter, List`1 result, CommandAst commandAst, CompletionContext context, Dictionary`2
boundArguments) in
C:\arena\source\PowerShell\src\System.Management.Automation\engine\CommandCompletion\CompletionCompleters.cs:line 2187
at System.Management.Automation.CompletionCompleters.ProcessParameter(String commandName, CommandAst commandAst,
CompletionContext context, List`1 result, MergedCompiledCommandParameter parameter, Dictionary`2 boundArguments) in
C:\arena\source\PowerShell\src\System.Management.Automation\engine\CommandCompletion\CompletionCompleters.cs:line 1807
at System.Management.Automation.CompletionCompleters.GetArgumentCompletionResultsWithSuccessfulPseudoBinding(Completion
Context context, ArgumentLocation argLocation, CommandAst commandAst) in
C:\arena\source\PowerShell\src\System.Management.Automation\engine\CommandCompletion\CompletionCompleters.cs:line 1550
at System.Management.Automation.CompletionCompleters.CompleteCommandArgument(CompletionContext context) in
C:\arena\source\PowerShell\src\System.Management.Automation\engine\CommandCompletion\CompletionCompleters.cs:line 1061
at System.Management.Automation.CompletionAnalysis.GetResultHelper(CompletionContext completionContext, Int32&
replacementIndex, Int32& replacementLength, Boolean isQuotedString) in
C:\arena\source\PowerShell\src\System.Management.Automation\engine\CommandCompletion\CompletionAnalysis.cs:line 768
at System.Management.Automation.CompletionAnalysis.GetResults(PowerShell powerShell, Int32& replacementIndex, Int32&
replacementLength) in
C:\arena\source\PowerShell\src\System.Management.Automation\engine\CommandCompletion\CompletionAnalysis.cs:line 380
at System.Management.Automation.CommandCompletion.CompleteInputImpl(Ast ast, Token[] tokens, IScriptPosition
positionOfCursor, Hashtable options) in
C:\arena\source\PowerShell\src\System.Management.Automation\engine\CommandCompletion\CommandCompletion.cs:line 579
at System.Management.Automation.CommandCompletion.CompleteInput(String input, Int32 cursorIndex, Hashtable options) in
C:\arena\source\PowerShell\src\System.Management.Automation\engine\CommandCompletion\CommandCompletion.cs:line 102
at CallSite.Target(Closure , CallSite , Type , String , Int32 , Hashtable )
Configuration
.NET 6 Preview 7 SDK on Windows 10 x64.
Regression?
Yes, from all prior versions of .NET Core.
Other information
Repro steps:
On PowerShell built against .NET 6 preview 7 SDK run the following steps:
PS:7> $cmd = 'Get-Process -Id '
PS:8> TabExpansion2 -inputScript $cmd -cursorColumn $cmd.Length
MethodInvocationException:
Line |
38 | … return [System.Management.Automation.CommandCompletion]::Complet …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "CompleteInput" with "3" argument(s): "The generic type '<>A{00000002}`3' was used with an invalid instantiation in assembly 'System.Management.Automation, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'."
I looked more into the issue and found that this exception is triggered by the use of a interpolated string: var idAndName = $"{processId} - {processName}". The exception goes away after I replace it with var idAndName = processId + " - " + processName;.
The interesting part is that both processId and processName in the code are of the dynamic type. The exception may be related to that.
Metadata
Metadata
Assignees
Labels
Area-CompilersBugFeature - Interpolated String ImprovementsInterpolated string improvementsInterpolated string improvements