Skip to content

Commit

Permalink
enable parsing aliased references, fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
0x53A committed May 24, 2016
1 parent b3e41a0 commit 53cf2e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ public static PrecompilationCommandLineArgs Parse(string[] arguments, string bas
}
else if(arg.StartsWith("/r:") || arg.StartsWith("/reference:"))
{
// don't care about extern stuff for now..
// https://msdn.microsoft.com/en-us/library/ms173212.aspx
references.Add(ParseFileFromArg(arg));
references.Add(ParseFileFromReference(arg));
}
else if(arg.StartsWith("/appconfig:"))
{
Expand All @@ -105,5 +103,15 @@ private static string ParseFileFromArg(string arg, char delimiter = ':')
{
return Path.GetFullPath(arg.Substring(arg.IndexOf(delimiter) + 1));
}

private static string ParseFileFromReference(string arg)
{
var rxReference = new Regex("/(r|(reference)):([a-zA-Z0-9]*=)?(?<ref>.*)");
var match = rxReference.Match(arg);
if (!match.Success)
throw new Exception($"Could not find a reference in {arg}");
var reference = match.Groups["ref"].Value;
return Path.GetFullPath(reference);
}
}
}
3 changes: 3 additions & 0 deletions StackExchange.Precompilation.Tests/CommandLineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ public void ParseArguments()
[Test]
[TestCase("a b c", new string[0], (string)null)]
[TestCase("a b /r:c.dll", new[] { "c.dll" }, (string)null)]
[TestCase("a b /r:a=c.dll", new[] { "c.dll" }, (string)null)]
[TestCase("a b /reference:a=c.dll", new[] { "c.dll" }, (string)null)]
[TestCase("a b /r:c.dll /r:d.dll", new[] { "c.dll", "d.dll" }, (string)null)]
[TestCase("a b /r:c.dll /appconfig:moar.config /r:d.dll", new[] { "c.dll", "d.dll" }, "moar.config")]
[TestCase("a b /r:alias=c.dll /appconfig:moar.config /reference:d.dll", new[] { "c.dll", "d.dll" }, "moar.config")]
public void ParseArgumentCases(string cmdline, string[] references, string appconfig)
{
var dir = Guid.NewGuid().ToString();
Expand Down

0 comments on commit 53cf2e0

Please sign in to comment.