Skip to content

Add test helper and test cases to validate EventSource IDs#65408

Merged
danegsta merged 6 commits intodotnet:mainfrom
danegsta:danegsta/eventSourceTests
Feb 13, 2026
Merged

Add test helper and test cases to validate EventSource IDs#65408
danegsta merged 6 commits intodotnet:mainfrom
danegsta:danegsta/eventSourceTests

Conversation

@danegsta
Copy link
Copy Markdown
Member

@danegsta danegsta commented Feb 12, 2026

Add additional validation for EventSource IDs to catch misconfigured IDs in CI

New test helper and unit tests for EventSource IDs

Description

Adds a new EventSourceValidator test helper that ensures WriteEvent IDs match the configured Metadata ID and ensures no duplicate IDs are introduced for a given EventSource. Adds tests to run the helper for existing EventSources in the project. Checks for duplicate IDs and Event/WriteEvent ID mismatches.

Fixes #65407

Copilot AI review requested due to automatic review settings February 12, 2026 20:38
@github-actions github-actions bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Feb 12, 2026
Copy link
Copy Markdown
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

Adds a reusable test helper to validate EventSource event ID correctness (matching [Event(N)] to WriteEvent(N, ...) and detecting duplicates), and wires it into several existing test suites to catch misconfigured event IDs in CI.

Changes:

  • Introduces EventSourceValidator helper based on EventSource.GenerateManifest(..., EventManifestOptions.Strict) plus duplicate-ID detection.
  • Adds focused unit tests for the validator itself.
  • Adds “EventIdsAreConsistent” tests for existing EventSources and documents the recommended pattern.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Testing/src/Tracing/EventSourceValidator.cs New validator utility for Event ID consistency and duplicate detection.
src/Testing/test/EventSourceValidatorTests.cs Unit tests validating validator behavior (pass, mismatch, duplicates, invalid types).
src/SignalR/common/Http.Connections/test/Internal/HttpConnectionsEventSourceTests.cs Adds EventSource ID consistency test for HttpConnectionsEventSource.
src/Shared/test/Shared.Tests/CertificateManagerEventSourceTests.cs Adds EventSource ID consistency test for CertificateManagerEventSource.
src/Servers/Kestrel/Core/test/KestrelEventSourceTests.cs Adds EventSource ID consistency test for Kestrel’s internal KestrelEventSource.
src/Hosting/Hosting/test/Internal/HostingEventSourceTests.cs Adds EventSource ID consistency test for HostingEventSource.
docs/EventSourceAndCounters.md Documents the new validator and recommends adding a one-line consistency test for new EventSources.

@github-actions github-actions bot added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Feb 12, 2026
@danegsta danegsta enabled auto-merge February 12, 2026 20:58
@danegsta danegsta merged commit bb01877 into dotnet:main Feb 13, 2026
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 11.0-preview2 milestone Feb 13, 2026
@danegsta
Copy link
Copy Markdown
Member Author

/backport to release/10.0

@github-actions
Copy link
Copy Markdown
Contributor

Started backporting to release/10.0 (link to workflow run)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EventSource ID validation tests

3 participants