Browse Source

Merge branch 'master' into feature/ReferenceAssemblyOverly

pull/3013/head
workgroupengineering 11 months ago committed by GitHub
parent
commit
2f904f90d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      .gitignore
  2. 8
      Directory.Packages.props
  3. 8
      ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
  4. 2
      ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
  5. 75
      ICSharpCode.Decompiler.Tests/Helpers/TestsAssemblyOutput.cs
  6. 16
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  7. 2
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  8. 2
      ICSharpCode.Decompiler.Tests/VBPrettyTestRunner.cs
  9. 9
      ILSpy.BamlDecompiler.Tests/ILSpy.BamlDecompiler.Tests.csproj

1
.gitignore vendored

@ -20,3 +20,4 @@ ILSpy.Installer/wix/ @@ -20,3 +20,4 @@ ILSpy.Installer/wix/
/VERSION
/ICSharpCode.Decompiler/Properties/DecompilerVersionInfo.cs
*/.vscode/
DecompilerTests.config.json

8
Directory.Packages.props

@ -21,20 +21,22 @@ @@ -21,20 +21,22 @@
<PackageVersion Include="Microsoft.DiaSymReader.Converter.Xml" Version="1.1.0-beta2-22171-02" />
<PackageVersion Include="Microsoft.DiaSymReader" Version="1.4.0" />
<PackageVersion Include="Microsoft.DiaSymReader.Native" Version="17.0.0-beta1.21524.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="Microsoft.NETCore.ILAsm" Version="8.0.0" />
<PackageVersion Include="Microsoft.NETCore.ILDAsm" Version="8.0.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.Composition" Version="17.10.37" />
<PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
<PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" />
<PackageVersion Include="Mono.Cecil" Version="0.11.5" />
<PackageVersion Include="NaturalSort.Extension" Version="4.3.0" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17" />
<PackageVersion Include="NUnit" Version="4.1.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="NuGet.Protocol" Version="6.10.0" />
<PackageVersion Include="NuGet.Protocol" Version="6.10.1" />
<PackageVersion Include="PowerShellStandard.Library" Version="5.1.1" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="System.ComponentModel.Composition" Version="8.0.0" />
@ -43,7 +45,7 @@ @@ -43,7 +45,7 @@
<PackageVersion Include="System.Reflection.Metadata" Version="8.0.0" />
<PackageVersion Include="System.Resources.Extensions" Version="8.0.0" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageVersion Include="TomsToolbox.Wpf.Styles" Version="2.14.0" />
<PackageVersion Include="TomsToolbox.Wpf.Styles" Version="2.15.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
</ItemGroup>
</Project>

8
ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs

@ -408,13 +408,13 @@ namespace ICSharpCode.Decompiler.Tests @@ -408,13 +408,13 @@ namespace ICSharpCode.Decompiler.Tests
if ((options & CompilerOptions.UseRoslynMask) != 0 && (options & CompilerOptions.TargetNet40) == 0)
options |= CompilerOptions.UseTestRunner;
string testFileName = testName + ".cs";
string testOutputFileName = testName + Tester.GetSuffix(options) + ".exe";
string testOutputFileName = TestsAssemblyOutput.GetFilePath(TestCasePath, testName, Tester.GetSuffix(options) + ".exe");
CompilerResults outputFile = null, decompiledOutputFile = null;
try
{
outputFile = await Tester.CompileCSharp(Path.Combine(TestCasePath, testFileName), options,
outputFileName: Path.Combine(TestCasePath, testOutputFileName)).ConfigureAwait(false);
outputFileName: testOutputFileName).ConfigureAwait(false);
string decompiledCodeFile = await Tester.DecompileCSharp(outputFile.PathToAssembly, Tester.GetSettings(options)).ConfigureAwait(false);
if ((options & CompilerOptions.UseMcsMask) != 0)
{
@ -452,13 +452,13 @@ namespace ICSharpCode.Decompiler.Tests @@ -452,13 +452,13 @@ namespace ICSharpCode.Decompiler.Tests
if ((options & CompilerOptions.UseRoslynMask) != 0)
options |= CompilerOptions.UseTestRunner;
string testFileName = testName + ".vb";
string testOutputFileName = testName + Tester.GetSuffix(options) + ".exe";
string testOutputFileName = TestsAssemblyOutput.GetFilePath(TestCasePath, testName, Tester.GetSuffix(options) + ".exe");
CompilerResults outputFile = null, decompiledOutputFile = null;
try
{
outputFile = await Tester.CompileVB(Path.Combine(TestCasePath, testFileName), options,
outputFileName: Path.Combine(TestCasePath, testOutputFileName)).ConfigureAwait(false);
outputFileName: testOutputFileName).ConfigureAwait(false);
string decompiledCodeFile = await Tester.DecompileCSharp(outputFile.PathToAssembly, Tester.GetSettings(options)).ConfigureAwait(false);
decompiledOutputFile = await Tester.CompileCSharp(decompiledCodeFile, options).ConfigureAwait(false);

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

@ -886,7 +886,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -886,7 +886,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
get {
if (pathToAssembly == null)
{
pathToAssembly = Path.GetTempFileName();
pathToAssembly = TestsAssemblyOutput.GetTempFileName();
tempFiles.Add(pathToAssembly);
}
return pathToAssembly;

75
ICSharpCode.Decompiler.Tests/Helpers/TestsAssemblyOutput.cs

@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
// Copyright (c) 2024 Christoph Wille
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.IO;
using Microsoft.Extensions.Configuration;
namespace ICSharpCode.Decompiler.Tests.Helpers
{
/// <summary>
/// Centralizes all file-path generation for compilation output (assemblies)
///
/// DecompilerTests.config.json file format:
/// {
/// "TestsAssemblyTempPath": "d:\\test\\"
/// }
/// </summary>
internal static class TestsAssemblyOutput
{
static string? TestsAssemblyTempPath = null;
private static bool UseCustomPath => !string.IsNullOrWhiteSpace(TestsAssemblyTempPath);
static TestsAssemblyOutput()
{
if (!File.Exists("DecompilerTests.config.json"))
return;
var builder = new ConfigurationBuilder()
.AddJsonFile("DecompilerTests.config.json", optional: true, reloadOnChange: false);
IConfigurationRoot configuration = builder.Build();
var pathRedirectIfAny = configuration["TestsAssemblyTempPath"];
if (!string.IsNullOrWhiteSpace(pathRedirectIfAny))
{
TestsAssemblyTempPath = pathRedirectIfAny;
}
}
public static string GetFilePath(string testCasePath, string testName, string computedExtension)
{
if (!UseCustomPath)
return Path.Combine(testCasePath, testName) + computedExtension;
// As we are using the TestsAssemblyTempPath flat, we need to make sure that duplicated test names don't create file name clashes
return Path.Combine(TestsAssemblyTempPath, testName) + Guid.NewGuid().ToString() + computedExtension;
}
public static string GetTempFileName()
{
if (!UseCustomPath)
return Path.GetTempFileName();
return Path.Combine(TestsAssemblyTempPath, Path.GetRandomFileName());
}
}
}

16
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -1,9 +1,16 @@ @@ -1,9 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsWindowsX64 Condition="$([MSBuild]::IsOsPlatform('Windows')) And $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) == X64">true</IsWindowsX64>
<IsWindowsARM64 Condition="$([MSBuild]::IsOsPlatform('Windows')) And $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) == ARM64">true</IsWindowsARM64>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$(IsWindowsX64) == true">win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$(IsWindowsARM64) == true">win-arm64</RuntimeIdentifier>
<IsPackable>false</IsPackable>
<StartupObject>AutoGeneratedProgram</StartupObject>
@ -43,14 +50,16 @@ @@ -43,14 +50,16 @@
<ItemGroup>
<PackageReference Include="DiffLib" />
<PackageReference Include="CliWrap" />
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
<PackageReference Include="NuGet.Protocol" />
<PackageReference Include="System.Collections.Immutable" />
<PackageReference Include="System.Reflection.Metadata" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" />
<PackageReference Include="Microsoft.DiaSymReader.Converter.Xml" />
<PackageReference Include="Microsoft.DiaSymReader" />
<PackageReference Include="Microsoft.DiaSymReader.Native" />
<PackageReference Include="Microsoft.DiaSymReader" />
<PackageReference Include="Microsoft.DiaSymReader.Native" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
@ -114,6 +123,7 @@ @@ -114,6 +123,7 @@
<ItemGroup>
<Compile Include="DisassemblerPrettyTestRunner.cs" />
<Compile Include="Helpers\RoslynToolset.cs" />
<Compile Include="Helpers\TestsAssemblyOutput.cs" />
<Compile Include="Output\InsertParenthesesVisitorTests.cs" />
<Compile Include="ProjectDecompiler\TargetFrameworkTests.cs" />
<Compile Include="TestAssemblyResolver.cs" />

2
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -714,7 +714,7 @@ namespace ICSharpCode.Decompiler.Tests @@ -714,7 +714,7 @@ namespace ICSharpCode.Decompiler.Tests
async Task Run([CallerMemberName] string testName = null, AssemblerOptions asmOptions = AssemblerOptions.None, CompilerOptions cscOptions = CompilerOptions.None, DecompilerSettings decompilerSettings = null)
{
var csFile = Path.Combine(TestCasePath, testName + ".cs");
var exeFile = Path.Combine(TestCasePath, testName) + Tester.GetSuffix(cscOptions) + ".exe";
var exeFile = TestsAssemblyOutput.GetFilePath(TestCasePath, testName, Tester.GetSuffix(cscOptions) + ".exe");
if (cscOptions.HasFlag(CompilerOptions.Library))
{
exeFile = Path.ChangeExtension(exeFile, ".dll");

2
ICSharpCode.Decompiler.Tests/VBPrettyTestRunner.cs

@ -147,7 +147,7 @@ namespace ICSharpCode.Decompiler.Tests @@ -147,7 +147,7 @@ namespace ICSharpCode.Decompiler.Tests
{
var vbFile = Path.Combine(TestCasePath, testName + ".vb");
var csFile = Path.Combine(TestCasePath, testName + ".cs");
var exeFile = Path.Combine(TestCasePath, testName) + Tester.GetSuffix(options) + ".exe";
var exeFile = TestsAssemblyOutput.GetFilePath(TestCasePath, testName, Tester.GetSuffix(options) + ".exe");
if (options.HasFlag(CompilerOptions.Library))
{
exeFile = Path.ChangeExtension(exeFile, ".dll");

9
ILSpy.BamlDecompiler.Tests/ILSpy.BamlDecompiler.Tests.csproj

@ -1,9 +1,16 @@ @@ -1,9 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsWindowsX64 Condition="$([MSBuild]::IsOsPlatform('Windows')) And $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) == X64">true</IsWindowsX64>
<IsWindowsARM64 Condition="$([MSBuild]::IsOsPlatform('Windows')) And $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) == ARM64">true</IsWindowsARM64>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$(IsWindowsX64) == true">win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$(IsWindowsARM64) == true">win-arm64</RuntimeIdentifier>
<IsPackable>false</IsPackable>
<StartupObject>AutoGeneratedProgram</StartupObject>

Loading…
Cancel
Save