Search

Please give VB.Net some equivalent for C# 'dynamic' with Option Strict On by MarkTJackson

Closed
as Other Help for as Other

16
0
Sign in
to vote
Type: Suggestion
ID: 591963
Opened: 8/31/2010 8:13:26 AM
Access Restriction: Public
0
Workaround(s)
Please give VB.Net an equivalent for the C# 4 'dynamic' keyword when using Option Strict On.

In my experience most professional developers prefer to avoid Option Strict Off. In C#, with the dynamic keyword we can be very explicit about the dynamic parts of my program. It's like telling the compiler: "hey, I know what I'm doing for this specific part of my program". With VB.Net we have to turn off Option Strict for a whole module, which can lead to subtle bugs creeping in.

Please can we have some equivalent to 'dynamic' so that we can use some of the more modern techniques in a safe way? Like using a dynamic object to reference the HTML Document Object Model (DOM), or accessing a dynamic language like IronPython.
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

 

Steps to reproduce

http://msdn.microsoft.com/en-us/library/ee461504.aspx

Product Language

English

Operating System

Windows Vista

Operating System Language

English

Actual results

Option Strict Off is required

Expected results

Please provide an alternative
File Attachments
0 attachments
Sign in to post a comment.
Posted by Đonny on 1/6/2011 at 1:54 PM
I'd personally prefer the Dynamic pseudo-type (as in C#, two ways of late binding), but #pragma is acceptable for me (if it can be used inside a method, not like #regions in VB, like #regions in C#).
Posted by Microsoft on 1/5/2011 at 8:57 AM
Hi Mark. Thanks for the comment. I agree that many developers don't like to use "Option Strict Off". And accessing DOM is a really good example.

One approach is not to have any "Option Strict" declaration at the top of the file. Instead right click on the project > Properties > Compile and set them to "warning". This way you're still explicit about where it's happening -- except the explicitness comes through as warnings rather than through annotations in your code. But that's not a very good workaround.

We discussed this in VB Language Design Meetings but didn't come up with very good answers. Here are the notes:
http://blogs.msdn.com/b/lucian/archive/2010/01/28/core2-dynamic-pseudo-type-scoped-late-binding.aspx

The main thing is that we're reluctant to have two ways to do late-binding in the language. I think that localized #pragmas would proably be the best solution.

I've added your connect bug number to our internal "backlog list of items that users have requested". We'll use the weight of requests in this list to help guide our plans for future versions.

Thanks again for the feedback,

--
Lucian Wischik, VB spec lead
Posted by Microsoft on 8/31/2010 at 5:04 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.