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

LINQ in VB Issue: Unknown Variable

4 Answers 84 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.
kencox
Top achievements
Rank 1
kencox asked on 19 Nov 2009, 03:24 AM
I'm looking for a list of known issues but in the meantime, here's one that's causing hundreds of errors in my ASP.NET VB project. I'm using Entity Framework.

JustCode flags 'apt' in the following as "VisualBasic.NET: Unknown variable or member 'apt'.

        For Each apt In Apts  
            aptinfo = New AppointmentInfo(apt.Subject, apt.Start, apt.End)  
            sessApts.Add(aptinfo)  
        Next 

Ken

4 Answers, 1 is accepted

Sort by
0
Tsviatko Yovtchev
Telerik team
answered on 19 Nov 2009, 05:08 PM
Hi Ken

The known issues list is coming soon, please, stay tuned.

As for the errors you are experiencing it's kinda hard to reproduce/investigate using the code snippet you provided. Can you provide a self-contained sample, i.e. the complete method where that occurs together with the definitions of all the types used in it where each type refers only primitive types or other types from the sample? If that's not possible what's the closest thing we can get?

Best wishes,
Tsviatko
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.
0
Michael Josiah
Top achievements
Rank 1
answered on 20 Nov 2009, 11:40 PM
I am experiancing the same issue. Please try and test the scenario using VB.NET and Linq to Objects. It also does not like inferred variables within a for loop.

So lets say you have a collection of People objects that you want to loop through

for each p in persons
  p.name = "michael"
next

JustCode would highlight "p" with the message VisualBasic,NET : Unknown member or variable 'p'
0
kencox
Top achievements
Rank 1
answered on 21 Nov 2009, 01:17 AM
For an easier example to set up, try the following in an ASP.NET 3.5 VB web page:

    Protected Sub Page_Load _  
      (ByVal sender As Object, ByVal e As System.EventArgs) _  
        Handles Me.Load  
        Dim q = From f In System.Drawing.FontFamily.Families  
        For Each fnt In q  
            Response.Write(fnt.Name & "<br />")  
        Next  
    End Sub 

You'll see that JustCode flags all the references to "fnt" even though they are valid in VB LINQ.

Thanks to Michael for also contributing an example.

Ken
Microsoft MVP [ASP.NET]
0
Tsviatko Yovtchev
Telerik team
answered on 23 Nov 2009, 09:16 AM
Hi guys,

Thanks a bunch for the code samples. We are able to reproduce the issue on our side now so fixing it is inevitable. We'll let you know as soon as we release the build with that fix. Once again thanks for the code samples. I really appreciate it.


Best wishes,
Tsviatko
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
kencox
Top achievements
Rank 1
Answers by
Tsviatko Yovtchev
Telerik team
Michael Josiah
Top achievements
Rank 1
kencox
Top achievements
Rank 1
Share this question
or