Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dsc/tests/dsc_user_functions.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

Describe 'user function tests' {
It 'user function working with expression: <expression>' -TestCases @(
@{ expression = "[MyFunction.ComboFunction('test', 42, true)]"; expected = 'test-42-True' }
@{ expression = "[__MyFunction.ComboFunction('test', 42, true)]"; expected = 'test-42-True' }
@{ expression = "[MyOtherNamespace.ArrayFunction(createArray('a','b','c','d'))]"; expected = @('["b","c","d"]-a') }
) {
param($expression, $expected)

$configYaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
functions:
- namespace: MyFunction
- namespace: __MyFunction
members:
ComboFunction:
parameters:
Expand Down
2 changes: 1 addition & 1 deletion grammars/tree-sitter-dscexpression/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = grammar({

function: $ => prec(PREC.FUNCTION, seq(field('name', $.functionName), '(', field('args', optional($.arguments)), ')')),
functionName: $ => choice(
/[a-zA-Z][a-zA-Z0-9]*(\.[a-zA-Z0-9]+)?/,
/[_a-zA-Z][_a-zA-Z0-9]*(\.[a-zA-Z0-9]+)?/,
$._booleanLiteral
),
arguments: $ => seq($._argument, repeat(seq(',', $._argument))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,16 @@ User Function with nested function
(function
(functionName)))
(boolean)))))

=====
User Function with namespace prefixed by underscores
=====
[__bicep.myFunction('param1')]
---

(statement
(expression
(function
(functionName)
(arguments
(string)))))
Loading