Browse Source

Let's avoid switching to C# 6 for now.

pull/681/head
Daniel Grunwald 10 years ago
parent
commit
7265de118d
  1. 13
      ICSharpCode.Decompiler/Tests/FSharpPatterns/FSharpPatternTests.cs
  2. 11
      ICSharpCode.Decompiler/Tests/FSharpPatterns/TestHelpers.cs
  3. 32
      ICSharpCode.Decompiler/Tests/FSharpPatterns/ToolLocator.cs

13
ICSharpCode.Decompiler/Tests/FSharpPatterns/FSharpPatternTests.cs

@ -5,7 +5,6 @@ using System.Linq; @@ -5,7 +5,6 @@ using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using static ICSharpCode.Decompiler.Tests.FSharpPatterns.TestHelpers;
namespace ICSharpCode.Decompiler.Tests.FSharpPatterns
{
@ -15,17 +14,17 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns @@ -15,17 +14,17 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns
[Test]
public void FSharpUsingDecompilesToCSharpUsing_Debug()
{
var ilCode = FuzzyReadResource("FSharpUsing.fs.Debug.il");
var csharpCode = FuzzyReadResource("FSharpUsing.fs.Debug.cs");
RunIL(ilCode, csharpCode);
var ilCode = TestHelpers.FuzzyReadResource("FSharpUsing.fs.Debug.il");
var csharpCode = TestHelpers.FuzzyReadResource("FSharpUsing.fs.Debug.cs");
TestHelpers.RunIL(ilCode, csharpCode);
}
[Test]
public void FSharpUsingDecompilesToCSharpUsing_Release()
{
var ilCode = FuzzyReadResource("FSharpUsing.fs.Release.il");
var csharpCode = FuzzyReadResource("FSharpUsing.fs.Release.cs");
RunIL(ilCode, csharpCode);
var ilCode = TestHelpers.FuzzyReadResource("FSharpUsing.fs.Release.il");
var csharpCode = TestHelpers.FuzzyReadResource("FSharpUsing.fs.Release.cs");
TestHelpers.RunIL(ilCode, csharpCode);
}
}
}

11
ICSharpCode.Decompiler/Tests/FSharpPatterns/TestHelpers.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns @@ -20,7 +20,7 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns
{
var asm = Assembly.GetExecutingAssembly();
var allResources = asm.GetManifestResourceNames();
var fullResourceName = allResources.Single(r => r.ToLowerInvariant().EndsWith(resourceName.ToLowerInvariant()));
var fullResourceName = allResources.Single(r => r.EndsWith(resourceName, StringComparison.OrdinalIgnoreCase));
return new StreamReader(asm.GetManifestResourceStream(fullResourceName)).ReadToEnd();
}
@ -33,7 +33,7 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns @@ -33,7 +33,7 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns
File.WriteAllText(sourceFile, source);
var asmFile = Path.ChangeExtension(sourceFile, ".dll");
var sscs = new Microsoft.FSharp.Compiler.SimpleSourceCodeServices.SimpleSourceCodeServices();
var result = sscs.Compile(new[] { "fsc.exe", "--debug:full", $"--optimize{(optimize ? "+" : "-")}", "--target:library", "-o", asmFile, sourceFile });
var result = sscs.Compile(new[] { "fsc.exe", "--debug:full", "--optimize" + (optimize ? "+" : "-"), "--target:library", "-o", asmFile, sourceFile });
File.Delete(sourceFile);
Assert.AreEqual(0, result.Item1.Length);
Assert.AreEqual(0, result.Item2);
@ -54,7 +54,7 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns @@ -54,7 +54,7 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns
File.WriteAllText(sourceFile, source);
var asmFile = Path.ChangeExtension(sourceFile, ".dll");
var args = $"{sourceFile} /dll /debug /output:{asmFile}";
var args = string.Format("{0} /dll /debug /output:{1}", sourceFile, asmFile);
using (var proc = Process.Start(new ProcessStartInfo(ilasm.Value, args) { UseShellExecute = false, }))
{
proc.WaitForExit();
@ -91,8 +91,9 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns @@ -91,8 +91,9 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns
// the F# assembly contains a namespace `<StartupCode$tmp6D55>` where the part after tmp is randomly generated.
// remove this from the ast to simplify the diff
var startupCodeNode = decompiler.SyntaxTree.Children.SingleOrDefault(d => (d as NamespaceDeclaration)?.Name?.StartsWith("<StartupCode$") ?? false);
startupCodeNode?.Remove();
var startupCodeNode = decompiler.SyntaxTree.Children.OfType<NamespaceDeclaration>().SingleOrDefault(d => d.Name.StartsWith("<StartupCode$", StringComparison.Ordinal));
if (startupCodeNode != null)
startupCodeNode.Remove();
decompiler.GenerateCode(new PlainTextOutput(output));
var fullCSharpCode = output.ToString();

32
ICSharpCode.Decompiler/Tests/FSharpPatterns/ToolLocator.cs

@ -19,19 +19,19 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns @@ -19,19 +19,19 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns
{
string[] windowsSdkPaths = new[]
{
@"Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\",
@"Microsoft SDKs\Windows\v8.0A\bin\",
@"Microsoft SDKs\Windows\v8.0\bin\NETFX 4.0 Tools\",
@"Microsoft SDKs\Windows\v8.0\bin\",
@"Microsoft SDKs\Windows\v7.1A\bin\NETFX 4.0 Tools\",
@"Microsoft SDKs\Windows\v7.1A\bin\",
@"Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\",
@"Microsoft SDKs\Windows\v7.0A\bin\",
@"Microsoft SDKs\Windows\v6.1A\bin\",
@"Microsoft SDKs\Windows\v6.0A\bin\",
@"Microsoft SDKs\Windows\v6.0\bin\",
@"Microsoft.NET\FrameworkSDK\bin"
};
@"Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\",
@"Microsoft SDKs\Windows\v8.0A\bin\",
@"Microsoft SDKs\Windows\v8.0\bin\NETFX 4.0 Tools\",
@"Microsoft SDKs\Windows\v8.0\bin\",
@"Microsoft SDKs\Windows\v7.1A\bin\NETFX 4.0 Tools\",
@"Microsoft SDKs\Windows\v7.1A\bin\",
@"Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\",
@"Microsoft SDKs\Windows\v7.0A\bin\",
@"Microsoft SDKs\Windows\v6.1A\bin\",
@"Microsoft SDKs\Windows\v6.0A\bin\",
@"Microsoft SDKs\Windows\v6.0\bin\",
@"Microsoft.NET\FrameworkSDK\bin"
};
foreach (var possiblePath in windowsSdkPaths)
{
@ -71,9 +71,9 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns @@ -71,9 +71,9 @@ namespace ICSharpCode.Decompiler.Tests.FSharpPatterns
{
string[] frameworkPaths = new[]
{
@"Microsoft.NET\Framework\v4.0.30319",
@"Microsoft.NET\Framework\v2.0.50727"
};
@"Microsoft.NET\Framework\v4.0.30319",
@"Microsoft.NET\Framework\v2.0.50727"
};
foreach (var possiblePath in frameworkPaths)
{

Loading…
Cancel
Save