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

Checking constructor arguments passed via Substitute.For/Substitute.ForPartsOf #1

Closed
dtchepak opened this issue May 22, 2018 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@dtchepak
Copy link
Member

Using an analyser for this came up in NSub#314, so I thought I'd raise this issue here for discussion and to see how practical it would be to implement.

@tpodolak
Copy link
Member

tpodolak commented May 24, 2018

I took an initial look at this one, and as for today I think I know how to write analyzer which prevents you from using

  • ForPartsOf on delegates and interfaces
  • ForPartsOf/For without arguments if there is no parameters constructor
  • ForPartsOf/For with wrong arguments if there is only one constructor and you pass the parameters directly (not via new [] { arg1, arg2, arg3 }) - this one is tricky but probably possible

The real problem for me will be situation when your class has multiple constructors and then I have to figure out proper overload to choose based on arguments user provided. I didn't find any public API in Roslyn which would do that for me, so this particular feature might not be implemented.

tpodolak added a commit that referenced this issue May 27, 2018
tpodolak added a commit that referenced this issue May 27, 2018
tpodolak added a commit that referenced this issue Jun 9, 2018
tpodolak added a commit that referenced this issue Jun 9, 2018
tpodolak added a commit that referenced this issue Jun 13, 2018
tpodolak added a commit that referenced this issue Jun 13, 2018
tpodolak added a commit that referenced this issue Jun 14, 2018
tpodolak added a commit that referenced this issue Jun 17, 2018
@tpodolak tpodolak self-assigned this Jun 17, 2018
tpodolak pushed a commit that referenced this issue Jun 18, 2018
[GH-1] - Minor message tweaks
tpodolak added a commit that referenced this issue Jun 18, 2018
[GH-1] - Checking constructor arguments passed via `Substitute.For`/`Substitute.ForPartsOf`
@tpodolak
Copy link
Member

Fixed in #13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants