feat(attr): add attribute change event system#9
Merged
Conversation
Add AttributeChanged event that fires when a modifier mutation actually changes the computed attribute value. Each subscriber is invoked individually via GetInvocationList(), so one subscriber's exception does not block others from receiving the event. - New AttrChangeType enum (SetModifier, RemoveModifier, RemoveAll, Clear) - New AttrChangedEventArgs<TKey, TValue> class - Events fire outside per-key and global locks to prevent deadlocks - Cache is invalidated before event firing so GetValue inside handlers returns fresh data - Same-value SetModifier is still a no-op and does not fire events
…nges - Add AttributeChanged event to API overview tables - Document AttrChangeType enum and AttrChangedEventArgs class - Add event usage example to Quick Start sections - Document event safety guarantees (lock-free, isolated subscribers) - Update thread safety section with event lock details - Update features list to mention change event system - Bilingual: English and Chinese READMEs aligned
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Add AttrLoggingConfigurationTest: factory creation, env var toggling, BeginScope, log-level filtering, exception formatting, provider Dispose - Add Attr constructor null-logger branch test (ArgumentNullException)
- Add ILogger dependency and constructor overloads to Attr - Add AttrLoggingConfiguration with console/file logging via env vars - Add event subscriber exception logging in RaiseAttributeChanged event
…Configuration - Add Logging Configuration section documenting AttrLoggingConfiguration.CreateLoggerFactory() - Document GAMEATTR_LOG_CONSOLE and GAMEATTR_LOG_FILE environment variables - Add code example for configuring and passing ILogger to constructor - Mention logging support in Features list - Update 100% test coverage bullet to include event behavior
Owner
Author
Updates between 988cb96 → 650796eThree new commits were added to extend the event system with logging support and finalize documentation:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an
AttributeChangedevent toAttr<TKey, TModId, TValue>that fires whenever a modifier mutation actually changes the computed attribute value.Changes
Event System (d507ba2)
AttributeChangedevent — fires on every effective mutation (SetModifier,RemoveModifier,RemoveAllModifiers,Clear)AttrChangeTypeenum —SetModifier,RemoveModifier,RemoveAll,ClearAttrChangedEventArgs<TKey, TValue>class — exposesKey,ChangeType,NewValueGetInvocationList()so one subscriber's exception does not block othersGetValueinside handlers returns fresh dataDocumentation Update (5697c0e)
Testing
AttrEventTest.cs) covering all event scenarios