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

JustCode analysis doesn't understand "var"

1 Answer 50 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.
Brian H. Madsen
Top achievements
Rank 2
Brian H. Madsen asked on 02 Dec 2009, 03:29 AM
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

1 Answer, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 03 Dec 2009, 04:05 PM
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.
Tags
Code Analysis
Asked by
Brian H. Madsen
Top achievements
Rank 2
Answers by
Jordan
Telerik team
Share this question
or