mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Flatten interface hierarchy when generating properties that implement interface properties (#8382)
`TypeBuilder.GetInterfaces()` returns only the interfaces that was explicitly passed to its constructor, so we need to flatten the interface hierarchy in order to properly support inherited interfaces.
This commit is contained in:
1 parent
c14d5dd67f
commit
0a570211df
2 files changed
+32
-4
No files matched your search
@@ -71,6 +71,15 @@ Describe 'Classes inheritance syntax' -Tags "CI" {
|
||||
$getter.Attributes -band [System.Reflection.MethodAttributes]::Virtual |Should -Be ([System.Reflection.MethodAttributes]::Virtual)
|
||||
}
|
||||
|
||||
It 'can implement inherited .NET interface properties' {
|
||||
Add-Type -TypeDefinition 'public interface IParent { int ParentInteger { get; set; } }
|
||||
public interface IChild : IParent { int ChildInteger { get; set; } }'
|
||||
$C1 = Invoke-Expression 'class ClassWithInheritedInterfaces : IChild { [int]$ParentInteger; [int]$ChildInteger } [ClassWithInheritedInterfaces]'
|
||||
$getter = $C1.GetMember('get_ParentInteger')
|
||||
$getter.ReturnType.FullName | Should -Be System.Int32
|
||||
$getter.Attributes -band [System.Reflection.MethodAttributes]::Virtual |Should -Be ([System.Reflection.MethodAttributes]::Virtual)
|
||||
}
|
||||
|
||||
It 'allows use of defined later type as a property type' {
|
||||
class A { static [B]$b }
|
||||
class B : A {}
|
||||
|
||||
Reference in new issue
Block a user