private XElement GetMethodsElement(CoberturaClass coberturaClass) { var methodsElement = new XElement("methods"); foreach (var method in coberturaClass.Methods) { var methodElement = new XElement("method"); methodElement.AddAttributeIfItHasValue("name", method.Name); methodElement.AddAttributeIfItHasValue("signature", method.Signature); methodElement.AddAttributeIfItHasValue("line-rate", method.LineRate); methodElement.AddAttributeIfItHasValue("branch-rate", method.BranchRate); if (method.Lines?.Any() == true) { var linesElement = GetLinesElement(method.Lines); methodElement.Add(linesElement); } methodsElement.Add(methodElement); } return(methodsElement); }
private XElement GetClassElement(CoberturaClass coberturaClass) { var classElement = new XElement("class"); classElement.AddAttributeIfItHasValue("name", coberturaClass.Name); classElement.AddAttributeIfItHasValue("filename", coberturaClass.FileName); classElement.AddAttributeIfItHasValue("line-rate", coberturaClass.LineRate); classElement.AddAttributeIfItHasValue("branch-rate", coberturaClass.BranchRate); classElement.AddAttributeIfItHasValue("complexity", coberturaClass.Complexity); if (coberturaClass.Methods?.Any() == true) { var methodsElement = GetMethodsElement(coberturaClass); classElement.Add(methodsElement); } if (coberturaClass.Lines?.Any() == true) { var linesElement = GetLinesElement(coberturaClass.Lines); classElement.Add(linesElement); } return(classElement); }