Deprecate IStartupTask and AddStartupTask with warnings#9763
Merged
ReubenBond merged 7 commits intomainfrom Nov 10, 2025
Merged
Deprecate IStartupTask and AddStartupTask with warnings#9763ReubenBond merged 7 commits intomainfrom
ReubenBond merged 7 commits intomainfrom
Conversation
Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Deprecate AddStartupTask and IStartupTask with warnings
Deprecate IStartupTask and AddStartupTask with warnings
Nov 10, 2025
ReubenBond
reviewed
Nov 10, 2025
ReubenBond
reviewed
Nov 10, 2025
|
|
||
| public static partial class SiloBuilderStartupExtensions | ||
| { | ||
| [System.Obsolete("AddStartupTask is deprecated. Use BackgroundService or IHostedService instead. See https://learn.microsoft.com/dotnet/orleans/host/configuration-guide/startup-tasks for more information.", false)] |
Member
There was a problem hiding this comment.
Undo all changes under the src/api directory
ReubenBond
reviewed
Nov 10, 2025
ReubenBond
reviewed
Nov 10, 2025
ReubenBond
reviewed
Nov 10, 2025
ReubenBond
approved these changes
Nov 10, 2025
ReubenBond
approved these changes
Nov 10, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR deprecates the IStartupTask interface and AddStartupTask extension methods by marking them with [Obsolete] attributes (as warnings, not errors). The deprecation follows Microsoft's recommendation to use standard .NET hosting mechanisms like BackgroundService or IHostedService instead, which provide better error handling and don't cause silo unavailability on transient failures.
Key changes:
- Added
[Obsolete]attributes with descriptive messages and documentation links toIStartupTaskand all threeAddStartupTaskmethod overloads - Suppressed CS0618 obsolete warnings in existing test files that legitimately use the deprecated APIs
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Orleans.Runtime/Lifecycle/IStartupTask.cs | Added [Obsolete] attribute to the IStartupTask interface with guidance message |
| src/Orleans.Runtime/Hosting/SiloBuilderStartupExtensions.cs | Added [Obsolete] attributes to all three AddStartupTask method overloads with consistent guidance messages |
| test/Tester/StartupTaskTests.cs | Added #pragma warning disable CS0618 to suppress obsolete warnings for existing tests that verify startup task functionality |
ReubenBond
added a commit
that referenced
this pull request
Nov 18, 2025
This reverts commit 1a1a8c1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deprecates
IStartupTaskinterface andAddStartupTaskextension methods per Microsoft's recommendation to useBackgroundServiceorIHostedServiceinstead. These standard .NET hosting mechanisms provide better error handling and don't cause silo unavailability on transient failures.Changes
[Obsolete]attributes witherror: falseto:IStartupTaskinterfaceAddStartupTaskmethod overloads (generic, interface-typed, delegate-typed)#pragma warning disableDeprecation Warning
Users will see compiler warnings pointing to the documentation:
Warning message: "IStartupTask is deprecated. Use BackgroundService or IHostedService instead. See https://learn.microsoft.com/dotnet/orleans/host/configuration-guide/startup-tasks for more information."
Original prompt
AddStartupTaskandIStartupTask#9762💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Microsoft Reviewers: Open in CodeFlow