mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix type inference for ICollection (#17752)
This commit is contained in:
@@ -2443,9 +2443,10 @@ namespace System.Management.Automation
|
||||
foreach (var m in type.GetMethods(BindingFlags.Public | BindingFlags.Instance))
|
||||
{
|
||||
var name = m.Name;
|
||||
// Equals without string allocation
|
||||
if (name.Length == propertyName.Length + 4
|
||||
&& name.StartsWith("get_")
|
||||
&& propertyName.IndexOf(name, 4, StringComparison.Ordinal) == 4)
|
||||
&& name.IndexOf(propertyName, 4, StringComparison.Ordinal) == 4)
|
||||
{
|
||||
res.Add(m);
|
||||
}
|
||||
|
||||
@@ -1251,6 +1251,12 @@ Describe "Type inference Tests" -tags "CI" {
|
||||
$res.Count | Should -Be 1
|
||||
$res.Name | Should -Be 'System.Int32[]'
|
||||
}
|
||||
|
||||
It 'Infers type of index item in an ICollection' -Skip:(!$IsWindows) {
|
||||
$res = [AstTypeInference]::InferTypeOf( { (Get-Acl -Path C:\).Access[0] }.Ast)
|
||||
$res.Count | Should -Be 1
|
||||
$res.Name | Should -Be 'System.Security.AccessControl.AuthorizationRule'
|
||||
}
|
||||
}
|
||||
|
||||
Describe "AstTypeInference tests" -Tags CI {
|
||||
|
||||
Reference in New Issue
Block a user