Skip to content

Conversation

@IISResetMe
Copy link
Collaborator

@IISResetMe IISResetMe commented Dec 2, 2018

PR Summary

TypeBuilder.GetInterfaces(), as introduced in #8303 returns only the interfaces that was explicitly passed to its constructor, so the current implementation doesn't work for inherited interfaces:

  Add-Type 'public interface ITestBase { string Base {get;} }
            public interface ITest : ITestBase { string Test {get;} }'
  class MyClass : ITest
  {
    [string]$Test
    [string]$Base
  }

In this example, ShouldImplementProperty() won't resolve ITestBase.Base and type definition fails because get_Base() isn't virtual.
During compilation the interface hierarchy is flattened, so we only need to resolve one level of ancestral interfaces.

PR Checklist

TypeBuilder.GetInterfaces() returns only the interfaces that was explicitly passed to its constructor, so the current implementation doesn't work for inherited interfaces:

  Add-Type 'public interface ITestBase { string Base {get;} }
            public interface ITest : ITestBase { string Test {get;} }'
  class : ITest
  {
    [string]$Test
    [string]$Base
  }

In this example, ShouldImplementProperty() won't resolve ITestBase.Base and type definition fails.
During compilation the interface hierarchy is flattened, so we only need to resolve one level of ancestral interfaces.
@iSazonov
Copy link
Collaborator

iSazonov commented Dec 3, 2018

@IISResetMe Please add a commit with [Feature] in title to run feature tests.

@IISResetMe IISResetMe changed the title Update ShouldImplementProperty() to flatten interface hierarchy [Feature] Update ShouldImplementProperty() to flatten interface hierarchy Dec 3, 2018
@IISResetMe
Copy link
Collaborator Author

@iSazonov I think we'll need to push an empty commit (or close-reopen pr) to trigger the tests again

@vexx32
Copy link
Collaborator

vexx32 commented Dec 3, 2018

@IISResetMe push an empty commit that contains the tag [Feature] in the commit message itself, yep! 😄

@adityapatwardhan adityapatwardhan changed the title [Feature] Update ShouldImplementProperty() to flatten interface hierarchy Update ShouldImplementProperty() to flatten interface hierarchy Dec 6, 2018
@stale
Copy link

stale bot commented Jan 6, 2019

This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days.
Thank you for your contributions.
Community members are welcome to grab these works.

@stale stale bot added the Stale label Jan 6, 2019
@iSazonov
Copy link
Collaborator

iSazonov commented Jan 6, 2019

@IISResetMe @daxian-dbw Could you please continue?

@stale stale bot removed the Stale label Jan 6, 2019
@IISResetMe
Copy link
Collaborator Author

@iSazonov I believe I've addressed all of @daxian-dbw's remarks, the only thing left was to run the feature tests.

Am I expected to remove the Invoke-Expression statement from the test? 😕

@iSazonov
Copy link
Collaborator

iSazonov commented Jan 13, 2019

@IISResetMe I think using Invoke-Expression haven't a security risk. The Codacy report is for custom scripts not tests. We have to align the settings.

@daxian-dbw Seems the PR is ready to merge. Please update your code review.

@IISResetMe
Copy link
Collaborator Author

[...] The Codacy report is for custom scripts not tests. We have to align the settings.

Yeah, looks like we might want to include it only if .ps1 files that don't match *.tests?.ps1$ are changed

@stale
Copy link

stale bot commented Feb 12, 2019

This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days.
Thank you for your contributions.
Community members are welcome to grab these works.

@stale stale bot added the Stale label Feb 12, 2019
@IISResetMe
Copy link
Collaborator Author

@daxian-dbw had a chance to update this? :)

@stale stale bot removed the Stale label Feb 15, 2019
Copy link
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Sorry for being tardy in responding (was on a trip for the past 3 weeks).

@daxian-dbw
Copy link
Member

As for the Codacy report about Invoke-Expression, the Invoke-Expression command is needed as the interfaces are defined at runtime.

@daxian-dbw daxian-dbw merged commit 0a57021 into PowerShell:master Feb 19, 2019
@iSazonov iSazonov added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Feb 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants