-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CSHARP-5319: Remove AsDateTime and similar from BsonValue #1494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a discussion going on about what exactly we should do.
I am proposing that we should keep AsLocalTime
and AsUniversalTime
because that it is the existing pattern established by all our other AsXyz
properties.
/// Casts the BsonValue to a DateTime in the local timezone (throws an InvalidCastException if the cast is not valid). | ||
/// </summary> | ||
[Obsolete("Use ToLocalTime instead.")] | ||
public DateTime AsLocalTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was obsoleted by mistake and we should keep the property and remove the [Obsolete]
attribute.
/// <summary> | ||
/// Casts the BsonValue to a DateTime in UTC (throws an InvalidCastException if the cast is not valid). | ||
/// </summary> | ||
[Obsolete("Use ToUniversalTime instead.")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was obsoleted by mistake and we should keep the property and remove the [Obsolete]
attribute.
/// Casts the BsonValue to a Nullable{DateTime} (throws an InvalidCastException if the cast is not valid). | ||
/// </summary> | ||
[Obsolete("Use ToNullableUniversalTime instead.")] | ||
public DateTime? AsNullableDateTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property should be replaced with two properties: AsNullableLocalTime
and AsNullableUniversalTime
.
/// <summary> | ||
/// Casts the BsonValue to a DateTime in UTC (throws an InvalidCastException if the cast is not valid). | ||
/// </summary> | ||
[Obsolete("Use ToUniversalTime instead.")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This obsoletion was proper and the member can be deleted.
The error message was wrong though. It should have been "Use AsUniversalTime" instead.
Given our time zone difference and that I'm out of the office tomorrow I have prototyped in code what we were discussing earlier today: https://github.com/rstam/mongo-csharp-driver/commits/csharp5319/ Summary of proposed changes: Remove Keep Add Leave any existing "to date" methods alone. |
/// </summary> | ||
public bool? AsNullableBoolean | ||
[EditorBrowsable(EditorBrowsableState.Never)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want DebuggerBrowsable
here.
Also, we want it for ALL AsXyz
properties, not just the DateTime ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right, DebuggerBrowsable
is the correct one, I've misunderstood the situation
@@ -77,6 +82,7 @@ public BsonBinaryData AsBsonBinaryData | |||
/// <summary> | |||
/// Casts the BsonValue to a BsonDateTime (throws an InvalidCastException if the cast is not valid). | |||
/// </summary> | |||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing attribute on line 94.
@@ -165,6 +180,7 @@ public BsonUndefined AsBsonUndefined | |||
/// <summary> | |||
/// Casts the BsonValue to a BsonValue (a way of upcasting subclasses of BsonValue to BsonValue at compile time). | |||
/// </summary> | |||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing attribute on line 192.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 just added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.