Skip to content

Add Native AOT support for .NET 8+#394

Open
bbartels wants to merge 6 commits intorajanadar:masterfrom
bbartels:master
Open

Add Native AOT support for .NET 8+#394
bbartels wants to merge 6 commits intorajanadar:masterfrom
bbartels:master

Conversation

@bbartels
Copy link

@bbartels bbartels commented Feb 20, 2026

Summary

  • Add System.Text.Json source generation via VaultSharpJsonContext to enable Native AOT compilation on .NET 8+, replacing all anonymous types used as request payloads with strongly-typed models (AotRequestModels.cs) decorated with [JsonPropertyName] attributes
  • Switch serialization/deserialization calls to use JsonTypeInfo-based overloads on .NET 8+ (via #if NET8_0_OR_GREATER) while preserving reflection-based fallback for older target frameworks
  • Update all [JsonConverter(typeof(JsonStringEnumConverter))] enum attributes to use the AOT-compatible generic JsonStringEnumConverter on .NET 8+
  • Refactor VaultApiException to use JsonDocument-based parsing instead of JsonSerializer.Deserialize<Dictionary<string, IEnumerable>>, avoiding reflection
  • Remove unnecessary [JsonDerivedType] attributes from AbstractAuditBackend (already handled by custom AuditBackendJsonConverter) and add missing [JsonPropertyName("type")] to audit backend subtypes
  • Expose JsonSerializerOptions on VaultClientSettings to allow consumers to register custom type resolvers (e.g., for KV secret data types)

@bbartels
Copy link
Author

@rajanadar If you get a chance to take a look! Would be great to expand with support across the dotnet ecosystem. We have some apps using Vaultsharp which we'd love to publish as AOT instead

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.

1 participant