Skip to content

feat(interceptors): added Interceptor page for .NET#4603

Open
flippedcoder wants to merge 4 commits into
mainfrom
mm/dotnet-interceptors
Open

feat(interceptors): added Interceptor page for .NET#4603
flippedcoder wants to merge 4 commits into
mainfrom
mm/dotnet-interceptors

Conversation

@flippedcoder
Copy link
Copy Markdown
Contributor

@flippedcoder flippedcoder commented May 21, 2026

What does this PR do?

Addresses #3875. .NET didn't have a page for interceptors and it's a request that's been brought up in the community a few times.

Notes to reviewers

┆Attachments: EDU-6406 feat(interceptors): added Interceptor page for .NET

@flippedcoder flippedcoder requested a review from a team as a code owner May 21, 2026 13:44
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
temporal-documentation Ready Ready Preview, Comment May 22, 2026 2:38pm

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

📖 Docs PR preview links

Copy link
Copy Markdown
Contributor

@brianmacdonald-temporal brianmacdonald-temporal left a comment

Choose a reason for hiding this comment

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

Just a couple of small notes

Comment thread docs/develop/dotnet/workers/interceptors.mdx Outdated
Comment thread docs/develop/dotnet/workers/interceptors.mdx Outdated
Comment thread docs/develop/dotnet/workers/interceptors.mdx Outdated
Comment thread docs/develop/dotnet/workers/interceptors.mdx Outdated
Comment thread docs/develop/dotnet/workers/interceptors.mdx Outdated
Comment thread docs/develop/dotnet/workers/interceptors.mdx Outdated

### Register on the Client

Pass interceptors in the `Interceptors` argument of `TemporalClient.ConnectAsync`. Client interceptors modify outbound calls such
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.

Technically not correct. Interceptors is a property on TemporalClientConnectOptions (which is what the new() is creating in the following example).

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.

I'm going to pick on this just a little bit more. Interceptors is a property, not an argument and not a field (like it is in Python). Properties are first class constructs in C# and this is how C# developers would expect them to be described: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties

Comment thread docs/develop/dotnet/workers/interceptors.mdx Outdated
Comment thread docs/develop/dotnet/workers/interceptors.mdx
Comment thread docs/develop/dotnet/workers/interceptors.mdx
Comment thread docs/develop/dotnet/workers/interceptors.mdx Outdated
Comment thread docs/develop/dotnet/workers/interceptors.mdx
Comment thread docs/develop/dotnet/workers/interceptors.mdx
public override Task<WorkflowHandle<TWorkflow, TResult>>
StartWorkflowAsync<TWorkflow, TResult>(StartWorkflowInput input)
{
input.Headers["user-id"] = new Payload
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.

input.Headers is nullable, so if the Headers property is not set, this will throw a NullReferenceException. You'll want to probably defend against it with something like:

var headers = input.Headers ?? new Dictionary<string, Payload>();
headers["user-id"] = new Payload
{
    Metadata = { ["encoding"] = ByteString.CopyFromUtf8("plain/text") },
    Data = ByteString.CopyFromUtf8(UserContext.UserId),
};

return base.StartWorkflowAsync<TWorkflow, TResult>(input with { Headers = headers });

input.Headers["user-id"] = new Payload
{
Metadata = { ["encoding"] = ByteString.CopyFromUtf8("plain/text") },
Data = ByteString.CopyFromUtf8(UserContext.UserId),
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.

Where is UserContext coming from? Do we need to import something or change it to something else?

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