You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Configure Visual Studio Code for writing C# code for Streamer.bot with linting and autocomplete.
4
4
icon: mdi:microsoft-visual-studio-code
5
5
ogImage:
6
-
icon: mdi:microsoft-visual-studio-code
6
+
props:
7
+
icon: mdi:microsoft-visual-studio-code
7
8
---
8
9
9
10
::tip
10
11
**VSCode Extension now available!**:br
11
-
This extension automates the process of setting up a Streamer.bot C# project directory with IntelliSense, while also providing hover documentation for CPH methods. Installation includes the base C# extension dependency.
12
+
This extension automates the process of setting up a Streamer.bot C# project directory with IntelliSense, while also providing hover documentation for CPH methods. Installation includes the base C# extension dependency.
12
13
::
13
14
14
15
::card{title="Streamer.bot C# Extension for Visual Studio Code"icon=mdi:microsoft-visual-studio-codecolor=infoto="https://marketplace.visualstudio.com/items?itemName=fajita-of-treason.streamer-bot-csharp"}
15
-
Write Streamer.bot C# code with IntelliSense and documentation
16
+
Write Streamer.bot C# code with IntelliSense and documentation
16
17
17
-
<small>by FajitaOfTreason</small>
18
+
<small>by FajitaOfTreason</small>
18
19
::
19
20
20
21
<hr>
@@ -26,18 +27,19 @@ By following these instructions, you'll be able to write code with linting, whic
26
27
## Prerequisites
27
28
28
29
::card-group
29
-
::card{title="Visual Studio Code"icon=mdi:microsoft-visual-studio-codeto="https://code.visualstudio.com/download"}
30
-
Follow the installation instructions for your operating system
31
-
::
30
+
::card{title="Visual Studio Code"icon=mdi:microsoft-visual-studio-codeto="https://code.visualstudio.com/download"}
31
+
Follow the installation instructions for your operating system
@@ -119,10 +123,11 @@ Do not use quotes around your Streamer.bot directory path, even if it contains s
119
123
120
124
::note
121
125
**Notes about `StreamerBot.csproj`**
126
+
122
127
- This file includes the Streamer.bot using statements in every `.cs` file automatically
123
128
- This file configures the project as a `.NET Framework 4.8.1` project
124
129
- To point to your own Streamer.bot DLLs, replace the contents of `<StreamerBotPath>` with the path to your own Streamer.bot directory (containing `Streamer.bot.exe` and `.dll` files)
125
-
::
130
+
::
126
131
127
132
### Create a .cs File
128
133
@@ -137,6 +142,7 @@ Create a new file ending with the `.cs` extension. This is the file we will use
137
142
Paste the `C# Code Example` below into your `.cs` file, replacing `UniqueClassName` with your filename
138
143
139
144
::code-collapse
145
+
140
146
```cs [UniqueClassName.cs]
141
147
usingSystem;
142
148
@@ -155,6 +161,7 @@ public class CPHInline
155
161
}
156
162
}
157
163
```
164
+
158
165
::
159
166
160
167
::read-more{to=#file-template-snippet}
@@ -178,11 +185,12 @@ See the [File Template Snippet](#file-template-snippet) section below for more i
178
185
- You can now type `CPH.` and it will automatically give you the available `CPH` methods
179
186
- This uses the `Streamer.bot.Plugin.Interface.dll` in your Streamer.bot folder
180
187
- The advantage of this is that you will have an up-to-date list of methods, classes, and enums available
181
-
::
188
+
::
182
189
183
190

184
191
185
192
## Debugging
193
+
186
194
While writing your code, you can check for compilation errors in the `Problems` view.
187
195
188
196
::navigate
@@ -193,50 +201,51 @@ Compilation errors will be shown in red, and will prevent your code from compili
193
201
194
202

195
203
196
-
197
204
Warnings will be shown in yellow, but will not prevent your code from compiling:
198
205
199
206

200
207
201
-
202
208
## Copying Code to Streamer.bot
203
209
204
210
When you code is ready to run in Streamer.bot, you can copy it into an [Execute C# Code](/api/sub-actions/core/csharp/execute-csharp-code) sub-action.
205
211
206
212
::steps{level=3}
207
-
### Select your Action
208
213
209
-
::navigate
210
-
In **Streamer.bot**, navigate to the `Actions` panel
211
-
::
214
+
### Select your Action
215
+
216
+
::navigate
217
+
In **Streamer.bot**, navigate to the `Actions` panel
218
+
::
212
219
213
-
- Create or select an existing action
214
-
- Add or select an `Execute C# Code` sub-action
220
+
- Create or select an existing action
221
+
- Add or select an `Execute C# Code` sub-action
215
222
216
-
### Copy your C# Code
217
-
- You can copy the entirety of your `.cs` file into Streamer.bot's C# code editor.
223
+
### Copy your C# Code
218
224
219
-
::tip
220
-
The preprocessor directives will ensure the VSCode specific sections are not active inside Streamer.bot.
221
-
::
225
+
- You can copy the entirety of your `.cs` file into Streamer.bot's C# code editor.
222
226
223
-
- Make sure the code compiles successfully by clicking `Compile`
224
-
- Click `Save and Compile`
227
+
::tip
228
+
The preprocessor directives will ensure the VSCode specific sections are not active inside Streamer.bot.
229
+
::
225
230
226
-
::note
227
-
If you see any errors ending with `(are you missing an assembly reference?)`, click `Find Refs`
228
-
::
231
+
- Make sure the code compiles successfully by clicking `Compile`
232
+
- Click `Save and Compile`
229
233
230
-
::success
231
-
Your code has now been added inside an `Execute C# Code` Sub-Action and is ready to run in your Action!
232
-
::
234
+
::note
235
+
If you see any errors ending with `(are you missing an assembly reference?)`, click `Find Refs`
236
+
::
237
+
238
+
::success
239
+
Your code has now been added inside an `Execute C# Code` Sub-Action and is ready to run in your Action!
240
+
::
233
241
::
234
242
235
243
## Additional Steps
236
244
237
245
These steps are optional, but can help speed up your workflow.
238
246
239
247
### File Template Snippet
248
+
240
249
To make creating new `.cs` files easier, you can create a workplace snippet that will fill in the Streamer.bot C# sub-action template code for you.
241
250
242
251
::navigate
@@ -250,38 +259,41 @@ Select the option to create a new snippets file for the current workspace, and e
250
259

251
260
252
261
Replace the contents of your new `.code-snippets` file with the code below:
253
-
::code-collapse
254
-
```json
255
-
{
256
-
"Execute C# Sub-Action Template" : {
257
-
"scope": "csharp",
258
-
"isFileTemplate": true,
259
-
"prefix": "streamer.bot-file-template",
260
-
"description": "New Execute C# Sub-Action for Streamer.bot",
261
-
"body": [
262
-
"using System;",
263
-
"",
264
-
"/*----- Class name should match FileName -----*/",
265
-
"#if EXTERNAL_EDITOR",
266
-
"public class ${TM_FILENAME_BASE} : CPHInlineBase",
You can use workplace snippets to quickly scaffold new Streamer.bot C# files!
297
+
286
298
- After creating new .cs files, you can now fill them with the snippet by either typing `sbfile`, and selecting the `streamer.bot-file-template` from the dropdown, or by running `Snippets: Fill File with Snippet` from the Command Palette
0 commit comments