Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 5, 2025

  • Investigate and understand the root cause of duplicate stringTable elements in GetManifestForRegisteredProvider()
  • Implement fix using HashSet to track emitted string IDs
  • Replace string.Format calls with string interpolation
  • Add unit test to verify no duplicate string IDs in stringTable
  • Build the changes
  • Run code review
  • Run security analysis with CodeQL
Original prompt

This section details on the original issue you should resolve

<issue_title>instrumentation manifest - duplicate stringTable elements</issue_title>
<issue_description>The stringTable in the instrumentation manifest generated by GetManifestForRegisteredProvider() can have duplicate elements.

e.g. Microsoft-JScript provider's manifest includes -

<string id="map_MethodAddressRangeMapJITLoopBody" value="JITLoopBody" />        
<string id="map_MethodAddressRangeMapJITLoopBody" value="JITLoopBody" />        
<string id="map_MethodAddressRangeMapJITLoopBody" value="JITLoopBody" />        
<string id="map_MethodAddressRangeMapJITLoopBody" value="JITLoopBody" />        
<string id="map_MethodAddressRangeMapJITLoopBody" value="JITLoopBody" />        
<string id="map_MethodAddressRangeMapJITLoopBody" value="JITLoopBody" />        
<string id="map_MethodAddressRangeMapJITLoopBody" value="JITLoopBody" />        
<string id="map_MethodAddressRangeMapJITLoopBody" value="JITLoopBody" />
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Added HashSet tracking to prevent duplicate string IDs when generating
stringTable entries in GetManifestForRegisteredProvider(). This prevents
duplicates for keywords, tasks, opcodes, and enum map values.

Co-authored-by: brianrob <[email protected]>
Copilot AI changed the title [WIP] Fix duplicate stringTable elements in instrumentation manifest Fix duplicate stringTable elements in instrumentation manifest Dec 5, 2025
Copilot AI requested a review from brianrob December 5, 2025 16:46
Copy link
Member

@brianrob brianrob left a comment

Choose a reason for hiding this comment

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

@copilot, please address these comments.

Also, please add a new unit test that validates that the fix works. Use a provider that is known to exist on all machines, such as "Microsoft-Windows-DotNETRuntime". Please make sure that there are duplicates before the change and that after the change there aren't any duplicates. You don't need to keep a copy of the old code to ensure that there are duplicates each time - just do this check once so that we know we're dealing with a manifest that previously produced duplicates.

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.

- Replace string.Format calls with string interpolation for stringId generation
- Add RegisteredTraceEventParserTests with test for duplicate stringTable entries

Co-authored-by: brianrob <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 5, 2025

@copilot, please address these comments.

Also, please add a new unit test that validates that the fix works. Use a provider that is known to exist on all machines, such as "Microsoft-Windows-DotNETR...

Addressed the string interpolation comment and added a new unit test GetManifestForRegisteredProvider_NoDuplicateStringTableEntries that validates no duplicate string IDs exist in the generated manifest. The test uses Microsoft-Windows-DotNETRuntime provider and is marked as Windows-only using [WindowsFact] since GetManifestForRegisteredProvider requires Windows TDH APIs. See commit a0fb478.

Copilot AI requested a review from brianrob December 5, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

instrumentation manifest - duplicate stringTable elements

2 participants