Skip to content

Added Parameter GenerateObjects #167

Merged
FriedrichWeinmann merged 11 commits into
PowershellFrameworkCollective:developmentfrom
Callidus2000:createObjects
Apr 19, 2022
Merged

Added Parameter GenerateObjects #167
FriedrichWeinmann merged 11 commits into
PowershellFrameworkCollective:developmentfrom
Callidus2000:createObjects

Conversation

@Callidus2000

Copy link
Copy Markdown
Contributor

Tried to contribute in order to solve my own Enhancement idea

For example

$createdContent=Invoke-PSMDTemplate -TemplateName module -Force -Name Test -verbose -parameters @{
    description="Nonsense"
} -EnableException -OutPath $PSScriptRoot -generateobjects

returns an array of the new Class

class TemplateResult {
    [string]$Filename
    [string]$Path
    [string]$FullPath
    $Content
    [bool]$IsText=$true
}

Another example

Invoke-PSMDTemplate -TemplateName function -Force -Name Test -verbose -OutPath $PSScriptRoot -GenerateObjects | Select-Object -ExpandProperty Content
function Test
{
	[CmdletBinding()]
	Param (
	
	)
	
	begin
	{
		
	}
	process
	{
	
	}
	end
	{
	
	}
}

@FriedrichWeinmann

Copy link
Copy Markdown
Member

Alright, fixed the test: Write-TemplateResults was evil (plural noun)
Should work just fine now.

Other than that, there are a few issues, but nothing I can't fix more conveniently once it is merged.
Specifically:

  • Array Addition (not an issue at this scale, but still something I try to avoid)
  • Commented out code
  • Build will fail, since adding a new file category (classes) requires you also to update the appropriate txt file in the build folder. This one is still under the old project template, so ... yeah. Not perfect, will need to address that in the near future.
  • PowerShell classes are a bandaid when you don't want to set up a C# solution for a project (or when your class excessively calls PowerShell commands). This project does have a C# solution though, so I'll be converting the PowerShell class before shipping the next release

Again, nothing of that is critical and I'll just go ahead and fix those after merging. Thank you for this very smooth implementation - an elegant solution to something I hadn't considered yet. Expect it to release soonish (just need to update a few templates before I'm good to roll).

@FriedrichWeinmann FriedrichWeinmann merged commit 14c1c34 into PowershellFrameworkCollective:development Apr 19, 2022
This was referenced Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants