Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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.</p> <p>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.</p> <p>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 <a href="http://msdn.microsoft.com/en-us/library/system.codedom.compiler.generatedcodeattribute.aspx" rel="nofollow">System.CodeDom.Compiler.GeneratedCodeAttribute</a> and the methods are all marked with the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggernonusercodeattribute.aspx" rel="nofollow">System.Diagnostics.DebuggerNonUserCodeAttribute</a>. </p> <p>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.</p> <p>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</p> <pre><code>//------------------------------------------------------------------------------ // &lt;auto-generated&gt; // 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. // &lt;/auto-generated&gt; //------------------------------------------------------------------------------ </code></pre> <h3>What now?</h3> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload