Editor Registration Enhancements编辑注册增强功能
Since its creation, Visual Studio has supported custom editor registration where an editor can declare its affinity for specific extensions (for example, .xaml and .rc), or that it is suitable for any extension (.). Starting in Visual Studio 2019 version 16.1, we broaden the support for editor registration.自创建以来,Visual Studio 就支持自定义编辑器注册,其中编辑器可以声明其与特定扩展名(例如 .xaml 和 .rc)的关联,或者它适用于任何扩展名 (.)。从 Visual Studio 2019 版本 16.1 开始,我们扩大了对编辑器注册的支持。
Filenames文件名
In addition to, or instead of, registering support for a particular file extension, an editor can register that it supports specific filenames by applying the new ProvideEditorFilename
attribute to the editor's package.除了注册对特定文件扩展名的支持之外,或者代替注册对特定文件扩展名的支持,编辑器可以通过将新的 ProvideEditorFilename 属性应用于编辑器的包来注册它支持特定文件名。
For example, an editor that supports all .json files would apply this ProvideEditorExtension
attribute to its package:例如,支持所有 .json 文件的编辑器会将此 ProvideEditorExtension 属性应用于其包:
C#Copy
C# 复制
[ProvideEditorExtension(typeof(MyEditor), ".json", MyEditor.Priority)]
Starting with 16.1, if MyEditor only supports a couple of well-known .json files, it can instead apply these ProvideEditorFilename
attributes to its package:从 16.1 开始,如果 MyEditor 只支持几个众所周知的 .json 文件,它可以将这些 ProvideEditorFilename 属性应用到它的包中:
C#Copy
C# 复制
[ProvideEditorFilename(typeof(MyEditor), "particular.json", MyEditor.Priority)]
[ProvideEditorFilename(typeof(MyEditor), "special.json", MyEditor.Priority)]