Skip to content

Work Around for multiple inheritance #14892

@Xpyder

Description

@Xpyder

Summary of the new feature/enhancement

Currently powershell is unable to implement Composition Over Inheritance because of a lack of support for custom "interfaces"

There is a way to get it to work, but it only works when running the code by hand, not in automated scripts

Proposed technical implementation details (optional)

The issue with the workaround boils down to a problem in the parser error: InterfaceNameExpected
It fails to recognize that using Add-Type will add types, instead it incorrectly assumes the given type will not be available

I think we should either allow a keyword to override this error, or educate the parser on the usage of Add-Type

Examples

I have included 3 examples:
A single file script that fails when run as a whole, but works if you manually run it line by line
A split that works, but is forced to have an incorrect dependency tree
A split that fails, because it's using a correct dependency tree

Note: The splits use dot sourcing, you'll need to adjust the paths to the appropriate folders on your computer
Fail - Single File.zip
Success - Bad Dependancy layout.zip
Fail - Good Dependency Layout.zip

Related issues

PowerShell/PowerShell-RFC#152
#2223

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugWG-Languageparser, language semantics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions