-
Notifications
You must be signed in to change notification settings - Fork 754
Fix duplicate stringTable elements in instrumentation manifest #2347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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]>
brianrob
left a comment
There was a problem hiding this 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
Addressed the string interpolation comment and added a new unit test |
marklio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable. I don't know the scenario here, but it seems like something you'd want some amount of friction to prevent in the first place, but this seems like a reasonable backstop for the bad data.
Thanks. This actually isn't a case of bad data. It's just that the way the code was written, each time we found a usage of a particular string key, we'd also emit the value into the string table. Because we didn't keep track of if we'd written the value into the string table, we'd write it multiple times if the key was used multiple times, which is a totally valid scenario. |
Update logic in
GetManifestForRegisteredProviderto ensure that it does not emit XML with duplicate string ids in the string table. This is done by keeping track of the set of previously written string ids so that the code only writes each string definition once.Original prompt
💡 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.