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+ /**
2+ * @name Compilation error
3+ * @description A compilation error can lead to extraction problems, and may indicate
4+ * a bug in the extractor.
5+ * @kind problem
6+ * @problem.severity recommendation
7+ * @precision medium
8+ * @id cs/compilation-error
9+ * @tags internal
10+ */
11+
12+ import csharp
13+ import semmle.code.csharp.commons.Diagnostics
14+
15+ from CompilerError diagnostic
16+ select diagnostic ,
17+ diagnostic .getSeverityText ( ) + " " + diagnostic .getTag ( ) + " " + diagnostic .getFullMessage ( )
Original file line number Diff line number Diff line change 1+ /**
2+ * @name Compilation message
3+ * @description A message emitted by the compiler.
4+ * @kind problem
5+ * @problem.severity recommendation
6+ * @precision medium
7+ * @id cs/compilation-warning
8+ * @tags internal
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+ /**
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 medium
9+ * @id cs/extraction-error
10+ * @tags internal
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+ /**
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 medium
7+ * @id cs/extraction-message
8+ * @tags internal
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
Original file line number Diff line number Diff line change 1+ Diagnostics/CompilerError.ql
Original file line number Diff line number Diff line change 1+ | Program.cs:7:13:7:13 | CS0219: The variable 'x' is assigned but its value is never used | Warning CS0219 The variable 'x' is assigned but its value is never used |
2+ | Program.cs:9:9:9:11 | CS0162: Unreachable code detected | Warning CS0162 Unreachable code detected |
3+ | Program.cs:9:13:9:13 | CS0219: The variable 'y' is assigned but its value is never used | Warning CS0219 The variable 'y' is assigned but its value is never used |
Original file line number Diff line number Diff line change 1+ Diagnostics/CompilerMessage.ql
You can’t perform that action at this time.
0 commit comments