C#: Add extraction error diagnostic query

This commit is contained in:
Tamas Vajk
2021-04-21 12:01:09 +02:00
parent a7cc9f98ef
commit 5149ffdd16
4 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
/**
* @name Extraction errors
* @description List all errors reported by the extractor. The returned issues are
* limited to those files where there are no compilation errors. This
* indicates a bug or limitation in the extractor, and could lead to
* inaccurate results.
* @kind diagnostic
* @id cs/diagnostics/extraction-errors
*/
import csharp
import semmle.code.csharp.commons.Diagnostics
from ExtractorError error
where not exists(CompilerError ce | ce.getLocation().getFile() = error.getLocation().getFile())
select error,
"Unexpected " + error.getOrigin() + " error: " + error.getText() + " in " +
error.getLocation().getFile(), 3

View File

@@ -0,0 +1 @@
Diagnostics/DiagnosticExtractionErrors.ql

View File

@@ -0,0 +1,17 @@
// semmle-extractor-options: --standalone
using System;
class Class
{
static void Main(string[] args)
{
int z = GetParamLength(__arglist(1, 2));
}
public static int GetParamLength(__arglist)
{
ArgIterator iterator = new ArgIterator(__arglist);
return iterator.GetRemainingCount();
}
}