New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support custom identity key for facts #336
Comments
I'm browsing through the source of NRules/src/NRules/NRules/Session.cs Line 430 in b8c44a3
Which tried to retrieve this from a dictionary, with the key being the fact (The key that has now changed if the record was mutated). And thus it would probably fail to find the fact. What side effects would there be from supporting an Side note, this is a bit of a pain without SourceLink (wink-wink nudge-nudge), can't quite tell what is exactly happening, just speculating 😛 Edit: Ignore my SourceLink poking, saw your other post. I can always build from source and add a nuget source to the output dir |
@douglasg14b the thing to highlight here is that each fact is its own key in the working memory (i.e. it's looked up in a dictionary, like you pointed out), so regardless of something being a class or a record, the expectation is that the hash code won't change. In other words, facts are expected to have identity. |
Thanks for taking a look! I think this might be capturing two things, and the title captures 1.
Personally support for Maybe I'm way off base, I'll let you comment. This is something I'd be willing to put work in to help make happen, if that changes anything. I'd probably need some tech design & considerations from you. |
Maybe there is a better way to phrase this, I'm looking at this as a way to pass an identity key for a fact where existing identity is not suitable (case 1) or there is no identity (case 2). |
It seems that the
Update()
workflow is broken whenrecord class
are utilized. Likely because of the value-type semantics of records, which mean when a record is changed, theHashCode
changes, making any keys in say a dictionary change (In ways they are not supposed to), making the fact un-findable.Records should be treated as immutable, however, the
Update()
method doesn't seem to support this as it expects the same object instance to be mutated, not a new object instance returned (ie. with the non-destructive mutation feature)Update()
I receive aFacts for update do not exist
exception.Update()
themyRecord with { MyProp = newValue }
syntax, I appear to enter an infinite loop of some sortIt also seems that because of the retraction of the fact in order to update it, it is not possible to make use of the
[Repeatability]
attribute 🤔If there is already support for this, how? If not, what sort of outlook does such support have? Is this something I could help implement?
The text was updated successfully, but these errors were encountered: