/// <summary>
        /// Initializes a new instance of the <see cref="NamespaceStatistics"/> class.
        /// </summary>
        /// <param name="module">Module containing the namespace.</param>
        /// <param name="name">Namespace name.</param>
        internal NamespaceStatistics(ModuleStatistics module, string name)
        {
            if (module == null) throw new ArgumentNullException("module");
            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name");

            Module = module;
            NamespaceName = name;
        }
        /// <summary>
        /// Creates a module coverage statistics based on given coverage buffer.
        /// </summary>
        /// <param name="files">List to which instrumented files are added.</param>
        /// <param name="module">Information about module coverage.</param>
        /// <param name="lineStartId">Starting identification number for method lines.</param>
        /// <returns>New <see cref="ModuleStatistics"/> instance.</returns>
        internal static ModuleStatistics Create(FileSpecList files, ICoverageModule module, ref long lineStartId)
        {
            var moduleStats = new ModuleStatistics(module.Name, module.Signature, module.ImageSize, module.ImageLinkTime);

            var lines = new List<BlockLineRange>();
            var coverageBuffer = module.GetCoverageBuffer(null /* tests */);
            using (var symbolReader = module.Symbols.CreateReader())
            {
                uint methodId;
                string methodName;
                string undecoratedMethodName;
                string className;
                string namespaceName;

                while (symbolReader.GetNextMethod(out methodId, out methodName, out undecoratedMethodName, out className, out namespaceName, lines))
                {
                    var namespaceStats = moduleStats.GetOrAddNamespace(namespaceName);
                    var classStats = namespaceStats.GetOrAddClass(className);

                    var methodStats = MethodStatistics.Create(methodId, methodName, undecoratedMethodName, coverageBuffer, lines, files, ref lineStartId);
                    classStats.AddMethod(methodStats);

                    // Clear the method list to be ready for next method.
                    lines.Clear();
                }
            }
            return moduleStats;
        }