private void ReadImplementedInterfaceMembers() { var implementedInterfaceMembersFile = Path.Combine(ProjectDestinationFolder, Constants.ImplementedInterfaceMembersFileName + ".txt"); if (!File.Exists(implementedInterfaceMembersFile)) { return; } var lines = File.ReadAllLines(implementedInterfaceMembersFile); foreach (var line in lines) { var parts = line.Split(';'); var implementationId = Serialization.HexStringToULong(parts[0]); var interfaceAssemblyName = string.Intern(parts[1]); var interfaceMemberId = Serialization.HexStringToULong(parts[2]); ImplementedInterfaceMembers.Add(implementationId, Tuple.Create(interfaceAssemblyName, interfaceMemberId)); } }
private void ReadBaseMembers() { var baseMembersFile = Path.Combine(ProjectDestinationFolder, Constants.BaseMembersFileName + ".txt"); if (!File.Exists(baseMembersFile)) { return; } var lines = File.ReadAllLines(baseMembersFile); foreach (var line in lines) { var parts = line.Split(';'); var derivedId = Serialization.HexStringToULong(parts[0]); var baseAssemblyName = string.Intern(parts[1]); var baseId = Serialization.HexStringToULong(parts[2]); BaseMembers[derivedId] = Tuple.Create(baseAssemblyName, baseId); } }
private void GenerateReferencesFile(string referencesFile) { string[] referencesLines = File.ReadAllLines(referencesFile, Encoding.UTF8); string rawReferencesFile = referencesFile; referencesFile = Path.ChangeExtension(referencesFile, ".html"); var referenceKindGroups = CreateReferences(referencesLines, out int totalReferenceCount, out string symbolName); using (var writer = new StreamWriter(referencesFile, append: false, encoding: Encoding.UTF8)) { Markup.WriteReferencesFileHeader(writer, symbolName); if (this.AssemblyId != Constants.MSBuildItemsAssembly && this.AssemblyId != Constants.MSBuildPropertiesAssembly && this.AssemblyId != Constants.MSBuildTargetsAssembly && this.AssemblyId != Constants.MSBuildTasksAssembly && this.AssemblyId != Constants.GuidAssembly) { string symbolId = Path.GetFileNameWithoutExtension(referencesFile); var id = Serialization.HexStringToULong(symbolId); WriteBaseMember(id, writer); WriteImplementedInterfaceMembers(id, writer); } foreach (var referenceKind in referenceKindGroups.OrderBy(t => (int)t.Item1)) { string formatString = ""; switch (referenceKind.Item1) { case ReferenceKind.Reference: formatString = "{0} reference{1} to {2}"; break; case ReferenceKind.DerivedType: formatString = "{0} type{1} derived from {2}"; break; case ReferenceKind.InterfaceInheritance: formatString = "{0} interface{1} inheriting from {2}"; break; case ReferenceKind.InterfaceImplementation: formatString = "{0} implementation{1} of {2}"; break; case ReferenceKind.Read: formatString = "{0} read{1} of {2}"; break; case ReferenceKind.Write: formatString = "{0} write{1} to {2}"; break; case ReferenceKind.Instantiation: formatString = "{0} instantiation{1} of {2}"; break; case ReferenceKind.Override: formatString = "{0} override{1} of {2}"; break; case ReferenceKind.InterfaceMemberImplementation: formatString = "{0} implementation{1} of {2}"; break; case ReferenceKind.GuidUsage: formatString = "{0} usage{1} of Guid {2}"; break; case ReferenceKind.EmptyArrayAllocation: formatString = "{0} allocation{1} of empty arrays"; break; case ReferenceKind.MSBuildPropertyAssignment: formatString = "{0} assignment{1} to MSBuild property {2}"; break; case ReferenceKind.MSBuildPropertyUsage: formatString = "{0} usage{1} of MSBuild property {2}"; break; case ReferenceKind.MSBuildItemAssignment: formatString = "{0} assignment{1} to MSBuild item {2}"; break; case ReferenceKind.MSBuildItemUsage: formatString = "{0} usage{1} of MSBuild item {2}"; break; case ReferenceKind.MSBuildTargetDeclaration: formatString = "{0} declaration{1} of MSBuild target {2}"; break; case ReferenceKind.MSBuildTargetUsage: formatString = "{0} usage{1} of MSBuild target {2}"; break; case ReferenceKind.MSBuildTaskDeclaration: formatString = "{0} import{1} of MSBuild task {2}"; break; case ReferenceKind.MSBuildTaskUsage: formatString = "{0} call{1} to MSBuild task {2}"; break; default: throw new NotImplementedException("Missing case for " + referenceKind.Item1); } var referencesOfSameKind = referenceKind.Item2.OrderBy(g => g.Item1); totalReferenceCount = CountItems(referenceKind); string headerText = string.Format( formatString, totalReferenceCount, totalReferenceCount == 1 ? "" : "s", symbolName); Write(writer, string.Format(@"<div class=""rH"">{0}</div>", headerText)); foreach (var sameAssemblyReferencesGroup in referencesOfSameKind) { string assemblyName = sameAssemblyReferencesGroup.Item1; Write(writer, "<div class=\"rA\">{0} ({1})</div>", assemblyName, CountItems(sameAssemblyReferencesGroup)); Write(writer, "<div class=\"rG\" id=\"{0}\">", assemblyName); foreach (var sameFileReferencesGroup in sameAssemblyReferencesGroup.Item2.OrderBy(g => g.Item1)) { Write(writer, "<div class=\"rF\">"); WriteLine(writer, "<div class=\"rN\">{0} ({1})</div>", sameFileReferencesGroup.Item1, CountItems(sameFileReferencesGroup)); foreach (var sameLineReferencesGroup in sameFileReferencesGroup.Item2) { var url = sameLineReferencesGroup.First().Url; Write(writer, "<a href=\"{0}\">", url); Write(writer, "<b>{0}</b>", sameLineReferencesGroup.Key); MergeOccurrences(writer, sameLineReferencesGroup); WriteLine(writer, "</a>"); } WriteLine(writer, "</div>"); } WriteLine(writer, "</div>"); } } Write(writer, "</body></html>"); } File.Delete(rawReferencesFile); }