Skip to content

Commit

Permalink
Merge revision 2791
Browse files Browse the repository at this point in the history
SVN: trunk@2792
  • Loading branch information
Sergey Koshcheyev committed May 2, 2007
1 parent df8f47c commit cb63d72
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/ProxyValidator/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ public virtual void SomeMethod(int arg1, object arg2)
}

public virtual event EventHandler VirtualEvent;

protected void NonVirtualProtectedMethod()
{
}

protected int NonVirtualProtectedProperty
{
get { return 0; }
set { }
}

protected event EventHandler NonVirtualProtectedEvent;

protected void NonVirtualPrivateMethod()
{
}

protected int NonVirtualPrivateProperty
{
get { return 0; }
set { }
}

protected event EventHandler NonVirtualPrivateEvent;
}

[Test]
Expand Down Expand Up @@ -144,13 +168,25 @@ internal int NonVirtualProperty
}
}

public class InvalidInternalField : ValidClass
{
internal int internalField;
}

[Test]
[ExpectedException(typeof(InvalidProxyTypeException))]
public void NonVirtualInternal()
{
Validate(typeof(InvalidNonVirtualInternalProperty));
}

[Test]
[ExpectedException(typeof(InvalidProxyTypeException))]
public void InternalField()
{
Validate(typeof(InvalidInternalField));
}

public class InvalidNonVirtualProtectedProperty : ValidClass
{
protected int NonVirtualProperty
Expand Down
6 changes: 5 additions & 1 deletion src/NHibernate/Proxy/ProxyTypeValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ private static void CheckAccessibleMembersAreVirtual(System.Type type, IList err
}
else if (member is FieldInfo && ((FieldInfo)member).IsPublic)
{
Error(errors, type, "field " + member.Name + " should not be public");
FieldInfo memberField = (FieldInfo) member;
if (memberField.IsPublic || memberField.IsAssembly || memberField.IsFamilyOrAssembly)
{
Error(errors, type, "field " + member.Name + " should not be public nor internal");
}
}
}
}
Expand Down

0 comments on commit cb63d72

Please sign in to comment.