Skip to content

Commit 4642bb2

Browse files
authored
Merge pull request #3774 from hvitved/csharp/tripleticks
C#: Enable syntax highlighting in QLDoc snippets
2 parents b36c23e + 652de80 commit 4642bb2

Some content is hidden

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

54 files changed

+442
-439
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Initializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected override void PopulateExpression(TextWriter trapFile)
7474
var typeInfoRight = cx.GetTypeInfo(assignment.Right);
7575
if (typeInfoRight.Type is null)
7676
// The type may be null for nested initializers such as
77-
// ```
77+
// ```csharp
7878
// new ClassWithArrayField() { As = { [0] = a } }
7979
// ```
8080
// In this case we take the type from the assignment

csharp/ql/src/Security Features/CWE-451/MissingXFrameOptions.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import semmle.code.csharp.frameworks.system.Web
2020
*/
2121
predicate hasWebConfigXFrameOptions(WebConfigXML webConfig) {
2222
// Looking for an entry in `webConfig` that looks like this:
23-
// ```
23+
// ```xml
2424
// <system.webServer>
2525
// <httpProtocol>
2626
// <customHeaders>

csharp/ql/src/Stubs/Stubs.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* This will generate stubs for all the required dependencies as well.
66
*
77
* Use
8-
* ```
8+
* ```ql
99
* select generatedCode()
1010
* ```
1111
* to retrieve the generated C# code.

csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Foreach.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
* Also we only deal with foreach stmts where there is only
66
* one declaration (see below).
77
* For example the code:
8-
* ```
8+
* ```csharp
99
* foreach(var item in some_enumerable) {
1010
* // body
1111
* }
1212
* ```
1313
* gets desugared to:
14-
* ```
14+
* ```csharp
1515
* Enumerator e = some_enumerable.GetEnumerator();
1616
* try
1717
* {

csharp/ql/src/experimental/ir/implementation/raw/internal/desugar/Lock.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* File that provides the desugaring of a `lock` stmt.
33
* The statement:
4-
* ```
4+
* ```csharp
55
* lock (anExpr) ...
66
* ```
77
* gets desugared to:
8-
* ```
8+
* ```csharp
99
* SomeRefType lockedVar = anExpr;
1010
* bool __lockWasTaken = false;
1111
* try {

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/AliasAnalysisImports.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module AliasModels {
1212
* the function returns.
1313
*
1414
* Example:
15-
* ```
15+
* ```csharp
1616
* int* g;
1717
* int* func(int* p, int* q, int* r, int* s, int n) {
1818
* *s = 1; // `s` does not escape.

csharp/ql/src/experimental/ir/internal/IRGuards.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class GuardCondition extends Expr {
9393
* implies that the truth of the child expression `part` has truth value `partIsTrue`.
9494
*
9595
* For example if the binary operation:
96-
* ```
96+
* ```csharp
9797
* x && y
9898
* ```
9999
* is true, `x` and `y` must also be true, so `impliesValue(x, true, true)` and
@@ -341,7 +341,7 @@ class IRGuardCondition extends Instruction {
341341
* predecessors. For example, in the following situation, an inference can be made about the
342342
* value of `x` at the end of the `if` statement, but there is no block which is controlled by
343343
* the `if` statement when `x >= y`.
344-
* ```
344+
* ```csharp
345345
* if (x < y) {
346346
* x = y;
347347
* }

csharp/ql/src/experimental/ir/rangeanalysis/RangeAnalysis.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
/*
1212
* This library tackles range analysis as a flow problem. Consider e.g.:
13-
* ```
13+
* ```csharp
1414
* len = arr.length;
1515
* if (x < len) { ... y = x-1; ... y ... }
1616
* ```

csharp/ql/src/semmle/code/asp/AspNet.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AspAttribute extends AspElement, @asp_attribute { }
3232
/**
3333
* An open tag, for example the tag on line 1 in
3434
*
35-
* ```
35+
* ```html
3636
* <script runat="server">
3737
* Label.Text = "Hello, World!";
3838
* </script>
@@ -67,7 +67,7 @@ class AspOpenTag extends AspElement, @asp_open_tag {
6767
/**
6868
* A close tag, for example the tag on line 3 in
6969
*
70-
* ```
70+
* ```html
7171
* <script runat="server">
7272
* Label.Text = "Hello, World!";
7373
* </script>
@@ -123,7 +123,7 @@ class AspServerComment extends AspComment {
123123
/**
124124
* A data-binding expression, for example `<%# myArray %>` in
125125
*
126-
* ```
126+
* ```html
127127
* <asp:ListBox id="List1" datasource='<%# myArray %>' runat="server">
128128
* ```
129129
*/

csharp/ql/src/semmle/code/cil/BasicBlock.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
2323
*
2424
* Example:
2525
*
26-
* ```
26+
* ```csharp
2727
* if (x < 0)
2828
* x = -x;
2929
* ```
@@ -41,7 +41,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
4141
*
4242
* Example:
4343
*
44-
* ```
44+
* ```csharp
4545
* if (!(x >= 0))
4646
* x = -x;
4747
* ```
@@ -75,7 +75,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
7575
*
7676
* Example:
7777
*
78-
* ```
78+
* ```csharp
7979
* int M(string s) {
8080
* if (s == null)
8181
* throw new ArgumentNullException(nameof(s));
@@ -97,7 +97,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
9797
*
9898
* Example:
9999
*
100-
* ```
100+
* ```csharp
101101
* int M(string s) {
102102
* if (s == null)
103103
* throw new ArgumentNullException(nameof(s));
@@ -124,7 +124,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
124124
*
125125
* Example:
126126
*
127-
* ```
127+
* ```csharp
128128
* if (x < 0) {
129129
* x = -x;
130130
* if (x > 10)
@@ -158,7 +158,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
158158
*
159159
* Example:
160160
*
161-
* ```
161+
* ```csharp
162162
* int M(string s) {
163163
* if (s == null)
164164
* throw new ArgumentNullException(nameof(s));
@@ -182,7 +182,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
182182
*
183183
* Example:
184184
*
185-
* ```
185+
* ```csharp
186186
* int M(string s) {
187187
* try {
188188
* return s.Length;
@@ -207,7 +207,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
207207
*
208208
* Example:
209209
*
210-
* ```
210+
* ```csharp
211211
* int M(string s) {
212212
* try {
213213
* return s.Length;
@@ -353,15 +353,15 @@ class ConditionBlock extends BasicBlock {
353353
* all predecessors of `this.getATrueSuccessor()` are either `this` or dominated by `this.getATrueSuccessor()`.
354354
*
355355
* For example, in the following C# snippet:
356-
* ```
356+
* ```csharp
357357
* if (x)
358358
* controlled;
359359
* false_successor;
360360
* uncontrolled;
361361
* ```
362362
* `false_successor` dominates `uncontrolled`, but not all of its predecessors are `this` (`if (x)`)
363363
* or dominated by itself. Whereas in the following code:
364-
* ```
364+
* ```csharp
365365
* if (x)
366366
* while (controlled)
367367
* also_controlled;

csharp/ql/src/semmle/code/csharp/Assignable.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private predicate nameOfChild(NameOfExpr noe, Expr child) {
5555
*
5656
* For example, the last occurrence of `Length` in
5757
*
58-
* ```
58+
* ```csharp
5959
* class C {
6060
* int Length;
6161
*
@@ -89,7 +89,7 @@ class AssignableRead extends AssignableAccess {
8989
* that can be reached from this read without passing through any other reads,
9090
* and which is guaranteed to read the same value. Example:
9191
*
92-
* ```
92+
* ```csharp
9393
* int Field;
9494
*
9595
* void SetField(int i) {
@@ -131,7 +131,7 @@ class AssignableRead extends AssignableAccess {
131131
*
132132
* For example, the last occurrence of `Length` in
133133
*
134-
* ```
134+
* ```csharp
135135
* class C {
136136
* int Length;
137137
*
@@ -454,7 +454,7 @@ class AssignableDefinition extends TAssignableDefinition {
454454
* reads, and which is guaranteed to read the value assigned in this
455455
* definition. Example:
456456
*
457-
* ```
457+
* ```csharp
458458
* int Field;
459459
*
460460
* void SetField(int i) {
@@ -720,7 +720,7 @@ module AssignableDefinitions {
720720
* An initializer definition for a field or a property, for example
721721
* line 2 in
722722
*
723-
* ```
723+
* ```csharp
724724
* class C {
725725
* int Field = 0;
726726
* }

csharp/ql/src/semmle/code/csharp/Attribute.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Attributable extends @attributable {
3838
/**
3939
* An attribute, for example `[...]` on line 1 in
4040
*
41-
* ```
41+
* ```csharp
4242
* [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
4343
* public static extern int GetFinalPathNameByHandle(
4444
* SafeHandle handle,
@@ -64,7 +64,7 @@ class Attribute extends TopLevelExprParent, @attribute {
6464
* Gets the `i`th constructor argument of this attribute. For example, only
6565
* `true` is a constructor argument in
6666
*
67-
* ```
67+
* ```csharp
6868
* MyAttribute[true, Foo = 0]
6969
* ```
7070
*/
@@ -76,7 +76,7 @@ class Attribute extends TopLevelExprParent, @attribute {
7676
* Gets the named argument `name` of this attribute. For example, only
7777
* `0` is a named argument in
7878
*
79-
* ```
79+
* ```csharp
8080
* MyAttribute[true, Foo = 0]
8181
* ```
8282
*/

0 commit comments

Comments
 (0)