You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Impossible to call overridden protected internal method of base class. #7622
Derive from a class with virtual protected internal method. For example, System.Diagnostics.Tracing.EventListener, System.Net.Http.DelegatingHandler.
Override that method.
Call that method of base class.
Add-Type-TypeDefinition @' public class BaseMembersTestClass { protected internal virtual int TestMethod() { return 1001; } }'@$derived=Invoke-Expression@' class BaseCallTestClass : BaseMembersTestClass { [int] TestMethod() { return 3 * ([BaseMembersTestClass]$this).TestMethod() } } [BaseCallTestClass]::new()'@$derived.TestMethod()
Expected behavior
Method of base class should be called.
Actual behavior
Overridden implementation called recursively until
Process is terminating due to StackOverflowException.
Environment data
>$PSVersionTable
Name Value
---------
PSVersion 6.0.3
PSEdition Core
GitCommitId v6.0.3
OS Microsoft Windows 10.0.17134
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
changed the title [-]Impossible to call overrided `protected internal` method of base class.[/-][+]Impossible to call overridden `protected internal` method of base class.[/+]on Aug 23, 2018
Yuriy Kushnir (@yurko7) By "overridden implementation called recursively", I'm guessing you get a StackOverflowException? Can you please paste into the issue description the exact output when the method is called?
Depends on implementation of overridden method. On unconditional call of base method, sure, we'll get a StackOverflowException.
Updated the issue description with exact output.
Activity
[-]Impossible to call overrided `protected internal` method of base class.[/-][+]Impossible to call overridden `protected internal` method of base class.[/+]Use non virtual call of 'family or assembly' methods of base class (P…
iSazonov commentedon Aug 24, 2018
/cc Rob Holt (@rjmholt) maybe add to #6652?
rjmholt commentedon Aug 24, 2018
Yuriy Kushnir (@yurko7) By "overridden implementation called recursively", I'm guessing you get a
StackOverflowException? Can you please paste into the issue description the exact output when the method is called?yurko7 commentedon Aug 24, 2018
Rob Holt (@rjmholt)
Depends on implementation of overridden method. On unconditional call of base method, sure, we'll get a
StackOverflowException.Updated the issue description with exact output.
rjmholt commentedon Aug 24, 2018
Yes, I would imagine it depends on the particular method. I just meant for the example class you specify in the issue.
Use non-virtual call to invoke 'family or assembly' methods on base c…
Use non-virtual call to invoke 'family or assembly' methods on base c…
Use non-virtual call to invoke 'family or assembly' methods on base c…
Use non-virtual call to invoke 'family or assembly' methods on base c…