diff --git a/AvaloniaVS.Shared/AvaloniaVS.Shared.projitems b/AvaloniaVS.Shared/AvaloniaVS.Shared.projitems
index a9be4040..4b375241 100644
--- a/AvaloniaVS.Shared/AvaloniaVS.Shared.projitems
+++ b/AvaloniaVS.Shared/AvaloniaVS.Shared.projitems
@@ -40,6 +40,7 @@
+
@@ -101,5 +102,6 @@
+
\ No newline at end of file
diff --git a/AvaloniaVS.Shared/SuggestedActions/Actions/Base/BaseSuggestedAction.cs b/AvaloniaVS.Shared/SuggestedActions/Actions/Base/BaseSuggestedAction.cs
new file mode 100644
index 00000000..6a87c820
--- /dev/null
+++ b/AvaloniaVS.Shared/SuggestedActions/Actions/Base/BaseSuggestedAction.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.VisualStudio.Imaging.Interop;
+using Microsoft.VisualStudio.Language.Intellisense;
+
+namespace AvaloniaVS.Shared.SuggestedActions.Actions.Base
+{
+ internal class BaseSuggestedAction
+ {
+ public bool HasActionSets { get; }
+
+ public ImageMoniker IconMoniker { get; }
+
+ public string IconAutomationText { get; }
+
+ public string InputGestureText { get; }
+
+ public bool HasPreview => true;
+
+ public void Dispose()
+ {
+ }
+
+ public bool TryGetTelemetryId(out Guid telemetryId)
+ {
+ telemetryId = Guid.Empty;
+ return false;
+ }
+
+ public Task> GetActionSetsAsync(CancellationToken cancellationToken)
+ {
+ return Task.FromResult>(null);
+ }
+ }
+}
diff --git a/AvaloniaVS.Shared/SuggestedActions/Actions/MissingAliasSuggestedAction.cs b/AvaloniaVS.Shared/SuggestedActions/Actions/MissingAliasSuggestedAction.cs
index 985b924e..149fb880 100644
--- a/AvaloniaVS.Shared/SuggestedActions/Actions/MissingAliasSuggestedAction.cs
+++ b/AvaloniaVS.Shared/SuggestedActions/Actions/MissingAliasSuggestedAction.cs
@@ -1,10 +1,9 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using AvaloniaVS.Shared.SuggestedActions.Actions.Base;
using AvaloniaVS.Shared.SuggestedActions.Helpers;
-using Microsoft.VisualStudio.Imaging.Interop;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Differencing;
@@ -12,74 +11,46 @@
namespace AvaloniaVS.Shared.SuggestedActions.Actions
{
- internal class MissingAliasSuggestedAction : ISuggestedAction
+ internal class MissingAliasSuggestedAction : BaseSuggestedAction, ISuggestedAction
{
private readonly ITrackingSpan _span;
private readonly ITextSnapshot _snapshot;
private readonly string _targetClassName;
- private readonly KeyValuePair _targetClassMetadata;
private readonly string _namespaceAlias;
private readonly IWpfDifferenceViewerFactoryService _diffFactory;
private readonly IDifferenceBufferFactoryService _diffBufferFactory;
private readonly ITextBufferFactoryService _bufferFactory;
- private readonly IReadOnlyDictionary _inverseNamespaces;
private readonly ITextViewRoleSet _previewRoleSet;
public MissingAliasSuggestedAction(ITrackingSpan span, IWpfDifferenceViewerFactoryService diffFactory, IDifferenceBufferFactoryService diffBufferFactory, ITextBufferFactoryService bufferFactory, ITextEditorFactoryService textEditorFactoryService, IReadOnlyDictionary inverseNamespaces)
{
- _inverseNamespaces = inverseNamespaces;
_span = span;
- _snapshot = span.TextBuffer.CurrentSnapshot;
+ _snapshot = _span.TextBuffer.CurrentSnapshot;
_targetClassName = _span.GetText(_snapshot);
- _targetClassMetadata = _inverseNamespaces.FirstOrDefault(x => x.Key.Split('.').Last() == _targetClassName);
- _namespaceAlias = _targetClassMetadata.Value.Split(':').Last().Split('.').Last();
+ var targetClassMetadata = inverseNamespaces.FirstOrDefault(x => x.Key.Split('.').Last() == _targetClassName);
+ _namespaceAlias = targetClassMetadata.Value.Split(':').Last().Split('.').Last();
_diffFactory = diffFactory;
_diffBufferFactory = diffBufferFactory;
_bufferFactory = bufferFactory;
_previewRoleSet = textEditorFactoryService.CreateTextViewRoleSet(PredefinedTextViewRoles.Analyzable);
- DisplayText = $"Use {_namespaceAlias.ToLower()} ({_targetClassMetadata.Value})";
+ DisplayText = $"Use {_namespaceAlias.ToLower()} ({targetClassMetadata.Value})";
}
- public bool HasActionSets { get; }
-
public string DisplayText { get; }
- public ImageMoniker IconMoniker { get; }
-
- public string IconAutomationText { get; }
-
- public string InputGestureText { get; }
-
- public bool HasPreview => true;
-
- public void Dispose()
- {
- }
-
- public Task> GetActionSetsAsync(CancellationToken cancellationToken)
- {
- return Task.FromResult>(null);
- }
-
public Task