Skip to content

Extract ManifestBuilder and EventListener#124323

Open
agocke wants to merge 1 commit intodotnet:mainfrom
agocke:extract-manifestbuilder
Open

Extract ManifestBuilder and EventListener#124323
agocke wants to merge 1 commit intodotnet:mainfrom
agocke:extract-manifestbuilder

Conversation

@agocke
Copy link
Member

@agocke agocke commented Feb 12, 2026

This reduces the size of the EventSource file, which I find helps reduce token usage

Copilot AI review requested due to automatic review settings February 12, 2026 08:28
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Feb 12, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors System.Diagnostics.Tracing implementation by extracting large helper types out of EventSource.cs into dedicated files, reducing the size of EventSource.cs while preserving behavior.

Changes:

  • Moved ManifestBuilder implementation into ManifestBuilder.cs.
  • Moved EventListener implementation into EventListener.cs.
  • Updated System.Private.CoreLib.Shared.projitems to compile the new files.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ManifestBuilder.cs New file containing the extracted ManifestBuilder implementation.
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs Removed in-file ManifestBuilder/EventListener definitions and kept remaining tracing types.
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventListener.cs New file containing the extracted EventListener implementation.
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems Adds the two new .cs files to the build.

private void WriteNameAndMessageAttribs(StringBuilder? stringBuilder, string elementName, string name)
{
stringBuilder?.Append(" name=\"").Append(name).Append('"');
WriteMessageAttrib(sb, elementName, name, name);
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

WriteNameAndMessageAttribs appends the name= attribute to its stringBuilder parameter but emits the message= attribute via the sb field (not the parameter). This makes the helper internally inconsistent and easy to misuse if it’s ever called with a different builder. Consider passing stringBuilder through to WriteMessageAttrib (or removing the parameter if the intent is to always write to sb).

Suggested change
WriteMessageAttrib(sb, elementName, name, name);
WriteMessageAttrib(stringBuilder, elementName, name, name);

Copilot uses AI. Check for mistakes.
Comment on lines +305 to +310
// If channelKeyworkds is present, and has keywords bits in the ValidPredefinedChannelKeywords then it is
// assumed that the keyword for that channel should be that bit.
// otherwise we allocate a channel bit for the channel.
// explicit channel bits are only used by WCF to mimic an existing manifest,
// so we don't dont do error checking.
public ulong GetChannelKeyword(EventChannel channel, ulong channelKeyword = 0)
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

Spelling/grammar in this comment block: “channelKeyworkds” should be “channelKeywords”, and “we don't dont do error checking” should be “we don't do error checking”.

Copilot uses AI. Check for mistakes.
EventPipeEventDispatcher.Instance.SendCommand(this, EventCommand.Update, false, EventLevel.LogAlways, (EventKeywords)0);
#endif // FEATURE_PERFTRACING
}
// We don't expose a Dispose(bool), because the contract is that you don't have any non-syncronous
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

Spelling in comment: “non-syncronous” should be “non-synchronous”.

Suggested change
// We don't expose a Dispose(bool), because the contract is that you don't have any non-syncronous
// We don't expose a Dispose(bool), because the contract is that you don't have any non-synchronous

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants