PowerShell / PSArm

PSArm is a PowerShell module that provides a PowerShell-embedded domain-specific language (DSL) for Azure Resource Manager (ARM) templates
MIT License
78 stars 19 forks source link

Use `ScriptBlock.InvokeWithContext` instead of writing raw function definitions #30

Closed SeeminglyScience closed 3 years ago

SeeminglyScience commented 4 years ago

Currently ArmDslProviderScriptProducer generates a large string of several function definitions (e.g. function keywordName { }) and dot sources it.

If it instead produced a Dictionary<string, ScriptBlock> (where string is the keyword/function name and ScriptBlock is the body) it could be passed to ScriptBlock.InvokeWithContext. That method will start a new scope and then define the functions to avoid overriding keywords from the current scope when a naming conflict occurs.