Generate RegisterProvider metadata at build time via source generator#9731
Generate RegisterProvider metadata at build time via source generator#9731
Conversation
|
@copilot looks like there's an error: [2025-10-27 16:03:32] [build-stdout] /home/runner/work/orleans/orleans/src/Orleans.CodeGenerator/MetadataGenerator.cs(118,50): error CS1503: Argument 1: cannot convert from 'Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax>' to 'Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax>' [/home/runner/work/orleans/orleans/src/Orleans.CodeGenerator/Orleans.CodeGenerator.csproj]**** |
Fixed in cba5aae. The issue was using |
|
@copilot the PR doesn't build |
I'm unable to reproduce the build failure locally due to network restrictions. Could you share the specific error message from the build log? This will help me identify and fix the issue. 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
- Add RegisteredProviders dictionary to TypeManifestOptions - Add RegisterProviderAttribute to LibraryTypes - Extend MetadataModel to track registered providers - Update CodeGenerator to discover RegisterProviderAttribute on assemblies - Update MetadataGenerator to emit provider registration code - Update DefaultClientServices to use generated metadata - Update DefaultSiloServices to use generated metadata Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>
Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>
…te duplication Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>
Changed from ExpressionSyntax[] to ArgumentSyntax[] and wrapped each expression in Argument() to match Roslyn API requirements for TupleExpression. This fixes the CS1503 compilation error. Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>
cba5aae to
b82420c
Compare
The source generator was emitting typeof() references to internal provider types from referenced assemblies, causing CS0122 errors. Add an accessibility check (matching the existing pattern for serializable types) to skip providers not accessible from the compilation assembly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…licates Multiple assemblies can register the same provider key (Target, Kind, Name). Using Dictionary.Add() throws ArgumentException on duplicates. Switch to indexer assignment which safely overwrites, matching the runtime behavior that existed before the source generator change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
This PR implements source generation for
RegisterProviderAttributeto eliminate runtime assembly scanning, improving startup performance.Changes
How It Works
Before: At runtime, DefaultClientServices and DefaultSiloServices scanned all assemblies for RegisterProviderAttribute, which was expensive.
After:
Benefits
Original prompt
💡 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