Skip to content
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

feat: Scrub/ignore by predicate function #1356

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JulianRooze
Copy link

@JulianRooze JulianRooze commented Nov 19, 2024

I'm trying to introduce Verify to our large existing code base and one area of friction is that we have thousands upon thousands of dynamic properties (auto-generated IDs) that we want to ignore or scrub, which all follow a similar pattern, they all end in ID. While it's possible to use reflection at startup to find all those properties and Scrub/Ignore them one by one, it's a bit wasteful as only a small subset of them will ever pass through a call to Verify, we have to pre-emptively ignore them ahead of time. For this, I think the ability to provide a callback function that gets called at the same point the normal "is property ignore/scrub dictionary" is a good approach. The callback can be based on either the string name of the property (or anything that's not a property like a dictionary key) or on the MemberInfo of the property if you need more information to determine if the property should be ignored or not.

I did not include benchmarks as I hope from the implementation it should be clear that there shouldn't be any performance impact from this, especially not if you don't opt-in to this feature, but let me know if you must have them.

Todo:

  • Docs I guess?

This is based on the discussion here:

https://github.com/orgs/VerifyTests/discussions/1345

@JulianRooze
Copy link
Author

JulianRooze commented Nov 19, 2024

@dotnet-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant