Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Replace Import-Module and . with using module #55

Open
chriskuech opened this issue Nov 27, 2019 · 1 comment
Open

Replace Import-Module and . with using module #55

chriskuech opened this issue Nov 27, 2019 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@chriskuech
Copy link
Contributor

We heavily rely on classes, which don't integrate well with Import-Module, which forces us to dot source a lot. using module should solve our import woes.

@chriskuech chriskuech added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Nov 27, 2019
@Stephanevg
Copy link

Stephanevg commented Feb 10, 2020

Hi @chriskuech Be carefull, as that would expose all your classes to the end user, and they could end up polluting his session.
It is possible to export classes by using a 'hybrid approach'. When you boil it down to the bare minimum, it is nothing more than wrapping the instantiation of a class in a function starting with the 'new-' keyword. Example, if you have a class called CustomRequirement you can do this.

Function New-CustomRequirement {
   Param(

    )
    return [CustomRequirement]::New() #possible to work with overloaded constructors and parameter sets.
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants