Issue with Default(T) in Nullable Type
Hi Stefan,
We just recently upgraded to the 1.2 release of Spring4d and noticed that the nullable type was changed in spring.pas. The Clear method was removed and in the operator overload Default(T) was provided instead. This breaks null values and we can also see that you have already updated the tip of your code with changes to resolve this.
We are not in a position to upgrade to the tip of the source at this time but need to resolve this issue in our 1.2 code base. Can you suggest a patch for us. For instance can we just grab the nullable type from the spring unit and replace ours without other side effects?
Comments (7)
-
reporter -
repo owner The point of removing the Clear method was to avoid the issue that you might call Clear on a nullable property which would result in clearing the value copy that was returned by the property getter but not changing the underlying value. In short: to make Nullable<T> immutable.
If you want to clear a nullable then assign Null or Nullable.Null to it.
-
repo owner - changed title to Issue with Default(T) in Nullable Type
- changed version to 1.2 (develop)
-
repo owner - changed status to wontfix
I forgot that Clear was a private method. The public API was not changed.
-
reporter Yes correct, So I see there was an issue that you fixed this morning. I will apply this change to our code.
Thanks,
-
repo owner - changed version to 1.2
-
repo owner - removed milestone
Removing milestone: Future version (automated comment)
- Log in to comment
OK so we just added back the Clear method to Nullable and are calling it in the operator overload for Variant. Seems to work.