Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 8a06659

Browse files
committed
Fix dependencies in InlineCommentMarginProvider
Lazily load `IPullRequestSessionManager` in `InlineCommentMarginProvider` to prevent loading the kitchen sink on VS startup.
1 parent 8a9c8aa commit 8a06659

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/GitHub.InlineReviews/InlineCommentMarginProvider.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,43 @@ internal sealed class InlineCommentMarginProvider : IWpfTextViewMarginProvider
2828
const string MarginName = "InlineComment";
2929
const string MarginPropertiesName = "Indicator Margin"; // Same background color as Glyph margin
3030

31+
readonly IGitHubServiceProvider serviceProvider;
3132
readonly IEditorFormatMapService editorFormatMapService;
3233
readonly IViewTagAggregatorFactoryService tagAggregatorFactory;
3334
readonly IInlineCommentPeekService peekService;
34-
readonly IPullRequestSessionManager sessionManager;
3535
readonly IPackageSettings packageSettings;
36+
IPullRequestSessionManager sessionManager;
3637

3738
[ImportingConstructor]
3839
public InlineCommentMarginProvider(
40+
IGitHubServiceProvider serviceProvider,
3941
IEditorFormatMapService editorFormatMapService,
4042
IViewTagAggregatorFactoryService tagAggregatorFactory,
4143
IInlineCommentPeekService peekService,
42-
IPullRequestSessionManager sessionManager,
4344
IPackageSettings packageSettings)
4445
{
46+
this.serviceProvider = serviceProvider;
4547
this.editorFormatMapService = editorFormatMapService;
4648
this.tagAggregatorFactory = tagAggregatorFactory;
4749
this.peekService = peekService;
48-
this.sessionManager = sessionManager;
4950
this.packageSettings = packageSettings;
5051
}
5152

53+
IPullRequestSessionManager SessionManager
54+
{
55+
get
56+
{
57+
// Lazily load the pull request session manager to prevent all of our assemblies
58+
// being loaded on VS startup.
59+
if (sessionManager == null)
60+
{
61+
sessionManager = serviceProvider.GetService<IPullRequestSessionManager>();
62+
}
63+
64+
return sessionManager;
65+
}
66+
}
67+
5268
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin parent)
5369
{
5470
if (IsMarginDisabled(wpfTextViewHost))
@@ -95,7 +111,7 @@ void TrackCommentGlyph(IWpfTextViewHost host, UIElement marginElement)
95111

96112
bool IsMarginVisible(ITextBuffer buffer)
97113
{
98-
if (sessionManager.GetTextBufferInfo(buffer) != null)
114+
if (SessionManager.GetTextBufferInfo(buffer) != null)
99115
{
100116
return true;
101117
}

0 commit comments

Comments
 (0)