Browse Source

Add failing test and test infrastructure adjustments to allow compiling referenced assemblies in one go.

pull/3686/head
Siegfried Pammer 2 weeks ago
parent
commit
a03f801cb7
  1. 16
      ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
  2. 2
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  3. 6
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  4. 21
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue3684.cs
  5. 16
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue3684.dep.cs

16
ICSharpCode.Decompiler.Tests/Helpers/Tester.cs

@ -489,6 +489,17 @@ namespace System.Runtime.CompilerServices @@ -489,6 +489,17 @@ namespace System.Runtime.CompilerServices
{
sourceFileNames.Add(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(sourceFileName), match.Groups[1].Value)));
}
List<string> dependencyAssemblies = new List<string>();
string sourceText = File.ReadAllText(sourceFileName);
foreach (Match match in Regex.Matches(sourceText, @"//\s*#dependency\s+([\w\d./\\]+)"))
{
string depSourcePath = Path.GetFullPath(Path.Combine(
Path.GetDirectoryName(sourceFileName), match.Groups[1].Value));
var depResults = await CompileCSharp(depSourcePath, flags | CompilerOptions.Library).ConfigureAwait(false);
dependencyAssemblies.Add(Path.GetFullPath(depResults.PathToAssembly));
}
bool targetNet40 = (flags & CompilerOptions.TargetNet40) != 0;
bool useRoslyn = (flags & CompilerOptions.UseRoslynMask) != 0;
@ -556,6 +567,11 @@ namespace System.Runtime.CompilerServices @@ -556,6 +567,11 @@ namespace System.Runtime.CompilerServices
references = references.Select(r => "-r:\"" + Path.Combine(refAsmPath, r) + "\"");
foreach (var dependency in dependencyAssemblies)
{
references = references.Append($"-r:\"{dependency}\"");
}
string otherOptions = $"-nologo -noconfig " +
$"-langversion:{languageVersion} " +
$"-unsafe -o{(flags.HasFlag(CompilerOptions.Optimize) ? "+ " : "- ")}";

2
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -167,6 +167,8 @@ @@ -167,6 +167,8 @@
<Compile Include="TestCases\Pretty\Issue3610.cs" />
<Compile Include="TestCases\Pretty\Issue3611.cs" />
<Compile Include="TestCases\Pretty\Issue3598.cs" />
<None Include="TestCases\Pretty\Issue3684.dep.cs" />
<None Include="TestCases\Pretty\Issue3684.cs" />
<None Include="TestCases\Ugly\NoLocalFunctions.Expected.cs" />
<None Include="TestCases\ILPretty\Issue3504.cs" />
<Compile Include="TestCases\ILPretty\MonoFixed.cs" />

6
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -852,6 +852,12 @@ namespace ICSharpCode.Decompiler.Tests @@ -852,6 +852,12 @@ namespace ICSharpCode.Decompiler.Tests
await RunForLibrary(cscOptions: cscOptions);
}
[Test]
public async Task Issue3684([ValueSource(nameof(roslyn4OrNewerOptions))] CompilerOptions cscOptions)
{
await RunForLibrary(cscOptions: cscOptions);
}
async Task RunForLibrary([CallerMemberName] string testName = null, AssemblerOptions asmOptions = AssemblerOptions.None, CompilerOptions cscOptions = CompilerOptions.None, Action<DecompilerSettings> configureDecompiler = null)
{
await Run(testName, asmOptions | AssemblerOptions.Library, cscOptions | CompilerOptions.Library, configureDecompiler);

21
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue3684.cs

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
// #dependency Issue3684.dep.cs
using CrossAssemblyDep;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
public static class Issue3684
{
public interface IInterface
{
string Name { get; set; }
}
public class DerivedClass : BaseClass, IInterface
{
T IInterface.Convert<T>(T input)
{
return ((BaseClass)this).Convert<T>(input);
}
}
}
}

16
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue3684.dep.cs

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
namespace CrossAssemblyDep
{
public class BaseClass
{
private string name = "BaseClass";
public string Name {
get {
return name;
}
set {
name = value;
}
}
}
}
Loading…
Cancel
Save