Skip to content

Commit 203c1ef

Browse files
committed
Merge branch 'master' into feature/fonts-and-colors
2 parents 6496bcc + 2f8d335 commit 203c1ef

File tree

18 files changed

+445
-167
lines changed

18 files changed

+445
-167
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Create a file called **nuget.config** in your solution folder, and paste in the
2626
<?xml version="1.0" encoding="utf-8"?>
2727
<configuration>
2828
<packageSources>
29-
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
29+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
3030
<add key="Toolkit CI" value="https://ci.appveyor.com/nuget/community-visualstudio-toolkit" />
3131
</packageSources>
3232
</configuration>

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ deploy:
3737
- provider: NuGet
3838
artifact: /package/
3939
api_key:
40-
secure: 4z/fHvSKQx2UG4a1aMzIN53MmzruQxIFtp91QzSAcSoEfuvNef7nDM2n8iBduo6u
40+
secure: TCK4iz4NnVAK6iAZbpocgig7CBxDTywbtFXcj61NfCr2aEHkT1mPuSj7/yLEkkp9
4141
on:
4242
branch: master
4343
appveyor_repo_commit_message_extended: /\[release\]/

demo/VSSDK.TestExtension/MEF/HighlightWord.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,25 @@
44
using Community.VisualStudio.Toolkit;
55
using System.ComponentModel.Composition;
66
using Microsoft.VisualStudio.Text.Editor;
7-
7+
using Microsoft.VisualStudio.Text.Classification;
8+
using System.Windows.Media;
89
namespace TestExtension.MEF
910
{
11+
12+
[Export(typeof(EditorFormatDefinition))]
13+
[Name("MarkerFormatDefinition/HighlightWordFormatDefinition")]
14+
[UserVisible(true)]
15+
internal class HighlightWordFormatDefinition : MarkerFormatDefinition
16+
{
17+
public HighlightWordFormatDefinition()
18+
{
19+
this.BackgroundColor = Colors.LightBlue;
20+
this.ForegroundColor = Colors.DarkBlue;
21+
this.DisplayName = "Highlight Word";
22+
this.ZOrder = 5;
23+
}
24+
}
25+
1026
/// <summary>
1127
/// This class demonstrates a HighlightWord tagger for text files
1228
/// and it only highlights whole words starting with a Letter

demo/VSSDK.TestExtension/ToolWindows/RunnerWindow.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.ComponentModel.Design;
3+
using System.Diagnostics;
34
using System.Runtime.InteropServices;
45
using System.Threading;
56
using System.Threading.Tasks;
@@ -30,6 +31,13 @@ public Pane()
3031
{
3132
BitmapImageMoniker = KnownMonikers.StatusInformation;
3233
ToolBar = new CommandID(PackageGuids.TestExtension, PackageIds.RunnerWindowToolbar);
34+
WindowFrameAvailable += (_, _) => Debug.WriteLine("RunnerWindow frame is now available");
35+
}
36+
37+
public override void OnToolWindowCreated()
38+
{
39+
base.OnToolWindowCreated();
40+
GetWindowFrame().OnShow += (_, args) => Debug.WriteLine($"RunnerWindow state changed: {args.Reason}");
3341
}
3442
}
3543
}

src/toolkit/Community.VisualStudio.Toolkit.Shared/Commands/Commands.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ public CommandInterceptor(CommandID cmd, Func<CommandProgression> func)
140140

141141
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
142142
{
143+
if (prgCmds[0].cmdID == _cmd.ID)
144+
{
145+
prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_ENABLED | (uint)OLECMDF.OLECMDF_SUPPORTED;
146+
return VSConstants.S_OK;
147+
}
143148
return (int)Microsoft.VisualStudio.OLE.Interop.Constants.OLECMDERR_E_NOTSUPPORTED;
144149
}
145150

src/toolkit/Community.VisualStudio.Toolkit.Shared/Documents/DocumentView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ internal DocumentView(IVsWindowFrame nativeFrame)
4242
public WindowFrame? WindowFrame { get; }
4343

4444
/// <summary>
45-
/// The text view loaded int he window frame.
45+
/// The text view loaded in the window frame.
4646
/// </summary>
4747
public IWpfTextView? TextView { get; }
4848

src/toolkit/Community.VisualStudio.Toolkit.Shared/ExtensionMethods/AsyncPackageExtensions.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Reflection;
@@ -43,30 +43,6 @@ public static async Task<IEnumerable<object>> RegisterCommandsAsync(this AsyncPa
4343
return commands;
4444
}
4545

46-
/// <summary>
47-
/// Automatically calls the <see cref="BaseCommand{T}.InitializeAsync(AsyncPackage)"/> method for every command that has the <see cref="CommandAttribute"/> applied.
48-
/// </summary>
49-
/// <param name="package"></param>
50-
/// <param name="assemblies"></param>
51-
/// <returns></returns>
52-
public static void RegisterToolWindows(this AsyncPackage package, params Assembly[] assemblies)
53-
{
54-
Type baseToolWindowType = typeof(BaseToolWindow<>);
55-
IEnumerable<Type> toolWindowTypes = IncludePackageAssembly(assemblies, package).SelectMany(x => x.GetTypes())
56-
.Where(x =>
57-
!x.IsAbstract
58-
&& x.IsAssignableToGenericType(baseToolWindowType));
59-
60-
foreach (Type toolWindowtype in toolWindowTypes)
61-
{
62-
MethodInfo initializeMethod = toolWindowtype.GetMethod(
63-
"Initialize",
64-
BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
65-
66-
initializeMethod.Invoke(null, new object[] { package });
67-
}
68-
}
69-
7046
/// <summary>
7147
/// Finds, creates and registers <see cref="BaseFontAndColorProvider"/> implementations.
7248
/// </summary>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
using Microsoft.VisualStudio.Shell;
6+
7+
namespace Community.VisualStudio.Toolkit
8+
{
9+
/// <summary>
10+
/// Extensions for an <see cref="ToolkitPackage"/>
11+
/// </summary>
12+
public static class ToolkitPackageExtensions
13+
{
14+
/// <summary>
15+
/// Automatically calls the <see cref="BaseToolWindow{T}.Initialize(ToolkitPackage)"/>
16+
/// method for every <see cref="BaseToolWindow{T}"/> in the package or provided assemblies.
17+
/// </summary>
18+
/// <param name="package">The package that contains the tool windows to register.</param>
19+
/// <param name="assemblies">The additional assemblies to look for tool windows in.</param>
20+
public static void RegisterToolWindows(this ToolkitPackage package, params Assembly[] assemblies)
21+
{
22+
List<Assembly> assembliesList = assemblies.ToList();
23+
Assembly packageAssembly = package.GetType().Assembly;
24+
if (!assembliesList.Contains(packageAssembly))
25+
assembliesList.Add(packageAssembly);
26+
27+
Type baseToolWindowType = typeof(BaseToolWindow<>);
28+
IEnumerable<Type> toolWindowTypes = assembliesList.SelectMany(x => x.GetTypes())
29+
.Where(x =>
30+
!x.IsAbstract
31+
&& x.IsAssignableToGenericType(baseToolWindowType));
32+
33+
foreach (Type? toolWindowtype in toolWindowTypes)
34+
{
35+
MethodInfo initializeMethod = toolWindowtype.GetMethod(
36+
"Initialize",
37+
BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
38+
39+
initializeMethod.Invoke(null, new object[] { package });
40+
}
41+
}
42+
}
43+
}

src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/ContentTypes.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class ContentTypes
2424
public const string Json = "JSON";
2525
public const string Xaml = "XAML";
2626
public const string Xml = "XML";
27+
public const string Repl = "REPL";
28+
public const string Output = "Output";
2729
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
2830
}
2931
}

src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/OutputWindowPane.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,18 @@ public void WriteLine(string value)
236236
});
237237
}
238238

239+
/// <summary>
240+
/// Writes the given text to the Output window pane.
241+
/// </summary>
242+
/// <param name="value">The text value to write.</param>
243+
public void Write(string value)
244+
{
245+
ThreadHelper.JoinableTaskFactory.Run(async () =>
246+
{
247+
await WriteAsync(value);
248+
});
249+
}
250+
239251
/// <summary>
240252
/// Writes a new line to the Output window pane.
241253
/// </summary>
@@ -249,6 +261,15 @@ public Task WriteLineAsync()
249261
/// </summary>
250262
/// <param name="value">The text value to write. May be an empty string, in which case a newline is written.</param>
251263
public async Task WriteLineAsync(string value)
264+
{
265+
await WriteAsync(value + Environment.NewLine);
266+
}
267+
268+
/// <summary>
269+
/// Writes the given text to the Output window pane.
270+
/// </summary>
271+
/// <param name="value">The text value to write.</param>
272+
public async Task WriteAsync(string value)
252273
{
253274
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
254275

@@ -261,11 +282,11 @@ public async Task WriteLineAsync(string value)
261282

262283
if (_pane is IVsOutputWindowPaneNoPump nopump)
263284
{
264-
nopump.OutputStringNoPump(value + Environment.NewLine);
285+
nopump.OutputStringNoPump(value);
265286
}
266287
else
267288
{
268-
ErrorHandler.ThrowOnFailure(_pane.OutputStringThreadSafe(value + Environment.NewLine));
289+
ErrorHandler.ThrowOnFailure(_pane.OutputStringThreadSafe(value));
269290
}
270291
}
271292

0 commit comments

Comments
 (0)