Skip to content

Fix runtime bugs & add TryBindConfiguration / IServiceCollection.RegisterAzureStorage#55

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/propose-new-features-improvements
Draft

Fix runtime bugs & add TryBindConfiguration / IServiceCollection.RegisterAzureStorage#55
Copilot wants to merge 3 commits into
mainfrom
copilot/propose-new-features-improvements

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

Three latent runtime bugs fixed and two developer-experience additions to align patterns across packages.

Bug fixes

  • PersistentService.SaveOnBlobAsync — mutated metadatas dictionary while iterating it (guaranteed InvalidOperationException); also called fire-and-forget SetMetadata instead of await SetMetadataAsync. Fixed by projecting to a new dictionary and awaiting the async overload.
  • IHttpContextAccessorExtensions.GetClaims — called Convert.FromBase64String on a potentially empty/missing header value, then dereferenced the deserialized result without null-checking. Now returns Enumerable.Empty<UserClaim>() on missing token or failed deserialization.
  • RequireDaprApiTokenAttribute — cached the expected token in static fields (_expectedToken / _initialized), making the token stale across test runs and introducing a startup race. Now reads from IConfiguration per-request via the scoped IServiceProvider.

New APIs

TryBindConfiguration<T> — optional-section variants of BindConfiguration<T> on both IHostApplicationBuilder and IServiceCollection. Silent no-op when the section is absent rather than throwing.

// Does not throw if "FeatureX" is absent from appsettings
builder.TryBindConfiguration<FeatureXSettings>("FeatureX");
builder.TryBindConfiguration<FeatureXSettings>(out var featureX, "FeatureX");

IServiceCollection.RegisterAzureStorage — direct IServiceCollection overload mirroring the existing RegisterCosmosDb(IServiceCollection, IConfiguration, TokenCredential) pattern. The IHostApplicationBuilder variant now delegates to it.

// Usable in test hosts, Worker Services, etc. without IHostApplicationBuilder
services.RegisterAzureStorage(configuration, new DefaultAzureCredential());

Docs

Corrected misleading "Bing configuration object on section" summaries and added missing <typeparam>/<returns> XML doc tags across StartupRegistersExtensions.

Copilot AI and others added 2 commits April 21, 2026 22:13
…ureStorage, improve docs

Agent-Logs-Url: https://github.com/mathieumack/MDev.Dotnet/sessions/8dbae19d-ba3a-4262-89e0-e8af463924e1

Co-authored-by: mathieumack <12582537+mathieumack@users.noreply.github.com>
Agent-Logs-Url: https://github.com/mathieumack/MDev.Dotnet/sessions/8dbae19d-ba3a-4262-89e0-e8af463924e1

Co-authored-by: mathieumack <12582537+mathieumack@users.noreply.github.com>
Copilot AI changed the title [WIP] Propose new features and improvements for developer benefit Fix runtime bugs & add TryBindConfiguration / IServiceCollection.RegisterAzureStorage Apr 21, 2026
Copilot AI requested a review from mathieumack April 21, 2026 22: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.

Propose New Features or Improvements to Benefit Developers

2 participants