Permalink
Browse files

Modified collection names for Generic types so that you get something…

… more reasonable than 'BaseType`1'.
  • Loading branch information...
1 parent a287568 commit a84e10e33af8bd7ad0230fdbd559802dda5fba62 @atheken committed May 30, 2010
Showing with 731 additions and 678 deletions.
  1. +10 −0 NoRM.Tests/MongoCollectionTests.cs
  2. +2 −2 NoRM.Tests/MongoConfigurationTests.cs
  3. +5 −0 NoRM.Tests/TestClasses.cs
  4. +5 −5 NoRM.Tests/TypeHelperTests.cs
  5. +1 −1 NoRM/Attributes/MongoDiscriminatedAttribute.cs
  6. +27 −27 NoRM/BSON/BSONSerializer.cs
  7. +34 −34 NoRM/BSON/BsonDeserializer.cs
  8. +2 −2 NoRM/BSON/Command.cs
  9. +8 −8 NoRM/BSON/DbTypes/DBReference.cs
  10. +7 −7 NoRM/BSON/DbTypes/GridFile.cs
  11. +11 −11 NoRM/BSON/DbTypes/ObjectId.cs
  12. +5 −5 NoRM/BSON/DbTypes/ObjectIdTypeConverter.cs
  13. +1 −1 NoRM/BSON/DbTypes/ScopedCodeGeneric.cs
  14. +3 −3 NoRM/BSON/DocumentExceedsSizeLimitsException.cs
  15. +15 −15 NoRM/BSON/Expando.cs
  16. +4 −4 NoRM/BSON/ExpandoProperty.cs
  17. +2 −2 NoRM/BSON/IExpando.cs
  18. +6 −6 NoRM/BSON/IdPropertyFinder.cs
  19. +17 −17 NoRM/BSON/MagicProperty.cs
  20. +52 −23 NoRM/BSON/{TypeHelper.cs → ReflectionHelper.cs}
  21. +2 −2 NoRM/Collections/CreateCollectionOptions.cs
  22. +41 −41 NoRM/Collections/IMongoCollectionGeneric.cs
  23. +3 −3 NoRM/Collections/MongoCollection.cs
  24. +95 −95 NoRM/Collections/MongoCollectionGeneric.cs
  25. +1 −1 NoRM/Commands/Modifiers/IncrementOperation.cs
  26. +13 −13 NoRM/Commands/Modifiers/M.cs
  27. +9 −9 NoRM/Commands/Modifiers/ModifierExpression.cs
  28. +2 −2 NoRM/Commands/Qualifiers/AllQualifier.cs
  29. +1 −1 NoRM/Commands/Qualifiers/ExistsQualifier.cs
  30. +1 −1 NoRM/Commands/Qualifiers/GreaterOrEqualQualifier.cs
  31. +1 −1 NoRM/Commands/Qualifiers/GreaterThanQualifier.cs
  32. +2 −2 NoRM/Commands/Qualifiers/InQualifier.cs
  33. +1 −1 NoRM/Commands/Qualifiers/LessOrEqualQualifier.cs
  34. +1 −1 NoRM/Commands/Qualifiers/LessThanQualifier.cs
  35. +1 −1 NoRM/Commands/Qualifiers/NotEqualQualifier.cs
  36. +2 −2 NoRM/Commands/Qualifiers/NotInQualifier.cs
  37. +25 −25 NoRM/Commands/Qualifiers/Q.cs
  38. +1 −1 NoRM/Commands/Qualifiers/SizeQualifier.cs
  39. +1 −1 NoRM/Commands/Qualifiers/WhereQualifier.cs
  40. +1 −1 NoRM/Configuration/ConfigurationContainer.cs
  41. +1 −1 NoRM/Configuration/IConfigurationContainer.cs
  42. +9 −9 NoRM/Configuration/IMongoConfigurationMap.cs
  43. +3 −3 NoRM/Configuration/IPropertyMappingExpression.cs
  44. +4 −4 NoRM/Configuration/ITypeConfiguration.cs
  45. +3 −3 NoRM/Configuration/ITypedConfigurationGeneric.cs
  46. +13 −11 NoRM/Configuration/MongoConfiguration.cs
  47. +21 −14 NoRM/Configuration/MongoConfigurationMap.cs
  48. +1 −1 NoRM/Configuration/MongoConfigurationMapException.cs
  49. +2 −2 NoRM/Configuration/MongoConfigurationTypeMap.cs
  50. +1 −1 NoRM/Configuration/MongoTypeConfiguration.cs
  51. +8 −8 NoRM/Configuration/MongoTypeConfigurationGeneric.cs
  52. +3 −3 NoRM/Configuration/PropertyMappingExpression.cs
  53. +15 −15 NoRM/Connections/Connection.cs
  54. +1 −1 NoRM/Connections/ConnectionProvider.cs
  55. +2 −2 NoRM/Connections/ConnectionProviderFactory.cs
  56. +14 −14 NoRM/Connections/ConnectionStringBuilder.cs
  57. +7 −7 NoRM/Connections/IConnection.cs
  58. +2 −2 NoRM/Connections/IConnectionProvider.cs
  59. +6 −6 NoRM/Connections/IOptionsContainer.cs
  60. +3 −3 NoRM/Connections/NormalConnectionProvider.cs
  61. +4 −4 NoRM/Connections/PooledConnectionProvider.cs
  62. +4 −4 NoRM/Connections/QueuedConnectionProviders.cs
  63. +10 −10 NoRM/Connections/TimedLock.cs
  64. +2 −2 NoRM/IMongoGrouping.cs
  65. +23 −23 NoRM/Linq/ExpressionVisitor.cs
  66. +9 −9 NoRM/Linq/LinqExtensions.cs
  67. +7 −7 NoRM/Linq/LinqTypeHelper.cs
  68. +1 −1 NoRM/Linq/MapReduceResult.cs
  69. +8 −8 NoRM/Linq/MongoQuery.cs
  70. +3 −3 NoRM/Linq/MongoQueryExecutor.cs
  71. +9 −9 NoRM/Linq/MongoQueryProvider.cs
  72. +18 −18 NoRM/Linq/MongoQueryTranslator.cs
  73. +3 −3 NoRM/Linq/PartialEvaluator.cs
  74. +2 −2 NoRM/MapReduce/MapReduce.cs
  75. +2 −2 NoRM/MapReduce/MapReduceOptions.cs
  76. +1 −1 NoRM/MapReduce/MapReduceOptionsGeneric.cs
  77. +13 −13 NoRM/Mongo.cs
  78. +8 −8 NoRM/MongoAdmin.cs
  79. +13 −13 NoRM/MongoDatabase.cs
  80. +1 −1 NoRM/MongoException.cs
  81. +5 −5 NoRM/MongoQueryExecutor.cs
  82. +1 −1 NoRM/NoRM.csproj
  83. +4 −4 NoRM/Protocol/Messages/DeleteMessage.cs
  84. +5 −5 NoRM/Protocol/Messages/GetMoreMessage.cs
  85. +4 −4 NoRM/Protocol/Messages/InsertMessage.cs
  86. +3 −3 NoRM/Protocol/Messages/Message.cs
  87. +4 −4 NoRM/Protocol/Messages/QueryMessageGeneric.cs
  88. +6 −6 NoRM/Protocol/Messages/ReplyMessage.cs
  89. +7 −7 NoRM/Protocol/Messages/UpdateMessage.cs
  90. +2 −2 NoRM/Protocol/SystemMessages/Requests/CreateCollectionRequest.cs
  91. +1 −1 NoRM/Protocol/SystemMessages/Requests/ExplainRequest.cs
  92. +2 −2 NoRM/Protocol/SystemMessages/Requests/MongoIndex.cs
  93. +1 −1 NoRM/Protocol/SystemMessages/Responses/CollectionInfo.cs
  94. +1 −1 NoRM/Protocol/SystemMessages/Responses/DatabaseInfo.cs
  95. +1 −1 NoRM/Protocol/SystemMessages/Responses/DistinctValuesResponse.cs
  96. +3 −3 NoRM/Protocol/SystemMessages/Responses/MapReduceResponse.cs
@@ -24,6 +24,16 @@ public MongoCollectionTests()
}
[Fact]
+ public void CollectionName_For_Deeply_Generic_Collection_Is_Legal_And_Reasonable()
+ {
+ using (var db = Mongo.Create(TestHelper.ConnectionString()))
+ {
+ var coll = db.GetCollection<GenericSuperClass<List<String>>>();
+ Assert.Equal("NormTests.GenericSuperClass_List_String", coll.FullyQualifiedName);
+ }
+ }
+
+ [Fact]
public void Find_On_Unspecified_Type_Returns_Expando_When_No_Discriminator_Available()
{
using (var db = Mongo.Create(TestHelper.ConnectionString("strict=false")))
@@ -37,13 +37,13 @@ public void Mongo_Configuration_Should_AutoMap_Id_Property()
[Fact]
public void Mongo_Configuration_Should_Notify_TypeHelper()
{
- var typeHelper = TypeHelper.GetHelperForType(typeof(User2));
+ var typeHelper = ReflectionHelper.GetHelperForType(typeof(User2));
Assert.Equal("LastName", typeHelper.FindProperty("LastName").Name);
//the mapping should cause the typehelper cache to be rebuilt with the new properties.
MongoConfiguration.Initialize(cfg => cfg.For<User2>(j => j.ForProperty(k => k.LastName).UseAlias("LNAME")));
- typeHelper = TypeHelper.GetHelperForType(typeof(User2));
+ typeHelper = ReflectionHelper.GetHelperForType(typeof(User2));
Assert.Equal("LastName", typeHelper.FindProperty("LNAME").Name);
}
@@ -36,6 +36,11 @@ public class ProductSumObjectId
public int Value { get; set; }
}
+ public class GenericSuperClass<T>
+ {
+
+ }
+
public class TestClass
{
public TestClass()
@@ -10,37 +10,37 @@ public class TypeHelperTests
[Fact]
public void Can_get_discriminator_for_type()
{
- var helper = TypeHelper.GetHelperForType(typeof(SuperClassObject));
+ var helper = ReflectionHelper.GetHelperForType(typeof(SuperClassObject));
Assert.Equal("Norm.Tests.SuperClassObject, NoRM.Tests", helper.GetTypeDiscriminator());
}
[Fact]
public void Can_get_discriminator_for_sub_type()
{
- var helper = TypeHelper.GetHelperForType(typeof(SubClassedObject));
+ var helper = ReflectionHelper.GetHelperForType(typeof(SubClassedObject));
Assert.Equal("Norm.Tests.SubClassedObject, NoRM.Tests", helper.GetTypeDiscriminator());
}
[Fact]
public void Can_Get_Discriminator_When_Discriminator_Is_On_An_Interface()
{
- var helper = TypeHelper.GetHelperForType(typeof(InterfaceDiscriminatedClass));
+ var helper = ReflectionHelper.GetHelperForType(typeof(InterfaceDiscriminatedClass));
Assert.Equal("Norm.Tests.InterfaceDiscriminatedClass, NoRM.Tests", helper.GetTypeDiscriminator());
}
[Fact]
public void Can_Get_Id_Property_For_Type()
{
- var helper = TypeHelper.GetHelperForType(typeof(SuperClassObject));
+ var helper = ReflectionHelper.GetHelperForType(typeof(SuperClassObject));
Assert.NotNull(helper.FindIdProperty());
}
[Fact]
public void Can_Infer_ID_From_Interface_Attribute()
{
- var helper = TypeHelper.GetHelperForType(typeof(DtoWithNonDefaultIdClass));
+ var helper = ReflectionHelper.GetHelperForType(typeof(DtoWithNonDefaultIdClass));
var something = helper.FindIdProperty();
Assert.NotNull(something);
@@ -16,7 +16,7 @@ public class MongoDiscriminatedAttribute : Attribute
/// <summary>
/// Finds the sub-type or interface from the given type that declares itself as a discriminating base class
/// </summary>
- /// <param name="type"></param>
+ /// <param retval="type"></param>
/// <returns></returns>
public static Type GetDiscriminatingTypeFor(Type type)
{
@@ -34,7 +34,7 @@ internal class BsonSerializer
/// <summary>
/// Initializes a new instance of the <see cref="BsonSerializer"/> class.
/// </summary>
- /// <param name="writer">
+ /// <param retval="writer">
/// The writer.
/// </param>
private BsonSerializer(BinaryWriter writer)
@@ -45,8 +45,8 @@ private BsonSerializer(BinaryWriter writer)
/// <summary>
/// Convert a document to it's BSON equivalent.
/// </summary>
- /// <typeparam name="T">Type to serialize</typeparam>
- /// <param name="document">The document.</param>
+ /// <typeparam retval="T">Type to serialize</typeparam>
+ /// <param retval="document">The document.</param>
/// <returns></returns>
public static byte[] Serialize<T>(T document)
{
@@ -71,7 +71,7 @@ private void NewDocument()
/// <summary>
/// Write the document terminator, prepenf the original length.
/// </summary>
- /// <param name="includeEeo">if set to <c>true</c> include eeo.</param>
+ /// <param retval="includeEeo">if set to <c>true</c> include eeo.</param>
private void EndDocument(bool includeEeo)
{
var old = _current;
@@ -94,7 +94,7 @@ private void EndDocument(bool includeEeo)
/// <summary>
/// increment the number of bytes written.
/// </summary>
- /// <param name="length">The length written.</param>
+ /// <param retval="length">The length written.</param>
private void Written(int length)
{
_current.Digested += length;
@@ -103,7 +103,7 @@ private void Written(int length)
/// <summary>
/// Writes a document.
/// </summary>
- /// <param name="document">The document.</param>
+ /// <param retval="document">The document.</param>
private void WriteDocument(object document)
{
NewDocument();
@@ -124,7 +124,7 @@ private void WriteDocument(object document)
/// <summary>
/// Writes a Flyweight.
/// </summary>
- /// <param name="document">The document.</param>
+ /// <param retval="document">The document.</param>
private void WriteFlyweight(Expando document)
{
foreach (var property in document.AllProperties())
@@ -136,7 +136,7 @@ private void WriteFlyweight(Expando document)
/// <summary>
/// Checks to see if the object is a DbReference. If it is, we won't want to override $id to _id.
/// </summary>
- /// <param name="type">The type of the object being serialized.</param>
+ /// <param retval="type">The type of the object being serialized.</param>
/// <returns>True if the object is a DbReference, false otherwise.</returns>
private static bool IsDbReference(Type type)
{
@@ -150,10 +150,10 @@ private static bool IsDbReference(Type type)
/// <summary>
/// Actually write the property bytes.
/// </summary>
- /// <param name="document">The document.</param>
+ /// <param retval="document">The document.</param>
private void WriteObject(object document)
{
- var typeHelper = TypeHelper.GetHelperForType(document.GetType());
+ var typeHelper = ReflectionHelper.GetHelperForType(document.GetType());
var idProperty = typeHelper.FindIdProperty();
var documentType = document.GetType();
var discriminator = typeHelper.GetTypeDiscriminator();
@@ -191,8 +191,8 @@ private void WriteObject(object document)
/// <summary>
/// Serializes a member.
/// </summary>
- /// <param name="name">The name.</param>
- /// <param name="value">The value.</param>
+ /// <param retval="retval">The retval.</param>
+ /// <param retval="value">The value.</param>
private void SerializeMember(string name, object value)
{
if (value == null)
@@ -269,10 +269,10 @@ private void SerializeMember(string name, object value)
}
/// <summary>
- /// Writes a name/value pair.
+ /// Writes a retval/value pair.
/// </summary>
- /// <param name="name">The name.</param>
- /// <param name="value">The value.</param>
+ /// <param retval="retval">The retval.</param>
+ /// <param retval="value">The value.</param>
private void Write(string name, object value)
{
if (value is IDictionary)
@@ -320,7 +320,7 @@ private void Write(string name, object value)
/// <summary>
/// Writes an enumerable list.
/// </summary>
- /// <param name="enumerable">
+ /// <param retval="enumerable">
/// The enumerable.
/// </param>
private void Write(IEnumerable enumerable)
@@ -335,7 +335,7 @@ private void Write(IEnumerable enumerable)
/// <summary>
/// Writes a dictionary.
/// </summary>
- /// <param name="dictionary">
+ /// <param retval="dictionary">
/// The dictionary.
/// </param>
private void Write(IDictionary dictionary)
@@ -349,7 +349,7 @@ private void Write(IDictionary dictionary)
/// <summary>
/// Writes binnary.
/// </summary>
- /// <param name="value">
+ /// <param retval="value">
/// The value.
/// </param>
private void WriteBinary(object value)
@@ -378,7 +378,7 @@ private void WriteBinary(object value)
/// <summary>
/// Writes a BSON type.
/// </summary>
- /// <param name="type">
+ /// <param retval="type">
/// The type.
/// </param>
private void Write(BSONTypes type)
@@ -388,10 +388,10 @@ private void Write(BSONTypes type)
}
/// <summary>
- /// Writes a name.
+ /// Writes a retval.
/// </summary>
- /// <param name="name">
- /// The name.
+ /// <param retval="retval">
+ /// The retval.
/// </param>
private void WriteName(string name)
{
@@ -402,10 +402,10 @@ private void WriteName(string name)
}
/// <summary>
- /// Writes a string name.
+ /// Writes a string retval.
/// </summary>
- /// <param name="name">
- /// The name.
+ /// <param retval="retval">
+ /// The retval.
/// </param>
private void Write(string name)
{
@@ -419,7 +419,7 @@ private void Write(string name)
/// <summary>
/// Writes a regex.
/// </summary>
- /// <param name="regex">
+ /// <param retval="regex">
/// The regex.
/// </param>
private void Write(Regex regex)
@@ -472,7 +472,7 @@ private void Write(Regex regex)
/// <summary>
/// Writes scoped code.
/// </summary>
- /// <param name="value">
+ /// <param retval="value">
/// The value.
/// </param>
private void Write(ScopedCode value)
Oops, something went wrong.

0 comments on commit a84e10e

Please sign in to comment.