@@ -117,15 +117,13 @@ public DateOnlySerializer(BsonType representation, DateOnlyDocumentFormat docume
117117 public override DateOnly Deserialize ( BsonDeserializationContext context , BsonDeserializationArgs args )
118118 {
119119 var bsonReader = context . Reader ;
120- DateOnly value ;
121120
122121 var bsonType = bsonReader . GetCurrentBsonType ( ) ;
123122
124123 switch ( bsonType )
125124 {
126125 case BsonType . DateTime :
127- value = VerifyAndMakeDateOnly ( BsonUtils . ToDateTimeFromMillisecondsSinceEpoch ( bsonReader . ReadDateTime ( ) ) ) ;
128- break ;
126+ return VerifyAndMakeDateOnly ( BsonUtils . ToDateTimeFromMillisecondsSinceEpoch ( bsonReader . ReadDateTime ( ) ) ) ;
129127
130128 case BsonType . Document :
131129 var ticks = 0L ;
@@ -153,30 +151,24 @@ public override DateOnly Deserialize(BsonDeserializationContext context, BsonDes
153151 } ;
154152
155153 case BsonType . Decimal128 :
156- value = VerifyAndMakeDateOnly ( new DateTime ( _converter . ToInt64 ( bsonReader . ReadDecimal128 ( ) ) , DateTimeKind . Utc ) ) ;
157- break ;
154+ return VerifyAndMakeDateOnly ( new DateTime ( _converter . ToInt64 ( bsonReader . ReadDecimal128 ( ) ) , DateTimeKind . Utc ) ) ;
158155
159156 case BsonType . Double :
160- value = VerifyAndMakeDateOnly ( new DateTime ( _converter . ToInt64 ( bsonReader . ReadDouble ( ) ) , DateTimeKind . Utc ) ) ;
161- break ;
157+ return VerifyAndMakeDateOnly ( new DateTime ( _converter . ToInt64 ( bsonReader . ReadDouble ( ) ) , DateTimeKind . Utc ) ) ;
162158
163159 case BsonType . Int32 :
164- value = VerifyAndMakeDateOnly ( new DateTime ( bsonReader . ReadInt32 ( ) , DateTimeKind . Utc ) ) ;
165- break ;
160+ return VerifyAndMakeDateOnly ( new DateTime ( bsonReader . ReadInt32 ( ) , DateTimeKind . Utc ) ) ;
166161
167162 case BsonType . Int64 :
168- value = VerifyAndMakeDateOnly ( new DateTime ( bsonReader . ReadInt64 ( ) , DateTimeKind . Utc ) ) ;
169- break ;
163+ return VerifyAndMakeDateOnly ( new DateTime ( bsonReader . ReadInt64 ( ) , DateTimeKind . Utc ) ) ;
170164
171165 case BsonType . String :
172- value = DateOnly . ParseExact ( bsonReader . ReadString ( ) , "yyyy-MM-dd" ) ;
173- break ;
166+ return DateOnly . ParseExact ( bsonReader . ReadString ( ) , "yyyy-MM-dd" ) ;
174167
175168 default :
176169 throw CreateCannotDeserializeFromBsonTypeException ( bsonType ) ;
177170 }
178171
179- return value ;
180172
181173 DateOnly VerifyAndMakeDateOnly ( DateTime dt )
182174 {
0 commit comments