-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Start using MEF #9107
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
Start using MEF #9107
Conversation
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.
Maybe like this:
Or using WinForm as service.
https://www.thecodebuzz.com/dependency-injection-windows-form-desktop-app-net-core/
We could start simple.
We already are using MEF, so I'm finding it hard to justify introduction of another DI framework.
This is really cool! Thanks for the link. |
The form can be thought of as a request to a remote system, where the response is generated not by a machine, but by a person. |
string Resolve(string repositoryPath); | ||
} | ||
|
||
/// <summary> | ||
/// Resolves the location of .git folder. | ||
/// </summary> | ||
[Export(typeof(IGitDirectoryResolver))] |
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.
💡 I recommend making the following changes:
- Eliminate all but one constructor
- Mark the remaining constructor with
[ImportingConstructor]
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.
Can you please help me understanding how to register FileSystem -> IFileSystem
?
diff --git a/GitCommands/Git/GitDirectoryResolver.cs b/GitCommands/Git/GitDirectoryResolver.cs
index 1d81f491f..d3610c9fc 100644
--- a/GitCommands/Git/GitDirectoryResolver.cs
+++ b/GitCommands/Git/GitDirectoryResolver.cs
@@ -28,16 +28,12 @@ public sealed class GitDirectoryResolver : IGitDirectoryResolver
{
private readonly IFileSystem _fileSystem;
+ [ImportingConstructor]
public GitDirectoryResolver(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
- public GitDirectoryResolver()
- : this(new FileSystem())
- {
- }
-
Introduce a basic scaffolding for use of MEF for components other than plugins. Refactor the following components: * AppTitleGenerator * GitDirectoryResolver * RepositoryDescriptionProvider * WindowsJumpListManager Add a basic test scaffolding.
@msftbot merge in 48 hours |
Hello @RussKie! Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:
If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you". |
Proposed changes
Use MEF tp compose and reference the following types:
AppTitleGenerator
RepositoryDescriptionProvider
WindowsJumpListManager
Test methodology
✒️ I contribute this code under The Developer Certificate of Origin.