Skip to content

Feature/di #1861

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

Merged
merged 24 commits into from
Oct 18, 2019
Merged

Feature/di #1861

merged 24 commits into from
Oct 18, 2019

Conversation

arturcic
Copy link
Member

@arturcic arturcic commented Oct 16, 2019

Refactored code to prepare the addition of DI to improve the modularity/testability.

Some of the changes introduced:

  • Introduce GitVersionApplication
  • Introduce several interfaces instead of creating class instances directly (IArgumentParser, IConfigFileLocator)
  • Replaced the old Logger static class with ILog interface with 2 appenders - ConsoleAppender and FileAppender. Updated the code to use the new ILog

This changes will allow gradually to introduce a DI (Autofac) so that we can later on split in modules some of the functionalities we currently support as addins/plugins call them whatever you want.

The GitVersion itself will just take as input the arguments and return as output the GitVersion information that later can be consumed by these plugins.

Example of plugins could be:

  • AssemblyInfo updater
  • BuildServer integration
  • In the future we'll be able to decouple the Git metadata reading from the version computation in separate module and so on

@arturcic arturcic requested a review from asbjornu October 16, 2019 17:27
Copy link
Member

@asbjornu asbjornu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I whole-heartedly condone and applaud the changes you're doing here, @arturcic! 🎉 👏 ❤️

I just have a few questions and comments made inline. I also wonder whether with all the refactoring you're doing here, there might be an opportunity to move code from GitVersionExe and GitVersionTask into GitVersionCore in order to tackle #883?

@arturcic
Copy link
Member Author

I whole-heartedly condone and applaud the changes you're doing here, @arturcic! 🎉 👏 ❤️

I just have a few questions and comments made inline. I also wonder whether with all the refactoring you're doing here, there might be an opportunity to move code from GitVersionExe and GitVersionCore into GitVersionCore in order to tackle #883?

I think you meant GitVersionExe and GitVersionTask into GitVersionCore. That makes sense, but as part of a different refactoring.

@arturcic arturcic force-pushed the feature/di branch 3 times, most recently from a03bf5f to 2788e4d Compare October 17, 2019 08:14
Copy link
Member

@asbjornu asbjornu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks great. The only thing I oppose is your wish to use Autofac as the DI Container. I wouldn't mind that much if the DI Container integration was made plugin-based so different containers could be used, but if we need to add a dependency to a DI Container, I think Microsoft's own would be the most non-controversial choice. Thoughts?

@asbjornu
Copy link
Member

I think you meant GitVersionExe and GitVersionTask into GitVersionCore.

Correct.

That makes sense, but as part of a different refactoring.

Ok.

@arturcic
Copy link
Member Author

I think this looks great. The only thing I oppose is your wish to use Autofac as the DI Container. I wouldn't mind that much if the DI Container integration was made plugin-based so different containers could be used, but if we need to add a dependency to a DI Container, I think Microsoft's own would be the most non-controversial choice. Thoughts?

To be honest I was thinking of Autofac because I have used it before, and also Cake-Build team is using it. I think we can use the DI from the .net core generic host https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host?view=aspnetcore-3.0. Or you mean something else?

@arturcic arturcic force-pushed the feature/di branch 2 times, most recently from c7c6ec6 to b3312b7 Compare October 18, 2019 06:07
@asbjornu
Copy link
Member

Are these changes so massive that they warrant a new major bump?

@arturcic
Copy link
Member Author

It's more a cleanup/refactor than big changes. There are no major breaking changes. There is only one important change, but backward compatible for now. The verbosity flag is using both LogLevel and Verbosity enums, but at some point we'll remove the loglevel enum and keep verbosity. The old Verbosity became LogLevel

@arturcic
Copy link
Member Author

This change was made to avoid the confusion between verbosity and loglevel. Now the LogLevel is used for the type of the log - Warn, Info and so on, and Verbosity for how verbose the log output is.

@arturcic
Copy link
Member Author

and I think we can already merge this, I have a pending draft PR based on this PR that introduce the DI container that you suggested, and I will need some feedback on that one

@arturcic arturcic added this to the 5.1.0 milestone Oct 18, 2019
@asbjornu asbjornu merged commit 5b566a5 into GitTools:master Oct 18, 2019
@asbjornu
Copy link
Member

Excellent. Great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants