Skip to content

Commit 5149ffd

Browse files
committed
C#: Add extraction error diagnostic query
1 parent a7cc9f9 commit 5149ffd

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @name Extraction errors
3+
* @description List all errors reported by the extractor. The returned issues are
4+
* limited to those files where there are no compilation errors. This
5+
* indicates a bug or limitation in the extractor, and could lead to
6+
* inaccurate results.
7+
* @kind diagnostic
8+
* @id cs/diagnostics/extraction-errors
9+
*/
10+
11+
import csharp
12+
import semmle.code.csharp.commons.Diagnostics
13+
14+
from ExtractorError error
15+
where not exists(CompilerError ce | ce.getLocation().getFile() = error.getLocation().getFile())
16+
select error,
17+
"Unexpected " + error.getOrigin() + " error: " + error.getText() + " in " +
18+
error.getLocation().getFile(), 3

csharp/ql/test/library-tests/diagnostics/DiagnosticExtractorErrors.expected

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Diagnostics/DiagnosticExtractionErrors.ql
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// semmle-extractor-options: --standalone
2+
3+
using System;
4+
5+
class Class
6+
{
7+
static void Main(string[] args)
8+
{
9+
int z = GetParamLength(__arglist(1, 2));
10+
}
11+
12+
public static int GetParamLength(__arglist)
13+
{
14+
ArgIterator iterator = new ArgIterator(__arglist);
15+
return iterator.GetRemainingCount();
16+
}
17+
}

0 commit comments

Comments
 (0)