c# - VS SDK ContentType does not work -
i trying include custom language back upwards visual studio.
to start with, need have gotodefinition
support. , struggling context menu include command.
i have defined contenttypedefinition
, have included fileextensiontocontenttypedefinition
such as:
internal sealed class gaugefilecontenttype { [export] [name("gauge")] [basedefinition("code")] internal static contenttypedefinition gaugecontenttypedefinition = null; [export] [fileextension(".spec")] [contenttype("gauge")] internal static fileextensiontocontenttypedefinition gaugefileextensiondefinition = null; }
now, despite this, on debugging, see dte.activedocument.type
text
, despite me adding [basedefinition('code')]
attribute. missing here?
are above definitions plenty tell visual studio bring context menu code?
i using visual studio 2013 ultimate.
after few days of head banging, managed figure out way.
i using experimental instance debugging, , did not clean , reinstall extension, , visual studio continued treat contenttype
'plain text', since had originally.
when build vsix , installed, opened same file in new instance of visual studio, brought right context menu.
however, brought out more wanted (i.e run unit tests
resharper). did more digging up.
in order ensure visual studio can handle command, checks calling iolecommandtarget.querystatus
method.
all had set commandflag (uint)olecmdf.olecmdf_enabled | (uint)olecmdf.olecmdf_supported
, homecoming vsconstants.s_ok
when cmdid
vsconstants.vsstd97cmdid.gotodefn
.
the final method looks this:
public int querystatus(ref guid pguidcmdgroup, uint ccmds, olecmd[] prgcmds, intptr pcmdtext) { if ((vsconstants.vsstd97cmdid)prgcmds[0].cmdid == vsconstants.vsstd97cmdid.gotodefn) { prgcmds[0].cmdf = (uint)olecmdf.olecmdf_enabled | (uint)olecmdf.olecmdf_supported; homecoming vsconstants.s_ok; } homecoming next.querystatus(pguidcmdgroup, ccmds, prgcmds, pcmdtext); }
c# visual-studio-extensions envdte visual-studio-sdk
No comments:
Post a Comment