Skip to content

Commit 98aeea3

Browse files
committed
Merge branch 'reference-doc-function' of https://github.com/Gijsreyn/operation-methods into reference-doc-function
2 parents eea11ff + 316f408 commit 98aeea3

File tree

82 files changed

+4060
-395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+4060
-395
lines changed

archive/registry/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ clap = { version = "4.1", features = ["derive"] }
1919
crossterm = { version = "0.26" }
2020
ntreg = { path = "../ntreg" }
2121
ntstatuserror = { path = "../ntstatuserror" }
22-
schemars = { version = "0.8" }
22+
schemars = { version = "1.0" }
2323
serde = { version = "1.0", features = ["derive"] }
2424
serde_json = { version = "1.0", features = ["preserve_order"] }
2525

build.ps1

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ param(
2424
)
2525

2626
$env:RUSTC_LOG=$null
27+
$env:RUSTFLAGS='-Dwarnings'
28+
2729
if ($Verbose) {
2830
$env:RUSTC_LOG='rustc_codegen_ssa::back::link=info'
2931
}
@@ -40,6 +42,7 @@ if ($GetPackageVersion) {
4042
$filesForWindowsPackage = @(
4143
'appx.dsc.extension.json',
4244
'appx-discover.ps1',
45+
'bicep.dsc.extension.json',
4346
'dsc.exe',
4447
'dsc_default.settings.json',
4548
'dsc.settings.json',
@@ -75,6 +78,7 @@ $filesForWindowsPackage = @(
7578
)
7679

7780
$filesForLinuxPackage = @(
81+
'bicep.dsc.extension.json',
7882
'dsc',
7983
'dsc_default.settings.json',
8084
'dsc.settings.json'
@@ -99,6 +103,7 @@ $filesForLinuxPackage = @(
99103
)
100104

101105
$filesForMacPackage = @(
106+
'bicep.dsc.extension.json',
102107
'dsc',
103108
'dsc_default.settings.json',
104109
'dsc.settings.json'
@@ -305,6 +310,7 @@ if (!$SkipBuild) {
305310
"dsc_lib",
306311
"dsc",
307312
"dscecho",
313+
"extensions/bicep",
308314
"osinfo",
309315
"powershell-adapter",
310316
'resources/PSScript',
@@ -313,8 +319,7 @@ if (!$SkipBuild) {
313319
"sshdconfig",
314320
"tools/dsctest",
315321
"tools/test_group_resource",
316-
"y2j",
317-
"."
322+
"y2j"
318323
)
319324
$pedantic_unclean_projects = @()
320325
$clippy_unclean_projects = @("tree-sitter-dscexpression", "tree-sitter-ssh-server-config")
@@ -564,7 +569,11 @@ if ($Test) {
564569
(Get-Module -Name Pester -ListAvailable).Path
565570
}
566571

567-
Invoke-Pester -ErrorAction Stop
572+
try {
573+
Invoke-Pester -ErrorAction Stop
574+
} catch {
575+
throw "Pester had unexpected error: $($_.Exception.Message)"
576+
}
568577
}
569578

570579
function Find-MakeAppx() {

docs/reference/resources/Microsoft/DSC/Transitional/RunCommandOnSet/examples/run-powershell-command.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ dsc config set --input $document
7070
To verify the result, you can run the `winget.exe` command:
7171

7272
```powershell
73-
winget list --id Microsoft.PowerShell
73+
winget list --id Microsoft.PowerShell.Preview
7474
```
7575

7676
<!-- Link reference definitions -->

docs/reference/resources/Microsoft/Windows/WindowsPowerShell/examples/manage-a-windows-service.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ differingProperties:
4040
- StartupType
4141
```
4242
43-
The `inDesiredState` field of the result object is set to `false`, indicating that the instance isn't in the desired state. The `differingProperties` field indicates that the `property` property is mismatched between the desired state and actual state.
43+
The `inDesiredState` field of the result object is set to `false`, indicating that the instance isn't in the desired state. The `differingProperties` field indicates that the `StartupType` property is mismatched between the desired state and actual state.
4444

4545
## Ensure a service is running with automatic startup
4646

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
description: Reference for the 'and' DSC configuration document function
3+
ms.date: 01/19/2025
4+
ms.topic: reference
5+
title: and
6+
---
7+
8+
# and
9+
10+
## Synopsis
11+
12+
Returns true if all arguments are true.
13+
14+
## Syntax
15+
16+
```Syntax
17+
and(<arg1>, <arg2>, ...)
18+
```
19+
20+
## Description
21+
22+
The `and()` function evaluates if all arguments are true. It takes two or more boolean arguments
23+
and returns `true` only if every argument is `true`. If any argument is `false`, the function
24+
returns `false`.
25+
26+
This function uses short-circuit evaluation, meaning it returns `false` as soon as it encounters
27+
the first `false` argument without evaluating the remaining arguments.
28+
29+
## Examples
30+
31+
### Example 1 - Basic and operation
32+
33+
This configuration demonstrates basic usage of the `and()` function.
34+
35+
```yaml
36+
# and.example.1.dsc.config.yaml
37+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
38+
resources:
39+
- name: Echo and result
40+
type: Microsoft.DSC.Debug/Echo
41+
properties:
42+
output: "[and(true, true)]"
43+
```
44+
45+
```bash
46+
dsc config get --file and.example.1.dsc.config.yaml
47+
```
48+
49+
```yaml
50+
results:
51+
- metadata:
52+
Microsoft.DSC:
53+
duration: PT0.1291763S
54+
name: Echo and result
55+
type: Microsoft.DSC.Debug/Echo
56+
result:
57+
actualState:
58+
output: true
59+
messages: []
60+
hadErrors: false
61+
```
62+
63+
### Example 2 - And operation with false value
64+
65+
This example shows the `and()` function returning false when one argument is false.
66+
67+
```yaml
68+
# and.example.2.dsc.config.yaml
69+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
70+
resources:
71+
- name: Echo and result with false
72+
type: Microsoft.DSC.Debug/Echo
73+
properties:
74+
output: "[and(true, false, true)]"
75+
```
76+
77+
```bash
78+
dsc config get --file and.example.2.dsc.config.yaml
79+
```
80+
81+
```yaml
82+
results:
83+
- metadata:
84+
Microsoft.DSC:
85+
duration: PT0.0329292S
86+
name: Echo and result with false
87+
type: Microsoft.DSC.Debug/Echo
88+
result:
89+
actualState:
90+
output: false
91+
messages: []
92+
hadErrors: false
93+
```
94+
95+
### Example 3 - And operation with multiple conditions
96+
97+
This configuration uses the `and()` function with multiple boolean expressions.
98+
99+
```yaml
100+
# and.example.3.dsc.config.yaml
101+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
102+
resources:
103+
- name: Echo complex and operation
104+
type: Microsoft.DSC.Debug/Echo
105+
properties:
106+
output: "[and(equals(5, 5), equals('hello', 'hello'), true)]"
107+
```
108+
109+
```bash
110+
dsc config get --file and.example.3.dsc.config.yaml
111+
```
112+
113+
```yaml
114+
results:
115+
- metadata:
116+
Microsoft.DSC:
117+
duration: PT0.0514415S
118+
name: Echo complex and operation
119+
type: Microsoft.DSC.Debug/Echo
120+
result:
121+
actualState:
122+
output: true
123+
messages: []
124+
hadErrors: false
125+
```
126+
127+
## Parameters
128+
129+
### arguments
130+
131+
The `and()` function requires two or more boolean arguments.
132+
133+
```yaml
134+
Type: boolean
135+
Required: true
136+
MinimumCount: 2
137+
MaximumCount: 18446744073709551615
138+
```
139+
140+
## Output
141+
142+
The `and()` function returns `true` if all arguments are `true`, otherwise it returns `false`.
143+
144+
```yaml
145+
Type: boolean
146+
```
147+
148+
<!-- Link reference definitions -->
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
---
2+
description: Reference for the 'bool' DSC configuration document function
3+
ms.date: 01/19/2025
4+
ms.topic: reference
5+
title: bool
6+
---
7+
8+
# bool
9+
10+
## Synopsis
11+
12+
Converts a string or number to a boolean value.
13+
14+
## Syntax
15+
16+
```Syntax
17+
bool(<value>)
18+
```
19+
20+
## Description
21+
22+
The `bool()` function converts a string or number to a boolean value. For string arguments,
23+
it accepts "true" (case-insensitive) which converts to `true`, and "false" (case-insensitive)
24+
which converts to `false`. For numeric arguments, zero converts to `false` and any non-zero
25+
value converts to `true`.
26+
27+
> [!NOTE]
28+
> Any string argument other than `true` or `false` (case-insensitive) will raise a DSC error.
29+
30+
## Examples
31+
32+
### Example 1 - Convert string to boolean
33+
34+
This configuration demonstrates converting string values to boolean.
35+
36+
```yaml
37+
# bool.example.1.dsc.config.yaml
38+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
39+
resources:
40+
- name: Echo bool from string
41+
type: Microsoft.DSC.Debug/Echo
42+
properties:
43+
output:
44+
trueValue: "[bool('true')]"
45+
falseValue: "[bool('FALSE')]"
46+
```
47+
48+
```bash
49+
dsc config get --file bool.example.1.dsc.config.yaml
50+
```
51+
52+
```yaml
53+
results:
54+
- metadata:
55+
Microsoft.DSC:
56+
duration: PT0.0334711S
57+
name: Echo bool from string
58+
type: Microsoft.DSC.Debug/Echo
59+
result:
60+
actualState:
61+
output:
62+
trueValue: true
63+
falseValue: false
64+
messages: []
65+
hadErrors: false
66+
```
67+
68+
### Example 2 - Convert number to boolean
69+
70+
This example shows the `bool()` function converting numeric values to boolean.
71+
72+
```yaml
73+
# bool.example.2.dsc.config.yaml
74+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
75+
resources:
76+
- name: Echo bool from numbers
77+
type: Microsoft.DSC.Debug/Echo
78+
properties:
79+
output:
80+
zeroIsFalse: "[bool(0)]"
81+
oneIsTrue: "[bool(1)]"
82+
negativeIsTrue: "[bool(-5)]"
83+
positiveIsTrue: "[bool(42)]"
84+
```
85+
86+
```bash
87+
dsc config get --file bool.example.2.dsc.config.yaml
88+
```
89+
90+
```yaml
91+
results:
92+
- metadata:
93+
Microsoft.DSC:
94+
duration: PT0.0323199S
95+
name: Echo bool from numbers
96+
type: Microsoft.DSC.Debug/Echo
97+
result:
98+
actualState:
99+
output:
100+
zeroIsFalse: false
101+
oneIsTrue: true
102+
negativeIsTrue: true
103+
positiveIsTrue: true
104+
messages: []
105+
hadErrors: false
106+
```
107+
108+
## Parameters
109+
110+
### value
111+
112+
The `bool()` function requires a single argument that is either a string or number.
113+
114+
For strings, valid values are:
115+
- "true" (case-insensitive) - converts to `true`
116+
- "false" (case-insensitive) - converts to `false`
117+
118+
For numbers:
119+
- 0 - converts to `false`
120+
- Any non-zero value - converts to `true`
121+
122+
```yaml
123+
Type: [string, integer]
124+
Required: true
125+
MinimumCount: 1
126+
MaximumCount: 1
127+
```
128+
129+
## Output
130+
131+
The `bool()` function returns a boolean value based on the input argument.
132+
133+
```yaml
134+
Type: boolean
135+
```

0 commit comments

Comments
 (0)