JustCode analysis doesn't understand "var"

2 posts, 0 answers
  1. Brian H. Madsen
    Brian H. Madsen avatar
    18 posts
    Member since:
    Nov 2008

    Posted 01 Dec 2009 Link to this post

    For some reason (doubt it's related to my other problems atm) but it gives me the "squibble" notification in instances where i'm using anonymous declarations, eg. var.

    // GetGroupListEntries returns type DataTable (System.Data)  
    var groups = GetGroupListEntries();  
     
    if (groups != null || groups.Rows.Count > 0)  
    {  
       foreach (var row in groups.Rows)  
       {  
            // do something here  
       }  

    that's the code itself..

    Have attached picture/screenshot of JustCode behavior...error is: C#: Unknown type of variable 'groups'

    Anybody else seeing this or is it in actual fact related to the other issues i'm having with code analysis?

    Cheers,
    Brian H. Madsen
    Microsoft MVP ASP.Net
  2. Jordan
    Admin
    Jordan avatar
    123 posts

    Posted 03 Dec 2009 Link to this post

    Hello Brian,

    Thanks for the feedback! There is a difference between the code snippet and the screenshot. There is a type SecurityListHelper and JustCode shows warnings for it. My guess is that the problem is in this type. Can you provide more information about it?

    JustCode doesn't show any warnings or errors for the following code:

     

    public class Test
    {
        public void Method()
        {
            // GetGroupListEntries returns type DataTable (System.Data) 
            var groups = GetGroupListEntries();
     
            if (groups != null || groups.Rows.Count > 0)
            {
                foreach (var row in groups.Rows)
                {
                    // do something here 
                }
            }
        }
     
        public DataTable GetGroupListEntries()
        {
            return new DataTable();
        }
    }

     

     

    Best wishes,
    Jordan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
Back to Top