From 3d42e85e5413b22e55058e721281be57cbdda484 Mon Sep 17 00:00:00 2001 From: Kristian Hellang Date: Thu, 10 Sep 2015 12:51:12 +0200 Subject: [PATCH] Added LangVersion CLI paramter --- LangVersionFixer/App.config | 9 ++++---- LangVersionFixer/Program.cs | 20 ++++++++++++++--- LangVersionFixer/Properties/AssemblyInfo.cs | 25 ++++----------------- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/LangVersionFixer/App.config b/LangVersionFixer/App.config index 88fa402..51fffc7 100644 --- a/LangVersionFixer/App.config +++ b/LangVersionFixer/App.config @@ -1,6 +1,7 @@ - + + - - - + + + \ No newline at end of file diff --git a/LangVersionFixer/Program.cs b/LangVersionFixer/Program.cs index bbece79..995981c 100644 --- a/LangVersionFixer/Program.cs +++ b/LangVersionFixer/Program.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Xml; @@ -10,11 +11,24 @@ public static class Program { public static void Main(string[] args) { + if (args.Length < 2) + { + Console.WriteLine("Usage: LangVersionFixer "); + return; + } + var directory = args[0]; + int langVersion; + if (!int.TryParse(args[1], out langVersion)) + { + Console.WriteLine($"'{args[1]}' is not a valid LangVersion parameter."); + return; + } + XNamespace @namespace = "http://schemas.microsoft.com/developer/msbuild/2003"; - var langeVersionElement = new XElement(@namespace + "LangVersion") { Value = "5" }; + var langVersionElement = new XElement(@namespace + "LangVersion") { Value = langVersion.ToString() }; var filePaths = GetFilePaths(directory, "*.csproj"); @@ -26,7 +40,7 @@ public static void Main(string[] args) var globalPropertyGroup = propertyGroups.FirstOrDefault(x => !x.HasAttributes) ?? propertyGroups.First(); - globalPropertyGroup.Add(langeVersionElement); + globalPropertyGroup.Add(langVersionElement); document.Descendants().Where(x => string.IsNullOrWhiteSpace(x.Value) && !x.HasElements).ToList().ForEach(x => x.RemoveNodes()); diff --git a/LangVersionFixer/Properties/AssemblyInfo.cs b/LangVersionFixer/Properties/AssemblyInfo.cs index 7dff580..362dbb6 100644 --- a/LangVersionFixer/Properties/AssemblyInfo.cs +++ b/LangVersionFixer/Properties/AssemblyInfo.cs @@ -1,36 +1,19 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("LangVersionFixer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LangVersionFixer")] -[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyCopyright("Copyright © Kristian Hellang 2015")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("ba839f37-bcd2-418f-967e-aa49cc905ed6")] -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] +[assembly: AssemblyInformationalVersion("1.1.0")]