This question is locked. New answers and comments are not allowed.
We have a large group of files that are generated and exist in a sub-folder called 'Generated'. They are marked as generated code in several standard ways but the code analysis still doesn't see them as generated and falsely reports problems with them. It would appear that the analysis only reacts to the correct extension rather than standard generated code constructs.
Note that Resharper and Visual Studio do not have this issue.
I would expect standard tags and directives to cause it to not analyze this file. Here are the constructs that it should recognize:
<auto-generated> in the header comments
#pragma warning disable anywhere in the file
System.CodeDom.Compiler.GeneratedCode attributes on the class
System.Diagnostics.DebuggerNonUserCode attributes on the methods or properties
Here is sample code:
//------------------------------------------------------------------------------
// <auto-generated>
// Copyright (c) 2014 -company-. All Rights Reserved.
//
// This code was generated by tool: -some code generator-
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#pragma warning disable
using System;
namespace Model
{
[System.CodeDom.Compiler.GeneratedCode("somecodegen","1.0.0.0")]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class SomeGenClass
{
[System.Diagnostics.DebuggerNonUserCode]
public Nullable<int> SomeProp
{
get;
set;
}
}
}
Note that Resharper and Visual Studio do not have this issue.
I would expect standard tags and directives to cause it to not analyze this file. Here are the constructs that it should recognize:
<auto-generated> in the header comments
#pragma warning disable anywhere in the file
System.CodeDom.Compiler.GeneratedCode attributes on the class
System.Diagnostics.DebuggerNonUserCode attributes on the methods or properties
Here is sample code:
//------------------------------------------------------------------------------
// <auto-generated>
// Copyright (c) 2014 -company-. All Rights Reserved.
//
// This code was generated by tool: -some code generator-
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#pragma warning disable
using System;
namespace Model
{
[System.CodeDom.Compiler.GeneratedCode("somecodegen","1.0.0.0")]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class SomeGenClass
{
[System.Diagnostics.DebuggerNonUserCode]
public Nullable<int> SomeProp
{
get;
set;
}
}
}