[closes gh-20] Unrolled operator overloading.

This commit is contained in:
Andrey Shchekin 2017-06-25 16:31:24 +12:00
Родитель c0f1f800c6
Коммит 7f3f4236c5
5 изменённых файлов: 47 добавлений и 1 удалений

@ -1 +1 @@
Subproject commit 1e338e0fdc676a005522ae6a10adb627a6b94b11
Subproject commit e4edcffab101aa0660e8fd83a5c7278c03924d6e

Просмотреть файл

@ -25,6 +25,7 @@ namespace SharpLab.Server.Decompilation {
var context = new DecompilerContext(module) {
Settings = {
OperatorOverloading = false,
AnonymousMethods = false,
YieldReturn = false,
AsyncAwait = false,

Просмотреть файл

@ -31,6 +31,8 @@ namespace SharpLab.Tests {
[InlineData("Module.vb2vb")]
// https://github.com/ashmind/SharpLab/issues/9
[InlineData("Lambda.CallInArray.cs2cs")]
// https://github.com/ashmind/SharpLab/issues/20
[InlineData("Casts.ExplicitOperatorOnNull.cs2cs")]
public async Task SlowUpdate_ReturnsExpectedDecompiledCode(string resourceName) {
var data = TestData.FromResource(resourceName);
var driver = await NewTestDriverAsync(data);

Просмотреть файл

@ -0,0 +1,39 @@
public class Foo {
public static explicit operator uint? (Foo foo) => 1;
}
public class Bar {
public void Baz() {
var x = (uint?)((Foo)null);
}
}
#=>
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[module: UnverifiableCode]
public class Foo
{
public static uint? op_Explicit(Foo foo)
{
return new uint?(1u);
}
}
public class Bar
{
public void Baz()
{
/*uint?*/Foo.op_Explicit(null);
}
}

Просмотреть файл

@ -26,6 +26,10 @@
<None Remove="TestCode\Simple.vb2vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestCode\Casts.ExplicitOperatorOnNull.cs2cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestCode\Ast\EmptyType.fs2ast" />
<EmbeddedResource Include="TestCode\Ast\LiteralTokens.fs2ast" />