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

Can't implement ISettings #7614

Closed
bjorkstromm opened this issue Dec 10, 2018 · 8 comments
Closed

Can't implement ISettings #7614

bjorkstromm opened this issue Dec 10, 2018 · 8 comments
Assignees
Labels
Area:Settings NuGet.Config and related issues RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Type:Bug
Milestone

Comments

@bjorkstromm
Copy link

I'm using the NuGet client libraries in a application, and now I need to write some tests. I've previously mocked ISettings quite easily. But now, when updating from 4.7.0 to 4.9.1 I've run into a problem with ISettings.

The problem:

Please advice... How to implement ISettings and specifically SettingSection using NuGet Client libraries. Thank you!

@bjorkstromm
Copy link
Author

bjorkstromm commented Dec 10, 2018

I went the easy route and used reflection for creating an instance of VirtualSettingSection, see https://github.com/cake-build/cake/pull/2371/files#diff-16c125384e832bf918d13f23c42bd6c4.. There should be a better option for implementing ISettings...

@jainaashish
Copy link
Contributor

@PatoBeltran can you help here?

@jainaashish jainaashish added the Resolution:Question This issues appears to be a question, not a product defect label Dec 13, 2018
@PatoBeltran
Copy link

hey @mholo65 I was looking into this, the idea is that if you want to implement ISettings, you should be able to implement the whole thing, and not necessarily take some of the decisions we used when doing our internal implementation.

I see that for your case you only want to mock it for testing purposes. From what I see there could be two options in how to solve this:

  1. Update Clone() to be public instead of internal.
  2. Update some of the internal constructors inVirtualSettingSection for people to use the same way we do in our tests.

I think the best solution out of the two would be the first one, and that way you could easily subclass SettingSection and easily mock it. I wouldn't want to do the second solution, since the VirtualSettingSection is just an implementation detail for our design and it doesn't make sense for people to be able to create this object when using our API. What do you think?

@PatoBeltran PatoBeltran added the Area:Settings NuGet.Config and related issues label Dec 14, 2018
@PatoBeltran PatoBeltran self-assigned this Dec 14, 2018
@bjorkstromm
Copy link
Author

@PatoBeltran, thanks for looking into this. Option 1) making it public is probably the best option. Want me to send a PR?

@PatoBeltran PatoBeltran added this to the 4.9.3 milestone Dec 17, 2018
@PatoBeltran
Copy link

@mholo65 if you can send a PR I would appreciate it!

@rrelyea rrelyea added RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Type:Bug and removed Resolution:Question This issues appears to be a question, not a product defect labels Dec 17, 2018
@PatoBeltran
Copy link

hey @mholo65 I sent a PR to fix this, I would appreciate if you can look at it and see if it would address your scenario. Thanks for helping us improve our codebase!

@PatoBeltran
Copy link

PR has been merged, closing this issue.

@bjorkstromm
Copy link
Author

@PatoBeltran thank you! This looks to solve the problem I was experiencing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:Settings NuGet.Config and related issues RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Type:Bug
Projects
None yet
Development

No branches or pull requests

4 participants