-
Notifications
You must be signed in to change notification settings - Fork 10
Make the FrameworkServices brokered services NativeAOT ready #376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
ServiceJsonRpcPolyTypeDescriptorfor JSON serialization via PolyType - Removes
RequiresUnreferencedCodeandRequiresDynamicCodeattributes 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 |
src/Microsoft.ServiceHub.Framework/Container/GlobalBrokeredServiceContainer.cs
Outdated
Show resolved
Hide resolved
0792e83 to
d3424db
Compare
…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.
d3424db to
b339a88
Compare
79e2ef7 to
979576c
Compare
No description provided.