Skip to content

Conversation

@alliscode
Copy link
Member

@alliscode alliscode commented Jan 22, 2026

Motivation and Context

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

alliscode and others added 2 commits January 22, 2026 09:21
…ce Generators and updating some samples to use new pattern.

This commit deprecates the reflection-based handler discovery approach
in favor of the new [MessageHandler] attribute with source generation.

Changes:
- Add [Obsolete] to ReflectingExecutor<T>, IMessageHandler<T>, IMessageHandler<T,R>
- Add #pragma to suppress warnings in internal reflection code
- Update Concurrent sample to use new [MessageHandler] pattern
- Add Directory.Build.props for samples to include generator
- Add documentation files explaining the migration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@markwallace-microsoft markwallace-microsoft added .NET workflows Related to Workflows in agent-framework labels Jan 22, 2026
@github-actions github-actions bot changed the title Wf obsolete reflector .NET: Wf obsolete reflector Jan 22, 2026
@alliscode alliscode changed the title .NET: Wf obsolete reflector Obsoleting ReflectingExecutor in favor of source gen Jan 22, 2026
@alliscode alliscode marked this pull request as ready for review January 22, 2026 17:59
Copilot AI review requested due to automatic review settings January 22, 2026 17:59
@alliscode
Copy link
Member Author

I will hold off on merging this until the docs are updated to clearly explain the new pattern.

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

This PR obsoletes the reflection-based ReflectingExecutor<TExecutor> pattern in favor of a source generation approach using the [MessageHandler] attribute. The changes ensure backward compatibility while guiding developers to the new recommended pattern.

Changes:

  • Marked ReflectingExecutor<TExecutor> and IMessageHandler<T> interfaces as obsolete with clear migration guidance
  • Added pragma warnings to suppress obsolete warnings in internal code and tests that need backward compatibility
  • Updated one sample executor to demonstrate the new [MessageHandler] pattern
  • Added source generator project reference to the Workflows samples Directory.Build.props

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ReflectingExecutor.cs Added [Obsolete] attribute with migration guidance to use [MessageHandler] attribute
IMessageHandler.cs Marked both IMessageHandler<TMessage> and IMessageHandler<TMessage, TResult> interfaces as obsolete
Executor.cs Added pragma to suppress obsolete warnings for internal backward compatibility
StatefulExecutor.cs Added pragma to suppress obsolete warnings for internal backward compatibility
RouteBuilderExtensions.cs Added pragma to suppress obsolete warnings for internal backward compatibility
MessageHandlerInfo.cs Added pragma to suppress obsolete warnings for internal backward compatibility
01_Simple_Workflow_Sequential.cs Added pragma to suppress obsolete warnings when testing legacy reflection-based pattern
02_Simple_Workflow_Condition.cs Added pragma to suppress obsolete warnings when testing legacy reflection-based pattern
03_Simple_Workflow_Loop.cs Added pragma to suppress obsolete warnings when testing legacy reflection-based pattern
ReflectionSmokeTest.cs Added pragma to suppress obsolete warnings when testing legacy reflection-based pattern
Directory.Build.props Added source generator project reference for samples using [MessageHandler] attribute
Concurrent/Program.cs Migrated ConcurrentStartExecutor from Executor<string> to base Executor with [MessageHandler] attribute

@alliscode alliscode changed the title Obsoleting ReflectingExecutor in favor of source gen [BREAKING] Obsoleting ReflectingExecutor in favor of source gen Jan 22, 2026
@lokitoth
Copy link
Member

There has been some pushback on this since Source Generators do not work with F#

@stephentoub
Copy link
Member

There has been some pushback on this since Source Generators do not work with F#

FWIW, even without the source generator I still think the right answer is deleting the reflection goo and just registering handlers directly. F# still has that experience.

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

Labels

.NET workflows Related to Workflows in agent-framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants