ValeraT1982 / ObjectsComparer

C# Framework provides mechanism to compare complex objects, allows to override comparison rules for specific properties and types.
MIT License
352 stars 86 forks source link

Add interface to ignore members in BaseComparer #13

Closed ianmann56 closed 4 years ago

ianmann56 commented 4 years ago

closes https://github.com/ValeraT1982/ObjectsComparer/issues/12

Checklist before ready:

ValeraT1982 commented 4 years ago

Implemented and uploaded new version to NuGet

ianmann56 commented 4 years ago

@ValeraT1982 Thank you for implementing that. However, #12 specifically was for targeting members based on a lambda.

My specific use case is that I want to ignore all members with a certain attribute on them. As of right now, there is now way to do that. you can only target specific members, types or names. I want to target members with a certain attribute.

What was added in a060a87b3a2853e304875ebe00ea98ccedd5e01a simply wraps already existing capabilities (still can only target by specific member, type or name). So I still can't target members by their attribute.

The reason I asked for lambda resolving was cause I figured rather than adding yet another specific way to override a targeted member, it might be better to just give the user a custom way to decide if any given member should be overridden without explicitly targeting it.

So the main concern in #12 is that I can't target the members that I want to override their comparers.

ianmann56 commented 4 years ago

Looking back at the issue, I realize I hadn't made that need as clear as I should have being that it was the main use case prompting the request. So my apologies for not expressing that better in the issue.

ValeraT1982 commented 4 years ago

@ianmann56 now I better understand what you want.

Look at this example - https://github.com/ValeraT1982/ObjectsComparer/tree/master/ObjectsComparer/ObjectsComparer.Examples/Example5

Does this solution works for you?

For now it's the best you can do. It's possible to add this Attribute based override/ignore logic in future versions.

ikirkpat commented 4 years ago

@ValeraT1982 that requires that you add it by type. I need to be able to target any member regardless of type or name that has a given attribute on it.

Do you mind if I create a new issue that has this attribute based override but obviously worded more specific and clearly? This PR fulfills that need and is done in the sense of logic... It just needs tests.

ValeraT1982 commented 4 years ago

@ikirkpat it works. Keep in mind override priorities. I was going to look at the issue maybe next week. You can wait or you can try to implement it yourself and create a pull request.

ianmann56 commented 4 years ago

@ikirkpat it works. Keep in mind override priorities. I was going to look at the issue maybe next week. You can wait or you can try to implement it yourself and create a pull request.

Thank you!