Skip to content

Commit

Permalink
Added a "warning" file to the filtered solution instead of writing to…
Browse files Browse the repository at this point in the history
… the console (which doesn't exist since it's a 'Windows Application').
  • Loading branch information
christianwarren committed Jul 30, 2015
1 parent c3aeb4e commit a914dba
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
41 changes: 29 additions & 12 deletions SLNTools.exe/OpenFilterFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
Expand Down Expand Up @@ -56,16 +57,13 @@ public override void Run(string[] args, MessageBoxErrorReporter reporter)
{
var filterFile = FilterFile.FromFile(parsedArguments.FilterFile);

foreach (var warning in filterFile.SourceSolution.Warnings)
{
Console.WriteLine("WARNING: {0}", warning);
}

// Save the filtered solution. We also add a link to the original solution file in the filtered solution.
// If we have to checkout the original solution file later on, its easier with that link.
var filteredSolution = filterFile.Apply();
var originalSolutionProject = CreateOriginalSolutionProject(filterFile.SourceSolutionFullPath);
filteredSolution.Projects.Add(originalSolutionProject);

// Add OriginalSolutionFile to the filter solution (and a warnings file if needed)
filteredSolution.Projects.Add(CreateOriginalSolutionProject(filterFile.SourceSolution));

filteredSolution.Save();
if (filterFile.CopyReSharperFiles)
{
Expand Down Expand Up @@ -126,10 +124,30 @@ public override void Run(string[] args, MessageBoxErrorReporter reporter)
}

private static Project CreateOriginalSolutionProject(
string originalSolutionFullPath)
SolutionFile sourceSolutionFile)
{
var originalSolutionName = Path.GetFileName(originalSolutionFullPath);
var project = new Project(
var originalSolutionName = Path.GetFileName(sourceSolutionFile.SolutionFullPath);

var propertyLines = new List<PropertyLine>();
propertyLines.Add(new PropertyLine(originalSolutionName, originalSolutionName));
if (sourceSolutionFile.Warnings.Count > 0)
{
var warningFileName = originalSolutionName + ".warnings.txt";
var warningFullPath = Path.Combine(Path.GetDirectoryName(sourceSolutionFile.SolutionFullPath) ?? ".", warningFileName);
using (var output = File.CreateText(warningFullPath))
{
output.WriteLine("The following warnings were found while parsing the file '{0}': ", originalSolutionName);
output.WriteLine();
foreach (var warning in sourceSolutionFile.Warnings)
{
output.WriteLine(warning);
}
}

propertyLines.Add(new PropertyLine(warningFileName, warningFileName));
}

return new Project(
null,
"{3D86F2A1-6348-4351-9B53-2A75735A2AB4}",
KnownProjectTypeGuid.SolutionFolder,
Expand All @@ -142,11 +160,10 @@ private static Project CreateOriginalSolutionProject(
"SolutionItems",
"ProjectSection",
"preProject",
new PropertyLine[] { new PropertyLine(originalSolutionName, originalSolutionName) })
propertyLines)
},
null,
null);
return project;
}
}
}
3 changes: 2 additions & 1 deletion SLNTools.exe/SLNTools.exe.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<StartupObject>CWDev.SLNTools.Program</StartupObject>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -36,6 +36,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down

0 comments on commit a914dba

Please sign in to comment.