Skip to content

Remove class baseType interfaces from proxified methods #1630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions src/NHibernate.Test/Async/NHSpecificTest/GH1628/Fixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by AsyncGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------


using NUnit.Framework;

namespace NHibernate.Test.NHSpecificTest.GH1628
{
using System.Threading.Tasks;
[TestFixture]
public class FixtureAsync : BugTestCase
{
protected override void OnSetUp()
{
using (var session = OpenSession())
using (var transaction = session.BeginTransaction())
{
var e1 = new Entity
{
Id = 1,
Name = "Bob",
ALongText = "Bob's very long text"
};
session.Save(e1);

var e2 = new Entity
{
Id = 2,
Name = "Sally",
ALongText = "Sally's very long text"
};
session.Save(e2);

transaction.Commit();
}
}

protected override void OnTearDown()
{
using (var session = OpenSession())
using (var transaction = session.BeginTransaction())
{
// The HQL delete does all the job inside the database without loading the entities, but it does
// not handle delete order for avoiding violating constraints if any. Use
// session.Delete("from System.Object");
// instead if in need of having NHbernate ordering the deletes, but this will cause
// loading the entities in the session.
session.CreateQuery("delete from System.Object").ExecuteUpdate();

transaction.Commit();
}
}

[Test]
public async Task ShouldNotThrowStackOverflowExceptionAsync()
{
using (var session = OpenSession())
using (session.BeginTransaction())
{
IEntity result = await (session.GetAsync<Entity>(2));
Assert.That(result, Is.Not.Null);
Assert.That(result.Thing, Is.Null);
}
}
}
}
16 changes: 16 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH1628/Entity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace NHibernate.Test.NHSpecificTest.GH1628
{
public interface IEntity
{
object Thing { get; }
}

public class Entity : IEntity
{
public virtual int Id { get; set; }

object IEntity.Thing { get { return null; } }
public virtual string Name { get; set; }
public virtual string ALongText { get; set; }
}
}
61 changes: 61 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH1628/Fixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using NUnit.Framework;

namespace NHibernate.Test.NHSpecificTest.GH1628
{
[TestFixture]
public class Fixture : BugTestCase
{
protected override void OnSetUp()
{
using (var session = OpenSession())
using (var transaction = session.BeginTransaction())
{
var e1 = new Entity
{
Id = 1,
Name = "Bob",
ALongText = "Bob's very long text"
};
session.Save(e1);

var e2 = new Entity
{
Id = 2,
Name = "Sally",
ALongText = "Sally's very long text"
};
session.Save(e2);

transaction.Commit();
}
}

protected override void OnTearDown()
{
using (var session = OpenSession())
using (var transaction = session.BeginTransaction())
{
// The HQL delete does all the job inside the database without loading the entities, but it does
// not handle delete order for avoiding violating constraints if any. Use
// session.Delete("from System.Object");
// instead if in need of having NHbernate ordering the deletes, but this will cause
// loading the entities in the session.
session.CreateQuery("delete from System.Object").ExecuteUpdate();

transaction.Commit();
}
}

[Test]
public void ShouldNotThrowStackOverflowException()
{
using (var session = OpenSession())
using (session.BeginTransaction())
{
IEntity result = session.Get<Entity>(2);
Assert.That(result, Is.Not.Null);
Assert.That(result.Thing, Is.Null);
}
}
}
}
11 changes: 11 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH1628/Mappings.hbm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
namespace="NHibernate.Test.NHSpecificTest.GH1628">

<class name="Entity">
<id name="Id" generator="assigned"/>
<property name="Name"/>
<property name="ALongText" lazy="true"/>
</class>

</hibernate-mapping>
2 changes: 1 addition & 1 deletion src/NHibernate/Proxy/DynamicProxy/ProxyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ private TypeInfo CreateUncachedProxyType(System.Type baseType, IReadOnlyCollecti
{
parentType = typeof (ProxyDummy);
interfaces.Add(baseType);
interfaces.UnionWith(baseType.GetInterfaces());
}
interfaces.UnionWith(baseType.GetInterfaces());

// Add the ISerializable interface so that it can be implemented
interfaces.Add(typeof (ISerializable));
Expand Down