I am trying to add color to the visual studio build output. So I am trying to get classifier of IClassifierProvider. But GetClassifier() is not getting called. What could be the problem? Source code sample is given below. When I am trying with VSColorOutput extension it getting initiated. Please tell me what i am missing?

 [ContentType("output")]
[Export(typeof(IClassifierProvider))]
public class OutputClassifierProvider : IClassifierProvider
{
    [Import]
    internal IClassificationTypeRegistryService ClassificationRegistry;

    [Import]
    internal SVsServiceProvider ServiceProvider;

    public static OutputClassifier OutputClassifier { get; private set; }

    public IClassifier GetClassifier(ITextBuffer buffer)
    {
        MessageBox.Show("asd");
        try
        {
            if (OutputClassifier == null)
            {
                OutputClassifier = new OutputClassifier();

            }
        }
        catch (Exception ex)
        {                
            throw;
        }
        return OutputClassifier;
    }
}
public class OutputClassifier: IClassifier
{
    public event EventHandler<ClassificationChangedEventArgs> ClassificationChanged;

    public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
    {
            return new List<ClassificationSpan>();
    }
}

Vsix manifest

<?xml version="1.0" encoding="utf-8"?>
<Vsix xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2010">
  <Identifier Id="3ac9d6e9-a3dc-4a27-a048-f4bb7fe5889b">
    <Name>Sample</Name>
    <Author>Company</Author>
    <Version>1.0</Version>
    <Description xml:space="preserve">It conatains set of features which will ease the life of Atmel Studio user.</Description>
    <Locale>1033</Locale>
    <InstalledByMsi>false</InstalledByMsi>
    <SupportedProducts>      
      <VisualStudio Version="10.0">
        <Edition>Pro</Edition>
      </VisualStudio>
    </SupportedProducts>
    <SupportedFrameworkRuntimeEdition MinVersion="4.0" MaxVersion="4.0" />
  </Identifier>
  <References>
    <Reference Id="Microsoft.VisualStudio.MPF" MinVersion="10.0">
      <Name>Visual Studio MPF</Name>
    </Reference>
  </References>

  <Content>
    <VsPackage>XFeatures.pkgdef</VsPackage>
  </Content>
</Vsix>
有帮助吗?

解决方案

Thanks Jason Malinowski I analyzed the manifest code and found MEF Content is missing there. After adding MEF to content tag, it is working now.

 <Content>
    <VsPackage>|%CurrentProject%;PkgdefProjectOutputGroup|</VsPackage>
    <MefComponent>|%CurrentProject%|</MefComponent>
  </Content>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top