# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. Describe 'Generic Method invocation' -Tags 'CI' { BeforeAll { $EmptyArrayCases = @( @{ Script = '[Array]::Empty[string]()' ExpectedType = [string[]] } @{ Script = '[Array]::Empty[System.Collections.Generic.Dictionary[System.Numerics.BigInteger, System.Collections.Generic.List[string[,]]]]()' ExpectedType = [System.Collections.Generic.Dictionary[System.Numerics.BigInteger, System.Collections.Generic.List[string[, ]]][]] } ) $IndexingAProperty = @( @{ Script = '[object]::Property[[type]]' IndexType = 'System.Management.Automation.Language.TypeExpressionAst' IndexString = '[type]' } @{ Script = '$object.IPSubnet[[Array]::IndexOf($_.IPAddress, $_.IPAddress[0])]' IndexType = 'System.Management.Automation.Language.InvokeMemberExpressionAst' IndexString = '[Array]::IndexOf($_.IPAddress, $_.IPAddress[0])' } @{ Script = @' [IPAddress]::Parse( $_.IPSubnet[ [Array]::IndexOf($_.IPAddress, $_.IPAddress[0]) ] ) '@ IndexType = 'System.Management.Automation.Language.InvokeMemberExpressionAst' IndexString = '[Array]::IndexOf($_.IPAddress, $_.IPAddress[0])' } @{ Script = @' [IPAddress]::Parse( $_.IPSubnet[ ([Array]::IndexOf($_.IPAddress, $_.IPAddress[0])) ] ) '@ IndexType = 'System.Management.Automation.Language.ParenExpressionAst' IndexString = '([Array]::IndexOf($_.IPAddress, $_.IPAddress[0]))' } ) $ExpectedParseErrors = @( @{ Script = '$object.Method[incompl' ExpectedErrors = @('EndSquareBracketExpectedAtEndOfType') ErrorCount = 1 } @{ Script = '[type]::Member[incompl' ExpectedErrors = @('EndSquareBracketExpectedAtEndOfType') ErrorCount = 1 } @{ Script = '$object.Method[Type1[Type2' ExpectedErrors = @('EndSquareBracketExpectedAtEndOfAttribute','EndSquareBracketExpectedAtEndOfType') ErrorCount = 2 } @{ Script = '[array]::empty[type]]()' ExpectedErrors = @('MissingArrayIndexExpression', 'UnexpectedToken', 'ExpectedExpression') ErrorCount = 3 } @{ Script = '$object.Method[type,]()' ExpectedErrors = @('MissingTypename') ErrorCount = 1 } @{ Script = '$object.Method[]()' ExpectedErrors = @('MissingArrayIndexExpression', 'UnexpectedToken', 'ExpectedExpression') ErrorCount = 3 } @{ Script = '$object.Method[,]()' ExpectedErrors = @('MissingExpressionAfterOperator', 'UnexpectedToken', 'ExpectedExpression') ErrorCount = 3 } @{ Script = '$object.Method[,type]()' ExpectedErrors = @('MissingExpressionAfterOperator', 'UnexpectedToken', 'ExpectedExpression') ErrorCount = 3 } @{ Script = '$object.Method[type()' ExpectedErrors = @('EndSquareBracketExpectedAtEndOfType', 'UnexpectedToken', 'ExpectedExpression') ErrorCount = 3 } @{ Script = '$object.Method[type)' ExpectedErrors = @('EndSquareBracketExpectedAtEndOfType', 'UnexpectedToken') ErrorCount = 2 } @{ Script = '$object.Method[[type]]()' ExpectedErrors = @('UnexpectedToken', 'ExpectedExpression') ErrorCount = 2 } @{ Script = '[Array]::Empty[[type]]()' ExpectedErrors = @('UnexpectedToken', 'ExpectedExpression') ErrorCount = 2 } @{ Script = '$object.Property[type]' ExpectedErrors = @('MissingArrayIndexExpression', 'UnexpectedToken') ErrorCount = 2 } ) } It 'does not throw a parse error for "