Dennis van der Stelt

The only way to win is to learn faster than anyone else

Community

Email Notifications

News

  • Addicted to Refactor! Pro

I read...

I Use...

Tags

Recent Posts

Archives

Blog Subscription Form

  • Email Notifications
    Go

October 2008 - Posts

Oslo : Building textual DSLs

This is the geek *** session Don Box mentioned. Chris Anderson and Giovanni Della-Libera are presenting, the entire Oslo team that’s here is inside this room.

IMG_3257 IMG_3260

module PDC

{

  language Contacts

  {

    syntax Main = checked:Contact => checked;

 

    syntax Contact =

      "Contact" ":" a:Alias =>

      Contact { Alias { a } };

    |

      "Contact" ":" a:Alias "-" n:PhoneNumber =>

      Contact { Alias { a }, Phone {phone} };

 

    token Alias = ('A'..'Z' | 'a'..'z')+;

 

    token Digit = "0".."9";

    token PhoneNumber = Digit#3 "-" Digit#3 "-" Digit#4;

 

    interleave TokensIHate = " " | "\r" | "\n"+;

  }

}

Tokenize is the first thing to do. The above can transform “Contact : dvdstelt - 425-555-1212”, and it removes weird characters. Chris and Gio than show how lists work, how the recursive results are flattened out, how to add comments and

IMG_3263 mgx.exe is used to generated an mgx file.

mgx /r:contacts.mgx input.contacts will generate M language code. The mgx is just a plain .zip file, as said before in one of my posts.

mgx /r:contacts.mgx input.contacts /t:xaml for transformation to xaml

You can Integrate MGrammar into the CLR

  • Use MSBuild tasks, include the .mg file in your solution and setup the msbuild file (csproj)
  • Use the MgrammarCompiler, which is an in memory compiler
  • DynamicParser
  • IGraphBuilder

A cool example of some MGrammer was grammar code for MSI setup package. MSI is really complex to write, so Chris and Gio build MGrammar to build the MSI. But their MGrammer became so complex, that they wrote another MGrammer code library to generate the other MGrammer code to generate the MSI installer ‘code’. The final result is about 50 lines of MGrammer and 400 lines of C#, pretty maintainable I’d say.

To sum up, MGrammer is a language for creating textual DSLs. The specification will be released under OSP, as noted on many other weblogs.

You can build your own language right now! Download at http://msdn.microsoft.com/oslo/

“M” and MService

I’ve been talking to people and perhaps here on the blog that during the Doug Purdy talk they showed a demo of MService where, with a few lines of code, a REST enabled WCF services with WF activities was created with only so few lines of actual code.

service Service

{

  operation PhotoUpload(stream : Stream) : Text

  {

    .PostUriTemplate = "upload";

 

    index : Text = invoke DateTime.Now.Ticks.ToString();

    filename : Text = "d:\\demo\\photo\\" + index + ".jpg";

    invoke MService.ServiceHelper.StoreInFile(stream, filename);

 

    return index;

  }

 

  operation PhotoGet(index : Text) : Stream

  {

    .UriTemplate = "getphoto/{index}";

    .ContentType = "image/jpeg";

 

    filename : Text = "d:\\demo\\photo\\" + index + ".jpg";

    return invoke File.OpenRead(filename);

  }

 

  endpoint HttpEndpoint

  {

    Binding = WebHttpBinding;

    Address = "http://localhost:8080/service/";

  }

}

Add breakpoints, post a photo or get one and the breakpoints are hit under debugging. You can see activities and endpoints in the locals window.

At the bottom you can see the endpoint defined. The first operation is PhotoUpload and it invokes code to store a file. Runtime this results in a WF activity storing the file on disc. The second operation is the get and it invokes a file read activity.

In the PhotoUpload operation you also see the invoke of DateTime.Now.Ticks.ToString(), which will result in a code-activity in WF, running the specified code.

This is just it, a REST enabled service for uploading, storing and retrieving images.

Remember that this is MService, including a WF/WCF runtime that understands the language ‘M’, hosted inside Dublin.

“Oslo” repositories and models

IMG_3245Just saw Chris Sells show a session on some other expects of Oslo that wasn’t introduced yet.

It was again stated that the repository in Oslo is a normal SQL Server database. All your models are just SQL in the database and everything is designed for extensibility.

Some of the core features are:

  • Repository capabilities
    • Repository features are built on SQL Server
      • Repository install also runs on useful features, e.g. replication and mirroring
    • Repository features are:
      • Catalog
      • Secure views
      • Auditing
      • Versioning
      • Claims-based security, etc

    The Oslo SDK provides tools to

    • Define new models : Intellipad, Visual Studio language services
    • Compile models : m.exe, msbuild build tasks
    • Deploy models : mx.exe

    Again, once your models are in the database, it’s just plain SQL data.
    Currently only SQL Server is supported, but of course the next logical step is XML and especially web services to put your models in the cloud!!!

  • Deployment
  • Application model can be used to define applications to be deployed.
    E.g. define a web service in the repository and deploy it without writing a line of code.

    The demo shown has in the database a few rows of data in the application model on a WCF service with WF. When deploying, it’s gathering data from the database and transforming it to something the runtime can understand. In the demo shown, the extension isn’t .svc but .xamlx

    mx.exe packages SQL for deployment to repository nodes
    • Packages can come from M files
    • packages can be exported from repository nodes
  • Security
    Security is claims-based.
    • Identity becomes just one of several possible claims
    • Claims presented to authorize operations against resources

    Repository tables keep track of claims, resources and operations

    • Triggers implemented on /t:Repository-generated views to check claims. Everything is stored in again in tables.
    • Views protect against direct access to tables

    Domain-specific security containers

    • Use “folders” to partition data
    • Apps decide which data goes into what folder
    • Security checks happen on folder boundaries
    • Must call the field “Folder” for compiler to find it
    • Folder ID must exist in the Item.Folders table
  • Versioning
    • Data change synchronization
      • Between nodes using SQL Server Replication and Occasionally Connected Systems
      • Import/Export using SQL Server Change Tracking, e.g. repository <-> file system
    • Schema evolution
      • Extend M type and provide backwards compatibility for old clients w/ computed values
      • SQL Server Integration Services (SSIS) for data migration
"Oslo": Customizing and Extending the Visual Design Experience

Together with Alex Thissen, Paul Gielens, Marco Stolk and Dries Marckmann we’ve been reflecting our thoughts on “M”. Right now we’re all at another Oslo talk about Quadrant.

Why “Quadrant”?

  • As more software becomes more model-driven, the volume of data in the system grows
  • We need a tool that lets people query, update, and visualize that data in ways that make sense for the task at hand.

What is “Quadrant”?

  • “Quadrant” is a tool for interacting with data
    • Flexible, focused design surfaces
    • Default experiences over arbitrary data
    • Rich declarative customization
  • “Quadrant” is completely data-driven, every bit of data in SQL Server.

“Quadrant” is the tool to work with. You have a canvas where you can drag everything you’re working with on that canvas. Icons that are blue can be dragged out and placed on the canvas again to get a full view on that item again. That way you can drill down in all models. Everything of course in WPF and this provides a great visual experience, or at least this is the idea I get from looking at the screen.

Terminology and features in quadrant

  • Canvas
    You can use the canvas to view the model. The model is loaded by Quadrant and you can drag models onto the canvas.
  • Repository Explorer
    At the bottom-left corner you have the explorer from which you can select everything related to applications, models, workflows, activities, etc. Everything that is data and is represented as a model.
  • Shapes
    Shapes are the squares on the canvas and are a model or a part of a model
  • Hyper icons
    Hyper icons are the blue icons I talked about. They can be dragged out of the shape and become a new shape themselves.

IMG_3234  IMG_3235  IMG_3236

Using Quadrant Takeaways

  • “Quadrant” connects people to data
  • Diverse data sets
  • Diverse interaction styles
  • Extensible
    • Create new or extend existing models
    • Create new or extend existing editing experiences

IMG_3238 

Customizing “Quadrant” Takeaways

  • Quadrant is a model-driven application
  • Customization via data stored in repository
  • View specification based on query/functional evaluation

Quadrant Architecture

The shell and surface has some core services like drag/drop, undo/redo, error handling, search, etc. The composition engine is getting data from a dataflow engine, giving queryable data, having target data, configuration and view state, which is all coming from M.

IMG_3239

Where are we?

  • “Quadrant” is a flexible tool for interacting with diverse data
  • “Quadrant” uses the repository for both specification and state
Best PDC session so far : Lap around “Oslo”

I’m at the “Lap around ‘Oslo’” talk together with Alex Thissen and Paul Gielens. This is by far the best session I’ve seen so far!

The talk began about models. We were looking at modeling and modeling domains, but what is a model? We have…

  • Drawings
    Models used to communicate with others, for example DataFlow or Use Case. See UML as Sketch.
  • Model-Assisted
    Models used to understand or manipulate code, for example StaticStructure or Sequence
  • Model-Driven
    Models executed by runtimes directly, for example HTML, CSS, XAML, BPEL

According to Douglas Purdy, Don Box says we’re on a 30 year journey and we’re 15 years in. We had COM(+), .NET 1.0, Web Services, .NET 3.0 and now we’re entering the next phase. Oslo is the next level for a model-driven platform. We’ve been heading there via configuration, attributes and doing more and more declarative instead of typing everything out. A great example for declarative development is of course LINQ.

Why is this happening? Transparency (better understand your application), flexibility (add changes to your application faster) and productivity. We need models

So what is Oslo?
It is the platform for model-driven development. Microsoft will bring us Oslo with the following components:

  • “M”
    The language for authoring models & DSLs
  • “Quadrant”
    The tool for interacting with models & DSLs
  • Repository
    The database for storing & sharing models, this will be SQL Server.

“M” gives you the modelling and textual DSLs. According to Douglas Purdy and to Don Box, this is going to be the next big thing. I could not agree more. I am SO excited about what I just saw. Take the example they’ve shown.

Module Microsoft.Samples

{

  // MusicItem is the schema

  type MusicItem

  {

    // Primary key

    Id : Integer64 = AutoNumber();

    Album : Text; // Album is constraint by type

    Artist : Text;

    // Rating is constraint and expression

    Rating : Integer32 where value <= 3;

  } where identity Id;

 

  // * is 0..n multiplicity

  MusicLibrary : MusicItem*;

}

The above declares a schema named “MusicItem” and a collection of those in a “MusicLibrary”. We compile this and than populate the result in the database.

// M compiler

// Repository is the database. When choosing -t:xml we generate XML

m.exe myfile.m /p:image -t:Repository

// Populating

mx.exe /i:myfile.mx /db:repository /ig /f

mx uses the compiled “binary” (this is a zip archive actually) and generates T-SQL.

create table [Microsoft.Samples].[MusicLibrary]

(

  -- the rest

)

You can fill the database with the following

Module Microsoft.Samples

{

  MusicLibrary

  {

    {

      Album = "Slippery when wet",

      Artitst = "Bon Jovi",

      Rating = 3

    },

    {

      Album = "Into the dark",

      Artitst = "Europe",

      Rating = 2

    }   

  } 

}

This creates two rows in the table MusicLibrary. But this is all the language “M”. How about a textual DSL? How’s this for coding:

"SomeAlbum" by "Led Zeppelin" is awesome!

"Back in Black" by "AC/DC" is so so.

"Bad" by "Michael Jackson" is terrible.

The above code can be transformed into the exact same code-block as above, where we filled the database with two records. How is this achieved? Take a look at the following code.

module Microsoft.Samples

{

  import Language;

 

  language MusicLibraryLanguage

  {

    syntax Main = s:Statement+ => MusicLibrary(valuesof(s){l

 

    syntax Statement = al:Grammar.TextLiteral "by" ar:Gramar.TextLiteral "is" ?????

    => { Album {al}, Artist {ar}, Rating

 

    @{(Classification["keyworkd"]} // colorize "awful"

    token Rating1 = "terrible" | "awful";

    token Rating2 = "so so";

    token Rating3 = "awesome";

 

    syntax Rating = Rating1 => 1 | Rating2 => 2 | Rating3 => 3;

 

    interleave skippable = Base.Whitespace

  }

}

I lost the code where it says “????”. The above code tells to look at by and is and takes the text there and parse it. It than looks at the rating and gives it an actual number. The Classification keyword makes the words “terrible” and “awful” become bold in the editor.

Now is this awesome or what? I’m so excited by this. This is one of the biggest steps in my history of developing software. You can now write code like

Give me a table called “Customers” with a primary key called “Id” and make it an integer with identity on, seeding from 1.

The best thing is, if you can think of a way to make that sentence shorter or more self-explaining, go ahead! Use MGrammer to define your own textual DSL.

MService
Another great demo was when they showed MService. With only a few lines of code (my battery ran flat, so I could not copy the code, but I photographed it and it will come in this blog!) they created a WCF service where they could upload an image and request it again, using a WF workflow. In about 38 lines of code, { and } on empty lines included!!!

Courtesy of Paul Gielens, I got the code from his weblog. The following starts a REST enabled WCF Service with a WF Writeline activity. Not a Console.Writeline, but a real WF activity.

module Service25

{

  service Service

  {

    operation Echo(str : text) : Text

    {

      .UriTemplate = "echo/{str}";

      WriteLine { Text = "Message : " + str }

      return str;

    }

  }

}

Debugging
At first I thought this was an awesome code generator. But boy was I wrong. They showed debugging and hitting breakpoints inside the textual DSL!!! The stack and locals windows showed the WCF channels and WF activities active. Can you believe it? Probably not, you just have to watch the stream on Channel9.

I’m now going to follow Don Box, hold on for more!

Loving it, loving it, loving it, as Don Box would say!

CodeRush Xpress

Mark Miller from DevExpress just announced CodeRush Xpress for C# developers, for free!!! In a partnership with Microsoft, DevExpress is making this tool available for Visual Studio. It’s a selection of CodeRush and Refactor! Pro features.

Refactor! Pro is one of my favorite tools available for Visual Studio. I haven’t really used CodeRush yet, but I will definitely install CodeRush Xpress.

Go get it here…

PDC 2008 Photos

A lot of photos, many many more to come…

Most are Los Angeles, Santa Monica beach and other locations. PDC 2008 isn’t that interesting to look at! ;-)

http://flickr.com/photos/dvdstelt/sets/72157608454625991/

PDC 2008 : Keynote 2

Scott Guthrie is talking… Very fast what he’s talking about…

  • WPF 4.0 has touch
  • .NET 4.0 can be loaded in the same process as .NET 2.0
  • Visual Studio 2010 is build in WPF
  • Ability to create awesome visualizers in Vsual Studio 2010
    Scott just shows us a 200 line code visualizer that replaces the normal /// comments with a nice box with much richer presentation
    This runs on MEF
  • MVC will be released in upcoming months
  • jQuery intellisense support for Visual Studio 2008 right now.
  • ASP.NET news
    • Better deployment options, like having multiple web.config files (or deltas) under the normal web.config
  • IIS smooth streaming for (amongst others) Silverlight streaming video will be released
  • Silverlight
    • 1 in 4 machines have Silverlight installed, according to ScottGu
    • New controls like Charting, TreeView, Dock Panel, etc.
      Full access to source code, of course
    • Updated Silverlight designer in Visual Studio 2010, based on WPF work done for VS2010
    • Run Silverlight inside and outside the browser

Strange, nothing about Silverlight 2.0 on mobile. There is a session about it though, but I’m going to “Oslo” sessions.

The language ‘M’

Yesterday, Alex and I were talking to a lot of people at the main hall when we walked by the Oslo booth. Don Box and David Langworthy were doing a presentation on the language ‘M’. Today we’ll hear much more during the keynote from Don Box and Chris Anderson, but it was great to see a demo already.

I write ‘yesterday’ because I’ll post this on Tuesday. It’s now Monday 11:30pm and I definitely need some sleep!

PDC2008 182 PDC2008 175  PDC2008 177

Silverlight 2.0 on mobile announced today

Yesterday Alex and I spoke to some people and from two resources we got to learn that Silverlight for mobile devices will most likely be revealed today at the keynote by Scott Guthrie.

The best is, it’s already able to run managed code. So that means Microsoft is skipping the first version and is immediately releasing Silverlight 2.0 for mobile devices.

More on this today, most likely on many weblogs!

PDC2008 keynote : Windows Azure

Blogging live at the PDC 2008 keynote…

Windows Azure
This new version of Windows was just announced. We’ve got desktop and server (back-end) versions of Windows and this should be the web tier, the operating system for the cloud. Windows Azure is about scaling up and keeping your applications and services up 24/7, no need to take them offline when updating. It contains Live Services, .NET Services, SQL Services, SharePoint Services, Dynamics CRM Services.

servicesPlatform

Microsoft is betting big on Windows Azure and cloud computing and will be offering the following products in Microsoft Online Services initiative.

  • Exchange online
  • SharePoint online
  • Dynamics CRM online

Bluehoo
On demo website running in the cloud is a cool website running on Azure. http://keynote.bluehoo.com/
It’s a social networking site where you can install software on your mobile and see other mobile devices (using bluetooth) around you. If they’ve installed Bluehoo on their mobile you can chat and share interests, etc.

http://m.bluehoo.com is the address to go to with your mobile. It seems an awesome app, we’ll have to try it!

PDC session schedule online

I just noticed the PDC session schedule is online. This means you can find out which sessions are in which slot(s) and you can finally start really planning sessions. This is always extremely difficult as I always want to be in multiple rooms at the same time! :-) I haven’t figured out if some sessions are repeated, as this makes choices sometimes more easy.

pdcschedule

 

Very nice is that you can click sessions in the agenda and mark them so you’ll know which one you want to visit. You can also create a printable version you can take with you to the PDC. Or if you have Windows Mobile (or Outlook on your laptop) you can import the schedule. That should make it also very easy to see where to be at which time! :)

Go check out your own schedule here.

Update : The future of C# by Anders Hejlsberg will be given twice. Once on day one and once on day 3. That’s good, because on day 3 I have 2 other sessions in the same slot.

Silverlight 2 released!

Silverlight 2.0 was just released a few hours ago! Awesome news! If you look at Scott Guthrie’s website, it was released a 3:07 AM. Some sick people over there! The first comment is more than three hours later, when people turned up for work! :-)

At Class-A we’re definitely going to provide training in Silverlight 2.0 so keep a watch on our site for more info. If you want to be mailed about it, get in contact with us and we’ll notify you.

If you want to get started with Silverlight 2, go get it here.

ClickOnce deployment, signed manifests and automated builds and ResolveKeySource failing…

I love ClickOnce, automated builds and a lot more Microsoft stuff. Unfortunately not for everything there is a simple solution. I ran into a new problem today. I was playing around with certificates, signed manifests and all of this in an automated build. I needed to make some application deployable via ClickOnce and instead of everyone else on the project, I used a certificate with a password in it.

Hence that I was the first to run into the problem when you deploy your beautiful little app into the automated build script. Without adding ClickOnce enabled deployment in the build script, when compiling it gave the following error:

ERROR MSB4018 in C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(1805,7) : The "ResolveKeySource" task failed unexpectedly.

Something about popping up a dialog box. You get on guess why…

The problem lies in the fact that at first compilation of the project, the certificate needs to be installed into the users personal store. Again, the users personal store. This means that our build user needs to have it in its own store.

You should start looking for your problem on the internet. Try this one. See how many MVP’s you can count that’ll tell you to login under the build user, open Visual Studio and build the project. That’s not a solution, it’s a work around. And a bad one. I don’t want to login under the build user and definitely not have Visual Studio build the project.

I’ve search and search, but there seems to be no simple solution. My solution was as follows

  1. Download “Run as…” from Sysinternals here.
    Some Windows versions enable “Run as” when holding the SHIFT key before clicking on a tool.
  2. Run it as ShellRunas /reg
    Or run ShellRunas.exe cmd.exe
  3. Fill in the credentials for your build user
  4. Now type “mmc” (without quotes)
  5. Press CTRL+M
  6. Select the “Certificates” snap in
  7. Choose “My user account”
  8. Press OK
  9. Open “Personal” –> “Certificates”
  10. Right-click “Certificates” and choose “All tasks” –> “Import…”
  11. Find the .pfx file
  12. Do NOT enable the strong private key protection.
  13. Finish the wizard

Try your build again.

Now we did not log into Windows as the build user. We went via cmd.exe because mmc.exe needs elevation and you can’t run it immediately via ShellRunas.

Hopes this helps some users…

Problems

A customer of us ran into some problems today. The following kind of describes the problem.

SQL Injection

More Posts Next page »