Browse Source

Update RoslynToolset to 4.3.0-2.final

pull/2749/head
Siegfried Pammer 3 years ago
parent
commit
22e9791f86
  1. 26
      ICSharpCode.Decompiler.Tests/Helpers/RoslynToolset.cs
  2. 6
      ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
  3. 2
      packages.props

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

@ -48,7 +48,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
this.baseDir = baseDir; this.baseDir = baseDir;
} }
protected async Task FetchPackage(string packageName, string version, string outputPath) protected async Task FetchPackage(string packageName, string version, string sourcePath, string outputPath)
{ {
ILogger logger = NullLogger.Instance; ILogger logger = NullLogger.Instance;
CancellationToken cancellationToken = CancellationToken.None; CancellationToken cancellationToken = CancellationToken.None;
@ -65,8 +65,8 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
using PackageArchiveReader packageReader = new PackageArchiveReader(packageStream); using PackageArchiveReader packageReader = new PackageArchiveReader(packageStream);
NuspecReader nuspecReader = await packageReader.GetNuspecReaderAsync(cancellationToken).ConfigureAwait(false); NuspecReader nuspecReader = await packageReader.GetNuspecReaderAsync(cancellationToken).ConfigureAwait(false);
var files = await packageReader.GetFilesAsync(cancellationToken).ConfigureAwait(false); var files = (await packageReader.GetFilesAsync(cancellationToken).ConfigureAwait(false)).ToArray();
files = files.Where(f => f.StartsWith("tools", StringComparison.OrdinalIgnoreCase)); files = files.Where(f => f.StartsWith(sourcePath, StringComparison.OrdinalIgnoreCase)).ToArray();
await packageReader.CopyFilesAsync(outputPath, files, await packageReader.CopyFilesAsync(outputPath, files,
(sourceFile, targetPath, fileStream) => { (sourceFile, targetPath, fileStream) => {
fileStream.CopyToFile(targetPath); fileStream.CopyToFile(targetPath);
@ -87,15 +87,15 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
{ {
} }
public async Task Fetch(string version) public async Task Fetch(string version, string packageName = "Microsoft.Net.Compilers.Toolset", string sourcePath = "tasks/net472")
{ {
string path = Path.Combine(baseDir, version, "tools"); string path = Path.Combine(baseDir, version, sourcePath);
if (!Directory.Exists(path)) if (!Directory.Exists(path))
{ {
await FetchPackage("Microsoft.Net.Compilers", version, Path.Combine(baseDir, version)).ConfigureAwait(false); await FetchPackage(packageName, version, sourcePath, Path.Combine(baseDir, version)).ConfigureAwait(false);
} }
installedCompilers.Add(version, path); installedCompilers.Add(SanitizeVersion(version), path);
} }
public string GetCSharpCompiler(string version) public string GetCSharpCompiler(string version)
@ -110,10 +110,18 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
string GetCompiler(string compiler, string version) string GetCompiler(string compiler, string version)
{ {
if (installedCompilers.TryGetValue(version, out var path)) if (installedCompilers.TryGetValue(SanitizeVersion(version), out var path))
return Path.Combine(path, compiler); return Path.Combine(path, compiler);
throw new NotSupportedException($"Cannot find {compiler} {version}, please add it to the initialization."); throw new NotSupportedException($"Cannot find {compiler} {version}, please add it to the initialization.");
} }
internal static string SanitizeVersion(string version)
{
int index = version.IndexOf("-");
if (index > 0)
return version.Remove(index);
return version;
}
} }
class VsWhereToolset : AbstractToolset class VsWhereToolset : AbstractToolset
@ -130,7 +138,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
string path = Path.Combine(baseDir, "tools"); string path = Path.Combine(baseDir, "tools");
if (!Directory.Exists(path)) if (!Directory.Exists(path))
{ {
await FetchPackage("vswhere", "2.8.4", baseDir).ConfigureAwait(false); await FetchPackage("vswhere", "2.8.4", "tools", baseDir).ConfigureAwait(false);
} }
vswherePath = Path.Combine(path, "vswhere.exe"); vswherePath = Path.Combine(path, "vswhere.exe");
} }

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

@ -113,8 +113,8 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
internal static async Task Initialize() internal static async Task Initialize()
{ {
await roslynToolset.Fetch("1.3.2").ConfigureAwait(false); await roslynToolset.Fetch("1.3.2", "Microsoft.Net.Compilers", "tools").ConfigureAwait(false);
await roslynToolset.Fetch("2.10.0").ConfigureAwait(false); await roslynToolset.Fetch("2.10.0", "Microsoft.Net.Compilers", "tools").ConfigureAwait(false);
await roslynToolset.Fetch("3.11.0").ConfigureAwait(false); await roslynToolset.Fetch("3.11.0").ConfigureAwait(false);
await roslynToolset.Fetch(roslynLatestVersion).ConfigureAwait(false); await roslynToolset.Fetch(roslynLatestVersion).ConfigureAwait(false);
@ -432,7 +432,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
if (roslynVersion != "legacy") if (roslynVersion != "legacy")
{ {
otherOptions += "/shared "; otherOptions += "/shared ";
if (!targetNet40 && Version.Parse(roslynVersion).Major > 2) if (!targetNet40 && Version.Parse(RoslynToolset.SanitizeVersion(roslynVersion)).Major > 2)
{ {
if (flags.HasFlag(CompilerOptions.NullableEnable)) if (flags.HasFlag(CompilerOptions.NullableEnable))
otherOptions += "/nullable+ "; otherOptions += "/nullable+ ";

2
packages.props

@ -14,7 +14,7 @@
<!-- Microsoft.NETCore.ILDAsm --> <!-- Microsoft.NETCore.ILDAsm -->
<ILDAsmVersion>6.0.0</ILDAsmVersion> <ILDAsmVersion>6.0.0</ILDAsmVersion>
<!-- Microsoft.CodeAnalysis.* --> <!-- Microsoft.CodeAnalysis.* -->
<RoslynVersion>4.1.0</RoslynVersion> <RoslynVersion>4.3.0-2.final</RoslynVersion>
<MonoCecilVersion>0.11.4</MonoCecilVersion> <MonoCecilVersion>0.11.4</MonoCecilVersion>
<AvalonEditVersion>6.1.3.50</AvalonEditVersion> <AvalonEditVersion>6.1.3.50</AvalonEditVersion>
<WpfStylesToolboxVersion>2.7.4</WpfStylesToolboxVersion> <WpfStylesToolboxVersion>2.7.4</WpfStylesToolboxVersion>

Loading…
Cancel
Save