Generated Code Not Skipped

4 posts, 1 answers
  1. Steve
    Steve avatar
    2 posts
    Member since:
    Aug 2014

    Posted 11 Dec 2014 Link to this post

    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;
            }
        }
    }
  2. Answer
    Nikolay Valchev
    Admin
    Nikolay Valchev avatar
    72 posts

    Posted 16 Dec 2014 Link to this post

    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.

     
  3. DevCraft banner
  4. Steve
    Steve avatar
    2 posts
    Member since:
    Aug 2014

    Posted 16 Dec 2014 in reply to Nikolay Valchev Link to this post

    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.
  5. Nikolay Valchev
    Admin
    Nikolay Valchev avatar
    72 posts

    Posted 19 Dec 2014 Link to this post

    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.

     
Back to Top