File tree Expand file tree Collapse file tree
semmle/code/csharp/commons
test/library-tests/compilations Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE qhelp PUBLIC
2+ "-//Semmle//qhelp//EN"
3+ "qhelp.dtd">
4+ <qhelp >
5+
6+ <overview >
7+ <p >
8+ This is an internal query that finds all compilation errors reported by the C# compiler used by the C# extractor.</p >
9+ </overview >
10+
11+ </qhelp >
Original file line number Diff line number Diff line change 1+ /**
2+ * @name Compilation error
3+ * @description A compilation error can cause extraction problems, and could lead to inaccurate results.
4+ * @kind problem
5+ * @problem.severity recommendation
6+ * @precision high
7+ * @id cs/compilation-error
8+ * @tags internal non-attributable
9+ */
10+
11+ import csharp
12+ import semmle.code.csharp.commons.Diagnostics
13+
14+ from CompilerError diagnostic
15+ select diagnostic ,
16+ diagnostic .getSeverityText ( ) + " " + diagnostic .getTag ( ) + " " + diagnostic .getFullMessage ( )
Original file line number Diff line number Diff line change 1+ <!DOCTYPE qhelp PUBLIC
2+ "-//Semmle//qhelp//EN"
3+ "qhelp.dtd">
4+ <qhelp >
5+
6+ <overview >
7+ <p >
8+ This is an internal query that finds all messages reported by the C# compiler used by the C# extractor. This may include both compiler errors and
9+ compiler warnings.
10+ </p >
11+ </overview >
12+
13+ </qhelp >
Original file line number Diff line number Diff line change 1+ /**
2+ * @name Compilation message
3+ * @description A message emitted by the compiler, including warnings and errors.
4+ * @kind problem
5+ * @problem.severity recommendation
6+ * @precision high
7+ * @id cs/compilation-message
8+ * @tags internal non-attributable
9+ */
10+
11+ import csharp
12+ import semmle.code.csharp.commons.Diagnostics
13+
14+ from Diagnostic diagnostic
15+ select diagnostic ,
16+ diagnostic .getSeverityText ( ) + " " + diagnostic .getTag ( ) + " " + diagnostic .getFullMessage ( )
Original file line number Diff line number Diff line change 1+ <!DOCTYPE qhelp PUBLIC
2+ "-//Semmle//qhelp//EN"
3+ "qhelp.dtd">
4+ <qhelp >
5+
6+ <overview >
7+ <p >
8+ This is an internal query that finds all errors reported by the C# extractor. It excludes results from files containing
9+ compilation errors, because these errors are likely to be caused by the compilation error rather than due to an internal
10+ error in the extractor.
11+ </p >
12+
13+ <p >Extractor errors can lead to inaccurate results.</p >
14+ </overview >
15+
16+ <recommendation >
17+ <p >
18+ Report extractor errors to Semmle.
19+ </p >
20+ </recommendation >
21+
22+ </qhelp >
Original file line number Diff line number Diff line change 1+ /**
2+ * @name Extraction error
3+ * @description An error message reported by the extractor, limited to those files where there are no
4+ * compilation errors. This indicates a bug or limitation in the extractor, and could lead
5+ * to inaccurate results.
6+ * @kind problem
7+ * @problem.severity recommendation
8+ * @precision high
9+ * @id cs/extraction-error
10+ * @tags internal non-attributable
11+ */
12+
13+ import csharp
14+ import semmle.code.csharp.commons.Diagnostics
15+
16+ from ExtractorError error
17+ where not exists ( CompilerError ce | ce .getLocation ( ) .getFile ( ) = error .getLocation ( ) .getFile ( ) )
18+ select error ,
19+ "Unexpected " + error .getOrigin ( ) + " error in element '" + error .getElementText ( ) +
20+ "' at location " + error .getStackTrace ( )
Original file line number Diff line number Diff line change 1+ <!DOCTYPE qhelp PUBLIC
2+ "-//Semmle//qhelp//EN"
3+ "qhelp.dtd">
4+ <qhelp >
5+
6+ <overview >
7+ <p >
8+ This is an internal query that finds all messages reported by the extractor. These results may include extraction errors
9+ that are caused by compilation errors.
10+ </p >
11+ <p >
12+ Extractor errors can lead to inaccurate results.
13+ </p >
14+ </overview >
15+
16+ </qhelp >
Original file line number Diff line number Diff line change 1+ /**
2+ * @name Extraction message
3+ * @description An error message reported by the extractor. This could lead to inaccurate results.
4+ * @kind problem
5+ * @problem.severity recommendation
6+ * @precision high
7+ * @id cs/extraction-message
8+ * @tags internal non-attributable
9+ */
10+
11+ import csharp
12+ import semmle.code.csharp.commons.Diagnostics
13+
14+ from ExtractorMessage message
15+ select message ,
16+ message .getSeverityText ( ) + " was generated by " + message .getOrigin ( ) + " in element '" +
17+ message .getElementText ( ) + "' at location " + message .getStackTrace ( )
Original file line number Diff line number Diff line change @@ -29,6 +29,17 @@ class Diagnostic extends @diagnostic {
2929 */
3030 int getSeverity ( ) { result = severity }
3131
32+ /** Gets a string representation of the severity of this diagnostic. */
33+ string getSeverityText ( ) {
34+ severity = 0 and result = "Hidden"
35+ or
36+ severity = 1 and result = "Info"
37+ or
38+ severity = 2 and result = "Warning"
39+ or
40+ severity = 3 and result = "Error"
41+ }
42+
3243 /** Gets the identifier of this diagnostic, for example "CS8019". */
3344 string getTag ( ) { result = tag }
3445
You can’t perform that action at this time.
0 commit comments