-
Notifications
You must be signed in to change notification settings - Fork 179
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
Custom attributes, additional interfaces, and constructor parameters unused when we create a Fake delegate #1353
Comments
We should also investigate if it's possible at all to add attributes to fake delegates. Would that even make sense? I'm not sure, my brain is a bit slow today. |
It wouldn't make sense to apply attributes to the delegate type (because we're not creating a new type, it already exists) or to the delegate instance (because instances are not reflection objects, they don't have attributes). It might make sense to apply attributes to the method that the delegate instance encapsulates. I can't think of many real-world use cases, though.
I don't think it's possible, at least with our current approach to generate fake delegates. Using |
@thomaslevesque, after your last comment, I think we're left with "just document the behaviour and throw when attributes are supplied on delegate creation", no? |
Yes, I think so. |
Throwing when the user tries to add attributes to a delegate is easy, if we want to do it while trying constructors (of which I'd expect only one). We can elicit this error:
If we like that, I can send a PR real soon now. Still, if there's perceived value in rejecting the construction without trying constructors, I'll carry on! |
I'm not sure which constructors you're talking about... We don't "try constructors" when faking delegates. Couldn't we check for this in |
Excellent point. Was approaching it from the
We could, if we wanted to spread knowledge of the various proxy types and what they can handle around the system. Right now it's a little more concentrated in the creation code. I'm not too bothered by modifying |
Good point. So the proper place to check this would probably be BTW, I just realized that it's not just the attribute list: we also ignore |
Yup. I noticed
I think so. So proper. Somewhat annoying. Okay. I'll keep plugging! |
Oh. That actually might work out easier than I was thinking. I'd thunk of |
Ha. I'm foolish. I'd originally put the check in |
Ah. So maybe we need to special case delegates to not mention constructors... |
I'm sensing a "ResolveStrategy" for Fakes to match the one we have for Dummies. :) That might actually not be a bad approach. |
Maybe not a bad approach, but probably overkill... |
Oh, but I'm having fun. Let me go a bit longer and then I can send a PR and you can reject it and I'll do the |
Lol! OK, have a go at it then ;) |
Relabelling as a bug, since we're no longer planning on supporting the attributes (interfaces, constructor arguments…) |
This change has been released as part of FakeItEasy 4.8.0. |
Mentioned by @thomaslevesque in #1352 (comment)
We should
The text was updated successfully, but these errors were encountered: