Skip to content

Modernize System.Diagnostics C# snippets - #13028

Open
gewarren wants to merge 5 commits into
mainfrom
gewarren-modernize-system-diagnostics
Open

Modernize System.Diagnostics C# snippets#13028
gewarren wants to merge 5 commits into
mainfrom
gewarren-modernize-system-diagnostics

Conversation

@gewarren

@gewarren gewarren commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Modernizes the first 60 C# snippets in the System.Diagnostics namespace, plus the related System.Diagnostics.SymbolStore sample, so they use current C# syntax while preserving the APIs and behavior being demonstrated.

Adds or consolidates .NET 10 snippet projects for the affected directories, including shared entry points where multiple samples compile together. All 39 affected System.Diagnostics projects and the SymbolStore project build successfully.


Internal previews

Toggle expand/collapse
File Preview link
snippets/csharp/System.Diagnostics.SymbolStore/ISymbolDocumentWriter/Overview/modulebuilder_definedocument.cs Learn preview
snippets/csharp/System.Diagnostics/BooleanSwitch/Enabled/source.cs Learn preview
snippets/csharp/System.Diagnostics/BooleanSwitch/Overview/source.cs Learn preview
snippets/csharp/System.Diagnostics/ConditionalAttribute/Overview/cas.cs Learn preview
snippets/csharp/System.Diagnostics/ConsoleTraceListener/Overview/program.cs Learn preview
snippets/csharp/System.Diagnostics/CorrelationManager/Overview/program.cs Learn preview
snippets/csharp/System.Diagnostics/CounterCreationData/.ctor/diagnostics_countercreationdata.cs Learn preview
snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs Learn preview
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor_countercreationdatacollection.cs Learn preview
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor.cs Learn preview
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/AddRange/countercreationdatacollection_addrange.cs Learn preview
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/Contains/countercreationdatacollection_contains.cs Learn preview
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/IndexOf/countercreationdatacollection_insert_indexof.cs Learn preview
snippets/csharp/System.Diagnostics/CounterSample/.ctor/countersample_ctor_2.cs Learn preview
snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/datareceivedevent.cs Learn preview
snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.cs Learn preview
snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.cs Learn preview
snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/Assert/source.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/Assert/source1.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/Assert/source2.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/Close/source.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/Fail/source.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/Fail/source1.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/Indent/source.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/Overview/source.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/Write/source.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/WriteIf/source.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/WriteIf/source1.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/WriteIf/source2.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/WriteIf/source3.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/WriteLine/source.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/WriteLine/source1.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/WriteLine/source2.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/WriteLine/source3.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/WriteLineIf/source.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/WriteLineIf/source1.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/WriteLineIf/source2.cs Learn preview
snippets/csharp/System.Diagnostics/Debug/WriteLineIf/source3.cs Learn preview
snippets/csharp/System.Diagnostics/DebuggerBrowsableAttribute/.ctor/program.cs Learn preview
snippets/csharp/System.Diagnostics/DefaultTraceListener/Overview/binomial.cs Learn preview
snippets/csharp/System.Diagnostics/DefaultTraceListener/Write/defaulttracelistener.cs Learn preview
snippets/csharp/System.Diagnostics/EntryWrittenEventArgs/.ctor/entrywritteneventargs_ctor2.cs Learn preview
snippets/csharp/System.Diagnostics/EntryWrittenEventArgs/Overview/entrywritteneventargs_ctor1.cs Learn preview
snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs Learn preview
snippets/csharp/System.Diagnostics/EventLog/.ctor/source.cs Learn preview
snippets/csharp/System.Diagnostics/EventLog/.ctor/source1.cs Learn preview
snippets/csharp/System.Diagnostics/EventLog/.ctor/source2.cs Learn preview
snippets/csharp/System.Diagnostics/EventLog/Clear/source.cs Learn preview
snippets/csharp/System.Diagnostics/EventLog/CreateEventSource/source.cs Learn preview

Note

This table shows the first 50 preview links (sorted alphabetically by file path) found in the OPS build report. For the full list, select OpenPublishing.Build Details within checks.

Build report

Update the first 60 System.Diagnostics samples and the SymbolStore sample to current C# patterns, and add or consolidate net10.0 snippet projects so each affected directory builds independently.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 81f0fa5e-3bcf-4d3b-b652-f7dc76e7ae03
Copilot AI lite review requested due to automatic review settings August 24, 2026 23:45
@gewarren
gewarren requested a review from a team as a code owner August 24, 2026 23:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Modernizes the first 60 System.Diagnostics C# snippets and the related SymbolStore sample for current .NET 10 projects.

Changes:

  • Updates C# syntax, formatting, disposal, and type usage.
  • Adds or consolidates executable projects and shared entry points.
  • Migrates the SymbolStore sample to PersistedAssemblyBuilder.

Reviewed changes

Copilot reviewed 94 out of 96 changed files in this pull request and generated 1 comment.

Show a summary per file
File Review result
snippets/csharp/System.Diagnostics/EventLog/MachineName/source.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/Log/source.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/source1.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/source.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/Program.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/Exists/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/EventLog/Exists/eventlog_exists_1.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/EntryWritten/source.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/Entries/source.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/EnableRaisingEvents/source.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/Delete/source1.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/Delete/source.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/Delete/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/EventLog/Delete/Program.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/CreateEventSource/source.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/CreateEventSource/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/EventLog/Clear/source.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/.ctor/source2.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/.ctor/source1.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/.ctor/source.cs No final comment.
snippets/csharp/System.Diagnostics/EventLog/.ctor/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/EventLog/.ctor/Program.cs No final comment.
snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs No final comment.
snippets/csharp/System.Diagnostics/EventInstance/Overview/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/EntryWrittenEventArgs/Overview/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/EntryWrittenEventArgs/Overview/entrywritteneventargs_ctor1.cs No final comment.
snippets/csharp/System.Diagnostics/EntryWrittenEventArgs/.ctor/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/EntryWrittenEventArgs/.ctor/entrywritteneventargs_ctor2.cs No final comment.
snippets/csharp/System.Diagnostics/DefaultTraceListener/Write/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/DefaultTraceListener/Write/defaulttracelistener.cs No final comment.
snippets/csharp/System.Diagnostics/DefaultTraceListener/Overview/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/DefaultTraceListener/Overview/binomial.cs No final comment.
snippets/csharp/System.Diagnostics/DebuggerBrowsableAttribute/.ctor/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/DebuggerBrowsableAttribute/.ctor/program.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteLineIf/source3.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteLineIf/source2.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteLineIf/source1.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteLineIf/source.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteLineIf/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteLine/source3.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteLine/source2.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteLine/source1.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteLine/source.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteLine/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteIf/source3.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteIf/source2.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteIf/source1.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteIf/source.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/WriteIf/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/Debug/Write/source.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/Overview/source.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/Indent/source.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/Fail/source1.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/Fail/source.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/Fail/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/Debug/Close/source.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/Assert/source2.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/Assert/source1.cs No final comment.
snippets/csharp/System.Diagnostics/Debug/Assert/source.cs No final comment.
snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.cs No final comment.
snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/Program.cs No final comment.
snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.cs No final comment.
snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.cs No final comment.
snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/datareceivedevent.cs No final comment.
snippets/csharp/System.Diagnostics/CounterSample/.ctor/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/CounterSample/.ctor/countersample_ctor_2.cs No final comment.
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/IndexOf/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/IndexOf/countercreationdatacollection_insert_indexof.cs No final comment.
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/Contains/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/Contains/countercreationdatacollection_contains.cs No final comment.
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/AddRange/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/AddRange/countercreationdatacollection_addrange.cs No final comment.
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/Program.cs No final comment.
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor.cs No final comment.
snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor_countercreationdatacollection.cs No final comment.
snippets/csharp/System.Diagnostics/CounterCreationData/Overview/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs No final comment.
snippets/csharp/System.Diagnostics/CounterCreationData/.ctor/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/CounterCreationData/.ctor/diagnostics_countercreationdata.cs No final comment.
snippets/csharp/System.Diagnostics/CorrelationManager/Overview/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/CorrelationManager/Overview/program.cs No final comment.
snippets/csharp/System.Diagnostics/ConsoleTraceListener/Overview/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/ConsoleTraceListener/Overview/program.cs No final comment.
snippets/csharp/System.Diagnostics/ConditionalAttribute/Overview/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/ConditionalAttribute/Overview/cas.cs Moderate issue (3 votes): retain the console trace listener setup before Debug.WriteLine and remove the replacement Console.WriteLine block.
snippets/csharp/System.Diagnostics/BooleanSwitch/Overview/source.cs No final comment.
snippets/csharp/System.Diagnostics/BooleanSwitch/Overview/remarks.cs No final comment.
snippets/csharp/System.Diagnostics/BooleanSwitch/Overview/Project.csproj No final comment.
snippets/csharp/System.Diagnostics/BooleanSwitch/Overview/Program.cs No final comment.
snippets/csharp/System.Diagnostics/BooleanSwitch/Enabled/source.cs No final comment.
snippets/csharp/System.Diagnostics/BooleanSwitch/Enabled/Project.csproj No final comment.
snippets/csharp/System.Diagnostics.SymbolStore/ISymbolDocumentWriter/Overview/Project.csproj No final comment.
snippets/csharp/System.Diagnostics.SymbolStore/ISymbolDocumentWriter/Overview/modulebuilder_definedocument.cs No final comment.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI and others added 2 commits August 24, 2026 23:57
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Comment thread snippets/csharp/System.Diagnostics/CounterSample/.ctor/countersample_ctor_2.cs Outdated
@gewarren gewarren closed this Aug 26, 2026
@gewarren gewarren reopened this Aug 26, 2026
@gewarren gewarren closed this Aug 27, 2026
@gewarren gewarren reopened this Aug 27, 2026
@gewarren gewarren closed this Aug 27, 2026
@gewarren gewarren reopened this Aug 27, 2026
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.

4 participants