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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:58:40+00:00 2026-06-05T22:58:40+00:00

I have a small Visual studio add-in that walks down active project and insert

  • 0

I have a small Visual studio add-in that walks down active project and insert code to every method.
My target project has web service reference and it created a bunch of auto-generated refenrece files that I do not care about.
Is there a way to detect whether a projectitem is autogen file?

The project file has tag under but ProjectItem.Properties doesn’t have it.
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-05T22:58:41+00:00Added an answer on June 5, 2026 at 10:58 pm

    Is there a way to do this 100% reliably? I don’t think so. The only way I’ve ever been able to tell if a file is autogenerated or not is by its content or by its filename.

    Often, generated code files in newer versions of (what I know) C# have a “.g.” within their names. This is not written in stone or guaranteed (I think windows forms and other older generators use “.Designer.”), but it can be used as an indication.

    If you look through different autogenerated code, you’ll see there are a number of different ways it can be marked. There is no specific way that is universal. For example, autogenerated wire-up code in WPF codebehind files (the hidden InitializeComponent() method resides there) contains a partial class definition marked with the System.CodeDom.Compiler.GeneratedCodeAttribute and the methods are all marked with the System.Diagnostics.DebuggerNonUserCodeAttribute.

    The first attribute resides on the class, so it may show up when inspecting the code via EnvDTE methods. You might have to resort to reading the file in raw and looking for that attribute.

    Even this isn’t enough information, as different code generators mark their code differently. Type safe DataSets and EF generated code mark their generated code with a comment at the top of the file

    //------------------------------------------------------------------------------
    // <auto-generated>
    //     This code was generated by a tool.
    //     Runtime Version:4.0.30319.551
    //
    //     Changes to this file may cause incorrect behavior and will be lost if
    //     the code is regenerated.
    // </auto-generated>
    //------------------------------------------------------------------------------
    

    What now?

    Unless you explore all the different ways autogenerated code is marked, and handle them all, there isn’t any way (unless I’m missing something!) you can guarantee skipping these files. You have to ask yourself if it is worth the effort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a setup project that currently adds Project Output's from different visual studio
I have a small C++ Win forms project developed by visual studio 2005. How
I have a small issue with the Code Analysis in Visual Studio 2010. I'm
I am writing a Visual Studio add-in to process C++ code, and think that
I have small C/C++ project in Visual Studio 2012 RC This applications parses the
I have a small asp.net application writed in Visual Studio 2005. Project working in
We (small team) currently have our Visual Studio projects on a network drive (no
I have visual studio 2008. I have a written a small C program. I
I'm using SilverLight on Visual Studio 2008, Ver 3.5 SP1, I have a small
I have several small Visual Studio Projects (C++). And many of these projects have

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.