C#: Add tests and update expected test output.

This commit is contained in:
Michael Nebel
2024-02-28 11:22:12 +01:00
parent 95dc2f71d3
commit 7535a15fda
5 changed files with 16 additions and 8 deletions

View File

@@ -106,8 +106,8 @@ arguments
| attributes.cs:151:6:151:11 | [Params(...)] | 0 | attributes.cs:151:45:151:47 | "a" |
| attributes.cs:151:6:151:11 | [Params(...)] | 1 | attributes.cs:151:36:151:38 | "b" |
| attributes.cs:151:6:151:11 | [Params(...)] | 2 | attributes.cs:151:19:151:29 | array creation of type Int32[] |
| attributes.cs:155:2:155:13 | [Experimental(...)] | 0 | attributes.cs:155:15:155:35 | "MyExperimentalClass" |
| attributes.cs:158:6:158:17 | [Experimental(...)] | 0 | attributes.cs:158:19:158:40 | "MyExperimentalMethod" |
| attributes.cs:155:2:155:13 | [Experimental(...)] | 0 | attributes.cs:155:15:155:37 | "MyExperimentalClassId" |
| attributes.cs:158:6:158:17 | [Experimental(...)] | 0 | attributes.cs:158:19:158:42 | "MyExperimentalMethodId" |
constructorArguments
| Assembly1.dll:0:0:0:0 | [Custom(...)] | 0 | Assembly1.dll:0:0:0:0 | 1 |
| Assembly1.dll:0:0:0:0 | [Custom(...)] | 0 | Assembly1.dll:0:0:0:0 | 3 |
@@ -204,8 +204,8 @@ constructorArguments
| attributes.cs:151:6:151:11 | [Params(...)] | 0 | attributes.cs:151:45:151:47 | "a" |
| attributes.cs:151:6:151:11 | [Params(...)] | 1 | attributes.cs:151:36:151:38 | "b" |
| attributes.cs:151:6:151:11 | [Params(...)] | 2 | attributes.cs:151:19:151:29 | array creation of type Int32[] |
| attributes.cs:155:2:155:13 | [Experimental(...)] | 0 | attributes.cs:155:15:155:35 | "MyExperimentalClass" |
| attributes.cs:158:6:158:17 | [Experimental(...)] | 0 | attributes.cs:158:19:158:40 | "MyExperimentalMethod" |
| attributes.cs:155:2:155:13 | [Experimental(...)] | 0 | attributes.cs:155:15:155:37 | "MyExperimentalClassId" |
| attributes.cs:158:6:158:17 | [Experimental(...)] | 0 | attributes.cs:158:19:158:42 | "MyExperimentalMethodId" |
namedArguments
| Assembly1.dll:0:0:0:0 | [Custom(...)] | Prop2 | Assembly1.dll:0:0:0:0 | array creation of type Object[] |
| Assembly1.dll:0:0:0:0 | [Custom(...)] | Prop2 | Assembly1.dll:0:0:0:0 | array creation of type Object[] |

View File

@@ -0,0 +1,2 @@
| attributes.cs:156:14:156:32 | MyExperimentalClass | attributes.cs:155:2:155:13 | [Experimental(...)] | MyExperimentalClassId |
| attributes.cs:159:17:159:36 | MyExperimentalMethod | attributes.cs:158:6:158:17 | [Experimental(...)] | MyExperimentalMethodId |

View File

@@ -0,0 +1,6 @@
import csharp
import semmle.code.csharp.frameworks.system.diagnostics.CodeAnalysis
from Attributable element, ExperimentalAttribute attribute
where attribute = element.getAnAttribute() and attribute.fromSource()
select element, attribute, attribute.getId()

View File

@@ -465,11 +465,11 @@ attributes.cs:
#-----| 0: (Attributes)
# 155| 1: [DefaultAttribute] [Experimental(...)]
# 155| -1: [TypeMention] ExperimentalAttribute
# 155| 0: [StringLiteralUtf16] "MyExperimentalClass"
# 155| 0: [StringLiteralUtf16] "MyExperimentalClassId"
# 159| 5: [Method] MyExperimentalMethod
# 159| -1: [TypeMention] Void
#-----| 0: (Attributes)
# 158| 1: [DefaultAttribute] [Experimental(...)]
# 158| -1: [TypeMention] ExperimentalAttribute
# 158| 0: [StringLiteralUtf16] "MyExperimentalMethod"
# 158| 0: [StringLiteralUtf16] "MyExperimentalMethodId"
# 159| 4: [BlockStmt] {...}

View File

@@ -152,9 +152,9 @@ class Class1
public void M4() { }
}
[Experimental("MyExperimentalClass")]
[Experimental("MyExperimentalClassId")]
public class MyExperimentalClass
{
[Experimental("MyExperimentalMethod")]
[Experimental("MyExperimentalMethodId")]
public void MyExperimentalMethod() { }
}