Skip to content

Commit

Permalink
Finally spot the actual issue.
Browse files Browse the repository at this point in the history
Waiting for some fix about this:
dotnet/runtime#25958
  • Loading branch information
olivier-spinelli committed Jun 12, 2020
1 parent 49f3e55 commit 7093b93
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions CK.Reflection/EmitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ public static MethodBuilder ImplementEmptyStubMethod( TypeBuilder tB, MethodInfo
// Enabling this on the 'in' parameter raises an explicit:
// System.TypeLoadException : Signature of the body and declaration in a method implementation do not match. Type: 'L2'. Assembly: 'TypeImplementorModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
// ...that clearly states that something's wrong in the signatures.
//
// tB.DefineMethodOverride( mB, method );
//
// This enforces the mapping: this avoids the bug of a virtual that would NOT be overridden. So we let it.
//
tB.DefineMethodOverride( mB, method );
return mB;
}

Expand Down
7 changes: 5 additions & 2 deletions Tests/CK.Reflection.Tests/AutoImplementorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ public abstract class L
// To test: this virtual returns -1, so the fact that the generated method doesn't
// override this base one doesn't block the type building.
//
// For this test to "work", the tB.DefineMethodOverride( mB, method ); call at the end of ImplementEmptyStubMethod
// must be removed.
//
public virtual int M( in ROStruct s ) => -1;

// The abstract is not implemented.
Expand All @@ -301,7 +304,8 @@ public void AutoImplementInROStruct()
var manual = (LManual)Activator.CreateInstance( typeof(LManual) );
manual.M( new ROStruct() ).Should().Be( 3712 );

Type builtType = b.CreateTypeInfo().AsType();
Assume.That( false, "'in' parameters support is not yet implemented: See https://github.com/dotnet/runtime/issues/25958." );
Type builtType = b.CreateType();
L o = (L)Activator.CreateInstance( builtType );
o.M( new ROStruct() ).Should().Be( -1, "Unfortunately... The implemented method DID NOT override the base one. This SHOULD be 0 (the default return of the stub)" );

Expand All @@ -311,7 +315,6 @@ public void AutoImplementInROStruct()
// Both parameters seems perfectly aligned. Same for the 2 methods.
// I'm clearly missing something here... Giving up for the moment.
//
Assume.That( false, "'in' parameters support is not yet implemented." );
}


Expand Down
2 changes: 1 addition & 1 deletion Tests/CK.Reflection.Tests/HelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace CK.Reflection.Tests
[TestFixture]
public class HelperTest
{
public int AnIntProperty { get { return 3; } }
public int AnIntProperty => 3;

[Test]
public void PropertyInfoThroughLambda()
Expand Down

0 comments on commit 7093b93

Please sign in to comment.