Loren Halvorson's Blog

If your only tool is a hammer...
Just released version 2.0.18 of XmlPreprocess

https://xmlpreprocess.codeplex.com/releases/view/110201

What's new in this release

  • For XML Spreadsheet 2003 format, used the frozen row at the top of the worksheet to indicate the beginning of the values. This prevents you from having to start your values at row 7. This can be overridden with the /firstValueRow (or /vr) argument.

Issues Fixed
  • Fix for Issue 13006 : Corrected default treatment of the value "false"

Beginning with this version, the FixFalse behavior that has caused confusion to so many, has hopefully been addressed in a way that still accommodates those who need backward compatibility.


The /FixFalse switch was introduced in Beta 1 to address issues caused when a settings has the value of False. When a value is False, the old behavior was to undefine the setting. This caused errors when you wanted to insert a literal "False" (a common value in configuration files). The workaround was to put the value in quotes, or pass the /f or /FixFalse switch.


There are now two executables in the binary package, one that breaks backward compatibility, and does the right thing by defaulting FixFalse to True (XmlPreprocess.exe), and one that maintains backward compatibility (XmlPreprocess-NoFixFalse.exe). Use the executable that is appropriate for your needs. If you are new to XmlPreprocess, most likely you're going to want to use XmlPreprocess.exe, and forget about the NoFixFalse version.


- XmlPreprocess.exe - This version defaults FixFalse to true, so you no longer need to pass it.
- XmlPreprocess-NoFixFalse.exe - This version is the old behavior. If you require the old behavior, feel free to rename this file to be XmlPreprocess.exe, and use it instead.

  • Fix for Issue 13009 : Fix for comments in Settings XML file.
Free T-SQL Formatter Updated

Tao Klerks has just released a new version (0.9.12) of the Poor Man’s T-SQL Formatter (I blogged about it last week) with several improvements and some more formatting options. He also set up a website so you can use it online http://poorsql.com.  Thanks Tao, it keeps getting better!

Free T-SQL Formatter

If you are working on a project that has a lot of SQL code and wish you could reformat it to make it more readable, I just stumbled on a slick utility that is being developed in C# by Tao Klerks named Poor Man’s T-SQL Formatter.  It can be found here:  http://www.architectshack.com/PoorMansTSqlFormatter.ashx  It’s not finished yet, but has enough functionality to be truly useful.  Tao tells me he is working on refactoring the code to make it more maintainable and adding more formatting options.

It has plug-ins for SQL Server Management Studio, and WinMerge, and a command line version that will allow you to integrate it into other tools like Beyond Compare thanks to a new -output command line option Tao recently added just for this purpose.

 

Here’s how I set it up for Beyond Compare 3:

In Beyond Compare 3, select the Tools | File Formats menu

Create a new Text Format named SQL Tidied

Mask: *.sql

Conversion: External program (Unicode filenames)

Loading: {path to PoorMansTSLFormatter}\SqlFormatter.exe -o "%t" "%s"

You probably want to move it in the list of formats to be just below the built-in SQL format so that it doesn’t get chosen automatically every time you compare SQL files.

 

Now you can compare two different SQL files after normalizing them to common “tidy” format which lets you see the true differences, and ignore unimportant ones like whitespace, wrapping etc.

Upgrading RDLC reports to Report Viewer 2010 in an ASP.NET web application

One of the web applications I am working on is an ASP.NET MVC 2 site targeting .NET 3.5 SP1 that uses the Microsoft Report Viewer control with local-mode RDLC reports. I initially developed this application using Visual Studio 2008. The client was OK if I started to use Visual Studio 2010, as long as I didn’t require .NET 4.0 just yet. The multi-targeting features of VS2010 were working great. I had started really enjoying VS 2010 and had no intention to go back to 2008. Then I needed to do some report work so I double clicked one of my RDLC files and was surprised to see this message box:

Microsoft Visual Studio
---------------------------
Microsoft Report Designer

Do you want to convert this report to RDLC 2008 format?  Please click OK to proceed or Cancel to open it in the XML editor.

My heart sunk and my blood ran cold. What have I done? I was afraid I would need to go back to VS 2008 just to keep the reports compatible with .NET 3.5! Fortunately, converting to the new Report Viewer control turned out to be OK (so far), but there were some surprises along the way.

It’s all good (mostly)

There are lots of nice new ajax, visual, and internal things about the new control but two of the highlights for me were:

  • Compatible with .NET 3.5 SP1 and .NET 4.0
  • Looks better in more browsers
    • Rendering is simplified and more standards compliant. I was able to put the strict DOCTYPE back in the page and (eventually) get resizing to work. More on resizing later.

Upgrading

The upgrading process was pretty straightforward.

  • Install the Report Viewer 2010 Redistributable (This will need to be installed on any server to which you deploy).
  • Convert RDLC files to new RDL 2008 schema. Simply opening the RDLC in Visual Studio 2010 converts to the new schema and automatically makes a backup.
  • Change assembly reference to the new 10.0.0.0 version of Microsoft.ReportViewer.WebForms.dll
  • Change version number in assembly names in web.config
    • You’ll see things in web.config that look similar to the following, make sure the version is 10.0.0.0
      Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A
  • Change version number in any *.aspx pages that include the report viewer control registration
    • <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
          Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
  • Include a ScriptManager on any *.aspx page that has a ReportViewer, or if you have a common master page that your reports share like I did, you can put it there, once for all.
    • <asp:ScriptManager ID="ScriptManager1" runat="server">
      </asp:ScriptManager>

Some surprises that required rework

  1. The data sets must be flat. In some of my reports I took advantage of the fact that in the previous Report Viewer you could refer to properties of child objects. You used to be able to do this:

    =Fields!ChildObject.Value.ChildProperty

    Now the data set need to be flat.  This means that I needed to flatten out my domain objects by pulling properties from the child objects up to the parent object. This could have been a big problem, but luckily the way I had structured my code allowed me to fairly easily define a flat report object and bind to that instead.
  2. Getting the report to fill the browser with 100% height and resize dynamically was trickier than I hoped.  And this is the main reason I wanted to write this post.

Making the report viewer resize

I used the incredibly powerful jQuery.UI.Layout already in this site, so I just continued to use it on the report pages. The trick to getting the report control to resize properly in my case was to find the report viewer control and call recalculateLayout() whenever the browser was resized. This happens on line 22 in the code below:

 

   1:  <%@ Page Language="C#" %>
   2:  <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
   3:      Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
   4:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   5:  <html xmlns="http://www.w3.org/1999/xhtml">
   6:  <head>
   7:      <title>Sample Report</title>
   8:      <script type="text/javascript" src="../../Scripts/jquery-1.4.2.min.js" ></script>
   8:      <script type="text/javascript" src="../../Scripts/jquery.layout.js" ></script>
  10:      <script type="text/javascript">
  11:          $(document).ready(function () {
  12:              $('body').layout({
  13:                  north__paneSelector: "#HeadingPane",
  14:                  center__paneSelector: "#ContentPane",
  15:                  resizable: false,
  16:                  closable: false,
  17:                  north__size: 20,
  18:                  spacing_open: 0,
  19:                  spacing_closed: 0,
  20:                  center__onresize: function () {
  21:                      var reportViewer = $find("ReportViewer");
  22:                      reportViewer.recalculateLayout();
  23:                  }
  24:              });
  25:          });
  26:      </script>
  27:  </head>
  28:   
  29:  <body>
  30:    <form id="form1" runat="server">
  31:      <asp:ScriptManager ID="ScriptManager1" runat="server">
  32:      </asp:ScriptManager>
  33:   
  34:      <div id="HeadingPane">
  35:          Page header content like site navigation goes here
  36:      </div>
  37:   
  38:      <div id="ContentPane">
  39:   
  40:      <asp:ObjectDataSource ID="SampleDataSource" runat="server" SelectMethod="GetSampleData"
  41:          TypeName="MyApp.Reports.ReportDataSource">
  42:      </asp:ObjectDataSource>
  43:      
  44:      <rsweb:ReportViewer ID="ReportViewer" runat="server" Font-Names="Verdana" 
  45:          Font-Size="8pt" Height="100%" Width="100%" ShowBackButton="false">
  46:          <LocalReport ReportPath="SampleReport.rdlc">
  47:              <DataSources>
  48:                  <rsweb:ReportDataSource DataSourceId="SampleDataSource" Name="SampleData" />
  49:              </DataSources>
  50:          </LocalReport>
  51:      </rsweb:ReportViewer>
  52:   
  53:      </div>
  54:    </form>
  55:  </body>
  56:  </html>
TestDriven.NET 3.0 Released

I haven’t posted anything to my blog in a long time, but I wanted to point out that a product I truly love and use often has been updated. Jamie Cansdale has released TestDriven.NET 3.0, still one of my all-time favorite Visual Studio add-ons for low-friction unit testing.  Now it works with Visual Studio 2010, MSTest and tons of new features and refinements.

Here’s Jamie’s announcement http://weblogs.asp.net/nunitaddin/archive/2010/06/09/testdriven-net-3-0-all-systems-go.aspx

MSBuild trick for making <Exec> calls more maintainable

One of my pet peeves with MSBuild’s <Exec> task is how long the lines get when you have lots of arguments.

I ran across a trick yesterday in a blog comment made by someone named Romain and thought it was a very nice solution to this problem. When you expand items using this form @(items, ‘DELIMITER’), it allows you to specify a delimiter to use between the items. In the case of a command line, you use a space. Thanks Romain.

<ItemGroup>
  <XmlPreprocessArgs Include="/nologo"/>
  <XmlPreprocessArgs Include="/v"/>
  <XmlPreprocessArgs Include="/x:&quot;$(InstallDir)\Environments\$(ApplicationName).EnvironmentSettings.xml&quot;"/>
  <XmlPreprocessArgs Include="/i:&quot;$(InstallDir)\UI.Shell.exe.config%3B$(InstallDir)\ClientLogging.config&quot;"/>
  <XmlPreprocessArgs Include="/e:&quot;$(Environment)&quot;"/>
</ItemGroup>

<Exec Command="&quot;$(InstallDir)\Environments\XmlPreprocess.exe&quot; @(XmlPreprocessArgs,' ')"
      WorkingDirectory="$(InstallDir)\Environments" />

Posted: Dec 11 2008, 01:52 PM by lorenh | with 5 comment(s)
Filed under: ,
Comparing XML Files with Beyond Compare 3...Brilliant

I bought a new laptop and was loading it with the tools I use every day. When it came to installing one of my favorites, Beyond Compare 2, I thought I'd check the Scooter web site to see if I had the latest version. I was happy to see they now had a version 3 with plenty of new features. I immediately reached for my credit card to buy a license. Folks, this is honestly one of the tools I don't even hesitate paying for...it's that good, and that invaluable. I don't work for them, I'm just a very happy customer.

The base tool itself is great, but I was really thrilled when I followed the link on the Download page to Additional file format downloads for version 3.  There I found something I've been looking for years...and in fact a while ago had written a plug-in for BC2 to do...the ability to compare Tidied XML.

How many times have you tried to compare two dense XML files to find out their differences only to be faced with a block of differences that looks like this:

Beyond Compare notices that there are differences in there somewhere, but can't really show you where with any precision. Further inspection is going to be needed, and forget merging selected changes over from one side to the other.

If you install the XML Tidied and XML tidied with attributes sorted file formats, you can now tell Beyond Compare to tidy up your documents, putting each attribute on its own line, so the differences stand out. You can now see exactly which attributes differ. Absolutely brilliant.

This is a fantastic feature that's already saved me a bunch of time. I see there is a similar add-in for HTML tidied files that also will come in handy.

A couple of other features in Beyond Compare that I've come to rely on over the years:

  • Beyond Compare has great "low-friction" integration with Windows Explorer. For example to compare two files, you just right click on one file and choose "Select Left Side For Compare", then right click on the other file and say "Compare to {file...}".  This works for folders too.
  • Beyond Compare has great FTP integration. I use it to deploy changed files to FTP sites very painlessly.

I also see it supports doing 3-way merging from most version control systems. I haven't tried this yet, but I'm going to see how hard it is to plug into TFS.  If anyone has pointers on how to set this up, let me know.

 Update: Scooter's website shows how to set it up here

They have a 30 day trial, so if you aren't so sure, you can give it a try for a while. Highly recommended.

New Release of XmlPreprocess

I finally got around to updating the XmlPreprocess tool with some changes I'm really excited about. For those of you not familiar with XmlPreprocess, it's a command line tool I wrote many years ago that can modify specially annotated XML files much like a code preprocessor. It is useful for deploying XML configuration files to many environments. I've blogged about it in the past as have others, and it's achieved a fair amount of use (albeit hidden below the surface) in my good friend Scott Colestock's Biztalk deployment framework.

The first thing I did was move it to a CodePlex project which replaces the prior SourceForge project.

Changes in this release

  • New Codeplex home with updated documentation and samples.
  • Requires .NET 2.0 or newer runtime.
  • Adds the ability to import spreadsheets directly thanks to Tom Abraham's excellent work on the Environment Settings Manager project. This is a really nice feature, and I thank Tom for giving me permission to use his spreadsheet reading code.
  • Adds a command line switch (/f or /fixfalse) to fix the behavior of "False" values. This has been a long-standing request and tripped up many people for example here and here.  For the anguish and consternation this has caused to you all, I sincerely apologize, and hope you forgive me. If you want to explicitly undefine a property, use the value "#undef" instead.  (Note: that for backward compatibility, this behavior is off by default, and you will need to add the /f or /fixfalse switch to enable it).
  • Adds a new command line switch (/v) to validate tokens, so if any replacement tokens are missing, it will report an error message identifying the missing tokens, return a nonzero error code and not write out the file.

I left the current release as Beta 1 in case anyone finds any issues right away, but we've been using the new version on a project without any issues yet.  It should be a drop-in backward compatible replacement for the old version (except for the new dependency on .NET 2.0 instead of 1.1).

Introducing Birch Cove Software

A few days into a 3 week vacation with my family I received a call that I wasn't surprised to receive. The company where I had worked for 6 years was downsizing and my position, along with many others in our department, was eliminated. Since downsizing (or worse) was happening across the entire sector, I didn't take it personally. In fact, I took it as a sign that I should try something different. A friend recently said that "getting laid off is one of the best thing that ever happened to him", and I hope to look back and say the same some day.

So I am officially hanging out my shingle and becoming an independent contractor. I've worked as a full time employee for the entirety of my 18 years in the industry, so working for myself is going to be something completely new. So here begins a new chapter in my life: Birch Cove Software, LLC. Wish me luck, and let me know if you have any tips or resources for getting a consulting business off the ground.

Red Gate will take over development of Lutz Roeder's .NET Reflector

I just received a newsletter from Red Gate, and nestled in the headlines was this interesting tidbit. If you haven't heard of .NET Reflector, it's one of my favorites, and I encourage you to check this invaluable tool out. It's what you reach for when you have to know what's going on inside that assembly but don't have the source.

Here's the announcement on Red Gate's site: http://www.simple-talk.com/opinion/opinion-pieces/the-future-of-reflector-/

James Moore who is the general manager of .NET Developer Tools at Red Gate states:

“I think we can provide a level of resources that will move the tool forward in a big way.  The first thing we are doing is continuing to offer the software to the community for free downloading.  The second thing is giving our product management and usability teams the task of going out into the community to get suggestions on how we can make this amazing tool even better."

I'm hopeful that Red Gate won't mess anything up. I've been using their ANTS profiler for years, and more recently discovered their wonderful SQL tools, and they are all excellent. For now they've promised to continue to give it away for free, but you know there will need to be some way to make money coming.

More Posts Next page »