This is a migrated thread and some comments may be shown as answers.

Generated Code Not Skipped

3 Answers 45 Views
Code Analysis
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Steve
Top achievements
Rank 1
Steve asked on 11 Dec 2014, 06:41 PM
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;
        }
    }
}

3 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Valchev
Telerik team
answered on 16 Dec 2014, 01:29 PM
Hello,

Thank you for the feedback!
We will consider your propositions as feature requests and will log them in our backlog system. As a temporary solution I would recommend you to add the sub-folder you mentioned earlier into our file filters (JustCode | Options | Code Analysis | General | Exclude file filters: -> just add ';\Generated\%\*;'). 
For more information how to use exclude files and folders from being analyzed you could look here.

If you have any further questions or remarks, please do not hesitate to contact us!

Regards,
Nikolay Valchev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Steve
Top achievements
Rank 1
answered on 16 Dec 2014, 09:53 PM
Thanks for the solution - that worked and filtered out those files.  I had put in "*\generated\*" since I hadn't seen that page when I looked last time.

I would still recommend, however, that the analysis tool be made aware of standard code generation constructs.  But for now this solves the problem.
0
Nikolay Valchev
Telerik team
answered on 19 Dec 2014, 08:17 AM
Hello Steve,

We are glad you were able to resolve your issue!

Regards,
Nikolay Valchev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Code Analysis
Asked by
Steve
Top achievements
Rank 1
Answers by
Nikolay Valchev
Telerik team
Steve
Top achievements
Rank 1
Share this question
or