Skip to content

Add Native AOT support for .NET 8+#394

Open
bbartels wants to merge 6 commits into
rajanadar:masterfrom
bbartels:master
Open

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

Conversation

@bbartels

@bbartels bbartels commented Feb 20, 2026

Copy link
Copy Markdown

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
Copy Markdown
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

@bbartels

bbartels commented Apr 8, 2026

Copy link
Copy Markdown
Author

@rajanadar Gentle ping on this :)

@ajacques

Copy link
Copy Markdown

+1 on AOT support. Importing a library that doesn't support AOT prevents the entire application from being able to enable AOT.

@stevefan1999-personal

Copy link
Copy Markdown

@bbartels Can I take your code and hard fork a new project? The name for VaultSharp will be changed to something else though

@bbartels

Copy link
Copy Markdown
Author

Feel free :)

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.

3 participants