<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Efficient Bits]]></title><description><![CDATA[Thoughts on making software by Jamie da Silva]]></description><link>https://efficientbits.azurewebsites.net/</link><generator>Ghost 0.11</generator><lastBuildDate>Mon, 06 Apr 2026 19:56:00 GMT</lastBuildDate><atom:link href="https://efficientbits.azurewebsites.net/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Build Nightmares]]></title><description><![CDATA[<p><strong>7/10 - Newtonsoft.Json.dll 6.x is installed in the GAC by an application on the dev server</strong></p>

<ul>
<li>MSBuild no longer copys Newtonsoft.Json.dll during build.</li>
<li>Build does not fail because old copies are in output folders.</li>
</ul>

<p><strong>8/11 - Newtonsoft.Json.dll 7.x is added</strong></p>]]></description><link>https://efficientbits.azurewebsites.net/build-nightmares/</link><guid isPermaLink="false">2297a73e-7874-4d94-9ff6-0a6c90dace69</guid><dc:creator><![CDATA[Jamie da Silva]]></dc:creator><pubDate>Sat, 12 Sep 2015 18:28:22 GMT</pubDate><content:encoded><![CDATA[<p><strong>7/10 - Newtonsoft.Json.dll 6.x is installed in the GAC by an application on the dev server</strong></p>

<ul>
<li>MSBuild no longer copys Newtonsoft.Json.dll during build.</li>
<li>Build does not fail because old copies are in output folders.</li>
</ul>

<p><strong>8/11 - Newtonsoft.Json.dll 7.x is added to ClientProject.Services</strong></p>

<ul>
<li>Build does not fail because this is not yet deployed.</li>
</ul>

<p><strong>9/8 - ClientProject.Services is referenced by ClientProject.Endpoint</strong></p>

<ul>
<li>Local builds do not fail because last copied Newtonsoft.Json.dll is still 6.x</li>
<li>Dev build copies Newtonsoft.Json.dll 7.x because it is not in the GAC.</li>
<li>Dev deploy does not fail because 6.x is in the GAC.</li>
</ul>

<p><strong>9/11 10:00pm - ClientProject.Endpoint is deployed to UAT</strong></p>

<ul>
<li>Endpoint fails to start with AutofacDependencyResolutionException and does not
display inner exception details; eventually get to underlying dll load exception.</li>
</ul>

<p><strong>9/11 11:40pm - All projects corrected to use same verison of 6.x</strong></p>

<ul>
<li>Build still copies 7.x from dirty output folders.</li>
</ul>

<p><strong>9/11 11:55pm - Folders are cleaned and Build is run again</strong></p>

<ul>
<li>No longer copies any Newtonsoft.Json.dll</li>
<li>Finally piece together how events of 7/10 are tied to how MSBuild works and how the default
copy local=true means only if not GAC'd but copy local=true after being toggled off then on again puts <code>&lt;Private&gt;True&lt;/Private&gt;</code> on the reference which <em>really</em> means always copy.  <a href="https://nuget.codeplex.com/workitem/4344"><strong><em>No seriously, that's a thing.</em></strong></a></li>
</ul>

<p><strong>9/11 1:00am - Fix reference in the ClientProject.Endpoint <em>by toggling CopyLocal off and back on</em>.</strong></p>

<ul>
<li>Confirm correct deployment in UAT!</li>
</ul>

<p><strong>9/11 1:30am - Discover that a workaround/fix exists in a later Nuget.</strong></p>

<ul>
<li>Discussion: <a href="https://nuget.codeplex.com/workitem/4344">https://nuget.codeplex.com/workitem/4344</a></li>
<li>Fix: <a href="https://nuget.codeplex.com/SourceControl/changeset/0b1c96abc37a5b3d8b482c686741e7b20e545790">https://nuget.codeplex.com/SourceControl/changeset/0b1c96abc37a5b3d8b482c686741e7b20e545790</a>, btw 
"Try jiggling it" - is a great description for that commit.</li>
</ul>

<p><strong>9/11 1:45a - Quit software development forever (or until morning whichever comes fist).</strong></p>

<p><strong>9/12 - UPDATE NUGET in Visual Studio</strong></p>]]></content:encoded></item><item><title><![CDATA[A Simple Order Process with Azure WebJobs]]></title><description><![CDATA[<p>The order system for <a href="http://velocity.silverlakesoftware.com/">Velocity</a> uses Azure WebJobs behind the scenes.  In this post, I'll explain how I use WebJobs and some things I've learned along the way.</p>

<h2 id="introduction">Introduction</h2>

<p>Azure WebJobs is really easy to work with.  All you need to is build a console app, put in the functions</p>]]></description><link>https://efficientbits.azurewebsites.net/a-simple-order-process-with-azure-webjobs/</link><guid isPermaLink="false">f13c4c25-8cba-42ff-a126-ece8447f6e72</guid><dc:creator><![CDATA[Jamie da Silva]]></dc:creator><pubDate>Tue, 02 Sep 2014 21:19:53 GMT</pubDate><content:encoded><![CDATA[<p>The order system for <a href="http://velocity.silverlakesoftware.com/">Velocity</a> uses Azure WebJobs behind the scenes.  In this post, I'll explain how I use WebJobs and some things I've learned along the way.</p>

<h2 id="introduction">Introduction</h2>

<p>Azure WebJobs is really easy to work with.  All you need to is build a console app, put in the functions you want available, and attach it to your website for automatic deployment.  Scott gives a great intro in his <a href="https://efficientbits.azurewebsites.net/a-simple-order-process-with-azure-webjobs/">Introducing Windows Azure Webjobs</a> post, so I will try not to duplicate that here.  I've found the <a href="https://efficientbits.azurewebsites.net/a-simple-order-process-with-azure-webjobs/">Microsoft Azure Blog</a> is the best resource for the latest information and as of the publishing this I'm looking the <a href="http://azure.microsoft.com/blog/2014/08/21/announcing-the-0-4-0-beta-preview-of-microsoft-azure-webjobs-sdk/">0.4.0-beta preview</a>.</p>

<p>One thing I will reiterate is how great the WebJobs control panel is.  Through the panel you can see the status of running jobs.  You can see a history of the various functions including inputs an outputs.  You can choose to replay a particular function or enter the inputs manually and trigger a run.  It also understands causality between functions so that it knows when a particular function was triggered by another.</p>

<h2 id="buildinganordersystem">Building an Order System</h2>

<p>Azure WebJobs is setup to make it very easy to work with Queues and Blobs in Azure.  I thought it would make a lot of sense to separate the actual order process from the website as much as possible in part to be as defensive against failures as I could.  I was using <a href="http://www.stripe.com/">Stripe</a> for payments and <a href="http://http://www.mailgun.com/">Mailgun</a> for transactional email.  What happens when one of these services is down?  Using a queue to manage the orders fits perfectly.  A transient failure can occur and the message replayed.</p>

<p>When I first started to develop the order system I had one function that was basically "Order a License".  The function would complete the charge with Stripe, create the license, and email a link to the customer.  I quickly realized this is less than ideal.  If, for example, the email were to fail I would have to come up with a different way to send the email. Replaying the function would either fail or create a duplicate charge and would not be helpful.</p>

<p>The obvious improvement was to separate each step into its own function.  This resulted in three distinct functions: <br>
1. OrderLicense <br>
2. GenerateLicense <br>
3. SendLicense <br>
Now if the mail service were temporarily down I could simply replay the SendLicense function.</p>

<h4 id="orderlicense">Order License</h4>

<p>This completes the charge with Stripe then  passes a message to the next queue to generate the license.  I kept this function particularly simple because once someone has decided to make a purchase then completing the charge is extremely important.  Everything else can be corrected or done manually, but I can't expect customers to make the purchase a second time.</p>

<h4 id="generatelicense">Generate License</h4>

<p>This function takes the information in the order and creates the license file.  The license file is stored as a blob.  This blob is registered as an output.  Now I did overload this function a bit and also use it to store a record of the order and the license.  I may need to refine this later, but so far this has been just fine.  Once complete this function outputs a message to trigger the next function.</p>

<h4 id="sendlicense">Send License</h4>

<p>This function only sends the final email to the customer thanking them for their purchase and including a link to their license.  </p>

<h2 id="webjobmagic">WebJob Magic</h2>

<p>Authoring these functions is really easy thanks to the WebJob SDK. Each one is based on a QueueTrigger to start the function.  They also have other inputs and outputs all of which are specified using special attributes on the parameters of the function.  The GenerateLicense function for example writes a license entry to a table and generates the license file as a blob.  These are simply handled as arguments to the function:</p>

<pre><code>[QueueTrigger("generate")] Message message,
[Table("Licenses")] CloudTable licenses,
[Blob("licenses/{TransactionId}.license")] out string license
</code></pre>

<p>This kind of stuff makes working with Azure really easy.  Note the use of <code>{TransactionId}</code> in the Blob attribute.  This automatically pulls the transaction id from the trigger message and uses it as the name of the blob.  I simply set the string before exiting the function and the blob is created.</p>

<p>The send license function takes similar advantage of the WebJob attributes:</p>

<pre><code>[Table("Orders", "{Email}", "{TransactionId}")] OrderEntity orderEntity
</code></pre>

<p>Again this uses special notations <code>{Email}</code> and <code>{TransactionId}</code> to automatically use values from the trigger message as the PartitionKey and RowKey for the table.  The SDK then supplies the function with the matching row in the argument.</p>

<p>Ultimately, the Azure WebJobs SDK does a good job of letting me describe the function with its inputs and outputs in terms of Azure components. This creates expressive code and reduces boilerplate.  </p>

<h2 id="betabluesandsometips">Beta Blues and Some Tips</h2>

<ul>
<li><p>There are some caveats to using WebJobs right now. It's a beta preview.  I haven't found any particular issues with bugs, but the behavior can and will change from release to release.   When releasing 0.4 for example, the Azure service was updated to use new connection string names.  Use at your own risk and be attentive to changes.</p></li>
<li><p>As of this writing beware of using slots.  I recently deployed a staging slot and a production slot.  I eventually switched to move staging to production but this left the old version of my continously running job side by side with the new version.  This can lead to bad things.</p></li>
<li><p>Failures in functions didn't always work as I expected.  By design, a blob will be created as an output even on failure.  Read the blog posts from the team carefully and test!  Version 0.4 seems to handle some scenarios better and introduces automatic handling of poision messages (those that repeatedly fail).</p></li>
<li><p>When upgrading to 0.4 my orders started taking a lot longer to process.  By design, the new version of the SDK will back off checking the queue when its empty.  This can be controlled in configuration with the MaxPollingInterval setting.</p></li>
<li><p>Version 0.4 of the SDK includes a way to automatically deploy the WebJob project along with the website. Prior to this I used the <a href="http://visualstudiogallery.msdn.microsoft.com/f4824551-2660-4afa-aba1-1fcc1673c3d0">WebJobsVs extension</a>. Update regarding my publishing problems - <strong>DO NOT CHECK "Exclude files from the App_Data folder"</strong>. At some point I did this and only on the production settings (smacks head), but App_Data is where jobs are published! Unfortunately for me the website included an unneeded reference to the webjob project so I would see the DLL copied into Bin during Publish and it didn't click right away that this wasn't the right place.</p></li>
<li><p>I used the <a href="https://www.nuget.org/packages/Microsoft.WindowsAzure.ConfigurationManager/">Windows Azure Configuration Manager</a> for all settings and connection strings.  This allows me to keep my development settings in the config files, but use the Azure settings upon deployment.</p></li>
<li><p>Google around for some good information on debugging, but at least know that you can just run the console app locally in the debugger as long as the config is pointed to the right storage account.  Don't forget to stop the jobs on any development slot pointed to the same account.</p></li>
</ul>

<h2 id="wrapup">Wrap up</h2>

<p>Be cautious about the beta preview status, but the Azure WebJobs SDK provides a powerful way to express the functions "jobs" that your website needs to perform in the background.  I can imagine that it will become even more useful as it approaches release and seems like a no-brainer option if you are already using Azure.</p>]]></content:encoded></item><item><title><![CDATA[Velocity 1.0]]></title><description><![CDATA[<p>Well the day has finally arrived and I am officially announcing Velocity 1.0.  It is now a feature complete offline API documentation browser and search tool.  Read all about on <a href="http://velocity.silverlakesoftware.com/">the product website</a>.</p>

<p>There are still plenty of features in <a href="http://kapeli.com/dash">Dash</a> (the inspiration for <a href="http://velocity.silverlakesoftware.com/">Velocity</a>) that I plan to</p>]]></description><link>https://efficientbits.azurewebsites.net/velocity-1-0/</link><guid isPermaLink="false">5d59eb8e-8512-4cc6-b110-ba621844925f</guid><dc:creator><![CDATA[Jamie da Silva]]></dc:creator><pubDate>Thu, 31 Jul 2014 06:10:44 GMT</pubDate><content:encoded><![CDATA[<p>Well the day has finally arrived and I am officially announcing Velocity 1.0.  It is now a feature complete offline API documentation browser and search tool.  Read all about on <a href="http://velocity.silverlakesoftware.com/">the product website</a>.</p>

<p>There are still plenty of features in <a href="http://kapeli.com/dash">Dash</a> (the inspiration for <a href="http://velocity.silverlakesoftware.com/">Velocity</a>) that I plan to be working on and I have plenty of other ideas too.  It would be great to get feedback on what you would find most valuable to help me prioritize what is next.  I've already been speaking with Gerard Delmàs and testing his new release of the <a href="https://github.com/gdelmas/IntelliJDashPlugin">IntelliDash plugin</a>, so I think something will be available soon. I will also be looking into a Visual Studio integration as soon as I can.</p>

<p>I'm committed to this product, but nothing gives a bigger vote of confidence than buying a license.  My hope is that you'll find Velocity a tool worth paying for and if you don't please let me know how I missed the mark so I can continue to make improvements.</p>

<p>If your interested in the backstory of Velocity then please read the <a href="http://efficientbits.com/the-velocity-origin-story/">The Velocity Origin Story</a>.  It tells a little about me and how Velocity came to be.</p>

<p>Let the journey begin.</p>

<h3 id="updates">Updates</h3>

<ul>
<li>Bogdan posted <a href="http://blog.kapeli.com/meet-velocity-for-windows">Meet Velocity for Windows</a> on his blog.</li>
<li>The extension for Visual Studio, <a href="http://visualstudiogallery.msdn.microsoft.com/2f45a9f6-e26a-4888-899f-5ed3ef24b37f">Search in Velocity</a>, is available now.</li>
</ul>]]></content:encoded></item><item><title><![CDATA[The Velocity Origin Story]]></title><description><![CDATA[<p>I guess these days it's probably not as amazing to others as it seems to me.  That I can be sitting in my home office in New Jersey and discuss making <a href="http://velocity.silverlakesoftware.com">Velocity</a>, a Windows version of <a href="http://kapeli.com/dash">Dash</a>, with the developer who created it in Romania.  I've had some doubts about</p>]]></description><link>https://efficientbits.azurewebsites.net/the-velocity-origin-story/</link><guid isPermaLink="false">391e9f45-97d3-4653-90c0-d102ea4a96f2</guid><dc:creator><![CDATA[Jamie da Silva]]></dc:creator><pubDate>Tue, 29 Jul 2014 19:58:09 GMT</pubDate><content:encoded><![CDATA[<p>I guess these days it's probably not as amazing to others as it seems to me.  That I can be sitting in my home office in New Jersey and discuss making <a href="http://velocity.silverlakesoftware.com">Velocity</a>, a Windows version of <a href="http://kapeli.com/dash">Dash</a>, with the developer who created it in Romania.  I've had some doubts about it that's for sure and at times it feels like such a long shot to succeed, but here I am really enjoying myself and now I get to see where this takes me.</p>

<h2 id="howdidigethere">How Did I Get Here?</h2>

<p>I've been an independent developer since 1997.  That's a long time to be on your own.  I've had good years and bad, but I've felt for quite a while now that I was doing it wrong.  </p>

<p>I build products, but a lot of my work has really been bespoke development. I'm proud of the work I've done and my products have been successful for my customers.  My form design software has been used to design the industry standard insurance forms since 1998.</p>

<p>The problem with my business is that it was never really a sustainable business.  My products are licensed to a single or handful of customers at best.  Many times I was lucky enough to secure a contract just when I needed it, but I've spent a lot of time wondering if I would be able to pay my bills and I can't even imagine what it would be like to go on vacation anymore.</p>

<p>Near the end of 2013, I finished a four year fixed-cost project that left me realizing I needed a change.  </p>

<h2 id="keepmovingforward">Keep Moving Forward</h2>

<blockquote>
  <p>"Around here, however, we don’t look backwards for very long. We keep moving forward, opening up new doors and doing new things, because we're curious… and curiosity keeps leading us down new paths" <em>– Walt Disney (as displayed at the end of Meet the Robinsons, a lesser known but endearing Disney movie.)</em></p>
</blockquote>

<p>I've had that posted on my desk for quite some time with the words "keep moving forward" underlined.  I feel like I'm someone prone to getting stuck and this serves as a reminder to just keep taking that next step.</p>

<p>I started to look over contract and job opportunities and soon realized how beneficial it would be to have a public reputation.  But it was more than than that too, because for many years I watched others write blogs, participate in open source, and grow businesses from nothing (like <a href="http://blog.codinghorror.com/introducing-stackoverflow-com/">StackOverflow</a> or <a href="https://balsamiq.com/">Balsamiq</a>).  I wanted to be doing these things.  I've been watching this community of people like me do awesome stuff and I wanted to join in.  It quickly seemed like a no-brainer; do some things you want to do and maybe help your future in the process.</p>

<blockquote>
  <p>I wanted to be doing these things.  I've been watching this community of people like me do awesome stuff and I wanted to join in.</p>
</blockquote>

<p>So the first thing a did was dust off a project I had started and stopped a few times over the years and decided it was interesting enough to turn into an open source project.  Thus <a href="https://github.com/ProxyFoo/ProxyFoo">ProxyFoo</a> was born.  It's a library I had wanted much earlier for my large project, but unfortunately couldn't spend the time on it then.  I hope it's useful for others and I get excited every time I see my download number go up on <a href="http://www.nuget.org/packages/ProxyFoo/">Nuget</a> (a paltry but "cool to me" 127 as of writing this).</p>

<p>I also started this blog.  As I mention in my <a href="http://efficientbits.com/first/">first post</a>, this was something I wanted to do for a long time.  I know me, I know I'll never be a writer on a consistent schedule, but I do enjoy it.  For me, this has always been one of those "do something that scares you" activities.  I get very uncomfortable very quickly when sharing things about myself.  <em>This post is huge for me.</em></p>

<p>And now, at the very least, someone can take a look at my work, can take a look at my writing, and get some idea of who I am, but I still need to make a better living.</p>

<h2 id="serendipity">Serendipity</h2>

<p>One project I think I've managed to spend a week on over the last few years is a little football pool app I use on the iPad for a family SuperBowl party.  In the course of working on it I discovered Dash.  Now, I tend to spend far too long researching products, so even before I downloaded it I had a pretty good idea of its reputation.  I used it for a day or so and went back to work on Windows.</p>

<p>I was lucky enough to find the post on Bogdan's blog.  He was looking for developers to bring Dash to other platforms.  </p>

<blockquote>
  <p>I am actively looking for developers of other platforms (iOS, Android, Windows or Linux) that would like to work on a Dash-like app, as their own project and for their own profit. <em>– Bogdan Popescu <a href="http://blog.kapeli.com/dash-for-ios-android-windows-or-linux">Dash for iOS, Android, Windows or Linux</a></em></p>
</blockquote>

<p>The bottom line was that in return for linking back to Dash he would allow access to the docsets on his servers.</p>

<p>I printed the page and let it sit for a couple of weeks.  On February 12th 2014, I filled out the form on his website and let him know I was interested.  </p>

<p>His permission to work on the Windows platform was not exclusive which I knew made this risky.  I had thought about developing some product ideas of my own, but I felt the thought of starting something from scratch was even more risky.  I needed to do something and at worst I felt Velocity would be a great product to add to my resume.</p>

<p>The first month I split a lot of my time between Velocity, ProxyFoo, and existing support work.  It was a slow start.  I emailed Bogdan again, and found that I was not the only developer making progress.  </p>

<p>Shortly after, around April 2014, I began to focus on Velocity exclusively. I ran into some interesting problems but managed to work through them all.  I'm sure there is good material for a blog post or two.  Eventually I was the only developer updating Bogdan, and after three long months, on June 23rd, I released the first Beta of Velocity.  Bogdan was great to work with and very helpful.</p>

<h2 id="findingjoy">Finding Joy</h2>

<p>Over the past month, a funny thing happened.  I've realized just how right this decision was.  I wanted to have my own business making software since I was a kid and this is bringing back that feeling.</p>

<p>Every download, every page view, brings me excitement.  When Bogdan (<a href="https://twitter.com/kapeli">@kapeli</a>) re-tweeted my Beta announcement I got more traffic to the Velocity website in an afternoon then I see in weeks on my company website.  I was literally running around the house screaming new country names at my family.  I got hits from all over the world and over the next few weeks I saw error messages reported to me in Swedish, French, and Chinese.  <strong>This is Awesome!</strong>  In the grand scheme of things my page view numbers were still very small, but even if this never gets bigger I have absolutely loved the ride.</p>

<p>I also found that it's a pretty cool experience to have a person you don't already know appreciate your work. I got a positive email from one user who ended up as my first customer for Velocity, and it felt pretty darn good.</p>

<h2 id="allin">All In</h2>

<p>I'm about to release v1.0 in the next day or two and I'm quite nervous.  I don't think it was as clearly defined when I started my business, but it seems obvious to me now that what I really want is to be an "indie" developer.  A guy that makes small products people enjoy using and makes a living do so.  Time isn't exactly on my side (which is why I'm still looking for contract work - see my <a href="http://careers.stackoverflow.com/jamiedasilva">careers page</a>) and I don't know what the future holds for this, but here I am - all in.</p>]]></content:encoded></item><item><title><![CDATA[Testing IL Generation]]></title><description><![CDATA[<p><a href="http://marcgravell.blogspot.com/2014/03/be-strict-with-me-dear-cli.html">Marc Gravell points out</a> some interesting problems when generating IL manually.  I was lucky that when working on <a href="http://proxyfoo.com">ProxyFoo</a> I did not run into any major headaches with this, but I do have some future ideas (that involve loading from disk) where based on Marc's info this could be a</p>]]></description><link>https://efficientbits.azurewebsites.net/testing-il-generation/</link><guid isPermaLink="false">c0667b5b-eb31-461a-b257-e38e3de1cebe</guid><dc:creator><![CDATA[Jamie da Silva]]></dc:creator><pubDate>Thu, 27 Mar 2014 17:15:00 GMT</pubDate><content:encoded><![CDATA[<p><a href="http://marcgravell.blogspot.com/2014/03/be-strict-with-me-dear-cli.html">Marc Gravell points out</a> some interesting problems when generating IL manually.  I was lucky that when working on <a href="http://proxyfoo.com">ProxyFoo</a> I did not run into any major headaches with this, but I do have some future ideas (that involve loading from disk) where based on Marc's info this could be a problem.</p>

<h3 id="background">Background</h3>

<p>Early on in development I would occasionaly save a generated assembly and run <a href="http://msdn.microsoft.com/en-us/library/62bwd2yd(v=vs.110).aspx">PEVerify</a> on it.  As the project got further along I would simply rely on tests to determine if the generated code worked as expected, but I knew eventually I would want something more robust.</p>

<p>Code generation in ProxyFoo always takes place in a dynamic assembly managed by the <a href="https://github.com/ProxyFoo/ProxyFoo/blob/master/source/ProxyFoo/ProxyModule.cs">ProxyModule</a> class.  In order to create an easy to use API all of the static methods will create and use a common default module.  The library provides a way for this default module to be cleared which I take advantage of for test seperation.  I wanted to use PEVerify as  part of every test too.</p>

<h3 id="peverifyintesting">PEVerify in Testing</h3>

<p>To make it easy to reuse, I created <a href="https://github.com/ProxyFoo/ProxyFoo/blob/9598239d8481961eea481c4a5ead618b65a9058a/source/ProxyFoo.Tests/ProxyFooTestsBase.cs">ProxyFooTestsBase</a> as a base TextFixture for tests with generated code.</p>

<p>The SetUp configures the default ProxyModule with a unique assembly name for the test and with flags that allow it to be saved.</p>

<pre><code class="language-cs">[SetUp]
public virtual void SetUp()  
{
    string assemblyName = "ZPFD." + TestContext.CurrentContext.Test.FullName.Replace("ProxyFoo.Tests.", "");
    foreach (var c in Path.GetInvalidFileNameChars())
        assemblyName = assemblyName.Replace(c, '_');
    var assemblyPath = assemblyName + ".dll";
    if (File.Exists(assemblyPath))
        File.Delete(assemblyPath);
    ProxyFooPolicies.ProxyModuleFactory = () =&gt; new ProxyModule(assemblyName, AssemblyBuilderAccess.RunAndSave);
    ProxyFooPolicies.ClearProxyModule();
}
</code></pre>

<p>I prefixed the file with 'Z' for the simple reason of having them be listed last when reviewing build output.  The next to last line overrides the default factory method to use the custom name and allow for saving; the last line clears any static content related to the ProxyModule.  I had never used <a href="http://nunit.org/index.php?p=testContext&amp;r=2.6.2">TestContext</a> before this, and was glad to find it.</p>

<pre><code class="language-cs">[TearDown]
public virtual void TearDown()  
{
    if (!ProxyModule.Default.IsAssemblyCreated)
        return;
    ProxyModule.Default.Save();
    if (TestContext.CurrentContext.Result.Status==TestStatus.Passed)
    {
        var assemblyPath = ProxyModule.Default.AssemblyName + ".dll";
        Assert.That(PeVerifyAssembly(".", assemblyPath), Is.EqualTo(0));
    }
    ProxyFooPolicies.ProxyModuleFactory = ProxyFooPolicies.DefaultProxyModuleFactory;
    ProxyFooPolicies.ClearProxyModule();
}
</code></pre>

<p>TearDown does the real work.  If the test passed it saves the assembly, runs PEVerify, and asserts that no issues were found.  This is also convenient when debugging issues with generated code, because I know have a unique assembly as part of the output I can load in <a href="http://www.red-gate.com/products/dotnet-development/reflector/">Reflector</a> (or other dissasembler) to review the code.  If necessary the passing test condition can be commented out, but I haven't needed this very often.</p>

<p>When I first added this to my existing tests, I did to my surprise find <a href="https://github.com/ProxyFoo/ProxyFoo/search?q=%22PE+verification%22+OR+%22Needed+for+PEVerify%22&amp;type=Code">several instances</a> where everything ran fine but failed verification.  In my case I found failures for not calling object's ctor from a generated class and a couple of cases where castclass was needed.</p>

<h3 id="conclusion">Conclusion</h3>

<p>My original concern was for compatiblity.  What the CLR lets slide now might not be allowed next time, and after reading Marc's article it was good to see there was even more reason to be this strict.  There's nothing earth shattering here so I'm sure this pattern could be adopted for testing generated code in other situations.  <a href="http://www.nuget.org/packages/Sigil/">Sigil</a> also looks really interesting, but in the case of ProxyFoo I wanted to avoid dependencies if possible.</p>]]></content:encoded></item><item><title><![CDATA[Sharing Git via Windows File Share]]></title><description><![CDATA[<p>This took a little effort to get all the pieces right, especially for me on the Mac, so I thought I would share the information.</p>

<p>I've recently taken the leap to start using <a href="http://git-scm.com/">Git</a>, mostly so that I could share <a href="http://proxyfoo.com">ProxyFoo</a> on <a href="http://github.com">GitHub</a>, but I've been happy enough with it</p>]]></description><link>https://efficientbits.azurewebsites.net/sharing-git-via-windows-file-share/</link><guid isPermaLink="false">6e26b35b-3536-4b27-b695-361874b9d4ba</guid><dc:creator><![CDATA[Jamie da Silva]]></dc:creator><pubDate>Wed, 19 Mar 2014 21:29:37 GMT</pubDate><content:encoded><![CDATA[<p>This took a little effort to get all the pieces right, especially for me on the Mac, so I thought I would share the information.</p>

<p>I've recently taken the leap to start using <a href="http://git-scm.com/">Git</a>, mostly so that I could share <a href="http://proxyfoo.com">ProxyFoo</a> on <a href="http://github.com">GitHub</a>, but I've been happy enough with it to start using it on an internal project also. I wanted a simple way to have a central GIT repository for my internal projects.  I didn't find the any of the "server" projects that appealing or overkill and since I'm a lone developer I'm choosing to go with the simple file sharing approach for now.  I'm using <a href="http://www.sourcetreeapp.com/">SourceTree</a> as a client on Mac and Windows.</p>

<h2 id="why">Why</h2>

<p>My development machine is backed up daily and I work alone so I don't absolutely need to have a central repository. However, I've always felt there should be a central repository that is the "master".  I run an in-office server for backup, file storage, and builds so this fits in well.  Once the project matures a little bit I'll probably set up a continuous integration server like <a href="http://www.jetbrains.com/teamcity/">TeamCity</a>.  No requirement for building a product should only live in your development workspace.  You should be able to pull down from your source control, maybe install a few prequisites (which I store centrally) and build.</p>

<p>I also have some projects on Mac OS X on my laptop that I would like to backup as well and this machine is not backed up regularly.  (On the Windows partition I do not have anything on my laptop that is not mirrored from my desktop machine.</p>

<h2 id="whatidid">What I did</h2>

<p>Note that this is for when you have an existing local repo first.  Replace <code>Server</code> with your server name, <code>Git</code> with your share name, and <code>Repo</code> with your repo name.  </p>

<h3 id="1setupthemasterrepo">1. Setup the master repo</h3>

<ul>
<li>I created a file share called Git with full access permissions and then adjusted the file permissions for my account to have access to the folder.</li>
<li>I used <code>git init --bare //Server/Git/Repo</code> from the command line to create the bare repo.  (A bare repo has no workspace which is precisely what I want for master repo.)</li>
</ul>

<h3 id="2aconnectawindowsrepo">2a. Connect a Windows repo</h3>

<ul>
<li>Using SourceTree, add a new remote.  You can do this from the main menu <code>Repository-&gt;Add Remote...</code> or from the Remotes header in the repo view and right click <code>New Remote...</code> Select the <code>Add</code> button on the Remotes tab and you should see the following dialog and enter the Remote Name as "origin" (or check Default remote) and enter the server path as <code>//Server/Git/Repo</code>. <img src="https://efficientbits.azurewebsites.net/content/images/2014/Mar/SourcetreeRemoteDetailsWin.png" alt="" title=""></li>
</ul>

<h3 id="2bconnectamacrepo">2b. Connect a Mac repo</h3>

<ul>
<li>Connect to the Windows file share using the Finder.  From the menu <code>Go-&gt;Connect to Server...</code></li>
<li><a href="http://osxdaily.com/2012/05/04/automatically-connect-to-network-drive-mac-os-x/">Set up an automatic connection to the network drive on login</a>.</li>
<li>Using SourceTree, add a new remote. You can do this from the main menu <code>Repository-&gt;Add Remote...</code> or from the Remotes header in the repo view and right click <code>New Remote...</code> Select the <code>Add</code> button on the Remotes tab and you should see the following dialog and enter the Remote Name as "origin" and enter the server path <em>(this is important)</em> as <code>/Volumes/Git/Repo</code>. </li>
</ul>

<p><img src="https://efficientbits.azurewebsites.net/content/images/2014/Mar/SourcetreeRemoteDetailsMac.png" alt=""></p>

<h3 id="3push">3. Push</h3>]]></content:encoded></item><item><title><![CDATA[First]]></title><description><![CDATA[<p><img src="https://efficientbits.azurewebsites.net/content/images/2017/05/number_one_by_dmclear-1.jpg" alt="Number 1!"></p>

<p>Well here it is.  I registered this domain in 2007, so it has only taken me 7 years to get to this point.  I'm not making any promises about posting regularly or often, but I do hope to provide value to anyone patient enough to read what I write.</p>

<p>I'm</p>]]></description><link>https://efficientbits.azurewebsites.net/first/</link><guid isPermaLink="false">7d9ab215-13af-4050-b335-4305a7f0b54e</guid><dc:creator><![CDATA[Jamie da Silva]]></dc:creator><pubDate>Sun, 16 Mar 2014 01:42:51 GMT</pubDate><content:encoded><![CDATA[<p><img src="https://efficientbits.azurewebsites.net/content/images/2017/05/number_one_by_dmclear-1.jpg" alt="Number 1!"></p>

<p>Well here it is.  I registered this domain in 2007, so it has only taken me 7 years to get to this point.  I'm not making any promises about posting regularly or often, but I do hope to provide value to anyone patient enough to read what I write.</p>

<p>I'm hoping to do at least a small series of posts on <a href="http://proxyfoo.com/">ProxyFoo</a> which is my first open source project.  I've had several open source projects that helped me along the way and I'm trying to increase my participation.</p>

<p>I've had the pleasure of working with the great libraries listed below (and more including the projects that some of these works depend on) and I am very greatful to the authors.</p>

<ul>
<li><a href="http://http://autofac.org/">Autofac</a></li>
<li><a href="http://www.castleproject.org/">Castle.Core</a></li>
<li><a href="https://code.google.com/p/dapper-dot-net/">Dapper-Dot-Net</a></li>
<li><a href="http://dotnetzip.codeplex.com/">DotNetZip</a></li>
<li><a href="http://jekyllrb.com/">Jekyll </a></li>
<li><a href="http://james.newtonking.com/json">Json.NET</a></li>
<li><a href="http://www.mono-project.com/Cecil">Mono.Cecil</a></li>
<li><a href="http://npoi.codeplex.com/">NPOI</a></li>
<li><a href="http://www.nuget.org/">NuGet</a></li>
<li><a href="http://www.nunit.org/">NUnit</a></li>
<li><a href="https://code.google.com/p/protobuf-net/">Protobuf-Net</a></li>
<li><a href="https://github.com/ServiceStackV3/ServiceStackV3">ServiceStack v3</a></li>
<li><a href="http://wixtoolset.org/">Windows Installer XML (WIX) Toolset</a></li>
<li><a href="http://wordlist.sourceforge.net/">Word Lists Collection</a></li>
<li><a href="http://zlib.net/">Zlib</a></li>
</ul>

<p>*<a href="http://www.flickr.com/photos/dmclear/5398254250/">Number 1!</a> by <a href="http://www.flickr.com/photos/dmclear/">Dave Mc Clear</a> is licensed under <a href="http://creativecommons.org/licenses/by/2.0/">CC BY 2.0</a></p>]]></content:encoded></item></channel></rss>