Repository navigation
v0.11.0
[0.11.0] - 2026-07-11: typed assertions against log definitions
Minor release. A [LoggerMessage] definition (or any other log call) becomes a reusable assertion value: capture it once, then assert it was logged by identity instead of matching rendered message text. Wording edits to a template no longer break tests that assert intent; renaming a definition or changing its signature breaks the capture lambda at compile time. Binary-compatible and additive; one source-level compatibility note is listed under Changed. Built against TUnit 1.58; pin TUnit at or above that version when adopting.
Added
LogDefinition.Capture(Action<ILogger>)(core) invoked a logging delegate once against a private probe logger and returned the captured call shape: event ID (numeric ID plus name), level, message template, formatted placeholder values, and exception. The probe collects every level, so anIsEnabledgate inside generated logging code cannot suppress the capture. A lambda that logs zero or multiple records fails fast with an explanatoryArgumentException. Argument values in the capture lambda are throwaway; store definitions instatic readonlyfields.Matching(LogDefinition)on theHasLogged()/HasNotLogged()/HasLoggedSequence()chains filtered to records carrying the definition's identity: equal event ID, event name, and message template. Argument values and level are deliberately not part of identity: chainWithProperty(...)to pin placeholder values andAtLevel(...)when the level matters. Works for definitions behind wrapper methods (the record carries the generated Core's identity), definitions with generator-assigned event IDs, and definitions hosted in generic classes (close the generic in the capture lambda).MatchingCall(Action<ILogger>)on the same chains matched a log call exactly: the definition's identity plus every placeholder value (formatted strings, order-insensitive, culture-invariant) plus the exception (both absent, or same runtime type and equal message). The lambda is invoked once against the probe at chain-build time with the exact argument values expected.LogFilter.Matching(LogDefinition)andLogFilter.MatchingCall(LogDefinition)exposed the same matching as composableILogRecordFilterfactories for reuse viaWithFilter(...)andLogFilter.All/Any/Not.
Changed
LogFilter.Matching(null!)call sites became ambiguous between theRegexandLogDefinitionoverloads; a null-literal argument needs a cast to pick one. Compiled code is unaffected.