Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12843d2

Browse files
committed
C#: Add tests for named attribute arguments
1 parent fa26087 commit 12843d2

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

csharp/ql/test/library-tests/arguments/arguments.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,17 @@ void f5()
6161
var tuple = (13, 14);
6262
(Prop, this[15, 16]) = tuple;
6363
}
64+
65+
[MyAttribute(false)]
66+
void f6() { }
67+
68+
[MyAttribute(true, y = "", x = 0)]
69+
void f7() { }
70+
}
71+
72+
class MyAttribute : Attribute
73+
{
74+
public int x;
75+
public string y { get; set; }
76+
public MyAttribute(bool b) { }
6477
}

csharp/ql/test/library-tests/attributes/AttributeArguments.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@
1212
| attributes.cs:38:12:38:30 | [AssemblyFileVersion(...)] | 0 | attributes.cs:38:32:38:40 | "1.0.0.0" |
1313
| attributes.cs:40:2:40:22 | [AttributeUsage(...)] | 0 | attributes.cs:40:24:40:50 | access to constant All |
1414
| attributes.cs:43:6:43:16 | [Conditional(...)] | 0 | attributes.cs:43:18:43:25 | "DEBUG2" |
15+
| attributes.cs:51:6:51:16 | [My(...)] | 0 | attributes.cs:51:18:51:22 | false |
16+
| attributes.cs:54:6:54:16 | [My(...)] | 0 | attributes.cs:54:18:54:21 | true |
17+
| attributes.cs:54:6:54:16 | [My(...)] | 1 | attributes.cs:54:28:54:29 | "" |
18+
| attributes.cs:54:6:54:16 | [My(...)] | 2 | attributes.cs:54:36:54:36 | 0 |

csharp/ql/test/library-tests/attributes/AttributeElements.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
| attributes.cs:41:7:41:9 | Foo | attributes.cs:40:2:40:22 | [AttributeUsage(...)] | System.AttributeUsageAttribute |
22
| attributes.cs:44:17:44:19 | foo | attributes.cs:43:6:43:16 | [Conditional(...)] | System.Diagnostics.ConditionalAttribute |
33
| attributes.cs:49:23:49:23 | x | attributes.cs:49:14:49:16 | [Foo(...)] | Foo |
4+
| attributes.cs:52:10:52:11 | M1 | attributes.cs:51:6:51:16 | [My(...)] | MyAttribute |
5+
| attributes.cs:55:10:55:11 | M2 | attributes.cs:54:6:54:16 | [My(...)] | MyAttribute |
46
| attributes.dll:0:0:0:0 | attributes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | attributes.cs:10:12:10:24 | [AssemblyTitle(...)] | System.Reflection.AssemblyTitleAttribute |
57
| attributes.dll:0:0:0:0 | attributes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | attributes.cs:11:12:11:30 | [AssemblyDescription(...)] | System.Reflection.AssemblyDescriptionAttribute |
68
| attributes.dll:0:0:0:0 | attributes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | attributes.cs:12:12:12:32 | [AssemblyConfiguration(...)] | System.Reflection.AssemblyConfigurationAttribute |

csharp/ql/test/library-tests/attributes/attributes.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,17 @@ static void foo() { }
4747
class Bar
4848
{
4949
int inc([Foo] int x) { return x + 1; }
50+
51+
[MyAttribute(false)]
52+
void M1() { }
53+
54+
[MyAttribute(true, y = "", x = 0)]
55+
void M2() { }
56+
}
57+
58+
class MyAttribute : Attribute
59+
{
60+
public int x;
61+
public string y { get; set; }
62+
public MyAttribute(bool b) { }
5063
}

0 commit comments

Comments
 (0)