Skip to content

Commit 6ab2e2b

Browse files
Extract constants
1 parent c4dec13 commit 6ab2e2b

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static async Task<CompilerResults> CompileVB(string sourceFileName, Compi
5353
CompilerOptions.UseRoslyn1_3_2 => ("1.3.2", "14", null),
5454
CompilerOptions.UseRoslyn2_10_0 => ("2.10.0", "latest", targetNet40 ? null : ".NETCoreApp,Version=v2.2"),
5555
CompilerOptions.UseRoslyn3_11_0 => ("3.11.0", "latest", targetNet40 ? null : ".NETCoreApp,Version=v5.0"),
56-
_ => (roslynLatestVersion, flags.HasFlag(CompilerOptions.Preview) ? "preview" : "latest", targetNet40 ? null : ".NETCoreApp,Version=v10.0")
56+
_ => (roslynLatestVersion, flags.HasFlag(CompilerOptions.Preview) ? "preview" : "latest", targetNet40 ? null : CurrentNetCoreAppVersion)
5757
};
5858

5959
var vbcPath = roslynToolset.GetVBCompiler(roslynVersion);

ICSharpCode.Decompiler.Tests/Helpers/Tester.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public enum AssemblerOptions
9393

9494
public static partial class Tester
9595
{
96+
public const string CurrentNetCoreVersion = "11.0";
97+
public const string CurrentNetCoreAppVersion = ".NETCoreApp,Version=v11.0";
98+
public const string CurrentNetCoreRefAsmVersion = "11.0.0-preview.2.26159.112";
99+
96100
public static readonly string TesterPath;
97101
public static readonly string TestCasePath;
98102

@@ -108,9 +112,9 @@ static Tester()
108112
TesterPath = Path.GetDirectoryName(typeof(Tester).Assembly.Location);
109113
TestCasePath = Path.Combine(TesterPath, "../../../../TestCases");
110114
#if DEBUG
111-
testRunnerBasePath = Path.Combine(TesterPath, "../../../../../ICSharpCode.Decompiler.TestRunner/bin/Debug/net11.0");
115+
testRunnerBasePath = Path.Combine(TesterPath, $"../../../../../ICSharpCode.Decompiler.TestRunner/bin/Debug/net{CurrentNetCoreVersion}");
112116
#else
113-
testRunnerBasePath = Path.Combine(TesterPath, "../../../../../ICSharpCode.Decompiler.TestRunner/bin/Release/net11.0");
117+
testRunnerBasePath = Path.Combine(TesterPath, $"../../../../../ICSharpCode.Decompiler.TestRunner/bin/Release/net{CurrentNetCoreVersion});
114118
#endif
115119
// To parse: <Project><ItemGroup><PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0-3.final" />
116120
packagesPropsFile = Path.Combine(TesterPath, "../../../../../Directory.Packages.props");
@@ -136,7 +140,7 @@ internal static async Task Initialize()
136140
await vswhereToolset.Fetch().ConfigureAwait(false);
137141
await RefAssembliesToolset.Fetch("5.0.0", sourcePath: "ref/net5.0").ConfigureAwait(false);
138142
await RefAssembliesToolset.Fetch("10.0.0", sourcePath: "ref/net10.0").ConfigureAwait(false);
139-
await RefAssembliesToolset.Fetch("11.0.0-preview.2.26159.112", sourcePath: "ref/net11.0").ConfigureAwait(false);
143+
await RefAssembliesToolset.Fetch(CurrentNetCoreRefAsmVersion, sourcePath: $"ref/net{CurrentNetCoreVersion}").ConfigureAwait(false);
140144

141145
#if DEBUG
142146
await BuildTestRunner("win-x86", "Debug").ConfigureAwait(false);
@@ -342,7 +346,7 @@ private static string ReplacePrivImplDetails(string il)
342346
};
343347

344348
static readonly Dictionary<string, Lazy<string>> targetFrameworkAttributeSnippetFiles = new() {
345-
{ ".NETCoreApp,Version=v11.0", new Lazy<string>(() => GetTargetFrameworkAttributeSnippetFile(".NETCoreApp,Version=v11.0")) },
349+
{ CurrentNetCoreAppVersion, new Lazy<string>(() => GetTargetFrameworkAttributeSnippetFile(CurrentNetCoreAppVersion)) },
346350
{ ".NETCoreApp,Version=v5.0", new Lazy<string>(() => GetTargetFrameworkAttributeSnippetFile(".NETCoreApp,Version=v5.0")) },
347351
{ ".NETCoreApp,Version=v2.2", new Lazy<string>(() => GetTargetFrameworkAttributeSnippetFile(".NETCoreApp,Version=v2.2")) },
348352
};
@@ -524,7 +528,7 @@ public static async Task<CompilerResults> CompileCSharp(string sourceFileName, C
524528
CompilerOptions.UseRoslyn1_3_2 => ("1.3.2", "6", null),
525529
CompilerOptions.UseRoslyn2_10_0 => ("2.10.0", "latest", targetNet40 ? null : ".NETCoreApp,Version=v2.2"),
526530
CompilerOptions.UseRoslyn3_11_0 => ("3.11.0", "latest", targetNet40 ? null : ".NETCoreApp,Version=v5.0"),
527-
_ => (roslynLatestVersion, flags.HasFlag(CompilerOptions.Preview) ? "preview" : "latest", targetNet40 ? null : ".NETCoreApp,Version=v11.0")
531+
_ => (roslynLatestVersion, flags.HasFlag(CompilerOptions.Preview) ? "preview" : "latest", targetNet40 ? null : CurrentNetCoreAppVersion)
528532
};
529533

530534
var cscPath = roslynToolset.GetCSharpCompiler(roslynVersion);
@@ -774,7 +778,7 @@ public static void CompileCSharpWithPdb(string assemblyName, Dictionary<string,
774778
}
775779

776780
var compilation = CSharpCompilation.Create(Path.GetFileNameWithoutExtension(assemblyName),
777-
syntaxTrees, coreDefaultReferences.Select(r => MetadataReference.CreateFromFile(Path.Combine(RefAssembliesToolset.GetPath(".NETCoreApp,Version=v11.0"), r))),
781+
syntaxTrees, coreDefaultReferences.Select(r => MetadataReference.CreateFromFile(Path.Combine(RefAssembliesToolset.GetPath(CurrentNetCoreAppVersion), r))),
778782
new CSharpCompilationOptions(
779783
OutputKind.DynamicallyLinkedLibrary,
780784
platform: Platform.AnyCpu,

0 commit comments

Comments
 (0)