★ wanayoo — archive 1999 https://github.com/PowerShell/PowerShell/issues/7622Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to call overridden `protected internal` method of base class. #7622

Closed
yurko7 opened this issue Aug 23, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@yurko7
Copy link
Contributor

commented Aug 23, 2018 •

Steps to reproduce

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

@yurko7 yurko7 changed the title Impossible to call overrided `protected internal` method of base class. Impossible to call overridden `protected internal` method of base class. Aug 23, 2018

@iSazonov

This comment has been minimized.

Copy link
Collaborator

commented Aug 24, 2018

/cc @rjmholt maybe add to #6652?

@rjmholt

This comment has been minimized.

Copy link
Member

commented Aug 24, 2018

@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?

@rjmholt rjmholt referenced this issue Aug 24, 2018

Open

Fix Various PowerShell Class Issues #6652

3 of 23 tasks complete
@yurko7

This comment has been minimized.

Copy link
Contributor Author

commented Aug 24, 2018

@rjmholt

I'm guessing you get a StackOverflowException?

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

This comment has been minimized.

Copy link
Member

commented 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.

daxian-dbw added a commit that referenced this issue Aug 29, 2018

TravisEz13 added a commit that referenced this issue Aug 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.