[CSHARP-229] ObjectId.TryParse shouldn't throw an exception Created: 19/May/11 Updated: 02/Apr/15 Resolved: 01/May/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.0, 1.4.1 |
| Fix Version/s: | 1.1, 1.5 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Andrey | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | TryParse, c# | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 2008 + MongoDb 1.8.1 + C# Driver 1.0 |
||
| Description |
|
Currently ObjectId.TryParse(string s, out ObjectId o) checks for null value and throws an exception if it's null. That is not how TryParse is implemented elsewhere - it should simply initialize o = ObjectId.Empty and return false - the whole idea of using TryParse is that it doesn't throw exceptions. Can you please fix that? |
| Comments |
| Comment by David MÃ¥rtensson [ 29/Jun/12 ] |
|
Any possibility to get this fix in an 1.4.3. We use the driver for a live project and was bitten quite bad when upgrading the driver last week, today we found this error and nuGet do not have the old version any more and we have already started to use some of the new features, so we either have to change every use of tryparse or wait for 1.5 before next release? |
| Comment by Robert Stam [ 01/May/12 ] |
|
Fixed again. This time added better comments to help prevent bug from being reintroduced. |
| Comment by Robert Stam [ 01/May/12 ] |
|
Reopening because bug was reintroduced. |
| Comment by Robert Stam [ 19/May/11 ] |
|
Fixed. Thanks for pointing this out. |