Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b99e647

Browse filesBrowse files
committed
Reverted my changes because git screwed up the diff
1 parent 55e313b commit b99e647
Copy full SHA for b99e647

File tree

3 files changed

+17
-62
lines changed
Filter options

3 files changed

+17
-62
lines changed

‎MongoDB.Net-Tests/Bson/TestRoundTrips.cs

Copy file name to clipboardExpand all lines: MongoDB.Net-Tests/Bson/TestRoundTrips.cs
+1-27
Original file line numberDiff line numberDiff line change
@@ -79,32 +79,6 @@ public void TestDateUTC(){
7979

8080
Assert.AreEqual(now.Hour,then.Hour, "Date did not round trip right.");
8181

82-
}
83-
84-
[Test]
85-
public void TestGUID() {
86-
MemoryStream ms = new MemoryStream();
87-
BsonWriter writer = new BsonWriter(ms);
88-
89-
Guid guid = Guid.NewGuid();
90-
91-
Document source = new Document();
92-
source.Append("uuid", guid);
93-
94-
/*Binary b = new Binary(guid.ToByteArray());
95-
b.Subtype = Binary.TypeCode.Uuid;
96-
source.Append("uuid", b);*/
97-
98-
writer.Write(source);
99-
writer.Flush();
100-
ms.Seek(0, SeekOrigin.Begin);
101-
102-
BsonReader reader = new BsonReader(ms);
103-
Document copy = reader.Read();
104-
105-
Guid read = (Guid)copy["uuid"];
106-
107-
Assert.AreEqual(guid, read, "UUID did not round trip right.");
108-
}
82+
}
10983
}
11084
}

‎MongoDBDriver/Bson/BsonReader.cs

Copy file name to clipboardExpand all lines: MongoDBDriver/Bson/BsonReader.cs
-7
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,6 @@ public Object ReadElementType (sbyte typeNum){
148148
}
149149
byte[] bytes = reader.ReadBytes (size);
150150
position += size;
151-
152-
// From http://en.wikipedia.org/wiki/Universally_Unique_Identifier
153-
// The most widespread use of this standard is in Microsoft's Globally Unique Identifiers (GUIDs).
154-
if (subtype == 3 && 16 == size) {
155-
return new Guid(bytes);
156-
}
157-
158151
Binary b = new Binary ();
159152
b.Bytes = bytes;
160153
b.Subtype = (Binary.TypeCode)subtype;

‎MongoDBDriver/Bson/BsonWriter.cs

Copy file name to clipboardExpand all lines: MongoDBDriver/Bson/BsonWriter.cs
+16-28
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,16 @@ public void WriteValue(BsonDataType dt, Object obj){
117117
return;
118118
}
119119
case BsonDataType.Binary:{
120-
if (obj is Guid) {
121-
writer.Write((int)16);
122-
writer.Write((byte)3);
123-
writer.Write(((Guid)obj).ToByteArray());
124-
} else {
125-
Binary b = (Binary)obj;
126-
if(b.Subtype == Binary.TypeCode.General){
127-
writer.Write(b.Bytes.Length + 4);
128-
writer.Write((byte)b.Subtype);
129-
writer.Write(b.Bytes.Length);
130-
}else{
131-
writer.Write(b.Bytes.Length);
132-
writer.Write((byte)b.Subtype);
133-
}
134-
writer.Write(b.Bytes);
120+
Binary b = (Binary)obj;
121+
if(b.Subtype == Binary.TypeCode.General){
122+
writer.Write(b.Bytes.Length + 4);
123+
writer.Write((byte)b.Subtype);
124+
writer.Write(b.Bytes.Length);
125+
}else{
126+
writer.Write(b.Bytes.Length);
127+
writer.Write((byte)b.Subtype);
135128
}
129+
writer.Write(b.Bytes);
136130
return;
137131
}
138132
default:
@@ -208,18 +202,14 @@ public int CalculateSize(Object val){
208202
return size;
209203
}
210204
case BsonDataType.Binary:{
211-
if (val is Guid)
212-
return 21;
213-
else {
214-
Binary b = (Binary)val;
215-
int size = 4; //size int
216-
size += 1; //subtype
217-
if(b.Subtype == Binary.TypeCode.General){
218-
size += 4; //embedded size int
219-
}
220-
size += b.Bytes.Length;
221-
return size;
205+
Binary b = (Binary)val;
206+
int size = 4; //size int
207+
size += 1; //subtype
208+
if(b.Subtype == Binary.TypeCode.General){
209+
size += 4; //embedded size int
222210
}
211+
size += b.Bytes.Length;
212+
return size;
223213
}
224214
default:
225215
throw new NotImplementedException(String.Format("Calculating size of {0} is not implemented.",val.GetType().Name));
@@ -305,8 +295,6 @@ protected BsonDataType TranslateToBsonType(Object val){
305295
ret = BsonDataType.Null;
306296
}else if(t == typeof(Binary)){
307297
ret = BsonDataType.Binary;
308-
}else if(t == typeof(Guid)){
309-
ret = BsonDataType.Binary;
310298
}else if(t == typeof(MongoMinKey)){
311299
ret = BsonDataType.MinKey;
312300
}else if(t == typeof(MongoMaxKey)){

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.