Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

The GetManifestForRegisteredProvider method hand-crafted XML using string concatenation. This refactoring replaces that approach with the built-in XmlWriter API.

Changes

  • Rewrote GetManifestForRegisteredProvider: Now uses XmlWriter for XML generation with automatic escaping and well-formed output
  • Preserved legacy implementation: Saved original as GetManifestForRegisteredProvider_Legacy() marked internal
  • Added structured data classes: Introduced EventData, TemplateData, MapData, etc. to separate data collection from XML serialization
  • Added equivalence test: GetManifestForRegisteredProvider_NewAndLegacyImplementationsProduceSameOutput() validates both implementations produce semantically identical XML through normalization

Example

Before:

StringWriter manifest = new StringWriter();
manifest.WriteLine("<instrumentationManifest xmlns=\"...\">");
manifest.WriteLine(" <instrumentation ...>");
// Manual string formatting with explicit XML escaping
string escapedValue = XmlUtilities.XmlEscape(keyValue.Value);
manifest.WriteLine("     <keyword name=\"{0}\" .../>");

After:

using (var writer = XmlWriter.Create(sb, settings))
{
    writer.WriteStartElement("instrumentationManifest", "http://schemas.microsoft.com/win/2004/08/events");
    writer.WriteStartElement("instrumentation");
    // Automatic escaping, guaranteed well-formed XML
    writer.WriteAttributeString("name", keyValue.Value);
}
Original prompt

GetManifestForRegisteredProvider hand crafts the XML to be returned. Please try re-writing this to use the built-in XmlWriter. Also, please save the existing implementation and put it into a new test that ensures that the output from the new version and the old version are identical.


💡 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.

Copilot AI and others added 2 commits January 16, 2026 01:02
Copilot AI changed the title [WIP] Refactor GetManifestForRegisteredProvider to use XmlWriter Refactor GetManifestForRegisteredProvider to use XmlWriter Jan 16, 2026
Copilot AI requested a review from brianrob January 16, 2026 01:07
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.

2 participants