Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-75822

Error parsing Cobertura file for C# project with multiple conversion operators differing by return type only

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Minor Minor
    • coverage-plugin
    • None
    • Jenkins 2.504.1
      coverage plugin 2.7.0

      This code:

      using System.Diagnostics.CodeAnalysis;
      
      namespace Sig.Core;
      
      public record PowerScribeSoapServiceAuthHeader(
          int SystemID,
          string AccessCode,
          string Username,
          string Password)
      {
          public static implicit operator PowerScribeExplorer.AuthHeader(PowerScribeSoapServiceAuthHeader source) =>
              new()
              {
                  SystemID = source.SystemID,
                  AccessCode = source.AccessCode,
                  Username = source.Username,
                  Password = source.Password
              };
      
          [ExcludeFromCodeCoverage]
          public static implicit operator PowerScribeCustomField.AuthHeader(PowerScribeSoapServiceAuthHeader source) =>
              new()
              {
                  SystemID = source.SystemID,
                  AccessCode = source.AccessCode,
                  Username = source.Username,
                  Password = source.Password
              };
      }
      

      produces this error when analyzed:

      java.lang.IllegalArgumentException: There is already the same child [METHOD] op_Implicit(Sig.Core.PowerScribeSoapServiceAuthHeader) <0> with the name op_Implicit(Sig.Core.PowerScribeSoapServiceAuthHeader) in [CLASS] Sig.Core.PowerScribeSoapServiceAuthHeader <5, LINE: 0.00% (0/11)>
      	at PluginClassLoader for coverage//edu.hm.hafner.coverage.Node.addChild(Node.java:178)
      	at PluginClassLoader for coverage//edu.hm.hafner.coverage.Node.addChildNode(Node.java:966)
      	at PluginClassLoader for coverage//edu.hm.hafner.coverage.Node.createMethodNode(Node.java:920)
      	at PluginClassLoader for coverage//edu.hm.hafner.coverage.parser.CoberturaParser.createMethodNode(CoberturaParser.java:238)
      	at PluginClassLoader for coverage//edu.hm.hafner.coverage.parser.CoberturaParser.createNode(CoberturaParser.java:226)
      	at PluginClassLoader for coverage//edu.hm.hafner.coverage.parser.CoberturaParser.readClassOrMethod(CoberturaParser.java:168)
      	at PluginClassLoader for coverage//edu.hm.hafner.coverage.parser.CoberturaParser.readClassOrMethod(CoberturaParser.java:199)
      	at PluginClassLoader for coverage//edu.hm.hafner.coverage.parser.CoberturaParser.readPackage(CoberturaParser.java:136)
      	at PluginClassLoader for coverage//edu.hm.hafner.coverage.parser.CoberturaParser.readModule(CoberturaParser.java:115)
      	at PluginClassLoader for coverage//edu.hm.hafner.coverage.parser.CoberturaParser.parseReport(CoberturaParser.java:93)
      	at PluginClassLoader for coverage//edu.hm.hafner.coverage.CoverageParser.parse(CoverageParser.java:82)
      	at PluginClassLoader for coverage//io.jenkins.plugins.coverage.metrics.steps.CoverageReportScanner.processFile(CoverageReportScanner.java:64)
      	at PluginClassLoader for plugin-util-api//io.jenkins.plugins.util.AgentFileVisitor.scanFiles(AgentFileVisitor.java:116)
      	at PluginClassLoader for plugin-util-api//io.jenkins.plugins.util.AgentFileVisitor.invoke(AgentFileVisitor.java:95)
      	at PluginClassLoader for plugin-util-api//io.jenkins.plugins.util.AgentFileVisitor.invoke(AgentFileVisitor.java:40)
      	at Jenkins v2.504.1//hudson.FilePath$FileCallableWrapper.call(FilePath.java:3593)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:225)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:50)
      	at hudson.remoting.Request$2.run(Request.java:391)
      	at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:81)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
      	at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:138)
      	at java.base/java.lang.Thread.run(Thread.java:1583)
      [Bitbucket] Notifying pull request build result
      [Bitbucket] Build result notified
      Finished: FAILURE
      

      It seems like the problem happens for functions that have the same signature except for the return type. Perhaps Jenkins coverage plugin does not consider the return type part of the signature.

      Workaround is possible using the [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] attribute so there is at most one of the similar named functions that is analysed.

      The error seems very similar to JENKINS-73175.

            drulli Ulli Hafner
            tsondergaard tsondergaard
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: