Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:46:58+00:00 2026-05-28T01:46:58+00:00

I would like to create a Visual Studio addin which can identify if the

  • 0

I would like to create a Visual Studio addin which can identify if the caret currently is inside a method, class or namespace block, i.e. if the caret moves, the addin should be able to note down the status that the caret is currently inside so-and-so element.

If this can be extended to any C# block enclosed in curly braces, e.g. properties, that would be excellent.

Although I have checked for similar questions, please let me know if this is a repeat question so I can mark it accordingly. If other VS Addin-related questions are obviously helpful here, please let me know that too.

Basically, I would like to know what techniques we can use and how this can be accomplished.

EDIT: I guess the short answer to get started is:

  • Get Visual Studio 2010 SDK SP1
  • Probably use the “Extensibility” project template “Editor Text Adornment” or some other such template.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:46:59+00:00Added an answer on May 28, 2026 at 1:46 am

    Actually, I think the first thing you need to do is to judge how many methods or properties in your class and what’s the position of them. After you obtain those information. The next step you need to do is to judge what’s the current cursor position now. Then you can do a compare with those methods information you obtained. Until now, you can get which method that your cursor in. This is a ballpark solution that I find.

    Let’s talk about some technical details:

    1.How to get the positions of methods and properties?

    you can use NRefacotry or CSParser to do this (I use NRefactory to finish my requirement)

    2.How to get cursor position?

    there is a method named “GetCaretPos” in IVsTextView. You can get ActiveTextView through TextManager. Then you could use “GetCaretPos” method. Here are some codes may help you.

        public static IVsTextManager TextManager
        {
            get
            {
                if (textManager == null)
                {
                    Object obj = Package.GetGlobalService(typeof(SVsTextManager));
                    if (obj == null)
                    {
                        throw new ArgumentException("get textmanager failed in VSTextView");
                    }
                    textManager = obj as IVsTextManager;
                }
                return textManager;
            }
        }
    
    
        public static IVsTextView ActiveTextView
        {
            get
            {
                IVsTextView activeView = null;
                if (TextManager != null)
                {
                    TextManager.GetActiveView(1, activeTextBuffer, out activeView);
                }
                return activeView;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a simple designer which looks like visual studio. Specifically,
Hi I would like to create a Visual Studio snippet that I can have
I would like to create a visual effect when an item in a listbox
How do you create a desktop application using C# that would look like Visual
I would like to create a database backed interactive AJAX webapp which has a
I want to create a Visual Studio 2010 Project Template, which is essentially a
I have a custom list definition created via visual studio 2010. I would like
I would like to create a compiled query which uses reusable where predicates. An
I would like create my own collection that has all the attributes of python
I would like create a web service in ASP.Net 2.0 that will supports JSON.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.