Razor: strongly typed code editing in VS

262 views
Skip to first unread message

Sebastiaan Janssen

unread,
Jun 17, 2012, 4:48:17 AM6/17/12
to umbra...@googlegroups.com
While in my mind this is sugar (I've been using XSLT / dynamics for way too long), it would be a fantastic productivity boost to get code completion in Razor.

I hope Aaron can share his experiences with Linq 2 Umbraco and what could be done to support strongly typed code editing in an elegant yet performant way. 

I'm thinking about the way VSDocs files help in VS with Javascript, is that something we should look at? Or do we need to go through the class-generation route still?

One other thought, does codemirror support any code completion? Maybe we could get some of this strongly typed stuff in the backoffice editor as well then. 

jbr...@gmail.com

unread,
Jun 17, 2012, 10:06:08 AM6/17/12
to umbra...@googlegroups.com
Even though this discussion has been separated from the code first generation discussion I would like to say it would be nice to use the code first objects in Razor.

Currently when using Razor I use things like .Where(""), but I don't really like that. You use a string instead of a lambda expression and because it's not strongly typed all values need to be casted to the correct type. Otherwise something like .Where("number > 3") wouldn't work. That can give performance problems: http://our.umbraco.org/forum/developers/razor/28479-Razor-menu-performance-(v4). I would much rather write queries like this in Razor: http://issues.umbraco.org/issue/U5-259#comment=67-657.

Jeroen

Gareth Evans

unread,
Jun 17, 2012, 10:14:05 AM6/17/12
to umbra...@googlegroups.com
In order to implement that, we'd need a full Linq provider; something that would be a huge amount of work, and I believe something that was a problem in v5.

If we were transforming xml files into document types though, that same transformation step could perhaps generate strongly typed DynamicNode instances in App_Code; it's just an idea though. Perhaps that could piggy back on the stuff that happens in Linq2Sql where you end up with the dynamic classes for your database schema. Not sure.

I discussed speeding up the property accesses at cg12 in the next release though, I can't look at it until I return to NZ though.

Gareth


--
You received this message because you are subscribed to the Google Groups "Umbraco development" group.
To view this discussion on the web visit https://groups.google.com/d/msg/umbraco-dev/-/eiBc-JIvjgMJ.
To post to this group, send email to umbra...@googlegroups.com.
To unsubscribe from this group, send email to umbraco-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/umbraco-dev?hl=en.


Pete Duncanson

unread,
Jun 18, 2012, 10:55:24 AM6/18/12
to umbra...@googlegroups.com
We've had success at using this with USiteBuilder and the ContentHelper method they have added. Is that not enough for now or am I missing something?

Michiel van Oosterhout

unread,
Jun 18, 2012, 11:14:57 AM6/18/12
to umbra...@googlegroups.com
There's also a new feature in WebMatrix, called 'App Specific Code Completion', see announcement here:  http://vishaljoshi.blogspot.nl/2012/06/announcing-webmatrix-2-rc.html 

I have no idea how that works, but I wanted to share it, perhaps there's something interesting we can learn from it.

I don't know how serious WebMatrix is taken as a tool for beginning or experienced developers, I don't use it myself, but it has great potential as a productive tool to just get a website done.

jbr...@gmail.com

unread,
Jun 24, 2012, 4:30:25 PM6/24/12
to umbra...@googlegroups.com
In this topic there is an interesting discussion about using a query API: https://groups.google.com/forum/#!topic/umbraco-dev/xZVUfW4qXIQ. Might be nice to combine that with strongly typed objects.

jbr...@gmail.com

unread,
Jul 17, 2012, 3:41:51 AM7/17/12
to umbra...@googlegroups.com
Not sure if this is the right place to ask this, but is there any more info about when speeding up the property accesses in Razor will be added? I've been looking at some old v4.5 sites with XSLT that have the same functionality as new websites with Razor, but the XSLT still feels a bit faster. Perhaps because of all casting that happens in Razor?
Reply all
Reply to author
Forward
0 new messages