-
Notifications
You must be signed in to change notification settings - Fork 7
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
[GH-1] - Checking constructor arguments passed via Substitute.For
/Substitute.ForPartsOf
#13
Conversation
… meaningful tests
…ersion and some test cases
…lict conversion and some test cases
…stitute/NSubstitute.Analyzers into GH-1-SubstituteForAnalyzers
…f For and ForPartsOf
Pull Request Test Coverage Report for Build a94vxlc6i7y4fhg2
💛 - Coveralls |
This looks amazing @tpodolak! I should be able to have a more thorough look at this over the weekend. PS: I've updated the docs to strongly advise the installation of NSubstitute.Analyzers along with the core NSubstitute package, and also included a dedicated doc page for the Analyzers project. This will go live with the next NSub release. I'll try to keep the dedicated doc page up to date with Analyzer features, but if you notice I miss any please raise an issue and I'll sort it out. |
Running through a large test project found false-positives if there is a generic
Very edge-case, but can come up when writing some test infrastructure for a project. |
How do I activate the quick fixes? Jumping to the compile error location doesn't seem to give me the option: Also these compiler errors should have NS codes like the other errors? Ideally I think the errors should contain info on how to fix the problems. For example:
Ideally with (sorry for brain-dumping all this info; I was just scribbling notes while playing around with this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!! @tpodolak Thank you for doing this!
LGTM! (Although I superficially reviewed it)
This one should be fixed now |
@tpodolak Ah, I forgot the first rule of computing: try turning it off and on again 🤦♂️ . Works fine now. 😄Can confirm the Did you want to merge this now? We can push description changes to another change (feel free to assign to me). Happy for you to merge this in whatever way is easiest for you. |
I would wait with merge as I am now working on message changes. Will push them today or tomorrow morning for the review, then we can merge. No need to create separate PR for that. |
@tpodolak Great. Feel free to push things out to other issues though if it is something others can work on, or even if it's just something you don't feel like working on at the moment. You're carrying the whole workload for this at the moment so don't want you getting burned out chasing up my little suggestions. 😂 |
@dtchepak messages should be fixed now, please take a look if they are good enough |
[GH-1] - Minor message tweaks
Substitute.For/Substitute.ForPartsOf constructor usage analyzers
This one comes together with two code fix providers. First one removes arguments from Substitute.For when used with interface. So it converts
Substitute.For<IFoo>(1, 2, 3)
toSubstitute.For<IFoo>()
. The second one replaces usages ofSubstitute.ForPartsOf
toSubstitute.For
whenForPartsOf
is used with interface or delegate.When it comes to analyzers apart from the one which corresponds to beforementioned fix-providers, I've implemented:
There were a couple of unexpected behaviors I wasn't aware of before, such as
so if you are aware of any other corner-cases let me know. I am a bit afraid of VisualBasic implementation as I don't know that language that well (and I had to analyze the syntax model not only semantic model), it seems to work fine with the examples converted from c# but I might have missed something.
PS
I am not that good at naming things/messages so if you think given diagnostic message is not descriptive enough let me know
PPS
For some reasons github show much more files in diff then it is supposed to. Either I did a wrong merge or it is a Github issue