Skip to content

Commit

Permalink
fixed Oid test. fixed an issue with indexers in the DefaultMemberFind…
Browse files Browse the repository at this point in the history
…er. Allowed private setters in the DefaultMemberFinder.
  • Loading branch information
craiggwilson committed May 23, 2010
1 parent 9dd25f6 commit f452be7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion source/MongoDB.Tests/UnitTests/TestOid.cs
Expand Up @@ -136,7 +136,7 @@ public void TestNotEquals()
}

[Test]
[ExpectedException(typeof(ArgumentNullException))]
[ExpectedException(typeof(ArgumentException))]
public void TestNullValue()
{
new Oid(String.Empty);
Expand Down
Expand Up @@ -74,7 +74,7 @@ public AutoMappingProfile()
{
_conventions = new ConventionProfile();
_isSubClass = t => false;
_memberFinder = PublicOrProtectedMemberFinder.Instance;
_memberFinder = DefaultMemberFinder.Instance;
}

/// <summary>
Expand Down
Expand Up @@ -7,16 +7,16 @@ namespace MongoDB.Configuration.Mapping.Auto
/// <summary>
///
/// </summary>
public class PublicOrProtectedMemberFinder : IMemberFinder
public class DefaultMemberFinder : IMemberFinder
{
///<summary>
///</summary>
public static readonly PublicOrProtectedMemberFinder Instance = new PublicOrProtectedMemberFinder();
public static readonly DefaultMemberFinder Instance = new DefaultMemberFinder();

/// <summary>
/// Initializes a new instance of the <see cref="PublicOrProtectedMemberFinder"/> class.
/// Initializes a new instance of the <see cref="DefaultMemberFinder"/> class.
/// </summary>
private PublicOrProtectedMemberFinder()
private DefaultMemberFinder()
{
}

Expand All @@ -32,18 +32,18 @@ public IEnumerable<MemberInfo> FindMembers(Type type)
var getMethod = prop.GetGetMethod(true);
var setMethod = prop.GetSetMethod(true);

if(getMethod==null||setMethod==null)
if(getMethod==null || getMethod.IsPrivate || setMethod==null)
continue;

if(getMethod.IsPrivate||setMethod.IsPrivate)
if (setMethod.GetParameters().Length != 1) //an indexer
continue;

yield return prop;
}

foreach (var field in type.GetFields())
foreach (var field in type.GetFields()) //all public fields
{
if (!field.IsInitOnly && !field.IsLiteral)
if (!field.IsInitOnly && !field.IsLiteral) //readonly
yield return field;
}
}
Expand Down
Expand Up @@ -164,7 +164,7 @@ public static class MemberReflectionOptimizer

if (!propertyInfo.CanWrite)
throw new InvalidOperationException("Cannot create a setter for a readonly property.");

ParameterExpression instanceParameter = Expression.Parameter(typeof(object), "target");
ParameterExpression valueParameter = Expression.Parameter(typeof(object), "value");

Expand Down
2 changes: 1 addition & 1 deletion source/MongoDB/MongoDB.csproj
Expand Up @@ -231,7 +231,7 @@
<Compile Include="Configuration\Mapping\Auto\IAutoMappingProfile.cs" />
<Compile Include="Configuration\Mapping\Auto\IMemberFinder.cs" />
<Compile Include="Configuration\Mapping\Auto\MemberOverrides.cs" />
<Compile Include="Configuration\Mapping\Auto\PublicOrProtectedMemberFinder.cs" />
<Compile Include="Configuration\Mapping\Auto\DefaultMemberFinder.cs" />
<Compile Include="Configuration\Mapping\Conventions\ConventionProfile.cs" />
<Compile Include="Configuration\Mapping\Conventions\DefaultCollectionAdapterConvention.cs" />
<Compile Include="Configuration\Mapping\Conventions\DefaultDefaultValueConvention.cs" />
Expand Down

0 comments on commit f452be7

Please sign in to comment.