Skip to content

Commit

Permalink
Use arrays instead of string addition.
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred committed Jan 27, 2021
1 parent c8eaf69 commit 5544fcf
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6133,6 +6133,7 @@ protected override void M3(delegate* unmanaged[Stdcall, Fastcall]<void> ptr) {}
public void Override_ConventionOrderingDoesNotMatter()
{
var source1 = @"
using System;
public unsafe class Base
{
public virtual void M1(delegate* unmanaged[Thiscall, Stdcall]<void> param) => Console.WriteLine(""Base Thiscall, Stdcall param"");
Expand All @@ -6143,6 +6144,7 @@ public unsafe class Base
";

var source2 = @"
using System;
unsafe class Derived1 : Base
{
public override void M1(delegate* unmanaged[Stdcall, Thiscall]<void> param) => Console.WriteLine(""Derived1 Stdcall, Thiscall param"");
Expand All @@ -6157,13 +6159,10 @@ unsafe class Derived2 : Base
public override void M3(delegate* unmanaged[Stdcall, Stdcall, Thiscall]<ref string> param) => Console.WriteLine(""Derived2 Stdcall, Stdcall, Thiscall ref param"");
public override delegate* unmanaged[Stdcall, Stdcall, Thiscall]<ref string> M4() { Console.WriteLine(""Derived2 Stdcall, Stdcall, Thiscall ref return""); return null; }
}
";

var @using = @"
using System;
";

var executableCode = @"
using System;
unsafe
{
delegate* unmanaged[Stdcall, Thiscall]<void> ptr1 = null;
Expand Down Expand Up @@ -6204,14 +6203,14 @@ unsafe class Derived2 : Base
Derived2 Stdcall, Stdcall, Thiscall ref return
";

var allSourceComp = CreateCompilationWithFunctionPointers(@using + executableCode + source1 + source2, options: TestOptions.UnsafeReleaseExe);
var allSourceComp = CreateCompilationWithFunctionPointers(new[] { executableCode, source1, source2 }, options: TestOptions.UnsafeReleaseExe);

CompileAndVerify(allSourceComp, expectedOutput: expectedOutput, symbolValidator: getSymbolValidator(separateAssembly: false));

var baseComp = CreateCompilationWithFunctionPointers(@using + source1);
var baseComp = CreateCompilationWithFunctionPointers(source1);
var metadataRef = baseComp.EmitToImageReference();

var derivedComp = CreateCompilationWithFunctionPointers(@using + executableCode + source2, references: new[] { metadataRef }, options: TestOptions.UnsafeReleaseExe);
var derivedComp = CreateCompilationWithFunctionPointers(new[] { executableCode, source2 }, references: new[] { metadataRef }, options: TestOptions.UnsafeReleaseExe);
CompileAndVerify(derivedComp, expectedOutput: expectedOutput, symbolValidator: getSymbolValidator(separateAssembly: true));

static Action<ModuleSymbol> getSymbolValidator(bool separateAssembly)
Expand Down

0 comments on commit 5544fcf

Please sign in to comment.