Bug 571488

Summary: 'var' keyword not recognised as anonymous type
Product: [Mono] MonoDevelop Reporter: A. A. <inspiration3>
Component: debuggerAssignee: Lluis Sanchez <lluis>
Status: RESOLVED DUPLICATE QA Contact: MD Bugs <monodevelop-bugs>
Severity: Major    
Priority: P5 - None    
Version: 2.2   
Target Milestone: ---   
Hardware: Other   
OS: Windows 7   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description A. A. 2010-01-17 20:23:05 UTC
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7

Any use of the var keyword (http://msdn.microsoft.com/en-us/library/bb383973.aspx) results in the following errors:

Error CS0246: The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference?) (CS0246)
Error CS0021: Cannot apply indexing with [] to an expression of type 'var' (CS0021)

Reproducible: Always
Comment 1 A. A. 2010-01-17 23:05:29 UTC
Further discussion from #monodevelop:

(8:32:56 PM) ins3: reported https://bugzilla.novell.com/show_bug.cgi?id=571488
(9:16:32 PM) brajkovic: ins3: Are you targeting .NET 3.5 or .NET 2.0?
(9:16:34 PM) brajkovic: Check your project settings.
(9:16:50 PM) brajkovic: Because that works for me on MonoDevelop trunk.
(9:18:20 PM) brajkovic: And has for a while now.
(9:18:34 PM) brajkovic: If you're targeting the wrong framwork version though, the compiler will bitch at you.
(9:19:01 PM) brajkovic: I'm not sure why you filed a MonoDevelop bug, because a) it's not MonoDevelop handling the compilation, it passes it off to the .NET compiler.
(9:24:50 PM) ins3: oh thanks brajkovic it worked when I changed it to .net 3.5 but I still think it's a bug, the compiler should still parser c# 3.0 code with a .net 2.0 profile
(9:25:04 PM) ins3: that's how visual studio works on 2005/2008
(9:25:13 PM) brajkovic: I don't think so.
(9:25:19 PM) brajkovic: It's relying on the .NET compiler.
(9:25:29 PM) brajkovic: Unless VS is using the 3.0 compiler to emit 2.0 IL.
(9:26:42 PM) ins3: it's 3.0 il with references to .net 2.0 runtime
(9:27:22 PM) brajkovic: Sounds fishy.
(9:27:23 PM) ins3: hence "Target Framework"
(9:27:45 PM) brajkovic: Anyway, I think MD uses the 2.0 compiler to target the 2.0 framework.
(9:28:27 PM) brajkovic: Which is why you're getting that.
(9:29:06 PM) ins3: why would anyone want the old compiler? I need to target .net 2.0 for compatibility with older versions of mono on debian etch
(9:29:30 PM) ins3: md should always use the newest compiler like vs
(10:28:47 PM) brajkovic: Ask mhutchw|gone or lluis_out, but I'm inclined to say that using the correct compiler for the target runtime is the better choice, particularly because it restricts you to the correct set of methods that should be implemented.
(10:29:05 PM) brajkovic: Targeting the 2.0 framework means MD won't show you methods in IntelliSense that aren't available in 2.0
Comment 2 Lluis Sanchez 2010-01-18 08:09:44 UTC
*** Bug 571484 has been marked as a duplicate of this bug. ***
Comment 3 Lluis Sanchez 2010-01-18 08:10:03 UTC
*** Bug 571486 has been marked as a duplicate of this bug. ***
Comment 4 Lluis Sanchez 2010-01-18 08:10:41 UTC
*** Bug 571485 has been marked as a duplicate of this bug. ***
Comment 5 Lluis Sanchez 2010-01-18 08:11:32 UTC
*** Bug 571487 has been marked as a duplicate of this bug. ***
Comment 6 Lluis Sanchez 2010-01-18 08:18:35 UTC
Dup.

*** This bug has been marked as a duplicate of bug 567906 ***