Click here to Skip to main content
15,886,799 members
Articles / Programming Languages / C#

Writing Your First Visual Studio Language Service

Rate me:
Please Sign up or sign in to vote.
4.95/5 (61 votes)
11 Dec 2009CPOL8 min read 233.1K   4K   157  
A guide to writing a language service for Visual Studio using Irony.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TextManager.Interop;
using Microsoft.VisualStudio.Package;

namespace Demo
{
    public class Methods : Microsoft.VisualStudio.Package.Methods
    {
        IList<Method> methods;
        public Methods(IList<Method> methods)
        {
            this.methods = methods;
        }

        public override int GetCount()
        {
            return methods.Count;
        }

        public override string GetName(int index)
        {
            return methods[index].Name;
        }

        public override string GetDescription(int index)
        {
            return methods[index].Description;
        }

        public override string GetType(int index)
        {
            return methods[index].Type;
        }

        public override int GetParameterCount(int index)
        {
            return (methods[index].Parameters == null) ? 0 : methods[index].Parameters.Count;
        }

        public override void GetParameterInfo(int index, int paramIndex, out string name, out string display, out string description)
        {
            Parameter parameter = methods[index].Parameters[paramIndex];
            name = parameter.Name;
            display = parameter.Display;
            description = parameter.Description;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions