<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pablo Galiano&#039;s Blog</title>
	<atom:link href="http://blogs.clariusconsulting.net/pga/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.clariusconsulting.net/pga</link>
	<description>Just another Clarius Blogs Sites site</description>
	<lastBuildDate>Tue, 01 Mar 2011 19:00:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>StickyNotes VS2010 TRIAL now available</title>
		<link>http://blogs.clariusconsulting.net/pga/stickynotes-vs2010-trial-now-available/</link>
		<comments>http://blogs.clariusconsulting.net/pga/stickynotes-vs2010-trial-now-available/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 04:54:02 +0000</pubDate>
		<dc:creator>pga</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.clariusconsulting.net/pga/stickynotes-vs2010-trial-now-available/</guid>
		<description><![CDATA[I am pleased to announce that StickyNotes version for Visual Studio 2010 is now available. I like to invite you to try this version of the product, and experience the updated interface and new features. Why should you try it: Visual Studio 2010 support with a new updated user interface *new* Support for VC++ projects [...]]]></description>
			<content:encoded><![CDATA[<p>I am pleased to announce that <a href="http://stickynotes4code.com/">StickyNotes</a> version for Visual Studio 2010 is now available.</p>
<p>I like to invite you to try this version of the product, and experience the updated interface and new features.
<p>Why should you try it:
<ul>
<li>Visual Studio 2010 support with a new updated user interface</li>
<li>*new* Support for VC++ projects</li>
<li>Create notes from Visual Studio tasks</li>
<li>Create notes from compiler, FxCop and StyleCop warnings</li>
<li>Convert notes to Visual Studio tasks</li>
<li>Email notes</li>
<li>Edit in place</li>
</ul>
<p> </p>
<p>You can download it from <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/69b3d5fa-5ad6-4064-a943-4dc7b87a4c80">here</a></p>
<p>Please try it out and don’t forget to send <a href="http://stickynotes4code.uservoice.com/forums/69491-vs2010">feedback</a></p>
<p> </p>
<p>Pablo</p>
<p><img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=263920" width="1" height="1"></p></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.clariusconsulting.net/pga/stickynotes-vs2010-trial-now-available/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MVP 2010</title>
		<link>http://blogs.clariusconsulting.net/pga/mvp-2010/</link>
		<comments>http://blogs.clariusconsulting.net/pga/mvp-2010/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 00:48:46 +0000</pubDate>
		<dc:creator>pga</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.clariusconsulting.net/pga/mvp-2010/</guid>
		<description><![CDATA[Today I received the confirmation email. I am a MVP again for Visual C#. I want to thank my MVP lead Fernando Garcia Loera and the rest of people involved in the evaluation process for the recognition of my community efforts.  Thanks Microsoft!!! Pablo]]></description>
			<content:encoded><![CDATA[<p>Today I received the confirmation email. I am a MVP again for Visual C#.
<p>I want to thank my MVP lead <a href="http://blogs.msdn.com/mvplead">Fernando Garcia Loera</a> and the rest of people involved in the evaluation process for the recognition of my community efforts.
<p>
<p>Thanks Microsoft!!!
<p>Pablo</p>
<p><img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=251020" width="1" height="1"></p>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.clariusconsulting.net/pga/mvp-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DSL / VS10 Extending a DSL part 1</title>
		<link>http://blogs.clariusconsulting.net/pga/dsl-vs10-extending-a-dsl-part-1/</link>
		<comments>http://blogs.clariusconsulting.net/pga/dsl-vs10-extending-a-dsl-part-1/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 18:01:11 +0000</pubDate>
		<dc:creator>pga</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.clariusconsulting.net/pga/dsl-vs10-extending-a-dsl-part-1/</guid>
		<description><![CDATA[***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***   This time I will talk about the new DSL extensibility feature in DSL VS10. This feature allows a model to be extended after it is deployed. This opens a huge number of possible scenarios including third party ones. In this part I will [...]]]></description>
			<content:encoded><![CDATA[<p><strong><u>***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***</u></strong></p>
<p><strong><u></u></strong> </p>
<p>This time I will talk about the new DSL extensibility feature in DSL VS10. This feature allows a model to be extended after it is deployed. This opens a huge number of possible scenarios including third party ones.</p>
<p>In this part I will cover the core changes and concepts in the new version of DSL to support the extensibility feature.</p>
<p>A DSL extension is indeed another DSL. This means that a DSL is extended by creating another DSL.</p>
<p>From now on I will refer to them as the extendee DSL and extension DSL respectively.</p>
<p>These are just a couple of extensibility points that can be provided (just to mention some of them):</p>
<ul>
<li>Add new domain classes / domain relationships
<li>Add new extension elements to existing model elements
<li>Add new commands
<li>Add modeling rules </li>
</li>
</li>
</li>
</ul>
<p>But the real thing is that we can completely override the behavior of the extendee DSL. What really happen behind the scenes is that the extendee domain model plus all the extension domain models found are being loaded into the same store.</p>
<p><strong><em>The new ExtensionElement domain class</em></strong></p>
<p>In the runtime there is a new abstract class called “ExtensionElement” that inherits from the well known ModelElement. This class is used to represent an extension to a model element. It also called “MEX”.</p>
<p><a href="http://www.clariusconsulting.net/images/blogs/pga/93a7a90f31fb_E31A/image.png"><img style="border-right-width:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/pga/93a7a90f31fb_E31A/image_thumb.png"></a> </p>
<p> </p>
<p><em><strong>The new “Extensions” domain relationship</strong></em></p>
<p>The ModelElement was updated and now includes a new “Extensions” domain property. This is basically an embedding relationship between ModelElement and ExtensionElement. </p>
<p> </p>
<p><em><strong>MEX extension methods</strong></em></p>
<p>Under the new <strong>Microsoft.VisualStudio.Modeling.Extensibility</strong> namespace, there are a couple of useful extension methods for the ModelElement class to do CRUD operation over the ModelElement extensions.</p>
<p> </p>
<p>Next part : MEF, extension providers and how extension domain models are being injected</p>
<p>Pablo</p>
<p><img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=162120" width="1" height="1"></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.clariusconsulting.net/pga/dsl-vs10-extending-a-dsl-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VS10 Beta 1 / Specifying isolated shell dependencies</title>
		<link>http://blogs.clariusconsulting.net/pga/vs10-beta-1-specifying-isolated-shell-dependencies/</link>
		<comments>http://blogs.clariusconsulting.net/pga/vs10-beta-1-specifying-isolated-shell-dependencies/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 12:34:28 +0000</pubDate>
		<dc:creator>pga</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.clariusconsulting.net/pga/vs10-beta-1-specifying-isolated-shell-dependencies/</guid>
		<description><![CDATA[***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***   In the previous version of the VS SDK, when we create an Isolated Shell project, there is a command to specify Shell Dependencies:   When we compile the project, those dependencies plus any pkgdef file are being copied to the \PackagesToLoad subfolder. Now [...]]]></description>
			<content:encoded><![CDATA[<p><strong><u>***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***</u></strong></p>
<p><strong><u></u></strong> </p>
<p>In the previous version of the VS SDK, when we create an Isolated Shell project, there is a command to specify Shell Dependencies:</p>
<p><a href="http://www.clariusconsulting.net/images/blogs/pga/523b7ca1a946_457/image.png"><img style="border-right-width:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/pga/523b7ca1a946_457/image_thumb.png"></a>  </p>
<p>When we compile the project, those dependencies plus any pkgdef file are being copied to the \PackagesToLoad subfolder. </p>
<p>Now is VS10, the Shell Dependencies command is gone and the way to add dependencies is via the References button. (which seems more natural to me)</p>
<p><a href="http://www.clariusconsulting.net/images/blogs/pga/523b7ca1a946_457/image_3.png"><img style="border-right-width:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/pga/523b7ca1a946_457/image_thumb_3.png"></a> </p>
<p>Another change is that the PackagesToLoad subfolder was renamed to “Extensions” to be sync with the full IDE extension naming thing. <img src='http://blogs.clariusconsulting.net/pga/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p> </p>
<p>Pablo</p>
<p><img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=161211" width="1" height="1"></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.clariusconsulting.net/pga/vs10-beta-1-specifying-isolated-shell-dependencies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VS10 Beta 1 / The &#8216;pga&#8217; instance</title>
		<link>http://blogs.clariusconsulting.net/pga/vs10-beta-1-the-pga-instance/</link>
		<comments>http://blogs.clariusconsulting.net/pga/vs10-beta-1-the-pga-instance/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 16:04:35 +0000</pubDate>
		<dc:creator>pga</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.clariusconsulting.net/pga/vs10-beta-1-the-pga-instance/</guid>
		<description><![CDATA[***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***   Creating a custom instance/hive for Visual Studio is easier than ever. In this post I will show the details to create a fictitious “pga” instance and configure our VSX development environment to point to it. This can be useful in some testing scenarios [...]]]></description>
			<content:encoded><![CDATA[<p>
				<strong><br />
						<u>***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***</u><br />
				</strong>
		</p>
<p> </p>
<p>Creating a custom instance/hive for Visual Studio is easier than ever. In this post I will show the details to create a fictitious “pga” instance and configure our VSX development environment to point to it.</p>
<p>This can be useful in some testing scenarios or when we just don’t want to reset the experimental instance to test something.</p>
<p> </p>
<p>
				<strong><br />
						<em>Creating the pga instance</em><br />
				</strong>
		</p>
<p>To create a new instance we use the CreateExpInstance tool: </p>
<p>%VSSDK_Installdir%\VisualStudioIntegration\Tools\Bin\CreateExpInstance.exe /Reset /VSInstance=10.0 /RootSuffix=<strong>pga</strong></p>
<p>Once we do that the following directory is created: </p>
<blockquote>
<p>%LocalAppData%\Microsoft\VisualStudio\10.0<strong>pga</strong>\Extensions\</p>
</blockquote>
<p>And all existing extensions in the main hive are copied to: </p>
<blockquote>
<p>%LocalAppData%\Microsoft\VisualStudio\10.0<strong>pga</strong>\Extensions\Extensions-10.0</p>
</blockquote>
<p>
				<em><br />
						<strong>Redirecting the VS SDK msbuild target to the pga instance</strong><br />
				</em>
		</p>
<p>Every time that we compile a VSPackage project the <a href="http://www.clariusconsulting.net/blogs/pga/archive/2009/07/03/157202.aspx">Microsoft.VsSDK.targets</a> msbuild target is executed doing all the necessary steps to deploy our extension.</p>
<p>But the default behavior is to deploy the extension under the experimental instance. To override that behavior we need to include the following property in the VSPackage csproj file:</p>
<p>&lt;PropertyGroup&gt;<br />  &lt;VSSDKTargetPlatformRegRootSuffix Condition=&quot;&#039;$(VSSDKTargetPlatformRegRootSuffix)&#039; == &#039;&#039;&quot;&gt;<strong>pga</strong>&lt;/VSSDKTargetPlatformRegRootSuffix&gt;<br />&lt;/PropertyGroup&gt; </p>
<p> </p>
<p>
				<strong><br />
						<em>Executing VS pointing to the pga instance</em><br />
				</strong>
		</p>
<p>To point Visual Studio to a particular instance we just use the /rootSuffix switch:</p>
<p>%VS_Installdir%\devenv.exe /rootSuffix <strong>pga</strong></p>
<p>Or we can just enable the F5 experience from the Debug tab in the project properties:</p>
<p>
				<a href="http://www.clariusconsulting.net/images/blogs/pga/VS10Thepgahive_9E45/image.png"><br />
						<img style="border:0px none" alt="image" src="http://www.clariusconsulting.net/images/blogs/pga/VS10Thepgahive_9E45/image_thumb.png"><br />
				</a>
		</p>
<p> </p>
<p>Pablo</p>
<p><img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=161051" width="1" height="1"></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.clariusconsulting.net/pga/vs10-beta-1-the-pga-instance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DSL VS10 / Locking policies</title>
		<link>http://blogs.clariusconsulting.net/pga/dsl-vs10-locking-policies/</link>
		<comments>http://blogs.clariusconsulting.net/pga/dsl-vs10-locking-policies/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 12:32:39 +0000</pubDate>
		<dc:creator>pga</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.clariusconsulting.net/pga/dsl-vs10-locking-policies/</guid>
		<description><![CDATA[***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***   Another new feature of the new version of the DSL toolkit is the ability to locks certain operations in a DSL. The idea is that we can define locking policies for a DSL and those policies are executed at runtime to constraint specific [...]]]></description>
			<content:encoded><![CDATA[<p><strong><u>***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***</u></strong></p>
<p> </p>
<p>Another new <a href="http://www.clariusconsulting.net/blogs/pga/archive/2009/07/14/160639.aspx">feature</a> of the new version of the DSL toolkit is the ability to locks certain operations in a DSL. The idea is that we can define locking policies for a DSL and those policies are executed at runtime to constraint specific operations such as Add/Delete/Update etc.</p>
<p>These locking policies can be defined at three different levels , Store, Partition and ModelElement respectively.</p>
<p><strong><em>Defining our own locking policies</em></strong></p>
<p>It is really simple to create our own policy class, we just need to create a class that inherits from ILockingPolicy.
<p>Then we need to define the locks that we are going to return, and for that we have three levels of granularity:
<ul>
<li>Store
<li>Partition
<li>ModelElement</li>
</li>
</li>
</ul>
<p>Locks are transitive following the “Store –&gt; Partition –&gt; ModelElement” object hierarchy.
<p>That means that if we set locks at the Store level, those locks also apply to the Partition and the ModelElement levels.
<p>The lock types are:
<p><a href="http://www.clariusconsulting.net/images/blogs/pga/DSLVS10_B602/image.png"><img style="border-right-width:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/pga/DSLVS10_B602/image_thumb.png"></a>
<p>
<p>public class MyLockingPolicy : ILockingPolicy<br />{<br />    public Locks RefineLocks(ModelElement element, Locks proposedLocks)<br />    {<br />        return proposedLocks;<br />    }
<p>    public Locks RefineLocks(Partition partition, Locks proposedLocks)<br />    {<br />        return proposedLocks;<br />    }
<p>    public Locks RefineLocks(Store store, Locks proposedLocks)<br />    {<br />        // TODO: return corresponding locks and they will also apply to Partition and ModelElement<br />    }
<p>}</p>
<p> </p>
<p><em><strong>Injecting our own ILockingPolicy</strong></em></p>
<p>The Store class constructor sets the locking policy by querying for a ILockingPolicy service. That means that one possible way to inject our own locking policy is to override the GetService method and return our policy class:</p>
<p>internal partial class MyDocData<br />{<br />    private ILockingPolicy myLockingPolicy;
<p>    public override object GetService(Type serviceType)<br />    {<br />        if (serviceType == typeof(SLockingPolicy) || serviceType == typeof(ILockingPolicy))<br />        {<br />            if (myLockingPolicy == null)<br />            {<br />                <strong>myLockingPolicy = new MyLockingPolicy();</strong><br />            }
<p>            return myLockingPolicy;<br />        }
<p>        return base.GetService(serviceType);<br />    }<br />}
</p>
<p> </p>
<p>At runtime the DSL infrastructure will query for existing locks using a set of extension methods located in the new <strong>ImmutabilityExtensionMethods</strong> class and constraint or not an operation accordingly.</p>
<p> </p>
<p><strong><em>The hardware model sample</em></strong></p>
<p>I published a <a href="http://code.msdn.microsoft.com/VS10XSamples">sample</a> that shows how to lock a DSL.</p>
<p>The scenario is that there are two personas:</p>
<ul>
<li>Developer: He uses the VS full IDE to author a hardware model.</li>
<li>Architect: He uses an Isolated shell to review the model and cannot do any modifications to it.</li>
</ul>
<p>The locks are being set by detecting the shell SKU.</p>
<p> </p>
<p>Pablo</p>
<p><img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=161025" width="1" height="1"></p>
</p>
</p>
</p>
</p>
</p>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.clariusconsulting.net/pga/dsl-vs10-locking-policies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VS10 Beta 1 / T4 Preprocessing part 2</title>
		<link>http://blogs.clariusconsulting.net/pga/vs10-beta-1-t4-preprocessing-part-2/</link>
		<comments>http://blogs.clariusconsulting.net/pga/vs10-beta-1-t4-preprocessing-part-2/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 14:16:11 +0000</pubDate>
		<dc:creator>pga</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.clariusconsulting.net/pga/vs10-beta-1-t4-preprocessing-part-2/</guid>
		<description><![CDATA[***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***   In the first part I covered the details of the T4 Preprocessing API. Now it’s time to create a preprocessed text template and mimic the GAX property directive processor feature. Let’s add a preprocessed text template. For that purpose there is a new [...]]]></description>
			<content:encoded><![CDATA[<p><strong><u>***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***</u></strong></p>
<p> </p>
<p>In the first <a href="http://www.clariusconsulting.net/blogs/pga/archive/2009/07/15/160836.aspx">part</a> I covered the details of the T4 Preprocessing API.</p>
<p>Now it’s time to create a preprocessed text template and mimic the GAX property directive processor feature.</p>
<p>Let’s add a preprocessed text template. For that purpose there is a new item template in the VS10 Add new item dialog:</p>
<p><a href="http://www.clariusconsulting.net/images/blogs/pga/VS10Beta1T4Preprocessingpart2_AEB2/image.png"><img style="border-right-width:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/pga/VS10Beta1T4Preprocessingpart2_AEB2/image_thumb.png"></a> </p>
<p>After we add a pre-compiled template item, we can see the output of the transformation:</p>
<p> </p>
<p><a href="http://www.clariusconsulting.net/images/blogs/pga/VS10Beta1T4Preprocessingpart2_AEB2/image_3.png"><img style="border-right-width:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/pga/VS10Beta1T4Preprocessingpart2_AEB2/image_thumb_3.png"></a> </p>
<p> </p>
<p><a href="http://www.clariusconsulting.net/images/blogs/pga/VS10Beta1T4Preprocessingpart2_AEB2/image_4.png"><img style="border-right-width:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/pga/VS10Beta1T4Preprocessingpart2_AEB2/image_thumb_4.png"></a> </p>
<p>As you can see, the namespace is calculated from the project default namespace property, and the tt item name is used to calculate the class name.</p>
<p><em><strong></strong></em> </p>
<p><em><strong>Using properties to mimic the GAX </strong></em><a href="http://www.clariusconsulting.net/blogs/kzu/archive/2006/01/13/XLinqVsTemplates.aspx"><em><strong>PropertyProcessor directive</strong></em></a></p>
<p>
<p>After the <strong>TemplatedPreprocessor </strong>runs we end up with a template class, which is just a regular class with some helper methods to write the transformation.
<p>These methods are similar to the ones provided in the base <a href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.texttemplating.texttransformation(VS.80).aspx">TextTransformation</a> class. But to remove the dependency to the Microsoft.VisualStudio.TextTemplating.10.0 assembly those methods are now part of our template class.
<p>To add properties that will be consumed inside the template, it is just a matter of declaring a partial class and adding them there:
<p>namespace PreTT<br />{<br />    public partial class MyPreTextTemplate<br />    {<br />        <strong>public string MyProperty { get; set; }</strong><br />    }<br />}
<p>Then from within the template we can just refer to the property:
<p>&lt;#@ template language=&quot;C#&quot; #&gt;<br />MyProperty value is &lt;#= <strong>this.MyProperty</strong> #&gt;
<p> </p>
<p>To test the transformation we create an instance of the template class and we call the TransformText method:</p>
<p>public static void Main(string[] args)<br />{<br />    Console.WriteLine(<br />        <strong>new MyPreTextTemplate { MyProperty = &#8220;Foo&#8221; }<br />        .TransformText()</strong>);
<p>    Console.Read();<br />}
<p> </p>
<p>And the transformation output is :</p>
<p><a href="http://www.clariusconsulting.net/images/blogs/pga/VS10Beta1T4Preprocessingpart2_AEB2/image_5.png"><img style="border-right-width:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/pga/VS10Beta1T4Preprocessingpart2_AEB2/image_thumb_5.png"></a> </p>
<p> </p>
<p>Pablo</p>
<p><img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=160853" width="1" height="1"></p>
</p>
</p>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.clariusconsulting.net/pga/vs10-beta-1-t4-preprocessing-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VS10 Beta 1 / T4 Preprocessing part 1</title>
		<link>http://blogs.clariusconsulting.net/pga/vs10-beta-1-t4-preprocessing-part-1/</link>
		<comments>http://blogs.clariusconsulting.net/pga/vs10-beta-1-t4-preprocessing-part-1/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 12:00:50 +0000</pubDate>
		<dc:creator>pga</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.clariusconsulting.net/pga/vs10-beta-1-t4-preprocessing-part-1/</guid>
		<description><![CDATA[***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***   Gareth wrote some time ago two nice posts about the T4 Preprocessing feature: The Rationale behind this feature The basic design This post will have two parts. The first one will cover the details of the new API and the second one will [...]]]></description>
			<content:encoded><![CDATA[<p><strong><u>***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***</u></strong></p>
<p> </p>
<p><a href="http://blogs.msdn.com/garethj">Gareth</a> wrote some time ago two nice posts about the T4 Preprocessing feature:</p>
<ul>
<li>The <a href="http://blogs.msdn.com/garethj/archive/2008/11/11/dsl-2010-feature-dives-t4-preprocessing-rationale.aspx">Rationale</a> behind this feature
<li>The basic <a href="http://blogs.msdn.com/garethj/archive/2008/11/12/dsl-2010-feature-dives-t4-preprocessing-part-two-basic-design.aspx">design</a> </li>
</li>
</ul>
<p>This post will have two parts. The first one will cover the details of the new API and the second one will show how to create a preprocessed text template and the how to mimic the GAX property directive processor feature using partial classes.</p>
<p>The precompiled text template feature is really useful in scenarios where the text templates doesn&#8217;t change at run time. </p>
<p>Let’s say that we have an application that uses a set of templates for code generation, and those templates never change. </p>
<p>This is a perfect fit for precompiled templates.  Instead of deploying a set of .tt files as part of the application, we can pre-compile them and they now can be part of the main application assembly or any other component assembly. </p>
<p>This *drastically* improves the performance because on each transformation this is what happens behind the scenes in order to get a transformation result:</p>
<ul>
<li>A template processor calls the template engine that:
<ul>
<li>Parses the template
<li>Processes the directives
<li>Generates the template class
<li><strong>If the text template doesn’t cache the assemblies (<em>CacheAssemblies</em>=&#8221;false”) or if the application domain needs to be recycled</strong>
<ul>
<li><strong>The template host creates an application domain</strong>
<li><strong>The template host resolves the assembly references that are defined in the template</strong>
<li><strong>The template host creates a transformation runner that:</strong>
<ul>
<li><strong>Compiles the generated template class into a temporary assembly</strong>
<li><strong>Loads the temporary  assembly into the application domain</strong>
<li><strong>Calls the “TransformText” method that returns the transformation result</strong></li>
</li>
</li>
</ul>
</li>
</li>
</li>
</ul>
<li><strong>Else</strong>
<ul>
<li><strong>The template host creates a transformation runner that:</strong>
<ul>
<li><strong>Uses the cached assembly</strong>
<li><strong>Calls the “TransformText” method that returns the transformation result</strong></li>
</li>
</ul>
</li>
</ul>
</li>
</li>
</li>
</li>
</li>
</ul>
</li>
</ul>
<p> </p>
<p>With a precompiled template we skip all the steps in <strong>*bold*</strong> and we just call the “TransformText” method in the compiled template class that is part of the application or component assembly.</p>
<p>Also, having a precompiled template means that a transformation can run in any .Net environment without the need of having Visual Studio or the Microsoft.VisualStudio.TextTemplating.* assemblies installed. </p>
<p> </p>
<p><em><strong>API changes to support template preprocessing</strong></em>
<ul>
<li>The following two interfaces were updated to include the new PreprocessTemplate method:</li>
</ul>
<blockquote><p>public interface <b>ITextTemplating</b></p>
<p><strong></strong>{ </p>
<p>string <b>PreprocessTemplate</b>(string inputFile, string content, ITextTemplatingCallback callback, string className, string classNamespace, out string[] references);</p>
<p>}</p>
<p>public interface <b>ITextTemplatingEngine</b></p>
<p><strong></strong>{ </p>
<p>string <b>PreprocessTemplate</b>(string content, ITextTemplatingEngineHost host, string className, string classNamespace, out string language, out string[] references);</p>
<p>}</p>
</blockquote>
<ul>
<li>A new <b>TemplatedPreprocessor</b> custom tool /single file generator was added:</li>
</ul>
<blockquote><p><a href="http://www.clariusconsulting.net/images/blogs/pga/VS10Beta1T4Preprocessingpart1_AEAC/image.png"><img style="border-right-width:0px;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/pga/VS10Beta1T4Preprocessingpart1_AEAC/image_thumb.png"></a> </p>
</blockquote>
<blockquote><p>This new custom tool is the responsible for creating the template class at design time. This tool basically does the following:</p>
</blockquote>
<ul>
<ul>
<li>Parses the template
<li>Processes the directives
<li>Generates the template class</li>
</li>
</li>
</ul>
</ul>
<p> </p>
<p>Stay tuned,</p>
<p>Pablo</p>
<p><img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=160836" width="1" height="1"></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.clariusconsulting.net/pga/vs10-beta-1-t4-preprocessing-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DSL / VS 10 ModelBus part 2</title>
		<link>http://blogs.clariusconsulting.net/pga/dsl-vs-10-modelbus-part-2/</link>
		<comments>http://blogs.clariusconsulting.net/pga/dsl-vs-10-modelbus-part-2/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 12:53:35 +0000</pubDate>
		<dc:creator>pga</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.clariusconsulting.net/pga/dsl-vs-10-modelbus-part-2/</guid>
		<description><![CDATA[***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***   In the first part of this series I described general concepts around the ModelBus infrastructure. In this second part I will describe the model bus service and how MEF is involved. The ModelBus as a Service The Microsoft.VisualStudio.Modeling.Sdk.Integration.Shell.10.0 is a VS Package that [...]]]></description>
			<content:encoded><![CDATA[<p><strong></strong><strong><u>***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***</u></strong></p>
<p> </p>
<p>In the first <a href="http://www.clariusconsulting.net/blogs/pga/archive/2009/07/14/160639.aspx">part</a> of this series I described general concepts around the ModelBus infrastructure. In this second part I will describe the model bus service and how MEF is involved.</p>
<p><em>The ModelBus as a Service</em></p>
<p>The Microsoft.VisualStudio.Modeling.Sdk.Integration.Shell.10.0 is a VS Package that defines one core service, the IModelBus service. </p>
<p>The model bus service creates and uses its own MEF <a href="http://mef.codeplex.com/Wiki/View.aspx?title=Hosting%20MEF%20and%20the%20Container&amp;referringTitle=Home">composition container</a> with two <a href="http://mef.codeplex.com/Wiki/View.aspx?title=Using%20Catalogs&amp;referringTitle=Home">directory catalogs</a> pointing to:</p>
<ul>
<li>%LocalAppData%\Microsoft\VisualStudio\10.0\Extensions </li>
<li>%VS10_Install_Dir%\Extensions</li>
</ul>
<p> </p>
<p>A DSL <a href="http://mef.codeplex.com/Wiki/View.aspx?title=Declaring%20Exports&amp;referringTitle=Home">exports</a> an adapter manager and provides some <a href="http://mef.codeplex.com/Wiki/View.aspx?title=Exports%20and%20Metadata&amp;referringTitle=Home">metadata</a> to specify which adapter this manager manages: </p>
<p>[Export(typeof(ModelBusAdapterManager))]</p>
<p>[HandlesAdapter(“MyAdapterId”)]<br />public partial class MyAdapterManager : VsModelingAdapterManager<br />{</p>
<p>…<br />}</p>
<p> </p>
<p>The main responsibility of the model bus is to find registered adapter managers, for that the composition container is used:</p>
<p>container.GetExportedObjects&lt;ModelBusAdapterManager&gt;()</p>
<p> </p>
<p>In order to register a DSL with the model bus we need to do the following steps:</p>
<ul>
<li>Update the model definition to introduce a domain property that will hold the model reference</li>
<li>Update the model serialization behavior to include the model reference serialization</li>
<li>Create an adapter for the DSL</li>
<li>Create an export an adapter manager for the DSL</li>
<li>Deploy the DSL under extensions (done automatically at compilation time via the <a href="http://www.clariusconsulting.net/blogs/pga/archive/2009/07/03/157202.aspx">VS SDK msbuild target</a>)</li>
</ul>
<p> </p>
<p>Stay tuned,</p>
<p>Pablo</p>
<p><img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=160650" width="1" height="1"></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.clariusconsulting.net/pga/dsl-vs-10-modelbus-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DSL / VS 10 ModelBus part 1</title>
		<link>http://blogs.clariusconsulting.net/pga/dsl-vs-10-modelbus-part-1/</link>
		<comments>http://blogs.clariusconsulting.net/pga/dsl-vs-10-modelbus-part-1/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 11:33:58 +0000</pubDate>
		<dc:creator>pga</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.clariusconsulting.net/pga/dsl-vs-10-modelbus-part-1/</guid>
		<description><![CDATA[***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***   One of the new main features of the new version of the DSL toolkit is the “ModelBus”. The model bus basically allows a model element to reference another model element (ModelBusReference). These two model elements could be defined either in the same DSL [...]]]></description>
			<content:encoded><![CDATA[<p><strong><u>***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***</u></strong></p>
<p> </p>
<p>One of the new main features of the new version of the DSL toolkit is the “ModelBus”. The model bus basically allows a model element to reference another model element (ModelBusReference). These two model elements could be defined either in the same DSL or in different ones. With a ModelBusReference we can do interesting model interactions such as navigating the references back and forth, performing validation across models, etc.</p>
<p> </p>
<p>The ModelBus infrastructure lives in two core assemblies:</p>
<ul>
<li>Microsoft.VisualStudio.Modeling.Sdk.Integration.10.0
<li>Microsoft.VisualStudio.Modeling.Sdk.Integration.Shell.10.0</li>
</li>
</ul>
<p> </p>
<p><em><strong>Microsoft.VisualStudio.Modeling.Sdk.Integration.10.0</strong></em></p>
<p>As the name implies, this assembly contains concepts that are totally decoupled from Visual Studio.</p>
<p>The main generic concepts are:</p>
<p><strong>ModeBusAdapter</strong></p>
<p>Is a bridge between the model bus and the underlying model. Therefore each model has its own adapter. </p>
<p>It’s main responsibilities are:</p>
<ul>
<li>Get all references of an element type
<li>Resolve a reference into an object
<li>Get the view associated with the model</li>
</li>
</li>
</ul>
<p><strong>ModelBusAdapterManager</strong></p>
<p>Is used to create and control the lifetime of adapters.</p>
<p>It’s main responsibilities are:</p>
<ul>
<li>Create adapters
<li>Create reference to a model
<li>Return the list of supported adapters
<li>Return the list of exposed element types. An exposed element type is an element that can be referenced by another element</li>
</li>
</li>
</li>
</ul>
<p><strong>ModelBusReference</strong></p>
<p>Encapsulates information about a reference in the model bus. It is composed of:</p>
<ul>
<li>Adapter reference
<li>Adapter id
<li>Model display name
<li>Element display name</li>
</li>
</li>
</li>
</ul>
<p>It is being serialized as: <strong></strong></p>
<p><a href="http://www.clariusconsulting.net/images/blogs/pga/79e347c828a1_F3C2/image.png"><img style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/pga/79e347c828a1_F3C2/image_thumb.png"></a> </p>
<p><strong>ModelBusAdapterReference</strong></p>
<p>Represents the base class for adapter references</p>
<p><strong>ModelBusView</strong></p>
<p>Allows a client to manipulate the design surface of the model (if applicable)</p>
<p>It’s main responsibilities are:</p>
<ul>
<li>Open view
<li>Close view
<li>Show view
<li>Hide view
<li>Select UI elements</li>
</li>
</li>
</li>
</li>
</ul>
<p> </p>
<p>Then we have a set of derived classes that are specific to DSLs:</p>
<ul>
<li>ModeBusAdapter&lt;- <strong>ModelingAdapter</strong>
<li>ModelBusAdapterReference &lt;- <strong>ModelingAdapterReference</strong></li>
</li>
</ul>
<p><strong>ModelingAdapter</strong></p>
<p>Represents the base class for DSL based adapters. In this case the model is a DSL model.</p>
<p><strong>ModelingAdapterReference</strong></p>
<p>Encapsulates information about a model element reference, it is composed of:</p>
<ul>
<li>Model element id
<li>View id
<li>Model file absolute path</li>
</li>
</li>
</ul>
<p>It is being serialized as: </p>
<p><a href="http://www.clariusconsulting.net/images/blogs/pga/79e347c828a1_F3C2/image_3.png"><img style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px" alt="image" src="http://www.clariusconsulting.net/images/blogs/pga/79e347c828a1_F3C2/image_thumb_3.png"></a> </p>
<p> </p>
<p><em><strong>Microsoft.VisualStudio.Modeling.Sdk.Integration.Shell.10.0</strong></em></p>
<p>In this assembly there are concepts that are coupled to the Visual Studio infrastructure.</p>
<p><strong>VsModelingAdapterManager</strong></p>
<p>This adapter manager introduces the notion of document handlers that knows how to handle a DocData concept.</p>
<p><strong>VsModelingView</strong></p>
<p>This implementation is tied to the DocView concept.</p>
<p> </p>
<p>Stay tuned,</p>
<p>Pablo</p>
<p><img src="http://www.clariusconsulting.net/aggbug.aspx?PostID=160639" width="1" height="1"></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.clariusconsulting.net/pga/dsl-vs-10-modelbus-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

