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 8236219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:04:31+00:00 2026-06-07T19:04:31+00:00

I’m trying to find a way to write a visual studio thing, or use

  • 0

I’m trying to find a way to write a visual studio “thing”, or use a tool out there, that allows me to parse each line so I can add custom code around other code that I would be checking with my own algorithm.

Basically, I want to have a readtext of the current file from the visual studio code editor, and then replace it with the new verson with my modified code.

Looked at resharper, macros, can’t figure out a way to do this and I dont want to have to copy all code from a file, paste it into a windows application form that I would write,and then copy paste back. Any ideas?

Thanks

  • 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-06-07T19:04:32+00:00Added an answer on June 7, 2026 at 7:04 pm

    I would suggest using Roslyn for this task. It provides the facilities to read solutions, projects, and then realize the source files inside as their constituent syntax or semantic trees. Eric Lippert covered the CTP on his blog (emphasis mine):

    Roslyn is a library of code analysis APIs useful for building compilers, development environments, refactoring engines and so on. It supports lexical, grammatical and semantic analysis of C# and Visual Basic. And it is awesome.

    You can also use Roslyn to create IDE Extensions, including creating your own refactoring tools:

    To extend the Visual Studio IDE, the Editor Services API exposes a set of extension points to existing language service features. A few examples of these include the completion list, code outliners, highlight references, syntax classifiers, and code refactorings. For each of these extensions, you need to create your own MEF provider and ensure that there is at least one Export* attribute that describes important details about the provider.

    In another question I demonstrated substituting type names (e.g. int with Int32) in a minimal amount of code, with this main loop:

    var workspace = Workspace.LoadSolution(path);
    var solution = workspace.CurrentSolution;
    foreach (var project in solution.Projects
        .Where(prj => prj.LanguageServices.Language == "C#"))
    {
        foreach (var doc in project.Documents
            .Where(d => d.SourceCodeKind == SourceCodeKind.Regular
                     && d.LanguageServices.Language == "C#"))
        {
            var tree = SyntaxTree.ParseCompilationUnit(
                doc.GetText(),
                doc.DisplayName);
    
            // Update the syntax tree
            var newTree = UpdatePredefinedTypes(tree);
    
            solution = solution.UpdateDocument(doc.Id, newTree.Text);
        }
    }
    
    workspace.ApplyChanges(workspace.CurrentSolution, solution);
    // When you run this on a project open in VS it notices the changes
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.