Skip to content
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/TraceEvent/RegisteredTraceEventParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ public static string GetManifestForRegisteredProvider(Guid providerGuid)
Dictionary<string, string> enumIntern = new Dictionary<string, string>();
StringWriter enumLocalizations = new StringWriter();

// Track emitted string IDs to prevent duplicates in the stringTable
HashSet<string> emittedStringIds = new HashSet<string>();

// Any task names used so far
Dictionary<string, int> taskNames = new Dictionary<string, int>();
// Any es used so far
Expand Down Expand Up @@ -374,7 +377,11 @@ public static string GetManifestForRegisteredProvider(Guid providerGuid)
int value = mapEntries[k].Value;
string valueName = new string((char*)(&enumBuffer[mapEntries[k].NameOffset])).Trim();
enumWriter.WriteLine(" <map value=\"0x{0:x}\" message=\"$(string.map_{1}{2})\"/>", value, enumName, valueName);
enumLocalizations.WriteLine(" <string id=\"map_{0}{1}\" value=\"{2}\"/>", enumName, valueName, valueName);
string stringId = string.Format("map_{0}{1}", enumName, valueName);
if (emittedStringIds.Add(stringId))
{
enumLocalizations.WriteLine(" <string id=\"{0}\" value=\"{1}\"/>", stringId, valueName);
}
}
if (enumInfo->Flag == MAP_FLAGS.EVENTMAP_INFO_FLAG_MANIFEST_VALUEMAP)
{
Expand Down Expand Up @@ -453,7 +460,11 @@ public static string GetManifestForRegisteredProvider(Guid providerGuid)
{
manifest.WriteLine(" <keyword name=\"{0}\" message=\"$(string.keyword_{1})\" mask=\"0x{2:x}\"/>",
keyValue.Value, keyValue.Value, keyValue.Key);
localizedStrings.WriteLine(" <string id=\"keyword_{0}\" value=\"{1}\"/>", keyValue.Value, keyValue.Value);
string stringId = string.Format("keyword_{0}", keyValue.Value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace new string.Format calls with string interpolation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced string.Format calls with string interpolation in commit a0fb478.

if (emittedStringIds.Add(stringId))
{
localizedStrings.WriteLine(" <string id=\"{0}\" value=\"{1}\"/>", stringId, keyValue.Value);
}
}
manifest.WriteLine(" </keywords>");
}
Expand All @@ -464,7 +475,11 @@ public static string GetManifestForRegisteredProvider(Guid providerGuid)
var task = tasks[taskValue];
manifest.WriteLine(" <task name=\"{0}\" message=\"$(string.task_{1})\" value=\"{2}\"{3}>", task.Name, task.Name, taskValue,
task.Opcodes == null ? "/" : ""); // If no opcodes, terminate immediately.
localizedStrings.WriteLine(" <string id=\"task_{0}\" value=\"{1}\"/>", task.Name, task.Name);
string taskStringId = string.Format("task_{0}", task.Name);
if (emittedStringIds.Add(taskStringId))
{
localizedStrings.WriteLine(" <string id=\"{0}\" value=\"{1}\"/>", taskStringId, task.Name);
}
if (task.Opcodes != null)
{
manifest.WriteLine(">");
Expand All @@ -473,7 +488,11 @@ public static string GetManifestForRegisteredProvider(Guid providerGuid)
{
manifest.WriteLine(" <opcode name=\"{0}\" message=\"$(string.opcode_{1}{2})\" value=\"{3}\"/>",
keyValue.Value, task.Name, keyValue.Value, keyValue.Key);
localizedStrings.WriteLine(" <string id=\"opcode_{0}{1}\" value=\"{2}\"/>", task.Name, keyValue.Value, keyValue.Value);
string opcodeStringId = string.Format("opcode_{0}{1}", task.Name, keyValue.Value);
if (emittedStringIds.Add(opcodeStringId))
{
localizedStrings.WriteLine(" <string id=\"{0}\" value=\"{1}\"/>", opcodeStringId, keyValue.Value);
}
}
manifest.WriteLine(" </opcodes>");
manifest.WriteLine(" </task>");
Expand Down