machine / machine.specifications

Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests.
MIT License
885 stars 178 forks source link

Should ObjectGraphHelper include static members? #400

Open grx70 opened 4 years ago

grx70 commented 4 years ago

Although this is not a textbook bug, I still find this to be an issue.

Namely, should ObjectGraphHelper include static members when building an object graph? From what I know, it is only used from within ShouldBeLike assertion extension method, and I don't see how static members could be of any importance in that context. On the other hand, I remember stumbling across an error, where a subject of a ShouldBeLike call was a class that exposed a static member of that same class, and it ended up in a nasty StackOverflowException.

So the proposed change would be to the ObjectGraphHelper.GetKeyValueNode method to filter out static members.

Personally I don't see why static members should be included in ShouldBeLike assertions. But I am more than welcome to be proven wrong.

I am submitting an issue over this so that it gets proper response from the community - is my reasoning sound and the change is justified, or am I missing something?

As a note - the problem with StackOverflowException seems to be resolved, but the question still stands - is it reasonable to include static members in the object graph?

AngusMcIntyreLTS commented 4 years ago

It is my opinion that this absolutely shouldn't for the reasons you suggest.