Skip to content

Commit 82f199e

Browse files
Fix configuration schema forbidding custom bytecode provider (#1764)
1 parent 8a788d6 commit 82f199e

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
21
using System.Configuration;
3-
using System.Reflection;
42
using NHibernate.Event;
53
using NUnit.Framework;
64
using NHibernate.Cfg;
@@ -13,7 +11,7 @@ namespace NHibernate.Test.CfgTest
1311
public class ConfigurationSchemaFixture
1412
{
1513
[Test]
16-
public void InvalidConfig()
14+
public void SessionFactoryIsRequiredWhenConfigurationIsNotLoadedFromAppConfig()
1715
{
1816
string xml =
1917
@"<?xml version='1.0' encoding='utf-8' ?>
@@ -22,7 +20,7 @@ public void InvalidConfig()
2220
</hibernate-configuration>";
2321

2422
XmlTextReader xtr = new XmlTextReader(xml, XmlNodeType.Document, null);
25-
Assert.Throws<HibernateConfigException>(()=>new HibernateConfiguration(xtr));
23+
Assert.Throws<HibernateConfigException>(() => new HibernateConfiguration(xtr));
2624
}
2725

2826
[Test]
@@ -35,6 +33,23 @@ public void FromAppConfigTest()
3533
Assert.IsTrue(hc.UseReflectionOptimizer);
3634
Assert.AreEqual("NHibernate.Test", hc.SessionFactory.Name);
3735
}
36+
37+
[Test]
38+
public void ByteCodeProvider()
39+
{
40+
Assume.That(TestsContext.ExecutingWithVsTest, Is.False);
41+
42+
var xml =
43+
@"<?xml version='1.0' encoding='utf-8' ?>
44+
<hibernate-configuration xmlns='urn:nhibernate-configuration-2.2'>
45+
<bytecode-provider type='test'/>
46+
<session-factory>
47+
</session-factory>
48+
</hibernate-configuration>";
49+
50+
var hc = HibernateConfiguration.FromAppConfig(xml);
51+
Assert.That(hc.ByteCodeProviderType, Is.EqualTo("test"));
52+
}
3853

3954
[Test]
4055
public void IgnoreSystemOutOfAppConfig()

src/NHibernate/nhibernate-configuration.xsd

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,17 @@
334334
</xs:sequence>
335335
<xs:attribute name="type" default="lcg">
336336
<xs:simpleType>
337-
<xs:restriction base="xs:string">
338-
<xs:enumeration value="lcg" />
339-
<xs:enumeration value="null" />
340-
</xs:restriction>
337+
<xs:union>
338+
<xs:simpleType>
339+
<xs:restriction base="xs:string">
340+
<xs:enumeration value="lcg" />
341+
<xs:enumeration value="null" />
342+
</xs:restriction>
343+
</xs:simpleType>
344+
<xs:simpleType>
345+
<xs:restriction base="xs:string" />
346+
</xs:simpleType>
347+
</xs:union>
341348
</xs:simpleType>
342349
</xs:attribute>
343350
</xs:complexType>

0 commit comments

Comments
 (0)