Skip to content

Conversation

@AArnott
Copy link
Member

@AArnott AArnott commented Nov 7, 2025

No description provided.

@AArnott AArnott added this to the PolyType milestone Nov 7, 2025
@AArnott AArnott requested a review from Copilot November 7, 2025 22:58
Copy link

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 pull request migrates framework services from ServiceJsonRpcDescriptor (System.Text.Json) to ServiceJsonRpcPolyTypeDescriptor (PolyType-based serialization) for improved AOT compatibility and performance. The changes introduce source-generated RPC contracts and remove dynamic code requirements.

  • Migrates core framework services (IRemoteServiceBroker, IAuthorizationService, IBrokeredServiceManifest, IMissingServiceDiagnosticsService) to use PolyType-based serialization with source generation
  • Adds the experimental UTF8 formatter to ServiceJsonRpcPolyTypeDescriptor for JSON serialization via PolyType
  • Removes RequiresUnreferencedCode and RequiresDynamicCode attributes from multiple APIs now that they support AOT compilation

Reviewed Changes

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

Show a summary per file
File Description
src/Microsoft.ServiceHub.Framework/FrameworkServices.cs Migrates core service descriptors to use ServiceJsonRpcPolyTypeDescriptor with PolyType source generation; adds assembly-level RPC contract export attribute and source generation context
src/Microsoft.ServiceHub.Framework/ServiceJsonRpcPolyTypeDescriptor.cs Adds experimental UTF8 formatter enum value and corresponding formatter creation method; adds RpcTargetMetadata property copying in copy constructor
src/Microsoft.ServiceHub.Framework/IRemoteServiceBroker.cs Adds JsonRpcContract and GenerateShape attributes; changes to partial interface for source generation support
src/Microsoft.ServiceHub.Framework/Services/IAuthorizationService.cs Adds JsonRpcContract and GenerateShape attributes; changes to partial interface for source generation support
src/Microsoft.ServiceHub.Framework/Services/IBrokeredServiceManifest.cs Adds JsonRpcContract and GenerateShape attributes; changes to partial interface for source generation support
src/Microsoft.ServiceHub.Framework/Container/IMissingServiceDiagnosticsService.cs Adds JsonRpcContract and GenerateShape attributes; changes to partial interface for source generation support
src/Microsoft.ServiceHub.Framework/Container/GlobalBrokeredServiceContainer.cs Updates MissingServiceDiagnostics descriptor to use ServiceJsonRpcPolyTypeDescriptor with PolyType type shape provider; updates RequiresUnreferencedCode attribute reason from Formatters to TypeLoad
src/Microsoft.ServiceHub.Framework/Container/MissingServiceAnalysis.cs Changes constructor visibility from internal to public to support serialization
src/Microsoft.ServiceHub.Framework/RemoteServiceBroker.cs Removes RequiresUnreferencedCode and RequiresDynamicCode attributes from connection methods
src/Microsoft.ServiceHub.Framework/MultiplexingRelayServiceBroker.cs Removes RequiresUnreferencedCode and RequiresDynamicCode attributes from ConnectToServerAsync
src/Microsoft.ServiceHub.Framework/ServiceBrokerClientMetadata.cs Updates to use generic JsonStringEnumConverter<T> for better type safety and performance
src/Microsoft.ServiceHub.Framework/ServiceMoniker.cs Adds ConstructorShape attribute; removes unused System.Diagnostics.CodeAnalysis import
src/Microsoft.ServiceHub.Framework/ServiceHub/LazyAuthorizationServiceProxy.cs Removes RequiresUnreferencedCode and RequiresDynamicCode attributes
src/Microsoft.ServiceHub.Framework/DelegatingServiceJsonRpcPolyTypeDescriptor.cs Removes RequiresUnreferencedCode and RequiresDynamicCode attributes
src/Microsoft.ServiceHub.Framework/Container/ServiceBrokerOfExportedServices.cs Removes RequiresUnreferencedCode and RequiresDynamicCode attributes
src/Microsoft.ServiceHub.Framework/Container/GlobalBrokeredServiceContainer.View.cs Adds RequiresUnreferencedCode(Reasons.TypeLoad) attribute
src/Microsoft.ServiceHub.Framework/Container/GlobalBrokeredServiceContainer.ProfferedViewIntrinsicService.cs Updates RequiresUnreferencedCode attribute reason from Formatters to TypeLoad
src/Microsoft.ServiceHub.Framework/Container/GlobalBrokeredServiceContainer.ProfferedServiceFactory.cs Updates RequiresUnreferencedCode attribute reason from Formatters to TypeLoad
src/Microsoft.ServiceHub.Framework/Container/GlobalBrokeredServiceContainer.ProfferedRemoteServiceBroker.cs Moves RequiresUnreferencedCode attribute from class to constructor
src/Microsoft.ServiceHub.Framework/Extensions/ServiceManagerReflectionHelpers.cs Updates RequiresUnreferencedCode attribute reason and removes RequiresDynamicCode
src/Microsoft.ServiceHub.Framework/Reflection/ProxyBase.cs Clarifies error message to specify "local services" for missing source-generated proxies
src/Microsoft.ServiceHub.Framework/Reasons.cs Removes unused CloseGenerics constant
src/Microsoft.ServiceHub.Framework/Microsoft.ServiceHub.Framework.csproj Adds analyzer references via AnalyzerUser.targets; adds NoWarn for ISB001
src/AnalyzerUser.targets New file defining analyzer project references for use by both src and test projects
test/Microsoft.ServiceHub.Framework.Tests/RemoteServiceBrokerFrameworkDescriptorTests.cs Updates tests to verify ServiceJsonRpcPolyTypeDescriptor usage and UTF8 formatter; adds #pragma warning disable PolyTypeJson
test/Microsoft.ServiceHub.Framework.Tests/RemoteServiceBrokerTests.cs Updates cast from ServiceJsonRpcDescriptor.JsonRpcConnection to ServiceJsonRpcPolyTypeDescriptor.JsonRpcConnection
test/Microsoft.ServiceHub.Framework.Tests/MissingServiceDiagnosticsTests.cs New test file for IMissingServiceDiagnosticsService RPC serialization
test/Microsoft.ServiceHub.Framework.Tests/Mocks/MockMissingServiceDiagnosticsService.cs New mock implementation for IMissingServiceDiagnosticsService tests
test/Microsoft.ServiceHub.Framework.Tests/Microsoft.ServiceHub.Framework.Tests.csproj Updates import path from test\AnalyzerUser.targets to src\AnalyzerUser.targets
Microsoft.ServiceBroker.slnx Moves AnalyzerUser.targets from test to src folder
Directory.Packages.props Updates StreamJsonRpc from version 2.24.45-preview to 2.24.51-preview

@AArnott AArnott force-pushed the NativeAOTFrameworkServices branch 3 times, most recently from 0792e83 to d3424db Compare November 7, 2025 23:14
…r` serialization

The descriptor for `IMissingServiceDiagnosticsService` was evidently always broken, because is used MessagePack-CSharp and `MissingServiceAnalysis` was not annotated with `[MessagePackObject]`.
The fix then is to just switch to Nerdbank.MessagePack, which doesn't require the attributes.

Also `ServiceMoniker` was dropping its `Version` property when serialized with Nerdbank.MessagePack on account of PolyType not seeing the constructor that could initialize the property.
@AArnott AArnott force-pushed the NativeAOTFrameworkServices branch from d3424db to b339a88 Compare November 8, 2025 01:57
@AArnott AArnott force-pushed the NativeAOTFrameworkServices branch from 79e2ef7 to 979576c Compare November 8, 2025 15:16
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.

2 participants