Skip to content

Lazy properties static proxy #1709

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
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
2 changes: 2 additions & 0 deletions src/AsyncGenerator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@
name: LinqReadonlyTestsContext
- conversion: Ignore
name: MultiThreadRunner
- conversion: Ignore
name: PeVerifier
Copy link
Member Author

@fredericDelaporte fredericDelaporte May 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was generating async tests for asynchronously calling the PEVerify. There is no point in testing that. Included in this commit because I have added tests using PeVerifier.

- conversion: Ignore
hasAttributeName: IgnoreAttribute
- conversion: NewType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//------------------------------------------------------------------------------


using System;
using System.Collections;
using NHibernate.Cfg;
using NUnit.Framework;
Expand All @@ -16,6 +17,7 @@ namespace NHibernate.Test.DynamicEntity.Interceptor
{
using System.Threading.Tasks;
[TestFixture]
[Obsolete("Require dynamic proxies")]
public class InterceptorDynamicEntityAsync : TestCase
{
protected override string MappingsAssembly
Expand Down Expand Up @@ -100,4 +102,4 @@ public async Task ItAsync()
session.Close();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//------------------------------------------------------------------------------


using System;
using System.Collections;
using System.Collections.Generic;
using NHibernate.Cfg;
Expand All @@ -17,6 +18,7 @@ namespace NHibernate.Test.DynamicEntity.Tuplizer
{
using System.Threading.Tasks;
[TestFixture]
[Obsolete("Require dynamic proxies")]
public class TuplizerDynamicEntityAsync : TestCase
{
protected override string MappingsAssembly
Expand Down Expand Up @@ -116,4 +118,4 @@ public async Task ItAsync()
session.Close();
}
}
}
}
46 changes: 0 additions & 46 deletions src/NHibernate.Test/Async/DynamicProxyTests/PeVerifier.cs

This file was deleted.

133 changes: 0 additions & 133 deletions src/NHibernate.Test/Async/DynamicProxyTests/PeVerifyFixture.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using NHibernate.Driver;
using NHibernate.Exceptions;
using NHibernate.Hql.Ast.ANTLR;
using NHibernate.Linq;
using NHibernate.Type;
using NUnit.Framework;

Expand Down Expand Up @@ -37,7 +36,7 @@ public void CompleteConfiguration()
.Through<DefaultCollectionTypeFactory>()
.Proxy
.DisableValidation()
.Through<DefaultProxyFactoryFactory>()
.Through<StaticProxyFactoryFactory>()
.ParsingHqlThrough<ASTQueryTranslatorFactory>()
.Mapping
.UsingDefaultCatalog("MyCatalog")
Expand Down Expand Up @@ -75,7 +74,7 @@ public void CompleteConfiguration()
Assert.That(cfg.Properties[Environment.CacheDefaultExpiration], Is.EqualTo("15"));
Assert.That(cfg.Properties[Environment.CollectionTypeFactoryClass], Is.EqualTo(typeof(DefaultCollectionTypeFactory).AssemblyQualifiedName));
Assert.That(cfg.Properties[Environment.UseProxyValidator], Is.EqualTo("false"));
Assert.That(cfg.Properties[Environment.ProxyFactoryFactoryClass], Is.EqualTo(typeof(DefaultProxyFactoryFactory).AssemblyQualifiedName));
Assert.That(cfg.Properties[Environment.ProxyFactoryFactoryClass], Is.EqualTo(typeof(StaticProxyFactoryFactory).AssemblyQualifiedName));
Assert.That(cfg.Properties[Environment.QueryTranslator], Is.EqualTo(typeof(ASTQueryTranslatorFactory).AssemblyQualifiedName));
Assert.That(cfg.Properties[Environment.DefaultCatalog], Is.EqualTo("MyCatalog"));
Assert.That(cfg.Properties[Environment.DefaultSchema], Is.EqualTo("MySche"));
Expand Down Expand Up @@ -108,13 +107,13 @@ public void UseDbConfigurationStringBuilder()
// The place where put default properties values is the Dialect itself.
var cfg = new Configuration();
cfg.SessionFactory()
.Proxy.Through<DefaultProxyFactoryFactory>()
.Proxy.Through<StaticProxyFactoryFactory>()
.Integrate
.Using<MsSql2005Dialect>()
.Connected
.Using(new SqlConnectionStringBuilder { DataSource = "(local)", InitialCatalog = "nhibernate", IntegratedSecurity = true });

Assert.That(cfg.Properties[Environment.ProxyFactoryFactoryClass], Is.EqualTo(typeof(DefaultProxyFactoryFactory).AssemblyQualifiedName));
Assert.That(cfg.Properties[Environment.ProxyFactoryFactoryClass], Is.EqualTo(typeof(StaticProxyFactoryFactory).AssemblyQualifiedName));
Assert.That(cfg.Properties[Environment.Dialect], Is.EqualTo(typeof(MsSql2005Dialect).AssemblyQualifiedName));
Assert.That(cfg.Properties[Environment.ConnectionString], Is.EqualTo("Data Source=(local);Initial Catalog=nhibernate;Integrated Security=True"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void FullConfiguration()
configure.Proxy(p =>
{
p.Validation = false;
p.ProxyFactoryFactory<DefaultProxyFactoryFactory>();
p.ProxyFactoryFactory<StaticProxyFactoryFactory>();
});
configure.Mappings(m=>
{
Expand Down Expand Up @@ -76,7 +76,7 @@ public void FullConfiguration()
Is.EqualTo(typeof(DefaultCollectionTypeFactory).AssemblyQualifiedName));
Assert.That(configure.Properties[Environment.UseProxyValidator], Is.EqualTo("false"));
Assert.That(configure.Properties[Environment.ProxyFactoryFactoryClass],
Is.EqualTo(typeof(DefaultProxyFactoryFactory).AssemblyQualifiedName));
Is.EqualTo(typeof(StaticProxyFactoryFactory).AssemblyQualifiedName));
Assert.That(configure.Properties[Environment.QueryTranslator],
Is.EqualTo(typeof(ASTQueryTranslatorFactory).AssemblyQualifiedName));
Assert.That(configure.Properties[Environment.DefaultCatalog], Is.EqualTo("MyCatalog"));
Expand Down
4 changes: 3 additions & 1 deletion src/NHibernate.Test/DynamicEntity/DataProxyHandler.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Collections;
using NHibernate.Proxy.DynamicProxy;

namespace NHibernate.Test.DynamicEntity
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dynamic entity tests are using NHibernate dynamic proxies as a general purpose proxy provider. But that is not the purpose of NHibernate to provide such a thing. Those tests will have to be rewritten with an independent proxy provider if they are to be kept after dropping dynamic proxies.

{
[Obsolete("Require dynamic proxies")]
public sealed class DataProxyHandler : Proxy.DynamicProxy.IInterceptor
{
private readonly Hashtable data = new Hashtable();
Expand Down Expand Up @@ -56,4 +58,4 @@ public object Intercept(InvocationInfo info)

#endregion
}
}
}
5 changes: 4 additions & 1 deletion src/NHibernate.Test/DynamicEntity/IProxyMarker.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;

namespace NHibernate.Test.DynamicEntity
{
[Obsolete("Require dynamic proxies")]
public interface IProxyMarker
{
DataProxyHandler DataHandler { get;}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Collections;
using NHibernate.Cfg;
using NUnit.Framework;

namespace NHibernate.Test.DynamicEntity.Interceptor
{
[TestFixture]
[Obsolete("Require dynamic proxies")]
public class InterceptorDynamicEntity : TestCase
{
protected override string MappingsAssembly
Expand Down Expand Up @@ -89,4 +91,4 @@ public void It()
session.Close();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;

namespace NHibernate.Test.DynamicEntity.Interceptor
{
[Obsolete("Require dynamic proxies")]
public class ProxyInterceptor : EmptyInterceptor
{
public override string GetEntityName(object entity)
Expand All @@ -21,4 +24,4 @@ public override object Instantiate(string entityName, object id)
return base.Instantiate(entityName, id);
}
}
}
}
4 changes: 3 additions & 1 deletion src/NHibernate.Test/DynamicEntity/ProxyHelper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using NHibernate.Proxy.DynamicProxy;

namespace NHibernate.Test.DynamicEntity
{
[Obsolete("Require dynamic proxies")]
public class ProxyHelper
{
private static readonly ProxyFactory proxyGenerator = new ProxyFactory();
Expand Down Expand Up @@ -67,4 +69,4 @@ public static string ExtractEntityName(object obj)
return null;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;

namespace NHibernate.Test.DynamicEntity.Tuplizer
{
[Obsolete("Require dynamic proxies")]
public class EntityNameInterceptor : EmptyInterceptor
{
public override string GetEntityName(object entity)
Expand All @@ -8,4 +11,4 @@ public override string GetEntityName(object entity)
return entityName;
}
}
}
}
Loading