ssw*_*qaa 2 visual-studio vsix visual-studio-extensions
我想创建扩展,当我将鼠标悬停在文本上时,该扩展允许显示自定义消息。
例如,“test-text”应该给出工具提示“OK”,而不是当前的“ITrackin...”
我试图遵循https://learn.microsoft.com/en-us/visualstudio/extensibility/walkthrough-displaying-quickinfo-tooltips?view=vs-2019 但人们说它不起作用,而且还有很长的路要走做这个。
Lance Li-MSFT 发送的示例确实很有帮助,但为了使其正常工作,我必须花费一些时间。
\n重要步骤:
\n<Assets>\n ...\n <Asset Type = "Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" />\n</Assets>\nRun Code Online (Sandbox Code Playgroud)\nLineAsyncQuickInfoSourceProvider.cs
\n它仅用于显示快速信息/工具提示。
\n<Assets>\n ...\n <Asset Type = "Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" />\n</Assets>\nRun Code Online (Sandbox Code Playgroud)\nLineAsyncQuickInfoSource.cs
\n在这里您可以自定义您想要显示的内容。
\nusing Microsoft.VisualStudio.Language.Intellisense;\nusing Microsoft.VisualStudio.Text;\nusing Microsoft.VisualStudio.Utilities;\nusing System.ComponentModel.Composition;\n\nnamespace JSONExtension\n{\n [Export(typeof(IAsyncQuickInfoSourceProvider))]\n [Name("Line Async Quick Info Provider")]\n [ContentType("any")]\n [Order]\n internal sealed class LineAsyncQuickInfoSourceProvider : IAsyncQuickInfoSourceProvider\n {\n public IAsyncQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer) //creates instance of LineAsyncQuickInfoSource for displaying Quick Info\n { \n return textBuffer.Properties.GetOrCreateSingletonProperty(() => new LineAsyncQuickInfoSource(textBuffer)); //this ensures only one instance per textbuffer is created\n }\n }\n}\n\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
2232 次 |
| 最近记录: |