Skip to content

Replace ETW events with incremental testing framework in RazorSourceGeneratorTests#12760

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/replace-etw-with-incremental-framework
Draft

Replace ETW events with incremental testing framework in RazorSourceGeneratorTests#12760
Copilot wants to merge 6 commits intomainfrom
copilot/replace-etw-with-incremental-framework

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

Summary of the changes

RazorSourceGeneratorTests relied on ETW events to verify generator execution, which forced sequential test execution due to global event contamination. Migrated to Roslyn's incremental generator testing framework.

Generator changes:

  • Added .WithTrackingName() to 8 pipeline steps (RazorSourceGeneratorOptions, GeneratedDeclarationCode, TagHelpersFromCompilation, TagHelpersFromReferences, ParsedDocuments, RewrittenTagHelpers, CheckedAndRewrittenTagHelpers, GeneratedCode)

Test infrastructure:

  • Added VerifyIncrementalSteps() and VerifyIncrementalStepsMultiple() helpers to verify step execution via TrackedSteps API
  • Removed RazorEventListener class and all ETW assertions (~290 lines)
  • Removed [Collection] attribute enabling parallel test execution

Test updates:

// Before: ETW events
Assert.Collection(eventListener.Events,
    e => Assert.Equal("ParseRazorDocumentStart", e.EventName),
    e => Assert.Equal("ParseRazorDocumentStop", e.EventName));

// After: Incremental framework
result.VerifyIncrementalSteps("ParsedDocuments", 
    IncrementalStepRunReason.New, IncrementalStepRunReason.New);

Tests now track execution reasons (New, Cached, Modified, Unchanged) instead of just event occurrence, providing better granularity and enabling parallel execution.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • mobile.events.data.microsoft.com
    • Triggering command: /home/REDACTED/work/razor/razor/.dotnet/dotnet /home/REDACTED/work/razor/razor/.dotnet/dotnet exec --depsfile /home/REDACTED/work/razor/razor/artifacts/bin/Microsoft.VisualStudioCode.RazorExtension.Test/Debug/net10.0/Microsoft.VisualStudioCode.RazorExtension.Test.deps.json --runtimeconfig /home/REDACTED/work/razor/razor/artifacts/bin/Microsoft.VisualStudioCode.RazorExtension.Test/Debug/net10.0/Microsoft.VisualStudioCode.RazorExtension.Test.runtimeconfig.json /home/REDACTED/.nuget/packages/xunit.REDACTED.console/2.9.2/tools/netcoreapp2.0/xunit.console.dll /home/REDACTED/work/razor/razor/artifacts/bin/Microsoft.VisualStudioCode.RazorExtension.Test/Debug/net10.0/Microsoft.VisualStudioCode.RazorExtension.Test.dll -noautoreporters -xml /home/REDACTED/work/razor/razor/artifacts/TestResults/Debug/Microsoft.VisualStudioCode.RazorExtension.Test_net10.0_x64.xml -html /home/REDACTED/work/razor/razor/artifacts/TestResults/Debug/Microsoft.VisualStudioCode.RazorExtension.Test_net10.0_x64.html c.cmd origin ash (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>RazorSourceGeneratorTests should use incremental framework instead of ETW</issue_title>
<issue_description>Today the tests in RazorSourceGeneratorTests use the ETW events to determine which parts of the generators ran. This is fragile as parallel tests can contribute to this, meaning we have to run them in sequential order.

Instead, we should use the incremental testing framework, an example of which is here: https://github.com/dotnet/runtime/blob/d78c24c497f5ae9046d6f61f85d0066d8a159b60/src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/LoggerMessageGeneratorIncrementalTests.cs

We already partially do this, but should completely replace all uses of ETW with it. We may need to add more .WithTrackingName calls to the generator itself in order to access each step that is currently tracked with ETW.</issue_description>

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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits February 10, 2026 21:47
… helpers

Co-authored-by: chsienki <16246502+chsienki@users.noreply.github.com>
Co-authored-by: chsienki <16246502+chsienki@users.noreply.github.com>
Co-authored-by: chsienki <16246502+chsienki@users.noreply.github.com>
Co-authored-by: chsienki <16246502+chsienki@users.noreply.github.com>
…cation

Co-authored-by: chsienki <16246502+chsienki@users.noreply.github.com>
Copilot AI changed the title [WIP] Update RazorSourceGeneratorTests to use incremental framework Replace ETW events with incremental testing framework in RazorSourceGeneratorTests Feb 10, 2026
Copilot AI requested a review from chsienki February 10, 2026 22:33
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.

RazorSourceGeneratorTests should use incremental framework instead of ETW

2 participants