-
-
Notifications
You must be signed in to change notification settings - Fork 567
Description
Is your feature request related to a problem? Please describe.
It would be nice to be able to match load/save of fields with an expression, instead of a FieldInfo.
Describe the solution you'd like
I think something like CodeMatch.LoadsField(() => default(MyClass).Field or CodeMatch.LoadsField(() => MyStaticClass.StaticField) would be nice (and for CodeMatch.StoresField too).
Describe alternatives you've considered
I think the alternative is to use something like CodeMatch.LoadsField(typeof(MyClass).Field(nameof(MyClass.Field))) or CodeMatch.LoadsField(typeof(MyStaticClass).Field(nameof(MyStaticClass.StaticField))), but the typeof and repetition of the class name make the code harder to read.
Additional context
There's already a LambdaExpression/Expression<Action> matcher for CodeMatch.Calls. It would just require SymbolExtensions to support extracting the Member FieldInfo from the MemberExpression