未验证 提交 cc3b78fe 编写于 作者: J Jason Malinowski 提交者: GitHub

Merge pull request #23121 from jasonmalinowski/add-version-info-to-about-screen

Add the Roslyn version string into Help > About
......@@ -15,6 +15,7 @@
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.CodeAnalysis.Host;
using Microsoft.VisualStudio.LanguageServices.Utilities;
// NOTE(DustinCa): The EditorFactory registration is in VisualStudioComponents\CSharpPackageRegistration.pkgdef.
// The reason for this is because the ProvideEditorLogicalView does not allow a name value to specified in addition to
......@@ -28,6 +29,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService
// (See vsproject\cool\coolpkg\pkg\VCSharp_Proj_System_Reg.pkgdef for an example).
[Guid(Guids.CSharpPackageIdString)]
[PackageRegistration(UseManagedResourcesOnly = true)]
[ProvideRoslynVersionRegistration(Guids.CSharpPackageIdString, "Microsoft Visual C#", productNameResourceID: 116, detailsResourceID: 117)]
[ProvideLanguageExtension(typeof(CSharpLanguageService), ".cs")]
[ProvideLanguageService(Guids.CSharpLanguageServiceIdString, "CSharp", languageResourceID: 101, RequestStockColors = true, ShowDropDownOptions = true)]
......
......@@ -215,4 +215,12 @@
<value>Naming Style;Name Styles;Naming Rule;Naming Conventions</value>
<comment>C# Naming Style options page keywords</comment>
</data>
<data name="116" xml:space="preserve">
<value>C# Tools</value>
<comment>Help &gt; About</comment>
</data>
<data name="117" xml:space="preserve">
<value>C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.</value>
<comment>Help &gt; About</comment>
</data>
</root>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Shell;
namespace Microsoft.VisualStudio.LanguageServices.Utilities
{
/// <summary>
/// Adds information to Help &gt; About screen showing the version of the Roslyn package.
/// </summary>
internal sealed class ProvideRoslynVersionRegistration : RegistrationAttribute
{
private readonly string _packageGuidString;
private readonly string _productName;
private readonly int _productNameResourceID;
private readonly int _detailsResourceID;
public ProvideRoslynVersionRegistration(string packageGuidString, string productName, int productNameResourceID, int detailsResourceID)
{
_packageGuidString = packageGuidString;
_productName = productName;
_productNameResourceID = productNameResourceID;
_detailsResourceID = detailsResourceID;
}
private string GetKeyName()
{
return "InstalledProducts\\" + _productName;
}
public override void Register(RegistrationContext context)
{
// Fetch the version of this build. As a reminder, this code runs during the build process, not at runtime -- it's
// ran by the CreatPkgDef.exe tool by reflecting over built assembly and invoking this method.
var version = FileVersionInfo.GetVersionInfo(typeof(ProvideRoslynVersionRegistration).Assembly.Location);
using (var key = context.CreateKey(GetKeyName()))
{
key.SetValue(null, "#" + _productNameResourceID);
key.SetValue("Package", Guid.Parse(_packageGuidString).ToString("B"));
key.SetValue("PID", version.ProductVersion);
key.SetValue("ProductDetails", "#" + _detailsResourceID);
key.SetValue("UseInterface", false);
key.SetValue("UseVSProductID", false);
}
}
public override void Unregister(RegistrationContext context)
{
context.RemoveKey(GetKeyName());
}
}
}
......@@ -9,6 +9,7 @@ Imports Microsoft.VisualStudio.LanguageServices.CSharp.Options.Formatting
Imports Microsoft.VisualStudio.LanguageServices.Implementation
Imports Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService
Imports Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
Imports Microsoft.VisualStudio.LanguageServices.Utilities
Imports Microsoft.VisualStudio.LanguageServices.VisualBasic.ObjectBrowser
Imports Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
Imports Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim
......@@ -38,6 +39,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic
<Guid(Guids.VisualBasicPackageIdString)>
<PackageRegistration(UseManagedResourcesOnly:=True)>
<ProvideRoslynVersionRegistration(Guids.VisualBasicPackageIdString, "Microsoft Visual Basic", 113, 114)>
<ProvideLanguageExtension(GetType(VisualBasicLanguageService), ".bas")>
<ProvideLanguageExtension(GetType(VisualBasicLanguageService), ".cls")>
<ProvideLanguageExtension(GetType(VisualBasicLanguageService), ".ctl")>
......
......@@ -186,4 +186,12 @@
<value>Change completion list settings;Pre-select most recently used member</value>
<comment>IntelliSense options page keywords</comment>
</data>
<data name="114" xml:space="preserve">
<value>Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.</value>
<comment>Help &gt; About</comment>
</data>
<data name="113" xml:space="preserve">
<value>Visual Basic Tools</value>
<comment>Help &gt; About</comment>
</data>
</root>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册