public static void GenerateTypeDesignMeasures(XmlTextWriter writer, ModuleDefinition module) { writer.WriteStartElement("Design"); var sourceRegistry = new SourceRegistry(module); // first generate and write measures for types colocated in the same files GenerateMultiTypeDesignMeasures(writer, module, sourceRegistry); // then deal with type with source locations not treated before foreach (var t in module.Types) { var path = t.GetSourcePath(); if (path!=null && !sourceRegistry.IsMultiTypeFile(path)) { DesignMeasures measures = GenerateTypeMeasures(t); measures.Write(writer); } } // and at last deal with types without source location foreach (var t in module.Types) { var path = t.GetSourcePath(); if (path == null) { var measures = GenerateTypeMeasures(t); measures.Write(writer); } } writer.WriteEndElement(); }
private static void GenerateMultiTypeDesignMeasures(XmlTextWriter writer, ModuleDefinition module, SourceRegistry sourceRegistry) { var multiTypeMeasures = new Dictionary<string, DesignMeasures>(); foreach (var t in module.Types) { var path = t.GetSourcePath(); if (sourceRegistry.IsMultiTypeFile(path)) { var measures = GenerateTypeMeasures(t); if (multiTypeMeasures.ContainsKey(path)) { multiTypeMeasures[path] = multiTypeMeasures[path].Merge(measures); } else { multiTypeMeasures[path] = measures; } } } foreach (var multiTypeMeasure in multiTypeMeasures.Values) { multiTypeMeasure.Write(writer); } }