[gh-139] Potential fix for value tuples.
This commit is contained in:
Родитель
fbe9dbb378
Коммит
a4f7b985a8
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace SharpLab.Server.Compilation.Internal {
|
||||
public static class NetFrameworkRuntime {
|
||||
private static readonly Assembly Mscorlib = typeof(object).Assembly;
|
||||
|
||||
public static Assembly AssemblyOfValueTuple { get; }
|
||||
= Mscorlib.GetType(typeof(ValueTuple).FullName) != null ? Mscorlib : typeof(ValueTuple).Assembly;
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ namespace SharpLab.Server.Compilation.Setups {
|
|||
_references = referenceCollector.SlowGetMetadataReferencesRecursive(
|
||||
// Essential
|
||||
typeof(Binder).Assembly,
|
||||
typeof(ValueTuple<>).Assembly,
|
||||
NetFrameworkRuntime.AssemblyOfValueTuple,
|
||||
|
||||
// Runtime
|
||||
typeof(JitGenericAttribute).Assembly,
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace SharpLab.Server.Compilation.Setups {
|
|||
o.ParseOptions = new VisualBasicParseOptions(maxLanguageVersion).WithFeatures(features);
|
||||
o.MetadataReferences = _referenceCollector.SlowGetMetadataReferencesRecursive(
|
||||
typeof(StandardModuleAttribute).Assembly,
|
||||
typeof(ValueTuple<>).Assembly,
|
||||
NetFrameworkRuntime.AssemblyOfValueTuple,
|
||||
typeof(JitGenericAttribute).Assembly
|
||||
).ToImmutableList();
|
||||
});
|
||||
|
|
|
@ -23,6 +23,18 @@ namespace SharpLab.Tests {
|
|||
_output = output;
|
||||
}
|
||||
|
||||
[Theory]
|
||||
// Tuples, https://github.com/ashmind/SharpLab/issues/139
|
||||
[InlineData("class C { void M((int, string) t) {} }")]
|
||||
public async Task SlowUpdate_DecompilesSimpleCodeWithoutErrors(string code) {
|
||||
var driver = MirrorSharpTestDriver.New().SetText(code);
|
||||
|
||||
var result = await driver.SendSlowUpdateAsync<string>();
|
||||
var errors = result.JoinErrors();
|
||||
|
||||
Assert.True(errors.IsNullOrEmpty(), errors);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Constructor.BaseCall.cs2cs")]
|
||||
[InlineData("NullPropagation.ToTernary.cs2cs")]
|
||||
|
|
Загрузка…
Ссылка в новой задаче