Dynamic objects and ReSharper

 

As you might have heard by now, C# 4.0 (or is it just 4?…) comes with a new keyword: dynamic. This means that you could do something like the following:

image

Simply put, ExpandoObject is a class that allows you to add and remove members at runtime. This allows us to call methods that are resolved at runtime. As such, the previous code will compile.

Just as you can declare methods, you can also declare properties:

image

This no doubt can come in handy when working with ViewModels and ASP.NET MVC.

However, there is one minor problem with dynamic objects: you lose intellisense, which means that if in your view, instead of typing dynaCustomer.FirstName, you type dynaCustomer.FristName, you won’t get any errors until you run the app.

image

And that’s where ReSharper can help:

image

This is the same code, but with ReSharper activated inside Visual Studio 2010! I typed the FirstName property for the first time. After that, I have full intellisense support for it. The same would apply to methods:

image

That puts dynamic into perspective.


Posted 11-24-2009 8:41 PM by Hadi Hariri
Filed under:

[Advertisement]

Comments

Bob wrote re: Dynamic objects and ReSharper
on 11-24-2009 4:10 PM

"However, there is one minor problem with dynamic objects: you loose intellisense, ..."

The word is lose, not loose.

Hadi Hariri wrote re: Dynamic objects and ReSharper
on 11-24-2009 4:22 PM

@Bob,

Sorry about that. You're absolutely correct. It was a typo. Corrected, thanks.

Rob Reynolds wrote re: Dynamic objects and ReSharper
on 11-25-2009 8:56 AM

Now that is a bonus! As always, the folks at Jetbrains continue to impress.

Pat Gannon wrote re: Dynamic objects and ReSharper
on 11-25-2009 6:34 PM

That is really cool stuff!  If only they could somehow integrate with IronRuby, and show all of the methods available on dynamic objects being returned from IronRuby invocations.  (Drooling at the possibility...)

Stefan wrote re: Dynamic objects and ReSharper
on 11-26-2009 2:12 AM

This isn't all that new, VS has done this with JS for ages, and while it could be better, it works alright, but is annoyingly wrong pretty often too.

social bookmark submissions wrote re: Dynamic objects and ReSharper
on 01-17-2013 10:07 AM

oRKJjC Really enjoyed this article.Really looking forward to read more. Will read on...

buy generic viagra wrote re: Dynamic objects and ReSharper
on 01-27-2013 5:21 AM

RuKFeq Looking forward to reading more. Great article. Much obliged.

discount generic viagra wrote re: Dynamic objects and ReSharper
on 01-27-2013 5:21 AM

UjzeC4 Thanks again for the blog.Much thanks again. Really Great.

loss weight pills wrote re: Dynamic objects and ReSharper
on 01-31-2013 1:52 PM

zGjFMN I cannot thank you enough for the blog post.Thanks Again. Great.

loss weight pills wrote re: Dynamic objects and ReSharper
on 02-01-2013 4:07 AM

g09sx2 I am so grateful for your blog.Really thank you! Keep writing.

buy viagra online wrote re: Dynamic objects and ReSharper
on 02-03-2013 2:48 AM

g1hNYm I really enjoy the blog post.Much thanks again.

buy imitrex online wrote re: Dynamic objects and ReSharper
on 02-14-2013 4:42 AM

qCRSW5 Im grateful for the post.Much thanks again.

buy imitrex online wrote re: Dynamic objects and ReSharper
on 02-15-2013 6:18 AM

T1kxix I cannot thank you enough for the blog post.Really looking forward to read more. Fantastic.

buy stendra generic wrote re: Dynamic objects and ReSharper
on 02-23-2013 11:36 AM

4x6ulT Say, you got a nice blog article.Really looking forward to read more. Keep writing.

buy viagra discount wrote re: Dynamic objects and ReSharper
on 02-23-2013 1:11 PM

jYVjx4 Really informative article post.Really thank you!

clomid no prescription wrote re: Dynamic objects and ReSharper
on 02-28-2013 10:23 AM

Qn1Iyc Muchos Gracias for your blog post.Really looking forward to read more. Awesome.

click here wrote re: Dynamic objects and ReSharper
on 03-03-2013 8:33 AM

FcLdxh Im thankful for the article post. Awesome.

Social bookmarks wrote re: Dynamic objects and ReSharper
on 03-22-2013 11:55 PM

X6RLHz This is one awesome blog post.Really looking forward to read more. Fantastic.

buy social bookmarks wrote re: Dynamic objects and ReSharper
on 03-23-2013 1:01 AM

Xb2Ef5 Thanks again for the blog.Much thanks again. Will read on...

social bookmarking service wrote re: Dynamic objects and ReSharper
on 04-04-2013 8:06 AM

9tufiV I cannot thank you enough for the article post.Really looking forward to read more. Much obliged.

stoner wrote re: Dynamic objects and ReSharper
on 04-06-2013 6:07 AM

Im obliged for the blog article.Really looking forward to read more. Great.

Social bookmarks wrote re: Dynamic objects and ReSharper
on 04-20-2013 7:19 AM

dHs1fJ Enjoyed every bit of your article post.Much thanks again. Really Cool.

best compact digital cameras wrote re: Dynamic objects and ReSharper
on 05-14-2013 12:32 PM

COayMO I really enjoy the article post.Really looking forward to read more. Really Great.

social bookmarking service wrote re: Dynamic objects and ReSharper
on 06-05-2013 6:52 PM

2QI33r I really like and appreciate your article post.Really thank you! Cool.

cheap social bookmarks wrote re: Dynamic objects and ReSharper
on 06-19-2013 9:41 AM

XVxbpb I truly appreciate this blog.Thanks Again. Will read on...

social bookmarks wrote re: Dynamic objects and ReSharper
on 06-20-2013 5:42 PM

MNp16e Hey, thanks for the blog article.Really looking forward to read more.

news and many more wrote re: Dynamic objects and ReSharper
on 07-04-2013 12:02 PM

ENxCnI I loved your article post.Really thank you! Will read on...

news wrote re: Dynamic objects and ReSharper
on 07-09-2013 3:58 AM

fuWM7k I really enjoy the article.Thanks Again. Want more.

super news wrote re: Dynamic objects and ReSharper
on 07-13-2013 11:54 AM

fr3Kfu Really enjoyed this blog post.Really looking forward to read more. Will read on...

buy viagra online cheap wrote re: Dynamic objects and ReSharper
on 07-24-2013 9:54 AM

Muchos Gracias for your article.Really looking forward to read more. Fantastic.

this site wrote re: Dynamic objects and ReSharper
on 07-25-2013 12:12 PM

Say, you got a nice article post.Really looking forward to read more. Cool.

hot news wrote re: Dynamic objects and ReSharper
on 07-26-2013 4:36 AM

y80G8u Say, you got a nice article.Much thanks again. Really Cool.

cheap social bookmarks wrote re: Dynamic objects and ReSharper
on 07-28-2013 10:44 PM

GHyCXl Great article post.Thanks Again.

best news wrote re: Dynamic objects and ReSharper
on 08-02-2013 1:42 PM

XaTWYn Enjoyed every bit of your blog post.Really thank you! Will read on...

best news wrote re: Dynamic objects and ReSharper
on 08-04-2013 1:16 AM

QcUslV Wow, great blog article.Much thanks again.

awesome links for you wrote re: Dynamic objects and ReSharper
on 08-19-2013 10:19 AM

wQp7UQ Thanks a lot for the article post.Much thanks again.

great link buildng wrote re: Dynamic objects and ReSharper
on 08-19-2013 9:32 PM

J4aKEU Very good article post.Really thank you! Much obliged.

awesome links for you wrote re: Dynamic objects and ReSharper
on 08-21-2013 5:34 PM

gY4Ojg I really like and appreciate your article post.Really looking forward to read more. Keep writing.

best link building wrote re: Dynamic objects and ReSharper
on 09-04-2013 3:18 AM

aeKhXf Thanks a lot for the blog.Really looking forward to read more. Will read on...

link building wrote re: Dynamic objects and ReSharper
on 09-07-2013 1:46 PM

smQ9Vh Fantastic article.Really looking forward to read more. Awesome.

online business wrote re: Dynamic objects and ReSharper
on 09-11-2013 6:05 PM

ovYtTY I appreciate you sharing this blog article.Much thanks again. Fantastic.

make money online wrote re: Dynamic objects and ReSharper
on 09-12-2013 7:56 PM

3gnW5q I value the article.Thanks Again. Fantastic.

pro link building wrote re: Dynamic objects and ReSharper
on 09-24-2013 6:42 AM

2DUpAK Hey, thanks for the blog post. Cool.

cheap seo work wrote re: Dynamic objects and ReSharper
on 09-29-2013 1:16 AM

MPjkBn Thanks a lot for the blog post.Thanks Again. Much obliged.

best linkbuilding wrote re: Dynamic objects and ReSharper
on 09-30-2013 6:37 PM

HsvpuT Great post.Much thanks again. Great.

link building team wrote re: Dynamic objects and ReSharper
on 10-15-2013 5:47 PM

c6hqdS Im grateful for the blog article.Really looking forward to read more. Want more.

smashing top seo wrote re: Dynamic objects and ReSharper
on 10-26-2013 11:07 AM

Nmsj9Z Great post.Really looking forward to read more. Awesome.

take a look at it! wrote re: Dynamic objects and ReSharper
on 11-01-2013 2:15 PM

wMazZg Really enjoyed this blog post.Really thank you! Awesome.

awesome stuff here wrote re: Dynamic objects and ReSharper
on 11-18-2013 3:26 AM

fWHwOh Im grateful for the blog post.Really thank you! Awesome.

check this out wrote re: Dynamic objects and ReSharper
on 11-21-2013 1:10 AM

jUJzhJ Muchos Gracias for your article. Fantastic.

check it out wrote re: Dynamic objects and ReSharper
on 01-09-2014 10:46 AM

xCKhHE Thank you ever so for you article post.Really thank you! Want more.

nice seo guys wrote re: Dynamic objects and ReSharper
on 01-15-2014 9:14 PM

FdvGV2 I appreciate you sharing this blog post.Really thank you! Keep writing.

check it out wrote re: Dynamic objects and ReSharper
on 02-06-2014 6:17 AM

RQ6qhx A big thank you for your blog article.Thanks Again. Fantastic.

stunning seo guys wrote re: Dynamic objects and ReSharper
on 02-28-2014 8:25 AM

HJGyIV Thanks again for the blog article.Really looking forward to read more. Really Great.

smashing site wrote re: Dynamic objects and ReSharper
on 03-13-2014 3:57 AM

aDNSkY Thanks a lot for the post.Thanks Again. Awesome.

check it out wrote re: Dynamic objects and ReSharper
on 03-22-2014 7:47 AM

H1HLyw I am so grateful for your article. Great.

stunning service wrote re: Dynamic objects and ReSharper
on 03-25-2014 7:13 PM

8wJuaO Thank you ever so for you blog article.Really thank you! Really Cool.

best money here wrote re: Dynamic objects and ReSharper
on 04-05-2014 2:59 PM

pH86SK Say, you got a nice article. Great.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)