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
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+49
Original file line number
Diff line number
Diff line change
@@ -151,6 +151,55 @@ Running the script for a project in `sdk\tables` would look like this:
151
151
eng\scripts\Export-API.ps1 tables
152
152
```
153
153
154
+
## Updating Sample Snippets
155
+
If the specific client library has sample snippets in markdown format, they were most likely created with help of the `eng\scripts\Update-Snippets.ps1` script.
156
+
Any changes made to the snippet markdown should be done via updating the corresponding C# snippet code and subsequently running the script.
157
+
158
+
Running the script for a project, for example in `sdk\keyvault`, would look like this:
159
+
```
160
+
eng\scripts\Update-Snippets.ps1 keyvault
161
+
```
162
+
163
+
When run, the code regions in the format below (where `<snippetName>` is the name of the snippet):
164
+
```c#
165
+
#regionSnippet:<snippetName>
166
+
//some sample code
167
+
stringsnippet="some snippet code";
168
+
169
+
// Lines prefixed with the below comment format will be ignored by the snippet updater.
170
+
/*@@*/stringignored="this code will not appear in the snippet markdown";
171
+
172
+
// Lines prefixed with the below comment format will appear in the snippet markdown, but will remain comments in the C#` code.
173
+
// Note: these comments should only be used for non-critical code as it will not be compiled or refactored as the code changes.
174
+
//@@ snippet = "value that would never pass a test but looks good in a sample!";
175
+
176
+
#endregion
177
+
```
178
+
will be mapped to any markdown file with a corresponding code region in the format below where the snippet names match:
179
+
180
+
**\`\`\`C# Snippet:\<snippetName>**
181
+
182
+
**\`\`\`**
183
+
184
+
See the following example of a [snippet C# file](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/search/Azure.Search.Documents/tests/Samples/HelloWorld.cs) and a [snippet markdown file](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/search/Azure.Search.Documents/samples/Sample01a_HelloWorld.md).
185
+
Note that snippet names need to be globally unique under a given service directory.
186
+
187
+
Snippets also can be integrated into XML doc comments. For example:
188
+
```c#
189
+
/// <summary>
190
+
/// Some Property.
191
+
/// </summary>
192
+
/// <example>
193
+
/// This is an example of using a snippet in XML docs.
194
+
/// <codesnippet="Snippet:<snippetName>">
195
+
/// // some sample code.
196
+
/// string snippet = "some snippet code";
197
+
/// </code>
198
+
publicstringSomeProperty { get; set; }
199
+
```
200
+
201
+
For general information about samples, see the [Samples Guidelines](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-samples)
202
+
154
203
## API Compatibility Verification
155
204
156
205
.NET is using the [ApiCompat tool](https://github.com/dotnet/arcade/tree/master/src/Microsoft.DotNet.ApiCompat) to enforce API compatibility between versions. Builds of GA'ed libraries will fail locally and in CI if there are breaking changes.
0 commit comments