Skip to content

Resilience + CI cleanup#39

Merged
poxet merged 13 commits intomasterfrom
develop
Apr 29, 2026
Merged

Resilience + CI cleanup#39
poxet merged 13 commits intomasterfrom
develop

Conversation

@poxet
Copy link
Copy Markdown
Contributor

@poxet poxet commented Apr 29, 2026

Summary

Resilience fix for AddCache() plus CI/cleanup work.

Library

  • AddCache assembly scan survives ReflectionTypeLoadException (PlutusWave / High). Both Assembly.GetTypes() call sites in CacheRegistrationExtensions (RegisterIPersistFromAssembly, InvokeAllPersistRegistrations) now go through a GetTypesSafe helper that catches the exception and returns the types that did load. Warns once per affected assembly via Console.Error so the root cause isn't silently swallowed. PlutusWave hit a fatal startup crash from an unrelated Quilt4Net.Toolkit / Microsoft.ApplicationInsights dll mismatch — with this fix, the consumer's app starts and prints a warning naming the offending assembly.
  • MongoDB persist layer uses ID-based lookup instead of predicate-based GetOneAsync(x => x.Id == key.Value, ...) / DeleteOneAsync(x => x.Id == item.Id, ...). Slightly faster, clearer; removes three TODO comments.

CI

  • Fix prerelease artifact version mismatch in build.yml (Tharga.Blazor / Medium). The previous single Pack step always stamped the stable version into the artifact, even on PR runs — the publish job would then push that stable .nupkg and --skip-duplicate would block the eventual master release. Split into two conditional Pack steps and added a Compute pre-release version step in the build job. All 5 packages updated (Tharga.Cache, .Redis, .MongoDB, .File, .Blazor).
  • Removed legacy Azure DevOps pipeline files (azure-pipelines.yml, buildnumber.yml). GitHub Actions is now the only CI/CD; AzDO pipeline was disabled after the 0.4.0 release.

Sample / cleanup

  • Sample CacheMonitorController.GetType resolves type by name via _cacheMonitor.GetInfos().FirstOrDefault(x => x.Type.Name == type). Was hardcoded to WeatherForecast[]. Returns 404 when the type isn't found.
  • Removed stale // TODO: Return all types automatically + commented GenericCache/GenericTimeCache lines from AllTypes test helper (over-engineering for 3 concrete cache types).
  • Removed // TODO: Enable this method in future version, so that memory will be default from CacheOptions — explicit RegisterType<TCache, TPersist>() is clearer than a silent default.

Tests

  • 3 new tests in GetTypesSafeTests.cs: normal assembly returns all types; throwing assembly returns only loaded types; throwing assembly does not propagate.
  • 463 tests pass (timing-sensitive tests can flake but all pass on retry).

Test plan

  • CI build runs the new test on PR.
  • Pre-release .nupkg artifacts have the 0.4.x-pre.N version (not stable).
  • After approval, master push publishes a stable 0.4.x and creates a GitHub release.
  • PlutusWave can remove the Quilt4Net.Toolkit 0.6.16 / AppInsights 2.23.0 pinning.

poxet added 13 commits April 18, 2026 15:35
Switched GetAsync and DropAsync from predicate-based overloads
(x => x.Id == key.Value) to the direct ID overloads already provided
by Tharga.MongoDB: GetOneAsync(TKey id) and DeleteOneAsync(TKey id).
Slightly faster and clearer; removes three TODO comments.
The previous single Pack step always stamped the stable version into
the artifact, even on PR runs. The publish job (running with the
prerelease environment on PRs) would then push that stable .nupkg to
NuGet — minting the next stable patch under a GitHub pre-release tag
and blocking the eventual master release via --skip-duplicate.

Split into two conditional Pack steps and added a dedicated
'Compute pre-release version' step in the build job:
- Pack (stable)      — only on push to master, uses version output
- Pack (pre-release) — only on pull_request,  uses preversion output

Reference template: Tharga.Mcp / Tharga.Blazor.
GitHub Actions (.github/workflows/build.yml) is now the only CI/CD.
Azure DevOps pipeline was disabled after the 0.4.0 release.
Wrap both Assembly.GetTypes() call sites (RegisterIPersistFromAssembly
and InvokeAllPersistRegistrations) in a GetTypesSafe helper that
catches ReflectionTypeLoadException and returns the types that did
load. Warns once per affected assembly via Console.Error so the root
cause isn't silently swallowed.

Reported by PlutusWave: a Quilt4Net.Toolkit / Microsoft.ApplicationInsights
version mismatch in an unrelated dll caused AddCache() to crash
during startup with no indication that a third-party dll was the
culprit. With this fix the consumer's app starts and emits a warning
naming the offending assembly.

Tests:
- Normal assembly returns all types unchanged.
- Throwing assembly returns only the loaded types and does not
  propagate the exception.
xUnit v3 added the xUnit1051 analyzer which warns on every Task.Delay
without TestContext.Current.CancellationToken. That added ~17 warnings
across our short-running test methods, pushing the CI threshold (10)
into failure.

- Suppress xUnit1051 in both test csproj NoWarn (stylistic, our tests
  are short-lived; bolting on a CancellationToken adds noise without
  improving correctness).
- Suppress CS0618 in ObsoleteTests.cs via #pragma — the file
  deliberately references the obsolete IMemoryWithRedis to assert
  it's marked [Obsolete].
- Drop nullable annotations from GetTypesSafeTests.ThrowingAssembly
  (test project doesn't have <Nullable>enable</Nullable>); fixes
  CS8632.

Local warning count: 38 → 2 (the single CS0162 for the unreachable
'yield break' in File.FindAsync, counted once per target framework).
The earlier 'update nuget packages' commit bumped Tharga.Console from
3.7.2 to 4.0.0, which is a breaking major version that restructured
the Tharga.Console.Commands.Base namespace (ContainerCommandBase,
ActionCommandBase, AsyncActionCommandBase no longer resolve from the
old using). The sample failed to build on CI as a result.

Reverting just the sample's package reference back to 3.7.2 so the CI
build is green. Adapting the sample to the 4.0.0 API is a separate
follow-up.
DropEvenIfUsed(keep: True) flaked on CI: at t=400 with TTL=400 the
third Get hit the expiration boundary, sometimes returning the still-
fresh original instead of refetching. Final Get then returned 'a4'
instead of the expected 'a3'.

Bumped delays to 250/250/300 (was 200/200/250) so every assertion now
sits >= 100ms away from the boundary on slow runners. Same change
applied to TimeToIdleCacheTests.KeepIfUsed for symmetry.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

@poxet poxet merged commit cf73a9b into master Apr 29, 2026
4 of 5 checks passed
@poxet poxet mentioned this pull request Apr 29, 2026
2 tasks
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