Skip to content

Handling interdependent classes #141

@iRon7

Description

@iRon7

Background:

From my project, I have created a few PowerShell classes currently contained by a single file.
As the project is growing (the number and size of the classes), I would like to separate my classes over multiple files.
The problem with doing so is that the classes are interdependent.
see: Is it possible to declare two interdependent classes each in a separate file?

mcve setup:

  • Create two PowerShell files as shown in the StackOverflow question:
    • .\Source\Classes\a.ps1
    • .\Source\Classes\b.ps1
  • and a single module.psm1 file in the root containing:
. $PSScriptRoot\Source\Classes\a.ps1
. $PSScriptRoot\Source\Classes\b.ps1
Export-ModuleMember -Function a, b

The issue(s) with this are in fact shown by VSCode (the PSScriptAnalyzer)

2024-04-19_12h09_10

In the comment of the related StackOverflow question @TheMadTechnician, suggests that maybe this is something PSDepend could help.

If that is correct, can you show (or refer to) an example based on this mcve?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions