SixPairs

June 10, 2014

Dsl inceleyen Dsl

Filed under: DSL — Ceyhun Ciper @ 07:58

Aslinda daha once MVVM generate etmek icin DSL’leri inceleyip ViewModel’lari create eden bir MVVMGen DSL’i yaratmistim; bunun ilk etabi bir DSL definition’i icindeki tum verileri toparlayip custom bir XML generate etmek olmustu. Ama DSL’leri zaten XML editlememek icin kullanmiyor muyum? Bu nedenle dsl’leri inceleyen bir dsl ihtiyaci hasil oldu.

Ilk yaklasimda MVVMGen sunu yapiyordu:

  1. Bir template ile bir dsl definition’inini analiz et
  2. Belli bir semaya uygun xml datasi gen. et
  3. xml datasindan C# class’lari generate et

1. adim zaten sakat: template’ler (debug edilebilmesine ragmen) pek kolay kullanimli degil; ozellikle intellisense sucks. Bu nedenle dsl designer extension’larina switch ettim. O zaman durum su:

  1. Dsl designer extension’lariyla dsl definition’ini analiz et
  2. Belli bir semaya uygun xml datasi gen. et
  3. xml datasindan C# class’lari generate et

2. adim icin de once bir sema tanimladim, sonra da xml’i buna gore (de)serialize ettim; ama iste burda “niye dsl’leri kullanmiyorum” diye kandime sormaya basladim… Yani dsl’in dsl’i… Ama sadece incelemek icin, yani bir meta-dsl degil. Boylelikle sema falan da yaratmaya veya xsd.exe’yi kullanmaya gerek kalmiyor.

3. adim icin ise template’ler kullanmak yerine Roslyn’i kullanmak daha mantikli.

2. adimin pre-requisite’leri:

  1. Load/save the dsl programmatically (easy)

 

May 13, 2011

Work Designer DSL User’s Guide

Filed under: DSL — Tags: , — Ceyhun Ciper @ 15:00

Install the “Work Designer” DSL from Visual Studio Gallery:

clip_image002[8]

Verify that it is installed:

clip_image004[8]

In any C# project, add a new “Work Designer” item:

clip_image006[6]

clip_image008[6]

First, you have to specify the folders where your projects are organized by setting the properties of your “Work Model” in the “Work Designer” tool window:

clip_image010[5]

You can organize the swimlanes any way you want:

clip_image012[5]

Then you can add your projects, categories, customers and sites using the toolbox:

clip_image014[5]

When you save your model, non-existing projects will be flagged with warnings:

clip_image016[5]

Notice that in your project there is also a template that generates an html report:

clip_image018[5]

clip_image020[6]

The code of the template will guide you in generating your own reports as the whole object model is available in the model:

clip_image022[5]

In fact, here is the object model to program on:

clip_image024

Work Designer DSL

Filed under: DSL — Tags: — Ceyhun Ciper @ 10:42

This is a visual DSL that lets you keep track of your projects; it is available on Visual Studio Gallery.

Click to enlarge

Here is a sample report:

Click to enlarge

February 7, 2011

Solution File Explorer

Filed under: DSL, MSBuild — Ceyhun Ciper @ 17:53

Any software house has dozens of Visual Studio solutions somewhere on the network. Some of them are quite old, but still in use. Some of them are not and they are not being used. Some of them need to be upgraded; you need to know which ones without opening them individually (which, by the way, will force you to upgrade them).

Here is an .sln file explorer that I uploaded to the Visual Studio Gallery:

Preview

February 4, 2011

Internal To Public

Filed under: DSL, Reflection — Ceyhun Ciper @ 19:26

Oftentimes, you need to access internal classes of assemblies for which you don’t have the sources. There are many good arguments why you should not do this:

  1. If it is internal, it is for a good reason.
  2. It will probably be modified in a subsequent version.
  3. It has side-effects that you are not aware of.

Argument 1 is weak; if it is not private, it is for a good reason: because it is re-used in some other part of the assembly. Thus argument 2 is weaker, because the assembly is less maintainable by its manufacturer.

On the other hand, there are many hidden jewels in assemblies that we use every day, especially from Microsoft. So some of the other reasons why classes are marked as internal are:

  1. They don’t want to clubber the namespace with unnecessary detail.
  2. They don’t want to write documentation for it; in the case of Microsoft, the MSDN documentation is already very weak, even for over-mature things such as EnvDTE, often consisting of text derived from xml comments giving just the name of a method and the names of its parameters. Imagine if they were to write these comments for non-vital parts of the library, let alone document it (which they have already bypassed).

An example of a useful internal class resides in the Microsoft.Build.dll; it is called SolutionParser and parses any .sln file, for which there is no schema, of course.

So, suppose I have the binaries of the following library:

image

Now suppose I want to access the very much uninteresting property “Property” of the “Class” class. Of course, I have to use reflection and write some code similar to the following:

image

Then I can access the property that I was going after:

var c = new SampleLibrary.Reflected.Class();
var p = c.Property;

As all this is very tedious to do by hand and quite automatic anyway, so I developed a DSL to do it for me; it is posted on the Visual Studio Gallery.

Idea: Create a repository of useful internal classes in Microsoft’s assemblies.

The property might as well be private:

image

Or the class itself:

image

The end result is of course the same.

Here is a screenshot:

image

And here is the screenshot upon conversion:

image

December 12, 2010

Visual Dot or Visual GraphViz

Filed under: DSL, GraphViz — Ceyhun Ciper @ 23:24

You can now design your dot graphs interactively using VS2010:

dot

It is available in Visual Studio Gallery.

Now, suppose I want to describe “Visual Dot” in terms of itself:image

Here I interactively describe the tool in the DSL and get the Xaml rendering in real-time.

Blog at WordPress.com.