Note: Even though * and ? are reminiscent of wildcard patterns, -as does _not_ generally support them; the problem is limited to appending * or ? to the _full_ type name.
Steps to reproduce
# These work as expected.
'System.Int32' -as [type] | should -be ([int])
'System.Int3*' -as [type] | should -not -be ([int]) # incomplete name with *, not supported
# These don't - they unexpectedly still return [int]
'System.Int32*' -as [type] | should -not -be ([int]) # complete name with *
'System.Int32?' -as [type] | should -not -be ([int]) # complete name with ?
_Update_: The problem is more general - see @HumanEquivalentUnit's comment below.
All tests should pass.
The last two tests fail, because the trailing * / ? following the full type name is unexpectedly ignored:
Expected [int] to be different from the actual value, but got the same value.
PowerShell Core 7.0.0-preview.4
This doesn't seem restricted to just *? characters, or to just one character, e.g.
PS C:\> 'system.int32%fwefwef' -as [type]
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Int32 System.ValueType
Quick testing, I guess any symbol which stops name parsing leads to anything in the string after that being igored.
Thanks, @HumanEquivalentUnit - great sleuthing - I've updated the issue title and added a link to your comment in the OP.
Most helpful comment
This doesn't seem restricted to just
*?characters, or to just one character, e.g.Quick testing, I guess any symbol which stops name parsing leads to anything in the string after that being igored.