Browse Source

.NET version information extracted from Tester

pull/4125/head
Christoph Wille 1 week ago
parent
commit
1b97efcd6a
  1. 2
      ICSharpCode.Decompiler.Tests/Documentation/IdStringProviderTests.cs
  2. 29
      ICSharpCode.Decompiler.Tests/Helpers/CurrentNetCoreVersion.cs
  3. 2
      ICSharpCode.Decompiler.Tests/Helpers/RoslynToolset.cs
  4. 2
      ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs
  5. 22
      ICSharpCode.Decompiler.Tests/Helpers/Tester.cs

2
ICSharpCode.Decompiler.Tests/Documentation/IdStringProviderTests.cs

@ -515,7 +515,7 @@ namespace ModreqParams @@ -515,7 +515,7 @@ namespace ModreqParams
roslynCompilation = CSharpCompilation.Create(
"IdStringTestAssembly",
new[] { syntaxTree },
Tester.CoreDefaultReferences.Select(r => MetadataReference.CreateFromFile(Path.Combine(Tester.RefAssembliesToolset.GetPath(Tester.CurrentNetCoreAppVersion), r))),
Tester.CoreDefaultReferences.Select(r => MetadataReference.CreateFromFile(Path.Combine(Tester.RefAssembliesToolset.GetPath(CurrentNetCoreVersion.AppVersion), r))),
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true));
// Verify the compilation has no errors (warnings are OK)

29
ICSharpCode.Decompiler.Tests/Helpers/CurrentNetCoreVersion.cs

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
// Copyright (c) 2015 Daniel Grunwald
//
// 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.
namespace ICSharpCode.Decompiler.Tests.Helpers
{
static class CurrentNetCoreVersion
{
public const string Version = "11.0";
public const string AppVersion = ".NETCoreApp,Version=v11.0";
public const string RefAsmVersion = "11.0.0-preview.5.26302.115";
public const string RefAsmPackage = "Microsoft.NETCore.App.Ref";
}
}

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

@ -228,7 +228,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -228,7 +228,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
{
}
public async Task Fetch(string version, string packageName = "Microsoft.NETCore.App.Ref", string sourcePath = "ref/net5.0")
public async Task Fetch(string version, string packageName = CurrentNetCoreVersion.RefAsmPackage, string sourcePath = "ref/net5.0")
{
string path = Path.Combine(baseDir, version, sourcePath);
if (!Directory.Exists(path))

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

@ -53,7 +53,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -53,7 +53,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
CompilerOptions.UseRoslyn1_3_2 => ("1.3.2", "14", null),
CompilerOptions.UseRoslyn2_10_0 => ("2.10.0", "latest", targetNet40 ? null : ".NETCoreApp,Version=v2.2"),
CompilerOptions.UseRoslyn3_11_0 => ("3.11.0", "latest", targetNet40 ? null : ".NETCoreApp,Version=v5.0"),
_ => (roslynLatestVersion, flags.HasFlag(CompilerOptions.Preview) ? "preview" : "latest", targetNet40 ? null : CurrentNetCoreAppVersion)
_ => (roslynLatestVersion, flags.HasFlag(CompilerOptions.Preview) ? "preview" : "latest", targetNet40 ? null : CurrentNetCoreVersion.AppVersion)
};
var vbcPath = roslynToolset.GetVBCompiler(roslynVersion);

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

@ -85,20 +85,16 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -85,20 +85,16 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
UseDebug = 0x1,
Force32Bit = 0x2,
Library = 0x4,
/// Testing our own disassembler, or working around a bug in ildasm.
// Testing our own disassembler, or working around a bug in ildasm.
UseOwnDisassembler = 0x8,
/// Work around bug in .NET 5 ilasm (https://github.com/dotnet/runtime/issues/32400)
// Work around bug in .NET 5 ilasm (https://github.com/dotnet/runtime/issues/32400)
UseLegacyAssembler = 0x10,
/// UseSortByNameFilter, implies UseOwnDisassembler
// UseSortByNameFilter, implies UseOwnDisassembler
SortedOutput = 0x20,
}
public static partial class Tester
{
public const string CurrentNetCoreVersion = "11.0";
public const string CurrentNetCoreAppVersion = ".NETCoreApp,Version=v11.0";
public const string CurrentNetCoreRefAsmVersion = "11.0.0-preview.5.26302.115";
public static readonly string TesterPath;
public static readonly string TestCasePath;
@ -123,9 +119,9 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -123,9 +119,9 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
TesterPath = Path.GetDirectoryName(typeof(Tester).Assembly.Location);
TestCasePath = Path.Combine(TesterPath, "../../../../TestCases");
#if DEBUG
testRunnerBasePath = Path.Combine(TesterPath, $"../../../../../ICSharpCode.Decompiler.TestRunner/bin/Debug/net{CurrentNetCoreVersion}");
testRunnerBasePath = Path.Combine(TesterPath, $"../../../../../ICSharpCode.Decompiler.TestRunner/bin/Debug/net{CurrentNetCoreVersion.Version}");
#else
testRunnerBasePath = Path.Combine(TesterPath, $"../../../../../ICSharpCode.Decompiler.TestRunner/bin/Release/net{CurrentNetCoreVersion}");
testRunnerBasePath = Path.Combine(TesterPath, $"../../../../../ICSharpCode.Decompiler.TestRunner/bin/Release/net{CurrentNetCoreVersion.Version}");
#endif
// To parse: <Project><ItemGroup><PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0-3.final" />
packagesPropsFile = Path.Combine(TesterPath, "../../../../../Directory.Packages.props");
@ -165,7 +161,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -165,7 +161,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
await vswhereToolset.Fetch().ConfigureAwait(false);
await RefAssembliesToolset.Fetch("5.0.0", sourcePath: "ref/net5.0").ConfigureAwait(false);
await RefAssembliesToolset.Fetch("9.0.0", sourcePath: "ref/net9.0").ConfigureAwait(false);
await RefAssembliesToolset.Fetch(CurrentNetCoreRefAsmVersion, sourcePath: $"ref/net{CurrentNetCoreVersion}").ConfigureAwait(false);
await RefAssembliesToolset.Fetch(CurrentNetCoreVersion.RefAsmVersion, sourcePath: $"ref/net{CurrentNetCoreVersion.Version}").ConfigureAwait(false);
#if DEBUG
const string testRunnerConfig = "Debug";
@ -472,7 +468,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -472,7 +468,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
public static IReadOnlyList<string> CoreDefaultReferences => coreDefaultReferences;
static readonly Dictionary<string, Lazy<string>> targetFrameworkAttributeSnippetFiles = new() {
{ CurrentNetCoreAppVersion, new Lazy<string>(() => GetTargetFrameworkAttributeSnippetFile(CurrentNetCoreAppVersion)) },
{ CurrentNetCoreVersion.AppVersion, new Lazy<string>(() => GetTargetFrameworkAttributeSnippetFile(CurrentNetCoreVersion.AppVersion)) },
{ ".NETCoreApp,Version=v9.0", new Lazy<string>(() => GetTargetFrameworkAttributeSnippetFile(".NETCoreApp,Version=v9.0")) },
{ ".NETCoreApp,Version=v5.0", new Lazy<string>(() => GetTargetFrameworkAttributeSnippetFile(".NETCoreApp,Version=v5.0")) },
{ ".NETCoreApp,Version=v2.2", new Lazy<string>(() => GetTargetFrameworkAttributeSnippetFile(".NETCoreApp,Version=v2.2")) },
@ -670,7 +666,7 @@ namespace System.Runtime.CompilerServices @@ -670,7 +666,7 @@ namespace System.Runtime.CompilerServices
CompilerOptions.UseRoslyn2_10_0 => ("2.10.0", "latest", targetNet40 ? null : ".NETCoreApp,Version=v2.2"),
CompilerOptions.UseRoslyn3_11_0 => ("3.11.0", "latest", targetNet40 ? null : ".NETCoreApp,Version=v5.0"),
CompilerOptions.UseRoslyn4_14_0 => ("4.14.0", "latest", targetNet40 ? null : ".NETCoreApp,Version=v9.0"),
_ => (roslynLatestVersion, flags.HasFlag(CompilerOptions.Preview) ? "preview" : "latest", targetNet40 ? null : CurrentNetCoreAppVersion)
_ => (roslynLatestVersion, flags.HasFlag(CompilerOptions.Preview) ? "preview" : "latest", targetNet40 ? null : CurrentNetCoreVersion.AppVersion)
};
var cscPath = roslynToolset.GetCSharpCompiler(roslynVersion);
@ -953,7 +949,7 @@ namespace System.Runtime.CompilerServices @@ -953,7 +949,7 @@ namespace System.Runtime.CompilerServices
}
var compilation = CSharpCompilation.Create(Path.GetFileNameWithoutExtension(assemblyName),
syntaxTrees, coreDefaultReferences.Select(r => MetadataReference.CreateFromFile(Path.Combine(RefAssembliesToolset.GetPath(CurrentNetCoreAppVersion), r))),
syntaxTrees, coreDefaultReferences.Select(r => MetadataReference.CreateFromFile(Path.Combine(RefAssembliesToolset.GetPath(CurrentNetCoreVersion.AppVersion), r))),
new CSharpCompilationOptions(
OutputKind.DynamicallyLinkedLibrary,
platform: Platform.AnyCpu,

Loading…
Cancel
Save