Skip to content

Commit

Permalink
Added LangVersion CLI paramter
Browse files Browse the repository at this point in the history
  • Loading branch information
khellang committed Sep 10, 2015
1 parent ea39ace commit 3d42e85
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
9 changes: 5 additions & 4 deletions LangVersionFixer/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
20 changes: 17 additions & 3 deletions LangVersionFixer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
Expand All @@ -10,11 +11,24 @@ public static class Program
{
public static void Main(string[] args)
{
if (args.Length < 2)
{
Console.WriteLine("Usage: LangVersionFixer <folder-with-csprojs> <lang-version-number>");
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");

Expand All @@ -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());

Expand Down
25 changes: 4 additions & 21 deletions LangVersionFixer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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")]

0 comments on commit 3d42e85

Please sign in to comment.