Skip to content

Conversation

RussKie
Copy link
Member

@RussKie RussKie commented Apr 24, 2021

Proposed changes

Use MEF tp compose and reference the following types:

  • AppTitleGenerator
  • RepositoryDescriptionProvider
  • WindowsJumpListManager

Test methodology

  • manual
  • unit tests

✒️ I contribute this code under The Developer Certificate of Origin.

@RussKie RussKie requested review from drewnoakes, sharwell and a user April 24, 2021 14:50
@ghost ghost assigned RussKie Apr 24, 2021
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Maybe like this:

image

Or using WinForm as service.

https://www.thecodebuzz.com/dependency-injection-windows-form-desktop-app-net-core/

We could start simple.

@RussKie
Copy link
Member Author

RussKie commented Apr 25, 2021

We already are using MEF, so I'm finding it hard to justify introduction of another DI framework.

Or using WinForm as service.

thecodebuzz.com/dependency-injection-windows-form-desktop-app-net-core

This is really cool! Thanks for the link.

@ghost
Copy link

ghost commented Apr 25, 2021

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))]
Copy link
Member

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:

  1. Eliminate all but one constructor
  2. Mark the remaining constructor with [ImportingConstructor]

Copy link
Member Author

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.
@RussKie RussKie marked this pull request as ready for review July 6, 2021 05:00
@RussKie
Copy link
Member Author

RussKie commented Jul 7, 2021

@msftbot merge in 48 hours

@ghost ghost added the status: auto merge label Jul 7, 2021
@ghost
Copy link

ghost commented Jul 7, 2021

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:

  • I won't merge this pull request until after the UTC date Fri, 09 Jul 2021 03:14:01 GMT, which is in 2 days

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".

@ghost ghost merged commit 0b48852 into gitextensions:master Jul 9, 2021
@ghost ghost added this to the 3.6 milestone Jul 9, 2021
@RussKie RussKie deleted the MEF_conversion branch February 6, 2022 01:32
@RussKie RussKie mentioned this pull request Aug 12, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants