Details
-
Type:
Bug
-
Status: Resolved (View Workflow)
-
Priority:
Minor
-
Resolution: Fixed
-
Component/s: analysis-core-plugin
-
Labels:
-
Environment:Jenkins 2.89.2
Static Analysis Utilities 1.93
Warnings Plug-in 4.64
Windows
-
Similar Issues:
Description
If there are some compiler warnings about a C# source file that is encoded in UTF-8 and starts with a Byte Order Mark, and the BOM is immediately followed by "namespace " and the name of the namespace, then the Warnings Plug-in does not recognize the namespace declaration and instead displays the relative directory name.
If I insert CRLF between the BOM and "namespace", then the Warnings Plug-in correctly displays the name of the namespace. Likewise, the namespace detector works OK if there is a comment with copyright notices at the top of the file.
Because I cannot find any namespace detection code in the Warnings Plug-in itself, I believe the problem is in the hudson.plugins.analysis.util.CsharpNamespaceDetector class, defined in Static Analysis Utilities aka analysis-core. It decodes the file as UTF-8 and then checks each line against the regexp "^namespace .*$" until it finds a match. Perhaps this can be changed to allow "\uFEFF" at the start of the line, or more generally whitespace.
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
Attachment | JENKINS-48869.test-case.zip [ 41088 ] |
Description |
If there are some compiler warnings about a C# source file that is encoded in UTF-8 and starts with a Byte Order Mark, and the BOM is immediately followed by "namespace " and the name of the namespace, then the Warnings Plug-in does not recognize the namespace declaration and instead displays the relative file name. If I insert CRLF between the BOM and "namespace", then the Warnings Plug-in correctly displays the name of the namespace. Likewise, the namespace detector works OK if there is a comment with copyright notices at the top of the file. Because I cannot find any namespace detection code in the Warnings Plug-in itself, I believe the problem is in the hudson.plugins.analysis.util.CsharpNamespaceDetector class, defined in Static Analysis Utilities aka analysis-core. It decodes the file as UTF-8 and then checks each line against the regexp "^namespace .*$" until it finds a match. Perhaps this can be changed to allow "\uFEFF" at the start of the line, or more generally whitespace. |
If there are some compiler warnings about a C# source file that is encoded in UTF-8 and starts with a Byte Order Mark, and the BOM is immediately followed by "namespace " and the name of the namespace, then the Warnings Plug-in does not recognize the namespace declaration and instead displays the relative directory name. If I insert CRLF between the BOM and "namespace", then the Warnings Plug-in correctly displays the name of the namespace. Likewise, the namespace detector works OK if there is a comment with copyright notices at the top of the file. Because I cannot find any namespace detection code in the Warnings Plug-in itself, I believe the problem is in the hudson.plugins.analysis.util.CsharpNamespaceDetector class, defined in Static Analysis Utilities aka analysis-core. It decodes the file as UTF-8 and then checks each line against the regexp "^namespace .*$" until it finds a match. Perhaps this can be changed to allow "\uFEFF" at the start of the line, or more generally whitespace. |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Resolved [ 5 ] |
Can you please attach such a file (or a small part of it)? Then creating a test case would be quite simple.