feat: implement Dapr.StateManagement package — AOT-safe, reflection-free#1806
feat: implement Dapr.StateManagement package — AOT-safe, reflection-free#1806
Conversation
…ackage Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/7ecd6668-69d9-4165-a773-49bbe8e3b4cf Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
…<> alignment Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/393269e7-0b77-46e5-b002-ce1e9e547858 Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
…ator csproj and FNV hash Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/393269e7-0b77-46e5-b002-ce1e9e547858 Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
…, generic Serialize<T> overload Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/63945548-1b45-4e00-8494-4af62136db8b Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1806 +/- ##
==========================================
- Coverage 65.42% 63.86% -1.57%
==========================================
Files 296 308 +12
Lines 8694 9093 +399
Branches 1009 1065 +56
==========================================
+ Hits 5688 5807 +119
- Misses 2761 3040 +279
- Partials 245 246 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot This project is failing to build. Can you give it another pass? |
…use new AddDaprClient<> factory delegates Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/4e81dcdf-2201-490f-9729-b9ae4477ab19 Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Fixed in 9ab98d1. Two root causes:
Full solution now builds cleanly; 74 |
Description
Ensures the Dapr.StateManagement implementation (and shared infrastructure in
Dapr.Common) does not use reflection and is fully Native AOT-safe.Changes Made
AOT / Reflection Elimination
IDaprSerializer— Added a newSerialize<T>(T value)generic overload. The non-genericSerialize(object?, Type?)andDeserialize(string?, Type)overloads (which accept a runtimeType) are now annotated with[RequiresUnreferencedCode]and[RequiresDynamicCode]to make their AOT-unsafety explicit.JsonDaprSerializer— Implements the newSerialize<T>(T)overload usingJsonSerializer.Serialize<T>(value, options), which is fully AOT-safe. Matching annotations added to the non-generic overloads.DaprStateManagementGrpcClient.SerializeValue<TValue>— Changed fromSerializer.Serialize(value, typeof(TValue))(reflection path) toSerializer.Serialize<TValue>(value)(AOT-safe generic path).DaprClientBuilderExtensions.AddDaprClient<>— Replaced twoActivator.CreateInstancecalls with explicitFunc<IConfiguration?, TClientBuilder>andFunc<IServiceCollection, TServiceBuilder>factory delegate parameters. No reflection is used in the hot path.Callers Updated
All 6
AddDaprClient<>callers updated to pass explicit factory lambdas (config => new TClientBuilder(config)/svc => new TServiceBuilder(svc)): Jobs, Cryptography, AI, DistributedLock, Messaging, and StateManagement.Test Fixes (Build Failure)
DaprClientBuilderExtensionsTests— Updated all 4 call sites to pass the two new required factory delegate parameters. FixedDaprTestClientBuilder.Build()which was throwingNotImplementedException; it now correctly callsBuildDaprClientDependenciesand returns a realDaprTestGrpcClient.Dapr.Workflow.Teststub serializers — Added the missingSerialize<T>(T)method to 6 stub/mockIDaprSerializer/IWorkflowSerializerimplementations:StubSerializer,CapturingSerializer,StubDaprSerializer,StubWorkflowSerializer,DependencyBasedSerializer, andMockSerializer.Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: