LINQPAD - Must have for your toolkit!

Last week while I was creating the StatusBar XAML for the SDMS application I read in the WPF Unleased book that you could use the grid for specifying width percentages.   I typed in the code verbatim and for the life of me could not get my SDMS application to display my left status bar textblock 1/3 the size of the right status bar textblock; both were defaulting to auto (the size of the text).  I tried labels, textblocks, etc to no avail.  Since I was wasting a lot of time changing, compiling and running, I jumped into XAMLPad ( .NET 2.0 SDK - command prompt) and got the same behavior (as expected) - when I remarked out the StatusBar elements the Grid worked! The issue is with the statusbar and the great thing was XAMLPad showed immediate results.   But this blog isn't about XAMLPad - when I get the StatusBar figured out I plan on blogging it thoroughly then...

As I started TDD on my LINQ Query to pull all the project names out of solution file (why explained below) I found myself coding, break pointing, running, examining and doing the same over again (once again losing much time in the process).   The thought came to me "google LINQPAD"; to my surprise a program came up and it instantly became my best friend.  If the author's intent was to sell his book he succeeded because within 15 minutes of using the application I was clicking the link and purchasing it :) 

REQUIREMENT 

Architect the CLRAddin WPF Calculator so that I can perform a gap analysis to determine what will be required to update the CompositeWPF application to support a CLRAddin module loader (modules loaded in their own AppDomain).   There are to many components to wrap my brain around it so the Architecture phase is neccessary.  The problem is I can't reverse engineer the calculator application with Visio for Architects because I'm using Visual Studio 2008 (it isn't supported).  

VISION STATEMENT

Complete a Visio Tool that will convert the solution and projects to Visual Studio 2005 so that it can be reverse engineered (generate all the Visio objects required for architecture).  Architect the existing WPF Calculator program and perform a gap analysis to create a MAFModuleLoader application for the CompositeWPF.

SOLUTION

Note before I continue: after downloading the LINQPAD if you'll go to C# 3.0 in a Nutshell (bottom left pane) and select "Before You Start" and click Readme.First() it will create the data objects (top left pane in image below) that you can use to run the samples and demos against.

In my case I use the following LINQ query to pull the project names and paths from the solution file:

string filePath = @"D:\MAFCompositeWPF\WPF_Caclulator\WPF Caclulator\DemoApplication.sln";

var query =
    from line in File.ReadAllLines(filePath)
    .Where(data => data.Contains("Project("))
    let record = line.Split(',')
    select new
        {
            Name = record[0].Split('=')[1].Replace("\"",""),
            Path = record[1].Replace("\"",""),
            Guid = record[2]
        };
query.Dump();  // This is a LINQPad command


The above query works against the following data:

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoApplication", "DemoApplication\DemoApplication.csproj", "{73C60A32-09A2-45C2-8C8C-8FD2817BB087}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HostView", "HostView\HostView.csproj", "{D589DDD6-6C12-4924-8831-3F312BBEA53E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Calculator.Contracts", "Calculator.Contracts\Calculator.Contracts.csproj", "{D3E90866-D7BA-4B2A-A192-99649C2734BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInView", "AddInView\AddInView.csproj", "{A4AA9D5C-28EA-4933-B750-E434B847B66F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInSideAdapters", "AddInSideAdapters\AddInSideAdapters.csproj", "{C7311113-761B-43CF-A327-89C884698A1D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HostSideAdapters", "HostSideAdapters\HostSideAdapters.csproj", "{16B44B99-FB0D-4C61-9780-FF3E863F9D64}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicArithmaticAddIn.cs", "BasicArithmaticAddIn.cs\BasicArithmaticAddIn.cs.csproj", "{9CF465E4-003E-451D-ACBD-526E66CBB17A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicVisualAddIn", "BasicVisualAddIn\BasicVisualAddIn.csproj", "{71E0E79C-FFF8-441D-82D2-D50FDE809C14}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphCalc", "Graphing Calculator\GraphCalc.csproj", "{1241B377-8BA7-4AE1-B6CD-66766348B521}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicStackOperations", "BasicStackOperations\BasicStackOperations.csproj", "{E8144FE1-51E4-4DD9-9620-5B3EFF5625A7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CAL", "CAL", "{28F48224-E0D4-4E43-93C6-E98D3789732E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Composite", "..\CAL\Composite\Composite.csproj", "{77138947-1D13-4E22-AEE0-5D0DD046CA34}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Composite.UnityExtensions", "..\CAL\Composite.UnityExtensions\Composite.UnityExtensions.csproj", "{17831F3B-6B82-4916-BD2B-2CE2071EA622}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Composite.Wpf", "..\CAL\Composite.Wpf\Composite.Wpf.csproj", "{F807062D-6FC9-4FF0-A9F5-5F94653EDC4D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedDLL", "SharedDLL\SharedDLL.csproj", "{7968177C-7610-4941-AB18-71BF5E2EA69D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CALDemoApplication", "CALDemoApplication\CALDemoApplication.csproj", "{6DE42D1B-BF16-48F1-8EEF-22AFE1446254}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CALDemoApplication.Infrastructure", "CALDemoApplication.Infrastructure\CALDemoApplication.Infrastructure.csproj", "{EB012DE4-816A-44A6-957C-1FED71EE1C31}"
EndProject
Global
 GlobalSection(TeamFoundationVersionControl) = preSolution
  SccNumberOfProjects = 11
  SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
  SccTeamFoundationServer = https://tfs05.codeplex.com/
  SccLocalPath0 = .
  SccProjectUniqueName1 = AddInSideAdapters\\AddInSideAdapters.csproj
  SccProjectName1 = AddInSideAdapters
  SccLocalPath1 = AddInSideAdapters
  SccProjectUniqueName2 = AddInView\\AddInView.csproj
  SccProjectName2 = AddInView
  SccLocalPath2 = AddInView
  SccProjectUniqueName3 = BasicArithmaticAddIn.cs\\BasicArithmaticAddIn.cs.csproj
  SccProjectName3 = BasicArithmaticAddIn.cs
  SccLocalPath3 = BasicArithmaticAddIn.cs
  SccProjectUniqueName4 = BasicStackOperations\\BasicStackOperations.csproj
  SccProjectName4 = BasicStackOperations
  SccLocalPath4 = BasicStackOperations
  SccProjectUniqueName5 = BasicVisualAddIn\\BasicVisualAddIn.csproj
  SccProjectName5 = BasicVisualAddIn
  SccLocalPath5 = BasicVisualAddIn
  SccProjectUniqueName6 = Calculator.Contracts\\Calculator.Contracts.csproj
  SccProjectName6 = Calculator.Contracts
  SccLocalPath6 = Calculator.Contracts
  SccProjectUniqueName7 = DemoApplication\\DemoApplication.csproj
  SccProjectName7 = DemoApplication
  SccLocalPath7 = DemoApplication
  SccProjectUniqueName8 = Graphing\u0020Calculator\\GraphCalc.csproj
  SccProjectName8 = Graphing\u0020Calculator
  SccLocalPath8 = Graphing\u0020Calculator
  SccProjectUniqueName9 = HostSideAdapters\\HostSideAdapters.csproj
  SccProjectName9 = HostSideAdapters
  SccLocalPath9 = HostSideAdapters
  SccProjectUniqueName10 = HostView\\HostView.csproj
  SccProjectName10 = HostView
  SccLocalPath10 = HostView
 EndGlobalSection
 GlobalSection(SolutionConfigurationPlatforms) = preSolution
  Debug|Any CPU = Debug|Any CPU
  Release|Any CPU = Release|Any CPU
 EndGlobalSection
 GlobalSection(ProjectConfigurationPlatforms) = postSolution
  {73C60A32-09A2-45C2-8C8C-8FD2817BB087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {73C60A32-09A2-45C2-8C8C-8FD2817BB087}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {73C60A32-09A2-45C2-8C8C-8FD2817BB087}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {73C60A32-09A2-45C2-8C8C-8FD2817BB087}.Release|Any CPU.Build.0 = Release|Any CPU
  {D589DDD6-6C12-4924-8831-3F312BBEA53E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {D589DDD6-6C12-4924-8831-3F312BBEA53E}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {D589DDD6-6C12-4924-8831-3F312BBEA53E}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {D589DDD6-6C12-4924-8831-3F312BBEA53E}.Release|Any CPU.Build.0 = Release|Any CPU
  {D3E90866-D7BA-4B2A-A192-99649C2734BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {D3E90866-D7BA-4B2A-A192-99649C2734BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {D3E90866-D7BA-4B2A-A192-99649C2734BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {D3E90866-D7BA-4B2A-A192-99649C2734BD}.Release|Any CPU.Build.0 = Release|Any CPU
  {A4AA9D5C-28EA-4933-B750-E434B847B66F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {A4AA9D5C-28EA-4933-B750-E434B847B66F}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {A4AA9D5C-28EA-4933-B750-E434B847B66F}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {A4AA9D5C-28EA-4933-B750-E434B847B66F}.Release|Any CPU.Build.0 = Release|Any CPU
  {C7311113-761B-43CF-A327-89C884698A1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {C7311113-761B-43CF-A327-89C884698A1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {C7311113-761B-43CF-A327-89C884698A1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {C7311113-761B-43CF-A327-89C884698A1D}.Release|Any CPU.Build.0 = Release|Any CPU
  {16B44B99-FB0D-4C61-9780-FF3E863F9D64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {16B44B99-FB0D-4C61-9780-FF3E863F9D64}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {16B44B99-FB0D-4C61-9780-FF3E863F9D64}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {16B44B99-FB0D-4C61-9780-FF3E863F9D64}.Release|Any CPU.Build.0 = Release|Any CPU
  {9CF465E4-003E-451D-ACBD-526E66CBB17A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {9CF465E4-003E-451D-ACBD-526E66CBB17A}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {9CF465E4-003E-451D-ACBD-526E66CBB17A}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {9CF465E4-003E-451D-ACBD-526E66CBB17A}.Release|Any CPU.Build.0 = Release|Any CPU
  {71E0E79C-FFF8-441D-82D2-D50FDE809C14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {71E0E79C-FFF8-441D-82D2-D50FDE809C14}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {71E0E79C-FFF8-441D-82D2-D50FDE809C14}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {71E0E79C-FFF8-441D-82D2-D50FDE809C14}.Release|Any CPU.Build.0 = Release|Any CPU
  {1241B377-8BA7-4AE1-B6CD-66766348B521}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {1241B377-8BA7-4AE1-B6CD-66766348B521}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {1241B377-8BA7-4AE1-B6CD-66766348B521}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {1241B377-8BA7-4AE1-B6CD-66766348B521}.Release|Any CPU.Build.0 = Release|Any CPU
  {E8144FE1-51E4-4DD9-9620-5B3EFF5625A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {E8144FE1-51E4-4DD9-9620-5B3EFF5625A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {E8144FE1-51E4-4DD9-9620-5B3EFF5625A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {E8144FE1-51E4-4DD9-9620-5B3EFF5625A7}.Release|Any CPU.Build.0 = Release|Any CPU
  {77138947-1D13-4E22-AEE0-5D0DD046CA34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {77138947-1D13-4E22-AEE0-5D0DD046CA34}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {77138947-1D13-4E22-AEE0-5D0DD046CA34}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {77138947-1D13-4E22-AEE0-5D0DD046CA34}.Release|Any CPU.Build.0 = Release|Any CPU
  {17831F3B-6B82-4916-BD2B-2CE2071EA622}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {17831F3B-6B82-4916-BD2B-2CE2071EA622}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {17831F3B-6B82-4916-BD2B-2CE2071EA622}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {17831F3B-6B82-4916-BD2B-2CE2071EA622}.Release|Any CPU.Build.0 = Release|Any CPU
  {F807062D-6FC9-4FF0-A9F5-5F94653EDC4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {F807062D-6FC9-4FF0-A9F5-5F94653EDC4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {F807062D-6FC9-4FF0-A9F5-5F94653EDC4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {F807062D-6FC9-4FF0-A9F5-5F94653EDC4D}.Release|Any CPU.Build.0 = Release|Any CPU
  {7968177C-7610-4941-AB18-71BF5E2EA69D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {7968177C-7610-4941-AB18-71BF5E2EA69D}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {7968177C-7610-4941-AB18-71BF5E2EA69D}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {7968177C-7610-4941-AB18-71BF5E2EA69D}.Release|Any CPU.Build.0 = Release|Any CPU
  {6DE42D1B-BF16-48F1-8EEF-22AFE1446254}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {6DE42D1B-BF16-48F1-8EEF-22AFE1446254}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {6DE42D1B-BF16-48F1-8EEF-22AFE1446254}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {6DE42D1B-BF16-48F1-8EEF-22AFE1446254}.Release|Any CPU.Build.0 = Release|Any CPU
  {EB012DE4-816A-44A6-957C-1FED71EE1C31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {EB012DE4-816A-44A6-957C-1FED71EE1C31}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {EB012DE4-816A-44A6-957C-1FED71EE1C31}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {EB012DE4-816A-44A6-957C-1FED71EE1C31}.Release|Any CPU.Build.0 = Release|Any CPU
 EndGlobalSection
 GlobalSection(SolutionProperties) = preSolution
  HideSolutionNode = FALSE
 EndGlobalSection
 GlobalSection(NestedProjects) = preSolution
  {77138947-1D13-4E22-AEE0-5D0DD046CA34} = {28F48224-E0D4-4E43-93C6-E98D3789732E}
  {17831F3B-6B82-4916-BD2B-2CE2071EA622} = {28F48224-E0D4-4E43-93C6-E98D3789732E}
  {F807062D-6FC9-4FF0-A9F5-5F94653EDC4D} = {28F48224-E0D4-4E43-93C6-E98D3789732E}
  {7968177C-7610-4941-AB18-71BF5E2EA69D} = {28F48224-E0D4-4E43-93C6-E98D3789732E}
 EndGlobalSection
EndGlobal 


To produce the following results (bottom pane holds the Dump() results):

I was able to tweak and tune my LINQ query (instantly seeing the results) until I had the output I was looking for.


Tags: , ,
Categories:


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know