Skip to content

Commit

Permalink
Building again
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpar committed Jul 4, 2021
1 parent f1d5126 commit e3e208f
Show file tree
Hide file tree
Showing 37 changed files with 205 additions and 187 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Expand Up @@ -13,7 +13,7 @@

<!-- The version of VS that should be targetted for testing for host agnostic projects. Prefer
the lowest supported Visual Studio version but allow changing via environment variable -->
<VisualStudioTestVersionDefault Condition="'$(VisualStudioTestVersionDefault)' == ''">14.0</VisualStudioTestVersionDefault>
<VisualStudioTestVersionDefault Condition="'$(VisualStudioTestVersionDefault)' == ''">16.0</VisualStudioTestVersionDefault>

<!-- Standard Calculation of NuGet package location -->
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == ''">$(NUGET_PACKAGES)</NuGetPackageRoot> <!-- Respect environment variable if set -->
Expand Down
3 changes: 2 additions & 1 deletion Src/VimApp/VimApp.csproj
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>VimApp</RootNamespace>
<AssemblyName>VimApp</AssemblyName>
<TargetFramework>net472</TargetFramework>
<VsVimIsRunnable>true</VsVimIsRunnable>
<DefineConstants>$(DefineConstants);VS_SPECIFIC_VIM_APP</DefineConstants>
<VisualStudioEditorHostVersion>$(VisualStudioTestVersionDefault)</VisualStudioEditorHostVersion>
</PropertyGroup>
<ItemGroup>
Expand All @@ -30,6 +30,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VimCore\VimCore.fsproj" />
<ProjectReference Include="..\VimTestUtils\VimTestUtils.csproj" />
<ProjectReference Include="..\VimWpf\VimWpf.csproj" />
<Reference Include="Microsoft.VisualStudio.TextManager.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Setup.Configuration.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
Expand Down
1 change: 0 additions & 1 deletion Src/VimApp/VimComponentHost.cs
Expand Up @@ -35,7 +35,6 @@ internal VimComponentHost()

editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));
editorHostFactory.Add(new AssemblyCatalog(typeof(VimKeyProcessor).Assembly));
editorHostFactory.Add(new AssemblyCatalog(typeof(VimComponentHost).Assembly));

_editorHost = editorHostFactory.CreateEditorHost();
_vim = _editorHost.CompositionContainer.GetExportedValue<IVim>();
Expand Down
2 changes: 2 additions & 0 deletions Src/VimCore/AssemblyInfo.fs
Expand Up @@ -11,6 +11,8 @@ open System.Runtime.CompilerServices
[<assembly:InternalsVisibleTo("Vim.UI.Wpf.UnitTest")>]
[<assembly:InternalsVisibleTo("Vim.VisualStudio.Shared.2017.UnitTest")>]
[<assembly:InternalsVisibleTo("Vim.VisualStudio.Shared.2019.UnitTest")>]
// TODO_SHARED this should be deleted
[<assembly:InternalsVisibleTo("VimApp")>]
[<assembly:InternalsVisibleTo("DynamicProxyGenAssembly2")>] // Moq
do()

Expand Up @@ -31,11 +31,8 @@ private sealed class JoinableTaskContextExportProvider : ExportProvider
internal JoinableTaskContextExportProvider()
{
_export = new Export(TypeFullName, GetValue);
#if VS_SPECIFIC_2017 || VS_SPECIFIC_2019
_context = ThreadHelper.JoinableTaskContext;
#else
#pragma warning disable VSSDK005
_context = new JoinableTaskContext(Thread.CurrentThread, new DispatcherSynchronizationContext());
#endif
}

protected override IEnumerable<Export> GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
Expand Down
56 changes: 52 additions & 4 deletions Src/VimEditorHost/EditorHostFactory.cs
Expand Up @@ -15,7 +15,7 @@ namespace Vim.EditorHost
public sealed partial class EditorHostFactory
{
#if VS_SPECIFIC_2015
internal static EditorVersion DefaultEditorVersion => EditorVersion.Vs2017;
internal static EditorVersion DefaultEditorVersion => EditorVersion.Vs2015;
internal static Version VisualStudioVersion => new Version(14, 0, 0, 0);
internal static Version VisualStudioThreadingVersion => new Version(14, 0, 0, 0);
#elif VS_SPECIFIC_2017
Expand Down Expand Up @@ -63,8 +63,34 @@ public void Add(ExportProvider exportProvider)

public CompositionContainer CreateCompositionContainer()
{
var catalog = new AggregateCatalog(_composablePartCatalogList.ToArray());
return new CompositionContainer(catalog, _exportProviderList.ToArray());
var aggregateCatalog = new AggregateCatalog(_composablePartCatalogList.ToArray());
#if DEBUG
DumpExports();
#endif

return new CompositionContainer(aggregateCatalog, _exportProviderList.ToArray());

#if DEBUG
void DumpExports()
{
var exportNames = new List<string>();
foreach (var catalog in aggregateCatalog)
{
foreach (var exportDefinition in catalog.ExportDefinitions)
{
exportNames.Add(exportDefinition.ContractName);
}
}

exportNames.Sort();
var groupedExportNames = exportNames
.GroupBy(x => x)
.Select(x => (Count: x.Count(), x.Key))
.OrderByDescending(x => x.Count)
.Select(x => $"{x.Count} {x.Key}")
.ToList();
}
#endif
}

public EditorHost CreateEditorHost()
Expand All @@ -78,7 +104,29 @@ private void BuildCatalog()
AppendEditorAssemblies(editorAssemblyVersion);
AppendEditorAssembly("Microsoft.VisualStudio.Threading", VisualStudioThreadingVersion);
_exportProviderList.Add(new JoinableTaskContextExportProvider());
_composablePartCatalogList.Add(new AssemblyCatalog(typeof(EditorHostFactory).Assembly));

// Other Exports needed to construct VsVim
var types = new List<Type>()
{
typeof(Implementation.BasicUndo.BasicTextUndoHistoryRegistry),
typeof(Implementation.Misc.BasicObscuringTipManager),
typeof(Implementation.Misc.VimErrorDetector),
#if VS_SPECIFIC_2019
typeof(Implementation.Misc.BasicExperimentationServiceInternal),
typeof(Implementation.Misc.BasicLoggingServiceInternal),
typeof(Implementation.Misc.BasicObscuringTipManager),
#elif VS_SPECIFIC_2017
typeof(Implementation.Misc.BasicLoggingServiceInternal),
typeof(Implementation.Misc.BasicObscuringTipManager),
#elif VS_SPECIFIC_2015

#else
#error Unsupported configuration
#endif

};

_composablePartCatalogList.Add(new TypeCatalog(types));
}

private void AppendEditorAssemblies(Version editorAssemblyVersion)
Expand Down
18 changes: 18 additions & 0 deletions Src/VimEditorHost/EditorSpecificUtil.cs
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Vim.EditorHost
{
public static class EditorSpecificUtil
{
#if VS_SPECIFIC_2015 || VS_SPECIFIC_2017
public const bool HasAsyncCompletion = false;
#elif VS_SPECIFIC_2019 || VS_SPECIFIC_MAC
public const bool HasAsyncCompletion = true;
#else
#error Unsupported configuration
#endif
public const bool HasLegacyCompletion = !HasAsyncCompletion;
}
}
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using Microsoft.VisualStudio.Text;

namespace Vim.UnitTest
namespace Vim.EditorHost
{
/// <summary>
/// Several portions of the Editor code will swallow exceptions from an extension
Expand Down
Expand Up @@ -7,7 +7,7 @@
using Microsoft.VisualStudio.Utilities;
using Vim.Extensions;

namespace Vim.UnitTest.Exports
namespace Vim.EditorHost.Implementation.Misc
{
/// <summary>
/// IVimErrorDetector MEF component. Useful in tracking down errors which are silently
Expand Down Expand Up @@ -129,12 +129,11 @@ void IExtensionErrorHandler.HandleError(object sender, Exception exception)
{
return;
}


#elif VS_SPECIFIC_2017 || VS_SPECIFIC_2015
#else
#error Unsupported configuration
#endif

_errorList.Add(exception);
}

Expand Down
9 changes: 7 additions & 2 deletions Src/VimEditorHost/README.md
@@ -1,5 +1,10 @@
# Vim Editor Host

This is a library designed to make it easy to host `IWpfTextView` instances. This is used in simple
editor test apps and unit tests.
This is a library designed to make it easy to host `IVimBuffer` instances. It facilitates both the
`VimApp` project as well as hosting in the unit tests

This is provided as a shared source project so that the editor behavior can be easily customized with
`#if` calls based on the specific editor we are creating

Logic and helpers here should be minimal. The goal is **only** for hosting the editor and vim

Expand Up @@ -3,15 +3,14 @@
using System.ComponentModel.Composition.Hosting;
using System.Linq;
using System.Text;
using Vim.EditorHost;
using Microsoft.VisualStudio.Text.Classification;
using Vim.UI.Wpf;
using Vim.UnitTest.Mock;
using Microsoft.VisualStudio.Text;

namespace Vim.UnitTest
namespace Vim.EditorHost
{
public sealed class VimEditorHost : EditorHost.EditorHost
public sealed class VimEditorHost : EditorHost
{
private readonly IVim _vim;
private readonly IVimBufferFactory _vimBufferFactory;
Expand Down
6 changes: 5 additions & 1 deletion Src/VimEditorHost/VimEditorHost.projitems
Expand Up @@ -13,9 +13,9 @@
<Compile Include="$(MSBuildThisFileDirectory)EditorHostFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)EditorHostFactory.JoinableTaskContextExportProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)EditorLocatorUtil.cs" />
<Compile Include="$(MSBuildThisFileDirectory)EditorSpecificUtil.cs" />
<Compile Include="$(MSBuildThisFileDirectory)EditorVersion.cs" />
<Compile Include="$(MSBuildThisFileDirectory)EditorVersionUtil.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IBasicUndoHistoryRegistry.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\BasicUndo\BasicUndoHistory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\BasicUndo\BasicUndoHistoryRegistry.cs" />
Expand All @@ -24,6 +24,10 @@
<Compile Include="$(MSBuildThisFileDirectory)Implementation\Misc\BasicLoggingServiceInternal.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\Misc\BasicObscuringTipManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\Misc\BasicWaitIndicator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\Misc\VimErrorDetector.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IVimErrorDetector.cs" />
<Compile Include="$(MSBuildThisFileDirectory)VimEditorHost.cs" />
<Compile Include="$(MSBuildThisFileDirectory)VimTestBase.cs" />
</ItemGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)app.config" />
Expand Down
@@ -1,4 +1,5 @@
using System;
#if VS_UNIT_TEST_HOST
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
Expand Down Expand Up @@ -27,6 +28,7 @@
using Xunit.Sdk;
using Vim.Extensions;
using Vim.VisualStudio.Specific;
using Vim.EditorHost.Implementation.Misc;

namespace Vim.UnitTest
{
Expand Down Expand Up @@ -560,7 +562,6 @@ private static VimEditorHost GetOrCreateVimEditorHost()
typeof(TestableKeyboardDevice),
typeof(TestableMouseDevice),
typeof(global::Vim.UnitTest.Exports.VimHost),
typeof(VimErrorDetector),
typeof(DisplayWindowBrokerFactoryService),
typeof(AlternateKeyUtil),
typeof(OutlinerTaggerProvider)
Expand Down Expand Up @@ -628,3 +629,4 @@ public static IEnumerable<object[]> SelectionOptions
}
}
}
#endif
Expand Up @@ -84,9 +84,9 @@ private FSharpOption<IWordCompletionSession> CreateWordCompletionSession(ITextVi
#else
#error Unsupported configuration
#endif


#region IWordCompletionSessionFactory


FSharpOption<IWordCompletionSession> IWordCompletionSessionFactory.CreateWordCompletionSession(ITextView textView, SnapshotSpan wordSpan, IEnumerable<string> wordCollection, bool isForward)
{
return CreateWordCompletionSession(textView, wordSpan, wordCollection, isForward);
Expand Down
1 change: 1 addition & 0 deletions Src/VimSpecific/VimSpecificUtil.cs
Expand Up @@ -4,6 +4,7 @@

namespace Vim.VisualStudio.Specific
{
// TODO_SHARED this type needs to be re-thought a lot
internal static class VimSpecificUtil
{
#if VS_SPECIFIC_2015 || VS_SPECIFIC_2017
Expand Down
4 changes: 2 additions & 2 deletions Src/VimTestUtils/Exports/OutlinerTaggerProvider.cs
Expand Up @@ -3,19 +3,19 @@
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using Vim.EditorHost;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;

namespace Vim.UnitTest.Exports
{
// TODO_SHARED move to editor host and make this internal again
[Export(typeof(ITaggerProvider))]
[ContentType("any")]
[TextViewRole(PredefinedTextViewRoles.Structured)]
[TagType(typeof(OutliningRegionTag))]
internal sealed class OutlinerTaggerProvider : ITaggerProvider
public sealed class OutlinerTaggerProvider : ITaggerProvider
{
ITagger<T> ITaggerProvider.CreateTagger<T>(ITextBuffer textBuffer)
{
Expand Down
Expand Up @@ -14,7 +14,7 @@

namespace Vim.EditorHost
{
public static class Extensions
public static partial class Extensions
{
#region ITextBufferFactoryService

Expand Down Expand Up @@ -108,11 +108,6 @@ public static SnapshotPoint GetCaretPoint(this ITextView textView)
return textView.Caret.Position.BufferPosition;
}

public static VirtualSnapshotPoint GetCaretVirtualPoint(this ITextView textView)
{
return textView.Caret.Position.VirtualBufferPosition;
}

public static ITextSnapshotLine GetCaretLine(this ITextView textView)
{
return textView.Caret.Position.BufferPosition.GetContainingLine();
Expand Down Expand Up @@ -271,15 +266,6 @@ public static NormalizedSnapshotSpanCollection GetTaggerExtent(this ITextSnapsho

#region SnapshotPoint

/// <summary>
/// Get the column that this SnapshotPoint occupies
/// </summary>
public static int GetColumn(this SnapshotPoint point)
{
var line = point.GetContainingLine();
return point.Position - line.Start.Position;
}

public static SnapshotSpan GetSpan(this SnapshotPoint point, int length)
{
return new SnapshotSpan(point, length);
Expand Down
9 changes: 0 additions & 9 deletions Src/VimTestUtils/Mock/Extensions.cs
Expand Up @@ -8,7 +8,6 @@
using Moq;
using Moq.Language.Flow;
using Vim.Extensions;
using Vim.EditorHost;

namespace Vim.UnitTest.Mock
{
Expand Down Expand Up @@ -142,14 +141,6 @@ public static void SetupCommandVisual(this Mock<ICommandUtil> commandUtil, Visua
}
}

public static void SetupPut(this Mock<ICommonOperations> operations, ITextBuffer textBuffer, params string[] newText)
{
operations
.Setup(x => x.Put(It.IsAny<SnapshotPoint>(), It.IsAny<StringData>(), It.IsAny<OperationKind>()))
.Callback(() => textBuffer.SetText(newText))
.Verifiable();
}

public static void SetupProcess(this Mock<INormalMode> mode, string input)
{
var count = 0;
Expand Down

0 comments on commit e3e208f

Please sign in to comment.