nullabletypes-cvs Mailing List for NullableTypes (Page 4)
Status: Inactive
Brought to you by:
lukadotnet
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(3) |
Feb
(3) |
Mar
|
Apr
|
May
(4) |
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2005 |
Jan
|
Feb
(4) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(7) |
Oct
(32) |
Nov
(2) |
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
(3) |
Jul
(5) |
Aug
(1) |
Sep
(10) |
Oct
(7) |
Nov
(23) |
Dec
(29) |
2009 |
Jan
(15) |
Feb
(15) |
Mar
(13) |
Apr
(17) |
May
(32) |
Jun
(25) |
Jul
(29) |
Aug
(8) |
Sep
(1) |
Oct
|
Nov
|
Dec
(9) |
2010 |
Jan
(10) |
Feb
(7) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(1) |
Jul
(2) |
Aug
|
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
From: Damien G. <dam...@us...> - 2005-10-11 09:25:29
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29226/src/Types Modified Files: NullableTimeSpan.cs Log Message: Clean up NullableTimeSpan and add new XML documentation. Index: NullableTimeSpan.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableTimeSpan.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableTimeSpan.cs 6 Oct 2005 16:05:35 -0000 1.1 --- NullableTimeSpan.cs 11 Oct 2005 09:25:33 -0000 1.2 *************** *** 5,9 **** // // Date Author Changes Reasons ! // 07-Apr-2003 DamienG Created New class // --- 5,10 ---- // // Date Author Changes Reasons ! // 29-Sep-2005 DamienG Created New class ! // 11-Oct-2005 DamienG Bugfix Clean up and all new XML documentation. // *************** *** 15,45 **** using sysXmlScm = System.Xml.Schema; [sys.Serializable] public struct NullableTimeSpan : INullable, sys.IComparable, sysXmlSrl.IXmlSerializable { #region Fields ! sys.TimeSpan _value; private bool _notNull; public static readonly NullableTimeSpan Null; /// <summary> ! /// A constant representing the largest possible value of a ! /// <see cref="NullableTimeSpan"/>. /// </summary> public static readonly NullableTimeSpan MaxValue = new NullableTimeSpan(sys.TimeSpan.MaxValue); /// <summary> ! /// A constant representing the smallest possible value of a ! /// <see cref="NullableTimeSpan"/>. /// </summary> public static readonly NullableTimeSpan MinValue = new NullableTimeSpan(sys.TimeSpan.MinValue); /// <summary> ! /// Represents a zero value that can be assigned to an instance of the ! /// <see cref="NullableTimeSpan"/> structure. /// </summary> - /// <remarks> - /// Zero field is a constant of the <see cref="NullableTimeSpan"/> structure. - /// </remarks> public static readonly NullableTimeSpan Zero = new NullableTimeSpan(0); --- 16,48 ---- using sysXmlScm = System.Xml.Schema; + /// <summary> + /// Represents an interval of time that is either a <see cref="System.TimeSpan" /> or <see cref="Null"/>. + /// </summary> [sys.Serializable] public struct NullableTimeSpan : INullable, sys.IComparable, sysXmlSrl.IXmlSerializable { + #region Fields ! ! private sys.TimeSpan _value; private bool _notNull; + /// <summary> + /// Represents the null <see cref="NullableTimeSpan"/>. This field is read-only. + /// </summary> public static readonly NullableTimeSpan Null; /// <summary> ! /// Represents the maximum <see cref="NullableTimeSpan"/> value. This field is read-only. /// </summary> public static readonly NullableTimeSpan MaxValue = new NullableTimeSpan(sys.TimeSpan.MaxValue); /// <summary> ! /// Represents the minimum <see cref="NullableTimeSpan"/> value. This field is read-only. /// </summary> public static readonly NullableTimeSpan MinValue = new NullableTimeSpan(sys.TimeSpan.MinValue); /// <summary> ! /// Represents the zero <see cref="NullableTimeSpan"/> value. This field is read-only. /// </summary> public static readonly NullableTimeSpan Zero = new NullableTimeSpan(0); *************** *** 47,60 **** #region Constructors ! public NullableTimeSpan (sys.TimeSpan timeSpan) { _value = timeSpan; _notNull = true; } ! public NullableTimeSpan (long ticks) { _value = new sys.TimeSpan (ticks); _notNull = true; } public NullableTimeSpan(int hours, int minutes, int seconds) { _value = new sys.TimeSpan(hours, minutes, seconds); --- 50,81 ---- #region Constructors ! ! /// <summary> ! /// Initializes a new <see cref="NullableTimeSpan"/> to the specified <see cref="System.TimeSpan"/> . ! /// </summary> ! /// <param name="timeSpan">A <see cref="System.TimeSpan"/>.</param> ! public NullableTimeSpan(sys.TimeSpan timeSpan) { _value = timeSpan; _notNull = true; } ! /// <summary> ! /// Initializes a new <see cref="NullableTimeSpan"/> to the specified number of ticks. ! /// </summary> ! /// <param name="ticks">A time period expressed in 100-nanosecond units.</param> ! public NullableTimeSpan(long ticks) { _value = new sys.TimeSpan (ticks); _notNull = true; } + /// <summary> + /// Initializes a new <see cref="NullableTimeSpan"/> to a specified number of hours, minutes, and seconds. + /// </summary> + /// <param name="hours">Number of hours.</param> + /// <param name="minutes">Number of minutes.</param> + /// <param name="seconds">Number of seconds.</param> + /// <exception cref="System.ArgumentOutOfRangeException"> + /// The parameters specify a <see cref="NullableTimeSpan"/> value less than <see cref="NullableTimeSpan.MinValue"/> or greater than <see cref="NullableTimeSpan.MaxValue"/>. + /// </exception> public NullableTimeSpan(int hours, int minutes, int seconds) { _value = new sys.TimeSpan(hours, minutes, seconds); *************** *** 62,101 **** } public NullableTimeSpan(int days, int hours, int minutes, int seconds) : this(days, hours, minutes, seconds, 0) { } public NullableTimeSpan(int days, int hours, int minutes, int seconds, int milliseconds) { _value = new sys.TimeSpan(days, hours, minutes, seconds, milliseconds); _notNull = true; } #endregion // Constructors #region INullable public bool IsNull { get { return !_notNull; } } #endregion // INullable #region IComparable - Ordering ! public int CompareTo(object value) { ! if (value == null) return 1; ! if (!(value is NullableTimeSpan)) throw new sys.ArgumentException(string.Format(sysGlb.CultureInfo.CurrentCulture, Locale.GetText("Value is not a {0}."), "NullableTypes.NullableTimeSpan")); ! NullableTimeSpan iValue = (NullableTimeSpan)value; ! if (iValue.IsNull && this.IsNull) ! return 0; ! ! if (iValue.IsNull) ! return 1; ! ! if (this.IsNull) ! return -1; ! return _value.CompareTo(iValue.Value); } --- 83,170 ---- } + /// <summary> + /// Initializes a new <see cref="NullableTimeSpan"/> to a specified number of days, hours, minutes, and seconds. + /// </summary> + /// <param name="days">Number of days.</param> + /// <param name="hours">Number of hours.</param> + /// <param name="minutes">Number of minutes.</param> + /// <param name="seconds">Number of seconds.</param> + /// <exception cref="System.ArgumentOutOfRangeException"> + /// The parameters specify a <see cref="NullableTimeSpan"/> value less than <see cref="NullableTimeSpan.MinValue"/> or greater than <see cref="NullableTimeSpan.MaxValue"/>. + /// </exception> public NullableTimeSpan(int days, int hours, int minutes, int seconds) : this(days, hours, minutes, seconds, 0) { } + /// <summary> + /// Initializes a new <see cref="NullableTimeSpan"/> to a specified number of days, hours, minutes, seconds and milliseconds. + /// </summary> + /// <param name="days">Number of days.</param> + /// <param name="hours">Number of hours.</param> + /// <param name="minutes">Number of minutes.</param> + /// <param name="seconds">Number of seconds.</param> + /// <param name="milliseconds">Number of milliseconds.</param> + /// <exception cref="System.ArgumentOutOfRangeException"> + /// The parameters specify a <see cref="NullableTimeSpan"/> value less than <see cref="NullableTimeSpan.MinValue"/> or greater than <see cref="NullableTimeSpan.MaxValue"/>. + /// </exception> public NullableTimeSpan(int days, int hours, int minutes, int seconds, int milliseconds) { _value = new sys.TimeSpan(days, hours, minutes, seconds, milliseconds); _notNull = true; } + #endregion // Constructors #region INullable + /// <summary> + /// Indicates whether or not this instance is <see cref="Null"/>. + /// </summary> + /// <value>true if this <see cref="NullableTimeSpan"/> is <see cref="Null"/>, otherwise false.</value> public bool IsNull { get { return !_notNull; } } + #endregion // INullable #region IComparable - Ordering ! ! /// <summary> ! /// Compares this instance to a specified object and returns an indication of their relative values. ! /// </summary> ! /// <param name="o">An object to compare, or <see langword="null" />.</param> ! /// <returns> ! /// <list type="table"> ! /// <listheader> ! /// <term>Value</term> ! /// <description>Condition</description> ! /// </listheader> ! /// <item> ! /// <term>-1</term> ! /// <description>This instance is less than <paramref name="o"/> or this instance is <see cref="Null"/> while <paramref name="o"/> is not.</description> ! /// </item> ! /// <item> ! /// <term>0</term> ! /// <description>This instance is equal to <paramref name="o"/>.</description> ! /// </item> ! /// <item> ! /// <term>1</term> ! /// <description>This instance is greater than <paramref name="o"/> or <paramref name="o"/> is <see cref="Null"/> while this instance is not.</description> ! /// </item> ! /// </list> ! /// </returns> ! /// <exception cref="System.ArgumentException"><paramref name="o" /> is not a <see cref="NullableTimeSpan"/>.</exception> ! public int CompareTo(object o) { ! if (o == null) return 1; ! if (!(o is NullableTimeSpan)) throw new sys.ArgumentException(string.Format(sysGlb.CultureInfo.CurrentCulture, Locale.GetText("Value is not a {0}."), "NullableTypes.NullableTimeSpan")); ! NullableTimeSpan ts = (NullableTimeSpan) o; ! if (ts.IsNull && IsNull) return 0; ! if (ts.IsNull) return 1; ! if (IsNull) return -1; ! return _value.CompareTo(ts.Value); } *************** *** 103,143 **** #region Equivalence - public override bool Equals(object value) { - if (!(value is NullableTimeSpan)) - return false; - else if (this.IsNull && ((NullableTimeSpan)value).IsNull) - return true; - else if (this.IsNull) - return false; - else if (((NullableTimeSpan)value).IsNull) - return false; - else - return (bool) (this == (NullableTimeSpan)value); - } ! public static NullableBoolean NotEquals(NullableTimeSpan x, NullableTimeSpan y) { ! return (x != y); } ! public static NullableBoolean operator == (NullableTimeSpan x, NullableTimeSpan y) { ! if (x.IsNull || y.IsNull) return NullableBoolean.Null; ! return new NullableBoolean (x.Value == y.Value); } ! public static NullableBoolean operator != (NullableTimeSpan x, NullableTimeSpan y) { ! if (x.IsNull || y.IsNull) return NullableBoolean.Null; ! return new NullableBoolean (!(x.Value == y.Value)); } ! public static NullableBoolean Equals(NullableTimeSpan x, NullableTimeSpan y) { ! return (x == y); } - public override int GetHashCode() { - return _value.GetHashCode(); - } #endregion // Equivalence #region IXmlSerializable /// <summary> /// This member supports the .NET Framework infrastructure and is not intended to be used directly --- 172,231 ---- #region Equivalence ! /// <summary> ! /// Returns a value indicating whether this instance is equal to a specified object. ! /// </summary> ! /// <param name="o">The object to compare with this instance.</param> ! /// <returns>true if <paramref name="o"/> is a <see cref="NullableGuid"/> that represents the same Guid as this instance; otherwise, false.</returns> ! public override bool Equals(object o) { ! if (!(o is NullableTimeSpan)) return false; ! NullableTimeSpan ts = (NullableTimeSpan) o; ! if (IsNull && ts.IsNull) return true; ! if (IsNull || ts.IsNull) return false; ! return (bool) (this == ts); } ! /// <summary> ! /// Indicates whether two <see cref="NullableTimeSpan"/> instances are equal. ! /// </summary> ! /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> ! /// <param name="t2">A <see cref="NullableTimeSpan"/>.</param> ! /// <see cref="NullableBoolean.Null"/> if either <paramref name="t1"/> or <paramref name="t2"/> are <see cref="Null"/>, ! /// <see cref="NullableBoolean.True"/> if the values of <paramref name="t1"/> and <paramref name="t2"/> are equal, ! /// <see cref="NullableBoolean.False"/> if the values of <paramref name="t1"/> and <paramref name="t2"/> are not equal. ! public static NullableBoolean operator == (NullableTimeSpan t1, NullableTimeSpan t2) { ! if (t1.IsNull || t2.IsNull) return NullableBoolean.Null; ! return new NullableBoolean (t1.Value == t2.Value); } ! /// <summary> ! /// Indicates whether two <see cref="NullableTimeSpan"/> instances are not equal. ! /// </summary> ! /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> ! /// <param name="t2">A <see cref="NullableTimeSpan"/>.</param> ! /// <see cref="NullableBoolean.Null"/> if either <paramref name="t1"/> or <paramref name="t2"/> are <see cref="Null"/>, ! /// <see cref="NullableBoolean.True"/> if the values of <paramref name="t1"/> and <paramref name="t2"/> are not equal, ! /// <see cref="NullableBoolean.False"/> if the values of <paramref name="t1"/> and <paramref name="t2"/> are equal. ! public static NullableBoolean operator != (NullableTimeSpan t1, NullableTimeSpan t2) { ! if (t1.IsNull || t1.IsNull) return NullableBoolean.Null; ! return new NullableBoolean (!(t1.Value == t1.Value)); } ! /// <summary> ! /// Indicates whether two <see cref="NullableTimeSpan"/> instances are equal. ! /// </summary> ! /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> ! /// <param name="t2">A <see cref="NullableTimeSpan"/>.</param> ! /// <see cref="NullableBoolean.Null"/> if either <paramref name="t1"/> or <paramref name="t2"/> are <see cref="Null"/>, ! /// <see cref="NullableBoolean.True"/> if the values of <paramref name="t1"/> and <paramref name="t2"/> are equal, ! /// <see cref="NullableBoolean.False"/> if the values of <paramref name="t1"/> and <paramref name="t2"/> are not equal. ! public static NullableBoolean Equals(NullableTimeSpan t1, NullableTimeSpan t2) { ! return (t1 == t2); } #endregion // Equivalence #region IXmlSerializable + /// <summary> /// This member supports the .NET Framework infrastructure and is not intended to be used directly *************** *** 157,162 **** sysXmlScm.XmlSchemaElement rootElement = new sysXmlScm.XmlSchemaElement(); rootElement.Name = "NullableTimeSpan"; ! rootElement.SchemaTypeName = ! new sysXml.XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); rootElement.IsNillable = true; --- 245,249 ---- sysXmlScm.XmlSchemaElement rootElement = new sysXmlScm.XmlSchemaElement(); rootElement.Name = "NullableTimeSpan"; ! rootElement.SchemaTypeName = new sysXml.XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); rootElement.IsNillable = true; *************** *** 193,197 **** string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); - sys.Console.WriteLine(elementValue); if (nilValue == null || nilValue == "false" || nilValue == "0") { _value = sysXml.XmlConvert.ToTimeSpan(elementValue); --- 280,283 ---- *************** *** 201,210 **** _notNull = false; } #endregion // IXmlSerializable #region Properties public sys.TimeSpan Value { get { ! if (this.IsNull) throw new NullableNullValueException(); --- 287,301 ---- _notNull = false; } + #endregion // IXmlSerializable #region Properties + /// <summary> + /// Contains the <see cref="System.TimeSpan"/> this instance represents if it is not <see cref="Null"/>. + /// </summary> + /// <exception cref="NullableNullValueException">instance represents <see cref="Null"/>.</exception> public sys.TimeSpan Value { get { ! if (IsNull) throw new NullableNullValueException(); *************** *** 212,240 **** } } #endregion // Properties #region Methods ! public static NullableBoolean GreaterThan(NullableTimeSpan x, NullableTimeSpan y) { ! return (x > y); } ! public static NullableBoolean GreaterThanOrEqual(NullableTimeSpan x, NullableTimeSpan y) { ! return (x >= y); } ! public static NullableBoolean LessThan(NullableTimeSpan x, NullableTimeSpan y) { ! return (x < y); } ! public static NullableBoolean LessThanOrEqual(NullableTimeSpan x, NullableTimeSpan y) { ! return (x <= y); } public static NullableTimeSpan Parse(string s) { ! return sys.TimeSpan.Parse (s); } ! public static NullableTimeSpan Add(NullableTimeSpan x, NullableTimeSpan y) { ! return (x + y); } --- 303,408 ---- } } + #endregion // Properties #region Methods ! ! /// <summary> ! /// Adds the specified <see cref="NullableTimeSpan"/> to this instance. ! /// </summary> ! /// <param name="ts">A <see cref="NullableTimeSpan"/>.</param> ! /// <returns>A <see cref="NullableTimeSpan"/> that represents the value of this instance plus the value of <paramref name="ts"/>.</returns> ! /// <exception cref="System.OverflowException">The resulting <see cref="NullableTimeSpan"/> is less than <see cref="NullableTimeSpan.MinValue"/> or greater than <see cref="NullableTimeSpan.MaxValue"/>.</exception> ! public NullableTimeSpan Add(NullableTimeSpan ts) { ! return (IsNull || ts.IsNull) ? NullableTimeSpan.Null : (_value + ts.Value); } ! /// <summary> ! /// Indicates whether a specified <see cref="NullableTimeSpan"/> is greater than another specified <see cref="NullableTimeSpan"/>. ! /// </summary> ! /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> ! /// <param name="t2">A <see cref="NullableTimeSpan"/>.</param> ! /// <returns> ! /// <see cref="NullableBoolean.True"/> if <paramref name="t1"/> is greater than <paramref name="t2"/>, ! /// <see cref="NullableBoolean.Null"/> if one or both of the instances are NullableTimeSpan.Null, ! /// <see cref="NullableBoolean.False"/> if <paramref name="t1"/> is less than or equal to <paramref name="t2"/>. ! /// </returns> ! public static NullableBoolean GreaterThan(NullableTimeSpan t1, NullableTimeSpan t2) { ! return (t1 > t2); } ! /// <summary> ! /// Indicates whether a specified <see cref="NullableTimeSpan"/> is greater than or equal to another specified <see cref="NullableTimeSpan"/>. ! /// </summary> ! /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> ! /// <param name="t2">A <see cref="NullableTimeSpan"/>.</param> ! /// <returns> ! /// <see cref="NullableBoolean.True"/> if <paramref name="t1"/> is greater than or equal to <paramref name="t2"/>, ! /// <see cref="NullableBoolean.Null"/> if one or both of the instances are NullableTimeSpan.Null, ! /// <see cref="NullableBoolean.False"/> if <paramref name="t1"/> is less than <paramref name="t2"/>. ! /// </returns> ! public static NullableBoolean GreaterThanOrEqual(NullableTimeSpan t1, NullableTimeSpan t2) { ! return (t1 >= t2); } ! /// <summary> ! /// Indicates whether a specified <see cref="NullableTimeSpan"/> is less than another specified <see cref="NullableTimeSpan"/>. ! /// </summary> ! /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> ! /// <param name="t2">A <see cref="NullableTimeSpan"/>.</param> ! /// <returns> ! /// <see cref="NullableBoolean.True"/> if <paramref name="t1"/> is less than <paramref name="t2"/>, ! /// <see cref="NullableBoolean.Null"/> if one or both of the instances are NullableTimeSpan.Null, ! /// <see cref="NullableBoolean.False"/> if <paramref name="t1"/> is greater than or equal to <paramref name="t2"/>. ! /// </returns> ! public static NullableBoolean LessThan(NullableTimeSpan t1, NullableTimeSpan t2) { ! return (t1 < t2); } + /// <summary> + /// Indicates whether a specified <see cref="NullableTimeSpan"/> is less than another specified <see cref="NullableTimeSpan"/>. + /// </summary> + /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> + /// <param name="t2">A <see cref="NullableTimeSpan"/>.</param> + /// <returns> + /// <see cref="NullableBoolean.True"/> if <paramref name="t1"/> is less than <paramref name="t2"/>, + /// <see cref="NullableBoolean.Null"/> if one or both of the instances are NullableTimeSpan.Null, + /// <see cref="NullableBoolean.False"/> if <paramref name="t1"/> is greater than or equal to <paramref name="t2"/>. + /// </returns> + public static NullableBoolean LessThanOrEqual(NullableTimeSpan t1, NullableTimeSpan t2) { + return (t1 <= t2); + } + + /// <summary> + /// Constructs a <see cref="NullableTimeSpan"/> from a time indicated by a specified string. + /// </summary> + /// <param name="s">A string.</param> + /// <returns>A <see cref="NullableTimeSpan"/> that corresponds to s.</returns> + /// <exception cref="System.ArgumentNullException">s is <see langword="null" />.</exception> + /// <exception cref="System.FormatException">s has an invalid format.</exception> + /// <exception cref="System.OverflowException"> + /// <paramref name="s"/> represents a number less than <see cref="NullableTimeSpan.MinValue"/> or greater than <see cref="NullableTimeSpan.MaxValue"/> + /// or at least one of the hours, minutes, or seconds components is outside its valid range. + /// </exception> public static NullableTimeSpan Parse(string s) { ! return sys.TimeSpan.Parse(s); } ! /// <summary> ! /// Subtracts the specified <see cref="NullableTimeSpan"/> from this instance. ! /// </summary> ! /// <param name="ts">A <see cref="NullableTimeSpan"/>.</param> ! /// <returns>A <see cref="NullableTimeSpan"/> whose value is the result of the value of this instance minus the value of <paramref name="ts"/>.</returns> ! /// <exception cref="System.OverflowException">The resulting <see cref="NullableTimeSpan"/> is less than <see cref="NullableTimeSpan.MinValue"/> or greater than <see cref="NullableTimeSpan.MaxValue"/>.</exception> ! public NullableTimeSpan Subtract(NullableTimeSpan ts) { ! return (IsNull || ts.IsNull) ? NullableTimeSpan.Null : (_value - ts.Value); ! } ! ! /// <summary> ! /// Returns a hash code for this instance. ! /// </summary> ! /// <returns>A 32-bit signed integer hash code.</returns> ! public override int GetHashCode() { ! return _value.GetHashCode(); } *************** *** 242,318 **** #region Operators - public static NullableTimeSpan operator + (NullableTimeSpan x, NullableTimeSpan y) { - if (x.IsNull || y.IsNull) - return NullableTimeSpan.Null; ! checked { ! return new NullableTimeSpan(x.Value + y.Value); ! } } ! public static NullableTimeSpan operator - (NullableTimeSpan x, NullableTimeSpan y) { ! if (x.IsNull || y.IsNull) ! return NullableTimeSpan.Null; ! ! checked { ! return new NullableTimeSpan(x.Value - y.Value); ! } } ! public static NullableBoolean operator > (NullableTimeSpan x, NullableTimeSpan y) { ! if (x.IsNull || y.IsNull) ! return NullableBoolean.Null; ! ! if (x.Value.CompareTo (y.Value) > 0) ! return new NullableBoolean (true); ! else ! return new NullableBoolean (false); } ! public static NullableBoolean operator >= (NullableTimeSpan x, NullableTimeSpan y) { ! if (x.IsNull || y.IsNull) ! return NullableBoolean.Null; ! ! if (x.Value.CompareTo (y.Value) >= 0) ! return new NullableBoolean (true); ! else ! return new NullableBoolean (false); } ! public static NullableBoolean operator < (NullableTimeSpan x, NullableTimeSpan y) { ! if (x.IsNull || y.IsNull) ! return NullableBoolean.Null; ! ! if (x.Value.CompareTo (y.Value) < 0) ! return new NullableBoolean (true); ! else ! return new NullableBoolean (false); } ! public static NullableBoolean operator <= (NullableTimeSpan x, NullableTimeSpan y) { ! if (x.IsNull || y.IsNull) ! return NullableBoolean.Null; ! ! if (x.Value.CompareTo (y.Value) <= 0) ! return new NullableBoolean (true); ! else ! return new NullableBoolean (false); } #endregion // Operators #region Conversion Operators ! public static explicit operator sys.TimeSpan(NullableTimeSpan x) { ! return x.Value; } ! public static explicit operator NullableTimeSpan(NullableString x) { ! if (x.IsNull) ! return NullableTimeSpan.Null; ! else ! return NullableTimeSpan.Parse (x.Value); } ! public static implicit operator NullableTimeSpan(sys.TimeSpan x) { ! return new NullableTimeSpan (x); } --- 410,543 ---- #region Operators ! /// <summary> ! /// Adds two specified <see cref="NullableTimeSpan"/> instances. ! /// </summary> ! /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> ! /// <param name="t2">A NullableTimeSpan.</param> ! /// <returns>A <see cref="NullableTimeSpan"/> whose value is the sum of the values of <paramref name="t1"/> and <paramref name="t2"/> or ! /// <see cref="NullableTimeSpan.Null"/> if either instance is <see cref="NullableTimeSpan.Null"/>. ! ///</returns> ! /// <exception cref="System.OverflowException">The resulting <see cref="NullableTimeSpan"/> is less than <see cref="NullableTimeSpan.MinValue"/> or greater than <see cref="NullableTimeSpan.MaxValue"/>.</exception> ! public static NullableTimeSpan operator + (NullableTimeSpan t1, NullableTimeSpan t2) { ! return (t1.IsNull || t2.IsNull) ? NullableTimeSpan.Null : new NullableTimeSpan(t1.Value + t2.Value); } ! /// <summary> ! /// Subtracts a specified <see cref="NullableTimeSpan"/> from another specified <see cref="NullableTimeSpan"/>. ! /// </summary> ! /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> ! /// <param name="t2">A <see cref="NullableTimeSpan"/>.</param> ! /// <returns>A <see cref="NullableTimeSpan"/> whose value is the result of the value of <paramref name="t1"/> minus the value of <paramref name="t2"/> or ! /// <see cref="NullableTimeSpan.Null"/> if either instance is <see cref="NullableTimeSpan.Null"/>. ! ///</returns> ! /// <exception cref="System.OverflowException">The resulting <see cref="NullableTimeSpan"/> is less than <see cref="NullableTimeSpan.MinValue"/> or greater than <see cref="NullableTimeSpan.MaxValue"/>.</exception> ! public static NullableTimeSpan operator - (NullableTimeSpan t1, NullableTimeSpan t2) { ! return (t1.IsNull || t2.IsNull) ? NullableTimeSpan.Null : new NullableTimeSpan(t1.Value - t2.Value); } ! /// <summary> ! /// Indicates whether a specified <see cref="NullableTimeSpan"/> is greater than another specified <see cref="NullableTimeSpan"/>. ! /// </summary> ! /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> ! /// <param name="t2">A <see cref="NullableTimeSpan"/>.</param> ! /// <returns> ! /// <see cref="NullableBoolean.True"/> if <paramref name="t1"/> is greater than <paramref name="t2"/>, ! /// <see cref="NullableBoolean.Null"/> if one or both of the instances are NullableTimeSpan.Null, ! /// <see cref="NullableBoolean.False"/> if <paramref name="t1"/> is less than or equal to <paramref name="t2"/>. ! /// </returns> ! public static NullableBoolean operator > (NullableTimeSpan t1, NullableTimeSpan t2) { ! return (t1.IsNull || t2.IsNull) ? NullableBoolean.Null : new NullableBoolean(t1.Value.CompareTo(t2.Value) > 0); } ! /// <summary> ! /// Indicates whether a specified <see cref="NullableTimeSpan"/> is greater than or equal to another specified <see cref="NullableTimeSpan"/>. ! /// </summary> ! /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> ! /// <param name="t2">A <see cref="NullableTimeSpan"/>.</param> ! /// <returns> ! /// <see cref="NullableBoolean.True"/> if <paramref name="t1"/> is greater than or equal to <paramref name="t2"/>, ! /// <see cref="NullableBoolean.Null"/> if one or both of the instances are NullableTimeSpan.Null, ! /// <see cref="NullableBoolean.False"/> if <paramref name="t1"/> is less than <paramref name="t2"/>. ! /// </returns> ! public static NullableBoolean operator >= (NullableTimeSpan t1, NullableTimeSpan t2) { ! return (t1.IsNull || t2.IsNull) ? NullableBoolean.Null : new NullableBoolean(t1.Value.CompareTo (t2.Value) >= 0); } ! /// <summary> ! /// Indicates whether a specified <see cref="NullableTimeSpan"/> is less than another specified <see cref="NullableTimeSpan"/>. ! /// </summary> ! /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> ! /// <param name="t2">A <see cref="NullableTimeSpan"/>.</param> ! /// <returns> ! /// <see cref="NullableBoolean.True"/> if <paramref name="t1"/> is less than <paramref name="t2"/>, ! /// <see cref="NullableBoolean.Null"/> if one or both of the instances are NullableTimeSpan.Null, ! /// <see cref="NullableBoolean.False"/> if <paramref name="t1"/> is greater than or equal to <paramref name="t2"/>. ! /// </returns> ! public static NullableBoolean operator < (NullableTimeSpan t1, NullableTimeSpan t2) { ! return (t1.IsNull || t2.IsNull) ? NullableBoolean.Null : new NullableBoolean(t1.Value.CompareTo(t2.Value) < 0); } ! /// <summary> ! /// Indicates whether a specified <see cref="NullableTimeSpan"/> is less than another specified <see cref="NullableTimeSpan"/>. ! /// </summary> ! /// <param name="t1">A <see cref="NullableTimeSpan"/>.</param> ! /// <param name="t2">A <see cref="NullableTimeSpan"/>.</param> ! /// <returns> ! /// <see cref="NullableBoolean.True"/> if <paramref name="t1"/> is less than <paramref name="t2"/>, ! /// <see cref="NullableBoolean.Null"/> if one or both of the instances are NullableTimeSpan.Null, ! /// <see cref="NullableBoolean.False"/> if <paramref name="t1"/> is greater than or equal to <paramref name="t2"/>. ! /// </returns> ! public static NullableBoolean operator <= (NullableTimeSpan t1, NullableTimeSpan t2) { ! return (t1.IsNull || t2.IsNull) ? NullableBoolean.Null : new NullableBoolean(t1.Value.CompareTo(t2.Value) <= 0); } + #endregion // Operators #region Conversion Operators ! ! /// <summary> ! /// Converts the specified <see cref="NullableTimeSpan"/> to a <see cref="System.TimeSpan"/>. ! /// </summary> ! /// <param name="ts">A <see cref="NullableTimeSpan"/> to convert.</param> ! /// <returns> ! /// A <see cref="System.TimeSpan"/> set to the <see cref="Value"/> of the ! /// <see cref="NullableTimeSpan"/>. ! /// </returns> ! /// <exception cref="NullableNullValueException"><paramref name="ts"/> is <see cref="Null"/>.</exception> ! public static explicit operator sys.TimeSpan(NullableTimeSpan ts) { ! return ts.Value; } ! /// <summary> ! /// Converts the specified <see cref="NullableString"/> to a <see cref="NullableTimeSpan"/>. ! /// </summary> ! /// <param name="s">A <see cref="NullableString"/> to convert.</param> ! /// <returns> ! /// <see cref="Null"/> if <paramref name="x"/> is ! /// <see cref="NullableString.Null"/> otherwise a new ! /// <see cref="NullableTimeSpan"/> structure containing the parsed value. ! /// </returns> ! /// <exception cref="System.FormatException"> ! /// <paramref name="s"/>does not consist solely of an optional sign followed ! /// by a sequence of digits ranging from 0 to 9. ! /// </exception> ! /// <exception cref="System.OverflowException"><paramref name="s"/>represents a timespan less than ! /// <see cref="NullableTimeSpan.MinValue"/> or greater than <see cref="NullableTimeSpan.MaxValue"/>. ! /// </exception> ! public static explicit operator NullableTimeSpan(NullableString s) { ! return (s.IsNull) ? NullableTimeSpan.Null : NullableTimeSpan.Parse(s.Value); } ! /// <summary> ! /// Converts the <see cref="System.TimeSpan"/> parameter to a ! /// <see cref="NullableTimeSpan"/> structure. ! /// </summary> ! /// <param name="ts">A <see cref="System.TimeSpan"/> to convert.</param> ! /// <returns> ! /// A new <see cref="NullableTimeSpan"/> constructed from <paramref name="ts"/>. ! /// </returns> ! public static implicit operator NullableTimeSpan(sys.TimeSpan ts) { ! return new NullableTimeSpan(ts); } *************** *** 320,342 **** #region Conversions /// <summary> ! /// Converts to a NullableString representing the time span. /// </summary> ! /// <returns>A NullableString representative of the NullableTimeSpan.</returns> ! public NullableString ToNullableString () { return (NullableString) this; } /// <summary> ! /// Converts the NullableTimeSpan value to a string. /// </summary> ! /// <returns>A string representative of the NullableTimeSpan.</returns> ! public override string ToString () { ! if (this.IsNull) ! return Locale.GetText("Null"); ! else ! return _value.ToString (); } #endregion // Conversions } ! } --- 545,566 ---- #region Conversions + /// <summary> ! /// Returns the <see cref="NullableString"/> representation of this instance. /// </summary> ! /// <returns>A <see cref="NullableString"/> that represents this instance.</returns> ! public NullableString ToNullableString() { return (NullableString) this; } /// <summary> ! /// Returns the string representation of the value of this instance. /// </summary> ! /// <returns>A string that represents this instance.</returns> ! public override string ToString() { ! return (IsNull) ? Locale.GetText("Null") : _value.ToString(); } + #endregion // Conversions } ! } \ No newline at end of file |
From: Damien G. <dam...@us...> - 2005-10-06 16:05:50
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1576/src/Tests Modified Files: DBNullConvertTest.cs NullConvertTest.cs Tests.csproj Added Files: NullableTimeSpanTest.cs Log Message: Implement NullableTimeSpan as per issue 1278920. Index: Tests.csproj =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/Tests.csproj,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Tests.csproj 12 Feb 2005 03:44:34 -0000 1.27 --- Tests.csproj 6 Oct 2005 16:05:35 -0000 1.28 *************** *** 195,198 **** --- 195,203 ---- /> <File + RelPath = "NullableTimeSpanTest.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "NullableTypeExceptionTest.cs" SubType = "Code" Index: DBNullConvertTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/DBNullConvertTest.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DBNullConvertTest.cs 23 Sep 2005 09:47:21 -0000 1.3 --- DBNullConvertTest.cs 6 Oct 2005 16:05:35 -0000 1.4 *************** *** 10,13 **** --- 10,14 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces // 05-Sep-2005 DamienG Upgrade Added tests for NullableGuid conversion + // 26-Sep-2005 DamienG Upgrade Added tests for NullableTimeSpan conversion // *************** *** 513,516 **** --- 514,554 ---- } + [nu.Test] + public void ToNullableTimeSpan() + { + _dbTable.Columns.Add("System.TimeSpan", typeof(sys.TimeSpan)); + + _dbTable.Rows.Add(new object[] {sys.TimeSpan.Zero}); + nua.AssertEquals( + "TestA#101", + NullableTimeSpan.Zero, + DBNullConvert.ToNullableTimeSpan(_dbTable.Rows[_dbTable.Rows.Count-1][0])); + + _dbTable.Rows.Add(new object[] {sys.DBNull.Value}); + nua.AssertEquals( + "TestA#102", + NullableTimeSpan.Null, + DBNullConvert.ToNullableTimeSpan(_dbTable.Rows[_dbTable.Rows.Count-1][0])); + + _dbTable.Rows.Add(new object[] {null}); + nua.AssertEquals( + "TestA#103", + NullableTimeSpan.Null, + DBNullConvert.ToNullableTimeSpan(_dbTable.Rows[_dbTable.Rows.Count-1][0])); + } + + + [nu.Test, nu.ExpectedException(typeof(sys.FormatException))] + public void ToNullableTimeSpanInvalidCastException() + { + DBNullConvert.ToNullableTimeSpan("invalid"); + } + + + [nu.Test, nu.ExpectedException(typeof(sys.ArgumentNullException))] + public void ToNullableTimeSpanArgumentNullException() + { + DBNullConvert.ToNullableTimeSpan(null); + } #endregion // DbValue to NullableTypes Tests - A# *************** *** 669,672 **** --- 707,723 ---- } + [nu.Test] + public void FromNullableTimeSpan() + { + nua.AssertEquals("TestB#091", + sys.DBNull.Value, + DBNullConvert.From(NullableString.Null)); + nua.AssertEquals("TestB#092", + System.TimeSpan.Zero, + DBNullConvert.From(NullableTimeSpan.Zero)); + nua.AssertEquals("TestB#093", + "4D38949B-1749-4496-9FD6-B3DA1275708C", + DBNullConvert.From(new NullableString("4D38949B-1749-4496-9FD6-B3DA1275708C"))); + } #endregion // DbValue from NullableTypes Tests - B# Index: NullConvertTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullConvertTest.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NullConvertTest.cs 7 Oct 2003 20:32:21 -0000 1.8 --- NullConvertTest.cs 6 Oct 2005 16:05:35 -0000 1.9 *************** *** 445,449 **** NullConvert.ToNullableDateTime("9" + sys.DateTime.MaxValue.ToString("yyyy-MMM-dd"), string.Empty); } ! #endregion // Non nullable built-in types to NullableTypes #region NullableTypes to non nullable built-in types - B# --- 445,459 ---- NullConvert.ToNullableDateTime("9" + sys.DateTime.MaxValue.ToString("yyyy-MMM-dd"), string.Empty); } ! ! [nu.Test] ! public void ToNullableGuid() { ! sys.Guid conventionalNullGuid = sys.Guid.NewGuid(); ! nua.AssertEquals("TestA#210", NullableGuid.Null, NullConvert.ToNullableGuid(conventionalNullGuid, conventionalNullGuid)); ! ! sys.Guid conventionalGuid = sys.Guid.NewGuid(); ! nua.AssertEquals("TestA#211", new NullableGuid(conventionalGuid).Value, NullConvert.ToNullableGuid(conventionalGuid, conventionalNullGuid)); ! } ! ! #endregion // Non nullable built-in types to NullableTypes #region NullableTypes to non nullable built-in types - B# *************** *** 584,587 **** --- 594,607 ---- } + [nu.Test] + public void FromNullableGuid() { + sys.Guid testGuid = sys.Guid.NewGuid(); + + nua.AssertEquals("TestB#097", sys.Guid.Empty, NullConvert.From(NullableGuid.Null, sys.Guid.Empty)); + nua.AssertEquals("TestB#098", null, NullConvert.From(NullableGuid.Null, null, "")); + nua.AssertEquals("TestB#099", sys.Guid.Empty, NullConvert.From(NullableGuid.Empty, testGuid)); + nua.AssertEquals("TestB#100", testGuid, NullConvert.From(testGuid, null, "")); + } + #endregion // NullableTypes to non nullable built-in types --- NEW FILE: NullableTimeSpanTest.cs --- // // NullableTypes.Tests.NullableTimeSpanTest // // Authors: Luca Minudel (luk...@us...) // Damien Guard (dam...@us...) // // Date Author Changes Reasons // 29-Sep-2005 DamienG Create // namespace NullableTypes.Tests { using nu = NUnit.Framework; using nua = NUnit.Framework.Assertion; using sys = System; using sysXml = System.Xml; using sysXmlScm = System.Xml.Schema; [nu.TestFixture] public class NullableTimeSpanTest { NullableTimeSpan _pos; NullableTimeSpan _bigPos; NullableTimeSpan _neg; NullableTimeSpan _bigNeg; NullableTimeSpan _zero; NullableTimeSpan _null; NullableTimeSpan _min; NullableTimeSpan _max; [nu.SetUp] public void SetUp() { _pos = new NullableTimeSpan(857423345343); _bigPos = _pos + _pos; _neg = new NullableTimeSpan(-3223422343234); _bigNeg = _neg + _neg; _zero = new NullableTimeSpan(0); _null = NullableTimeSpan.Null; _min = NullableTimeSpan.MinValue; _max = NullableTimeSpan.MaxValue; } #region Field Tests - A# [nu.Test] public void FieldMax() { nua.AssertEquals("TestA#01", sys.TimeSpan.MaxValue, NullableTimeSpan.MaxValue.Value); } [nu.Test] public void FieldMin() { nua.AssertEquals("TestA#02", sys.TimeSpan.MinValue, NullableTimeSpan.MinValue.Value); } [nu.Test] public void NullField() { nua.Assert("TestA#03", NullableTimeSpan.Null.IsNull); } [nu.Test] public void ZeroField() { nua.AssertEquals("TestA#04", new sys.TimeSpan(0), NullableTimeSpan.Zero.Value); nua.AssertEquals("TestA#05", _zero.Value, NullableTimeSpan.Zero.Value); } #endregion // Field Tests - A# #region Constructor Tests - B# [nu.Test] public void Create() { sys.TimeSpan createFromTimeSpan = new System.TimeSpan(5, 6, 7, 8); NullableTimeSpan createdFromTimeSpan = new NullableTimeSpan(createFromTimeSpan); nua.AssertEquals("TestB#03", createFromTimeSpan, createdFromTimeSpan.Value); // TODO } #endregion // Constructor Tests - B# #region INullable Tests - C# public void IsNullProperty() { nua.Assert ("TestC#01", _null.IsNull); nua.Assert ("TestC#02", !_pos.IsNull); } #endregion // INullable Tests - C# #region IComparable - Ordering Tests - D# [nu.Test] public void Compare() { nua.Assert("TestD#01", (((sys.IComparable)_pos).CompareTo(_null) > 0)); nua.Assert("TestD#02", (((sys.IComparable)_pos).CompareTo(_neg) > 0)); nua.Assert("TestD#03", (((sys.IComparable)_pos).CompareTo(_bigPos) < 0)); nua.Assert("TestD#04", (((sys.IComparable)_pos).CompareTo(_pos) == 0)); nua.Assert("TestD#05", (((sys.IComparable)_null).CompareTo(_pos) < 0)); nua.Assert("TestD#06", (((sys.IComparable)_null).CompareTo(_neg) < 0)); nua.Assert("TestD#07", (((sys.IComparable)_null).CompareTo(NullableTimeSpan.Null) == 0)); nua.Assert("TestD#08", (((sys.IComparable)_neg).CompareTo(_null) > 0)); nua.Assert("TestD#09", (((sys.IComparable)_neg).CompareTo(_zero) < 0)); nua.Assert("TestD#11", (((sys.IComparable)_neg).CompareTo(_bigNeg) > 0)); nua.Assert("TestD#12", (((sys.IComparable)_neg).CompareTo(_neg) == 0)); } [nu.Test] [nu.ExpectedException(typeof(sys.ArgumentException))] public void CompareToWrongType() { ((sys.IComparable)_null).CompareTo(1); } #endregion // IComparable - Ordering Tests - D# #region Property Tests - E# // Value property [nu.Test] public void ValueProperty() { NullableTimeSpan maxTimeSpan = new NullableTimeSpan(sys.TimeSpan.MaxValue); nua.AssertEquals("TestE#01", sys.TimeSpan.MaxValue, maxTimeSpan.Value); NullableTimeSpan minTimeSpan = new NullableTimeSpan(sys.TimeSpan.MinValue); nua.AssertEquals("TestE#02", sys.TimeSpan.MinValue, minTimeSpan.Value); long i = 8276340; nua.AssertEquals("TestE#03", new sys.TimeSpan(i), new NullableTimeSpan(i).Value); } [nu.Test] [nu.ExpectedException(typeof(NullableTypes.NullableNullValueException))] public void ValuePropertyNull() { sys.TimeSpan iVal = _null.Value; } #endregion // Property Tests - E# #region Equivalence Tests - F# [nu.Test] public void StaticEqualsAndEqualityOperator() { // Case 1: either is NullableTimeSpan.Null nua.AssertEquals("TestF#01", NullableBoolean.Null, _null == _zero); nua.AssertEquals("TestF#02", NullableBoolean.Null, NullableTimeSpan.Equals(_neg, _null)); nua.AssertEquals("TestF#03", NullableBoolean.Null, NullableTimeSpan.NotEquals(_neg, _null)); // Case 2: both are NullableTimeSpan.Null nua.AssertEquals("TestF#04", NullableBoolean.Null, _null == NullableTimeSpan.Null); nua.AssertEquals("TestF#05", NullableBoolean.Null, NullableTimeSpan.Equals(NullableTimeSpan.Null, _null)); nua.AssertEquals("TestF#06", NullableBoolean.Null, NullableTimeSpan.NotEquals(NullableTimeSpan.Null, _null)); // Case 3: both are equal NullableTimeSpan x = _pos; nua.AssertEquals ("TestF#07", NullableBoolean.True, x == _pos); nua.AssertEquals ("TestF#08", NullableBoolean.True, NullableTimeSpan.Equals(_pos, x)); nua.AssertEquals ("TestF#09", NullableBoolean.False, NullableTimeSpan.NotEquals(_pos, x)); // Case 4: inequality nua.AssertEquals ("TestF#10", NullableBoolean.False, _zero == _neg); nua.AssertEquals ("TestF#11", NullableBoolean.False, NullableTimeSpan.Equals(_pos, _neg)); nua.AssertEquals ("TestF#12", NullableBoolean.True, NullableTimeSpan.NotEquals(_pos, _neg)); } [nu.Test] public void Equals() { // Case 1: either is NullableTimeSpan.Null nua.Assert("TestF#101", !_null.Equals(_zero)); nua.Assert("TestF#102", !_neg.Equals(_null)); // Case 2: both are NullableTimeSpan.Null nua.Assert("TestF#103", _null.Equals(NullableTimeSpan.Null)); nua.Assert("TestF#104", NullableTimeSpan.Null.Equals(_null)); // Case 3: both are equal NullableTimeSpan x = _pos; nua.Assert("TestF#105", x.Equals(_pos)); nua.Assert("TestF#106", _pos.Equals(x)); // Case 4: inequality nua.Assert("TestF#107", !_zero.Equals(_neg)); nua.Assert("TestF#108", !_pos.Equals(_neg)); } #endregion // Equivalence Tests - F# #region Method Tests - G# [nu.Test] public void Add() { long ix = -97643554; long iy = 20; NullableTimeSpan x = new NullableTimeSpan(ix); NullableTimeSpan y = new NullableTimeSpan(iy);; nua.AssertEquals("TestG#01", new sys.TimeSpan(ix + iy), NullableTimeSpan.Add(x,y).Value); } [nu.Test] public void GreaterThan() { long ix = -9537095; long iy = 2143; NullableTimeSpan x = new NullableTimeSpan(ix); NullableTimeSpan y = new NullableTimeSpan(iy); nua.AssertEquals ("TestG#40", ix > iy, NullableTimeSpan.GreaterThan(x,y).Value); } [nu.Test] public void GreaterThanOrEquals() { long ix = -954537095; long iy = 143; NullableTimeSpan x = new NullableTimeSpan(ix); NullableTimeSpan y = new NullableTimeSpan(iy); nua.AssertEquals ("TestG#51", ix >= iy, NullableTimeSpan.GreaterThanOrEqual(x,y).Value); nua.AssertEquals ("TestG#52", ix >= ix, NullableTimeSpan.GreaterThanOrEqual(x,x).Value); } [nu.Test] public void LessThan() { long ix = 8450; long iy = 6797346; NullableTimeSpan x = new NullableTimeSpan(ix); NullableTimeSpan y = new NullableTimeSpan(iy); nua.AssertEquals ("TestG#60", ix < iy, NullableTimeSpan.LessThan(x,y).Value); } [nu.Test] public void LessThanOrEquals() { long ix = 413236524; long iy = 143; NullableTimeSpan x = new NullableTimeSpan(ix); NullableTimeSpan y = new NullableTimeSpan(iy); nua.AssertEquals ("TestG#71", ix <= iy, NullableTimeSpan.LessThanOrEqual(x,y).Value); nua.AssertEquals ("TestG#72", ix <= ix, NullableTimeSpan.LessThanOrEqual(x,x).Value); } [nu.Test] public void Parse() { sys.TimeSpan ts = new sys.TimeSpan(-5,7,22,11,14); nua.AssertEquals ("TestG#130", ts, NullableTimeSpan.Parse(ts.ToString()).Value); } [nu.Test, nu.ExpectedException(typeof(sys.ArgumentNullException))] public void ParseArgumentNullException() { string sx = null; NullableTimeSpan.Parse(sx); } [nu.Test, nu.ExpectedException(typeof(sys.FormatException))] public void ParseFormatException() { string sx = "409'85"; NullableTimeSpan.Parse(sx); } [nu.Test, nu.ExpectedException(typeof(sys.OverflowException))] public void ParseOverflowException() { string sx = (long.MaxValue + 1M).ToString(); NullableTimeSpan.Parse(sx); } #endregion // Method Tests - G# #region Operator Tests - H# [nu.Test] public void AddOperator() { long ix = 23522342343; long iy = -122343; NullableTimeSpan nx = new NullableTimeSpan(ix); NullableTimeSpan ny = new NullableTimeSpan(iy); // Add nullable ints nua.AssertEquals("TestH#01", new sys.TimeSpan(ix + iy), (nx + ny).Value); nua.AssertEquals("TestH#02", new sys.TimeSpan(ix), (nx + _zero).Value); // Add Nulls nua.Assert("TestH#03", (nx + _null).IsNull); nua.Assert("TestH#04", (_null + ny).IsNull); nua.Assert("TestH#05", (_null + NullableTimeSpan.Null).IsNull); } [nu.Test, nu.ExpectedException(typeof(sys.OverflowException))] public void AddOperatorOverflow() { long ix = long.MaxValue; long iy = 1; NullableTimeSpan nx = new NullableTimeSpan(ix); NullableTimeSpan ny = new NullableTimeSpan(iy); NullableTimeSpan nz = nx + ny; } [nu.Test] public void GreaterThanOperator() { // GreaterThan nulls nua.Assert("TestH#51", (_pos > _null).IsNull); nua.Assert("TestH#52", (_null > _zero).IsNull); nua.Assert("TestH#53", (_null > _neg).IsNull); nua.Assert("TestH#54", (_null > NullableTimeSpan.Null).IsNull); // GreaterThan nullable ints nua.Assert("TestH#55", (_pos > _neg).IsTrue); nua.Assert("TestH#56", (_pos > _bigPos).IsFalse); nua.Assert("TestH#57", (_pos > _pos).IsFalse); nua.Assert("TestH#59", (_neg > _zero).IsFalse); nua.Assert("TestH#60", (_neg > _bigNeg).IsTrue); nua.Assert("TestH#61", (_neg > _neg).IsFalse); // GreaterThan ints nua.Assert("TestH#62", (_pos > _neg.Value).IsTrue); nua.Assert("TestH#63", (_pos > _bigPos.Value).IsFalse); nua.Assert("TestH#64", (_pos > _pos.Value).IsFalse); nua.Assert("TestH#65", (_neg > _zero.Value).IsFalse); nua.Assert("TestH#66", (_neg > _bigNeg.Value).IsTrue); nua.Assert("TestH#67", (_neg > _neg.Value).IsFalse); } [nu.Test] public void GreaterThanOrEqualsOperator() { // GreaterThanOrEquals nulls nua.Assert("TestH#71", (_pos >= _null).IsNull); nua.Assert("TestH#72", (_null >= _zero).IsNull); nua.Assert("TestH#73", (_null >= _neg).IsNull); nua.Assert("TestH#74", (_null >= NullableTimeSpan.Null).IsNull); // GreaterThanOrEquals nullable ints nua.Assert("TestH#75", (_pos >= _neg).IsTrue); nua.Assert("TestH#76", (_pos >= _bigPos).IsFalse); nua.Assert("TestH#77", (_pos >= _pos).IsTrue); nua.Assert("TestH#79", (_neg >= _zero).IsFalse); nua.Assert("TestH#80", (_neg >= _bigNeg).IsTrue); nua.Assert("TestH#81", (_neg >= _neg).IsTrue); // GreaterThanOrEquals ints nua.Assert("TestH#82", (_pos >= _neg.Value).IsTrue); nua.Assert("TestH#83", (_pos >= _bigPos.Value).IsFalse); nua.Assert("TestH#84", (_pos >= _pos.Value).IsTrue); nua.Assert("TestH#85", (_neg >= _zero.Value).IsFalse); nua.Assert("TestH#86", (_neg >= _bigNeg.Value).IsTrue); nua.Assert("TestH#87", (_neg >= _neg.Value).IsTrue); } [nu.Test] public void LessThanOperator() { // LessThan nulls nua.Assert("TestH#91", (_pos < _null).IsNull); nua.Assert("TestH#92", (_null < _zero).IsNull); nua.Assert("TestH#93", (_null < _neg).IsNull); nua.Assert("TestH#94", (_null < NullableTimeSpan.Null).IsNull); // LessThan nullable ints nua.Assert("TestH#95", (_pos < _neg).IsFalse); nua.Assert("TestH#96", (_pos < _bigPos).IsTrue); nua.Assert("TestH#97", (_pos < _pos).IsFalse); nua.Assert("TestH#99", (_neg < _zero).IsTrue); nua.Assert("TestH#100", (_neg < _bigNeg).IsFalse); nua.Assert("TestH#101", (_neg < _neg).IsFalse); // LessThan ints nua.Assert("TestH#102", (_pos < _neg.Value).IsFalse); nua.Assert("TestH#103", (_pos < _bigPos.Value).IsTrue); nua.Assert("TestH#104", (_pos < _pos.Value).IsFalse); nua.Assert("TestH#105", (_neg < _zero.Value).IsTrue); nua.Assert("TestH#106", (_neg < _bigNeg.Value).IsFalse); nua.Assert("TestH#107", (_neg < _neg.Value).IsFalse); } [nu.Test] public void LessThanOrEqualsOperator() { // LessThanOrEquals nulls nua.Assert("TestH#111", (_pos <= _null).IsNull); nua.Assert("TestH#112", (_null <= _zero).IsNull); nua.Assert("TestH#113", (_null <= _neg).IsNull); nua.Assert("TestH#114", (_null <= NullableTimeSpan.Null).IsNull); // LessThanOrEquals nullable ints nua.Assert("TestH#115", (_pos <= _neg).IsFalse); nua.Assert("TestH#116", (_pos <= _bigPos).IsTrue); nua.Assert("TestH#117", (_pos <= _pos).IsTrue); nua.Assert("TestH#119", (_neg <= _zero).IsTrue); nua.Assert("TestH#120", (_neg <= _bigNeg).IsFalse); nua.Assert("TestH#121", (_neg <= _neg).IsTrue); // LessThanOrEquals ints nua.Assert("TestH#122", (_pos <= _neg.Value).IsFalse); nua.Assert("TestH#123", (_pos <= _bigPos.Value).IsTrue); nua.Assert("TestH#124", (_pos <= _pos.Value).IsTrue); nua.Assert("TestH#125", (_neg <= _zero.Value).IsTrue); nua.Assert("TestH#126", (_neg <= _bigNeg.Value).IsFalse); nua.Assert("TestH#127", (_neg <= _neg.Value).IsTrue); } [nu.Test] public void SubtractionOperator() { sys.TimeSpan ix = new sys.TimeSpan(985); sys.TimeSpan iy = new sys.TimeSpan(-4534); NullableTimeSpan nx = new NullableTimeSpan(ix); NullableTimeSpan ny = new NullableTimeSpan(iy); // Subtraction nullable ints nua.AssertEquals("TestH#161", (ix - iy), (nx - ny).Value); nua.AssertEquals("TestH#162", ix, (nx - _zero).Value); // Subtraction Nulls nua.Assert("TestH#163", (nx - _null).IsNull); nua.Assert("TestH#164", (_null - ny).IsNull); nua.Assert("TestH#165", (_null - NullableTimeSpan.Null).IsNull); } [nu.Test, nu.ExpectedException(typeof(sys.OverflowException))] public void SubtractionOperatorOverflow() { NullableTimeSpan nz = NullableTimeSpan.MinValue - new NullableTimeSpan(1); } #endregion // Operator Tests - H# #region Conversion Operator Tests - I# [nu.Test] public void NullableStringConversionOperator() { nua.AssertEquals ("TestI#71", NullableTimeSpan.Null, (NullableTimeSpan)NullableString.Null); sys.TimeSpan ix = new sys.TimeSpan(95795); NullableString nx = new NullableString(ix.ToString()); nua.AssertEquals("TestI#72", ix, ((NullableTimeSpan)nx).Value); } [nu.Test, nu.ExpectedException(typeof(sys.OverflowException))] public void NullableStringConversionOperatorOverflowException() { NullableString nx = new NullableString((long.MaxValue + 1M).ToString()); NullableTimeSpan ny = (NullableTimeSpan)nx; } #endregion // Conversion Operator Tests - I# #region Conversion Tests - J# [nu.Test] public void ToNullableString() { sys.TimeSpan i = new sys.TimeSpan(14,07,59,11,12); NullableTimeSpan n = new NullableTimeSpan(i); nua.AssertEquals("TestJ#81", NullableString.Null, _null.ToNullableString()); nua.AssertEquals("TestJ#82", i.ToString(), n.ToNullableString().Value); nua.AssertEquals("TestJ#83", new NullableString(i.ToString()), n.ToNullableString()); } [nu.Test] public void ToStringTest() { sys.TimeSpan i = new sys.TimeSpan(12,4,234,6,999); nua.AssertEquals("TestJ#91", "Null", _null.ToString()); nua.AssertEquals("TestJ#92", i.ToString(), new NullableTimeSpan(i).ToString()); } #endregion // Conversion Tests - J# #region Serialization - K# [nu.Test] public void SerializableAttribute() { NullableTimeSpan serializedDeserialized; serializedDeserialized = SerializeDeserialize(_null); nua.Assert("TestK#01", serializedDeserialized.IsNull); nua.Assert("TestK#02", _null.Equals(serializedDeserialized)); serializedDeserialized = SerializeDeserialize(_zero); nua.Assert("TestK#03", !serializedDeserialized.IsNull); nua.AssertEquals("TestK#04", _zero.Value, serializedDeserialized.Value); nua.Assert("TestK#05", _zero.Equals(serializedDeserialized)); serializedDeserialized = SerializeDeserialize(_pos); nua.Assert("TestK#06", !serializedDeserialized.IsNull); nua.AssertEquals("TestK#07", _pos.Value, serializedDeserialized.Value); nua.Assert("TestK#08", _pos.Equals(serializedDeserialized)); serializedDeserialized = SerializeDeserialize(_neg); nua.Assert("TestK#09", !serializedDeserialized.IsNull); nua.AssertEquals("TestK#10", _neg.Value, serializedDeserialized.Value); nua.Assert("TestK#11", _neg.Equals(serializedDeserialized)); serializedDeserialized = SerializeDeserialize(_min); nua.Assert("TestK#12", !serializedDeserialized.IsNull); nua.AssertEquals("TestK#13", _min.Value, serializedDeserialized.Value); nua.Assert("TestK#14", _min.Equals(serializedDeserialized)); serializedDeserialized = SerializeDeserialize(_max); nua.Assert("TestK#15", !serializedDeserialized.IsNull); nua.AssertEquals("TestK#16", _max.Value, serializedDeserialized.Value); nua.Assert("TestK#17", _max.Equals(serializedDeserialized)); } private NullableTimeSpan SerializeDeserialize(NullableTimeSpan x) { System.Runtime.Serialization.Formatters.Soap.SoapFormatter serializer = new System.Runtime.Serialization.Formatters.Soap.SoapFormatter(); using (sys.IO.MemoryStream stream = new sys.IO.MemoryStream()) { serializer.Serialize(stream, x); // sys.Text.Decoder d = sys.Text.Encoding.Default.GetDecoder(); // char[] output = new char[d.GetCharCount(stream.GetBuffer(), 0, (int)stream.Length)]; // d.GetChars(stream.GetBuffer(), 0, (int)stream.Length, output, 0); // sys.Console.WriteLine(new string(output)); stream.Seek(0, sys.IO.SeekOrigin.Begin); // Return stream to start NullableTimeSpan y = (NullableTimeSpan)serializer.Deserialize(stream); stream.Close(); return y; } } [nu.Test] public void XmlSerializable() { NullableTimeSpan xmlSerializedDeserialized; xmlSerializedDeserialized = XmlSerializeDeserialize(_null); nua.Assert("TestK#30", xmlSerializedDeserialized.IsNull); nua.Assert("TestK#31", _null.Equals(xmlSerializedDeserialized)); xmlSerializedDeserialized = XmlSerializeDeserialize(_zero); nua.Assert("TestK#32", !xmlSerializedDeserialized.IsNull); nua.AssertEquals("TestK#33", _zero.Value, xmlSerializedDeserialized.Value); nua.Assert("TestK#34", _zero.Equals(xmlSerializedDeserialized)); xmlSerializedDeserialized = XmlSerializeDeserialize(_pos); nua.Assert("TestK#35", !xmlSerializedDeserialized.IsNull); nua.AssertEquals("TestK#36", _pos.Value, xmlSerializedDeserialized.Value); nua.Assert("TestK#37", _pos.Equals(xmlSerializedDeserialized)); xmlSerializedDeserialized = XmlSerializeDeserialize(_neg); nua.Assert("TestK#38", !xmlSerializedDeserialized.IsNull); nua.AssertEquals("TestK#39", _neg.Value, xmlSerializedDeserialized.Value); nua.Assert("TestK#40", _neg.Equals(xmlSerializedDeserialized)); xmlSerializedDeserialized = XmlSerializeDeserialize(_max); nua.Assert("TestK#41", !xmlSerializedDeserialized.IsNull); nua.AssertEquals("TestK#42", _max.Value, xmlSerializedDeserialized.Value); nua.Assert("TestK#43", _max.Equals(xmlSerializedDeserialized)); xmlSerializedDeserialized = XmlSerializeDeserialize(_min); nua.Assert("TestK#44", !xmlSerializedDeserialized.IsNull); nua.AssertEquals("TestK#45", _min.Value, xmlSerializedDeserialized.Value); nua.Assert("TestK#46", _min.Equals(xmlSerializedDeserialized)); } private NullableTimeSpan XmlSerializeDeserialize(NullableTimeSpan x) { System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(NullableTimeSpan)); using (sys.IO.MemoryStream stream = new sys.IO.MemoryStream()) { serializer.Serialize(stream, x); // sys.Text.Decoder d = sys.Text.Encoding.Default.GetDecoder(); // char[] output = new char[d.GetCharCount(stream.GetBuffer(), 0, (int)stream.Length)]; // d.GetChars(stream.GetBuffer(), 0, (int)stream.Length, output, 0); // sys.Console.WriteLine(new string(output)); stream.Seek(0, sys.IO.SeekOrigin.Begin); // Return stream to start NullableTimeSpan y = (NullableTimeSpan)serializer.Deserialize(stream); stream.Close(); return y; } } [nu.Test] public void XmlSerializableEmptyElementNil() { //<?xml version="1.0"?> //<NullableTimeSpan xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></NullableTimeSpan> System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(NullableTimeSpan)); using (sys.IO.MemoryStream baseStream = new sys.IO.MemoryStream()) { using (sys.IO.StreamWriter stream = new System.IO.StreamWriter(baseStream)) { stream.WriteLine("<?xml version=\"1.0\"?>"); stream.WriteLine("<NullableTimeSpan xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></NullableTimeSpan>"); stream.Flush(); // baseStream.Position = 0; // sys.IO.StreamReader streamReader = new System.IO.StreamReader(baseStream); // sys.Console.WriteLine(streamReader.ReadToEnd()); baseStream.Position = 0; // Return stream to start NullableTimeSpan y = (NullableTimeSpan)serializer.Deserialize(baseStream); nua.Assert(y.IsNull); baseStream.Close(); stream.Close(); } } } [nu.Test] public void XmlSerializableSchema() { sysXmlScm.XmlSchema xsd = ((sysXml.Serialization.IXmlSerializable)NullableTimeSpan.Null).GetSchema(); xsd.Compile(new sysXmlScm.ValidationEventHandler(ValidationCallBack)); ValidateXmlAgainstXmlSchema(xsd, _null); ValidateXmlAgainstXmlSchema(xsd, _min); ValidateXmlAgainstXmlSchema(xsd, _max); } private void ValidateXmlAgainstXmlSchema(sysXmlScm.XmlSchema xsd, NullableTimeSpan x) { sysXml.Serialization.XmlSerializer serializer = new sysXml.Serialization.XmlSerializer(typeof(NullableTimeSpan)); sys.IO.MemoryStream stream = null; sys.Xml.XmlValidatingReader validator = null; try { // Get the serialized NullableTimeSpan instance stream = new sys.IO.MemoryStream(); serializer.Serialize(stream, x); stream.Seek(0, sys.IO.SeekOrigin.Begin); // Return stream to start // Add the default namespace sysXml.XmlDocument doc = new sysXml.XmlDocument(); doc.Load(stream); sysXml.XmlAttribute defaultNs = doc.CreateAttribute("xmlns"); defaultNs.Value = "http://NullableTypes.SourceForge.Net/NullableTimeSpanXMLSchema"; doc.DocumentElement.Attributes.Append(defaultNs); // Validate validator = new sysXml.XmlValidatingReader(doc.OuterXml, sysXml.XmlNodeType.Document, null); validator.ValidationType = sys.Xml.ValidationType.Schema; validator.Schemas.Add(xsd); validator.ValidationEventHandler += new sys.Xml.Schema.ValidationEventHandler(ValidationCallBack); while(validator.Read()); } finally { if (validator != null) validator.Close(); if (stream != null) ((sys.IDisposable)stream).Dispose(); } } private static void ValidationCallBack(object sender, sysXmlScm.ValidationEventArgs args) { throw args.Exception; } #endregion //Serialization } } |
From: Damien G. <dam...@us...> - 2005-10-06 16:05:43
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1576/src/Types Modified Files: DbNullConvert.cs NullConvert.cs NullableString.cs Types.csproj Added Files: NullableTimeSpan.cs Log Message: Implement NullableTimeSpan as per issue 1278920. Index: NullableString.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableString.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** NullableString.cs 26 Sep 2005 13:34:17 -0000 1.16 --- NullableString.cs 6 Oct 2005 16:05:35 -0000 1.17 *************** *** 1430,1433 **** --- 1430,1453 ---- } + /// <summary> + /// Converts the <see cref="NullableTimeSpan"/> parameter to a + /// <see cref="NullableString"/> structure. + /// </summary> + /// <param name="x"> + /// A <see cref="NullableTimeSpan"/> to be converted to a + /// <see cref="NullableString"/> structure. + /// </param> + /// <returns> + /// <see cref="Null"/> if <paramref name="x"/> is + /// <see cref="NullableTimeSpan.Null"/> otherwise a new + /// <see cref="NullableString"/> structure that's the string representation + /// of <paramref name="x"/>. + /// </returns> + public static explicit operator NullableString(NullableTimeSpan x) { + if (x.IsNull) + return NullableString.Null; + + return new NullableString(x.Value.ToString()); + } /// <summary> Index: DbNullConvert.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/DbNullConvert.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DbNullConvert.cs 23 Sep 2005 09:47:22 -0000 1.5 --- DbNullConvert.cs 6 Oct 2005 16:05:35 -0000 1.6 *************** *** 15,19 **** // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces // 28-Jan-2005 DamienG Upgrade Added support for NullableGuid and added regions. ! // 05-Sep-2005 DamienG Upgrade Added // --- 15,19 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces // 28-Jan-2005 DamienG Upgrade Added support for NullableGuid and added regions. ! // 05-Sep-2005 DamienG Upgrade Added NullableTimeSpan. // *************** *** 437,440 **** --- 437,482 ---- "Value is not a {0} neither a DBNull Value."), "System.String")); } + + /// <summary> + /// Converts an object value that is DBNull or System.TimeSpan to an + /// equivalent NullableTimeSpan value. + /// </summary> + /// <param name="x"> + /// A value of <see cref="System.TimeSpan"/> type from either a + /// <see cref="System.Data.DataRow"/> Item value, a + /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a + /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. + /// </param> + /// <returns> + /// <see cref="NullableTimeSpan.Null"/> if <paramref name="x"/> is + /// <see cref="System.DBNull"/> otherwise a + /// <see cref="NullableTimeSpan"/> constructed from <paramref name="x"/>. + /// </returns> + /// <exception cref="System.ArgumentNullException"> + /// <paramref name="x"/> is null. + /// </exception> + /// <exception cref="System.InvalidFormatException"> + /// <paramref name="x"/> is not DBNull, <see cref="System.TimeSpan"/> or <see cref="System.Int6$" />. + /// </exception> + public static NullableTimeSpan ToNullableTimeSpan(object x) { + if (x == sys.DBNull.Value) + return NullableTimeSpan.Null; + + if (x is long) + return new NullableTimeSpan((long)x); + + if (x is sys.TimeSpan) + return new NullableTimeSpan((sys.TimeSpan) x); + + if (x is string) + return NullableTimeSpan.Parse((string) x); + + if (x == null) + throw new sys.ArgumentNullException("x"); + + throw new sys.InvalidCastException( + string.Format(sysGlb.CultureInfo.CurrentCulture, Locale.GetText( + "Value is not a {0} neither a DBNull Value."), "System.TimeSpan, System.String, System.Int64")); + } #endregion // To converters *************** *** 682,685 **** --- 724,749 ---- return x.Value; } + + /// <summary> + /// Converts the specified value to an + /// equivalent <see cref="System.Object"/> value that can be assigned to + /// a <see cref="System.Data.DataRow"/> Item value, a + /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a + /// <see cref="System.Data.IDataRecord"/> Item value. + /// </summary> + /// <param name="x"> + /// A <see cref="NullableTimeSpan"/> value. + /// </param> + /// <returns> + /// <see cref="System.DBNull"/> if <paramref name="x"/> is + /// <see cref="NullableTimeSpan.Null"/> otherwise + /// the <see cref="NullableTimeSpan.Value"/> of <paramref name="x"/>. + /// </returns> + public static object From(NullableTimeSpan x) { + if (x.IsNull) + return sys.DBNull.Value; + + return x.Value; + } #endregion // From converters } Index: Types.csproj =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/Types.csproj,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Types.csproj 12 Feb 2005 03:44:34 -0000 1.18 --- Types.csproj 6 Oct 2005 16:05:35 -0000 1.19 *************** *** 72,78 **** <Reference Name = "System.XML" ! AssemblyName = "System.XML" HintPath = "H:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> </References> </Build> --- 72,83 ---- <Reference Name = "System.XML" ! AssemblyName = "System.Xml" HintPath = "H:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> + <Reference + Name = "System.Data" + AssemblyName = "System.Data" + HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" + /> </References> </Build> *************** *** 150,153 **** --- 155,163 ---- /> <File + RelPath = "NullableTimeSpan.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "NullableTypeException.cs" SubType = "Code" Index: NullConvert.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullConvert.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** NullConvert.cs 12 Feb 2005 03:44:34 -0000 1.6 --- NullConvert.cs 6 Oct 2005 16:05:35 -0000 1.7 *************** *** 12,15 **** --- 12,16 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces // 28-Jan-2005 DamienG Upgrade Added helpers for NullableGuid and added regions. + // 26-Sep-2005 DamienG Upgrade Added helpers for NullableTimeSpan. // *************** *** 672,676 **** return x.Value; } ! #endregion // From converters #region To converters --- 673,712 ---- return x.Value; } ! ! /// <summary> ! /// Converts the specified <see cref="NullableTimeSpan"/> value to an equivalent ! /// <see cref="System.String"/> value using a conventional <see cref="System.String"/> value to ! /// represent the <see cref="NullableTimeSpan.Null"/> value. ! /// </summary> ! /// <param name="x"> ! /// The <see cref="NullableTimeSpan"/> value to convert. ! /// </param> ! /// <param name="conventionalNullValue"> ! /// The <see cref="System.String"/> value that conventionally represent the ! /// <see cref="NullableTimeSpan.Null"/> value. ! /// </param> ! /// <param name="format"> ! /// A string that specifies the return format of <paramref name="x"/> if it is not ! /// <see cref="NullableTimeSpan.Null"/>. ! /// </param> ! /// <returns> ! /// <paramref name="conventionalNullValue"/> if <paramref name="x"/> is ! /// <see cref="NullableTimeSpan.Null"/> otherwise the equivalent string of the ! /// <see cref="NullableTimeSpan.Value"/> of <paramref name="x"/> formatted as specified by ! /// <paramref name="format"/>. ! /// </returns> ! /// <exception cref="System.FormatException"> ! /// The length of <paramref name="format"/> is 1, and it is not one of the format specifier characters ! /// defined for DateTimeFormatInfo. ! /// <para> -or- </para> ! /// <paramref name="format"/> does not contain a valid custom format pattern. ! /// </exception> ! public static sys.TimeSpan From(NullableTimeSpan x, sys.TimeSpan conventionalNullValue) { ! if (x.IsNull) ! return conventionalNullValue; ! ! return x.Value; ! } ! #endregion // From converters #region To converters *************** *** 1242,1246 **** return new NullableDateTime(x); - } --- 1278,1281 ---- *************** *** 1316,1320 **** return new NullableString(x); } ! #endregion // To converters } } --- 1351,1362 ---- return new NullableString(x); } ! ! public static NullableTimeSpan ToNullableTimeSpan(sys.TimeSpan x, sys.TimeSpan conventionalNullValue) { ! if (x == conventionalNullValue) ! return NullableTimeSpan.Null; ! ! return new NullableTimeSpan(x); ! } ! #endregion // To converters } } --- NEW FILE: NullableTimeSpan.cs --- // // NullableTypes.NullableTimeSpan // // Authors: Damien Guard (dam...@us...) // // Date Author Changes Reasons // 07-Apr-2003 DamienG Created New class // namespace NullableTypes { using sys = System; using sysGlb = System.Globalization; using sysXml = System.Xml; using sysXmlSrl = System.Xml.Serialization; using sysXmlScm = System.Xml.Schema; [sys.Serializable] public struct NullableTimeSpan : INullable, sys.IComparable, sysXmlSrl.IXmlSerializable { #region Fields sys.TimeSpan _value; private bool _notNull; public static readonly NullableTimeSpan Null; /// <summary> /// A constant representing the largest possible value of a /// <see cref="NullableTimeSpan"/>. /// </summary> public static readonly NullableTimeSpan MaxValue = new NullableTimeSpan(sys.TimeSpan.MaxValue); /// <summary> /// A constant representing the smallest possible value of a /// <see cref="NullableTimeSpan"/>. /// </summary> public static readonly NullableTimeSpan MinValue = new NullableTimeSpan(sys.TimeSpan.MinValue); /// <summary> /// Represents a zero value that can be assigned to an instance of the /// <see cref="NullableTimeSpan"/> structure. /// </summary> /// <remarks> /// Zero field is a constant of the <see cref="NullableTimeSpan"/> structure. /// </remarks> public static readonly NullableTimeSpan Zero = new NullableTimeSpan(0); #endregion // Fields #region Constructors public NullableTimeSpan (sys.TimeSpan timeSpan) { _value = timeSpan; _notNull = true; } public NullableTimeSpan (long ticks) { _value = new sys.TimeSpan (ticks); _notNull = true; } public NullableTimeSpan(int hours, int minutes, int seconds) { _value = new sys.TimeSpan(hours, minutes, seconds); _notNull = true; } public NullableTimeSpan(int days, int hours, int minutes, int seconds) : this(days, hours, minutes, seconds, 0) { } public NullableTimeSpan(int days, int hours, int minutes, int seconds, int milliseconds) { _value = new sys.TimeSpan(days, hours, minutes, seconds, milliseconds); _notNull = true; } #endregion // Constructors #region INullable public bool IsNull { get { return !_notNull; } } #endregion // INullable #region IComparable - Ordering public int CompareTo(object value) { if (value == null) return 1; if (!(value is NullableTimeSpan)) throw new sys.ArgumentException(string.Format(sysGlb.CultureInfo.CurrentCulture, Locale.GetText("Value is not a {0}."), "NullableTypes.NullableTimeSpan")); NullableTimeSpan iValue = (NullableTimeSpan)value; if (iValue.IsNull && this.IsNull) return 0; if (iValue.IsNull) return 1; if (this.IsNull) return -1; return _value.CompareTo(iValue.Value); } #endregion // IComparable - Ordering #region Equivalence public override bool Equals(object value) { if (!(value is NullableTimeSpan)) return false; else if (this.IsNull && ((NullableTimeSpan)value).IsNull) return true; else if (this.IsNull) return false; else if (((NullableTimeSpan)value).IsNull) return false; else return (bool) (this == (NullableTimeSpan)value); } public static NullableBoolean NotEquals(NullableTimeSpan x, NullableTimeSpan y) { return (x != y); } public static NullableBoolean operator == (NullableTimeSpan x, NullableTimeSpan y) { if (x.IsNull || y.IsNull) return NullableBoolean.Null; return new NullableBoolean (x.Value == y.Value); } public static NullableBoolean operator != (NullableTimeSpan x, NullableTimeSpan y) { if (x.IsNull || y.IsNull) return NullableBoolean.Null; return new NullableBoolean (!(x.Value == y.Value)); } public static NullableBoolean Equals(NullableTimeSpan x, NullableTimeSpan y) { return (x == y); } public override int GetHashCode() { return _value.GetHashCode(); } #endregion // Equivalence #region IXmlSerializable /// <summary> /// This member supports the .NET Framework infrastructure and is not intended to be used directly /// from your code. /// </summary> [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] sysXml.Schema.XmlSchema sysXmlSrl.IXmlSerializable.GetSchema() { // <?xml version="1.0"?> // <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" // targetNamespace="http://NullableTypes.SourceForge.Net/NullableTimeSpanXMLSchema" // xmlns="http://NullableTypes.SourceForge.Net/NullableTimeSpanXMLSchema" // elementFormDefault="qualified"> // <xs:element name="NullableTimeSpan" type="xs:duration" nillable="true" /> // </xs:schema> // Element: NullableTimeSpan sysXmlScm.XmlSchemaElement rootElement = new sysXmlScm.XmlSchemaElement(); rootElement.Name = "NullableTimeSpan"; rootElement.SchemaTypeName = new sysXml.XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); rootElement.IsNillable = true; // Xml Schema sysXmlScm.XmlSchema xsd = new sysXmlScm.XmlSchema(); xsd.Id = "NullableTimeSpan"; xsd.Namespaces.Add("xs", "http://www.w3.org/2001/XMLSchema"); xsd.TargetNamespace = "http://NullableTypes.SourceForge.Net/NullableTimeSpanXMLSchema"; xsd.Items.Add(rootElement); xsd.ElementFormDefault = sysXmlScm.XmlSchemaForm.Qualified; return xsd; } /// <summary> /// This member supports the .NET Framework infrastructure and is not intended to be used directly /// from your code. /// </summary> [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.WriteXml(sysXml.XmlWriter writer) { if (!IsNull) writer.WriteString(sysXml.XmlConvert.ToString(_value)); else writer.WriteAttributeString("xsi", "nil", "http://www.w3.org/2001/XMLSchema-instance", "true"); } /// <summary> /// This member supports the .NET Framework infrastructure and is not intended to be used directly /// from your code. /// </summary> [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); sys.Console.WriteLine(elementValue); if (nilValue == null || nilValue == "false" || nilValue == "0") { _value = sysXml.XmlConvert.ToTimeSpan(elementValue); _notNull = true; } else _notNull = false; } #endregion // IXmlSerializable #region Properties public sys.TimeSpan Value { get { if (this.IsNull) throw new NullableNullValueException(); return _value; } } #endregion // Properties #region Methods public static NullableBoolean GreaterThan(NullableTimeSpan x, NullableTimeSpan y) { return (x > y); } public static NullableBoolean GreaterThanOrEqual(NullableTimeSpan x, NullableTimeSpan y) { return (x >= y); } public static NullableBoolean LessThan(NullableTimeSpan x, NullableTimeSpan y) { return (x < y); } public static NullableBoolean LessThanOrEqual(NullableTimeSpan x, NullableTimeSpan y) { return (x <= y); } public static NullableTimeSpan Parse(string s) { return sys.TimeSpan.Parse (s); } public static NullableTimeSpan Add(NullableTimeSpan x, NullableTimeSpan y) { return (x + y); } #endregion // Methods #region Operators public static NullableTimeSpan operator + (NullableTimeSpan x, NullableTimeSpan y) { if (x.IsNull || y.IsNull) return NullableTimeSpan.Null; checked { return new NullableTimeSpan(x.Value + y.Value); } } public static NullableTimeSpan operator - (NullableTimeSpan x, NullableTimeSpan y) { if (x.IsNull || y.IsNull) return NullableTimeSpan.Null; checked { return new NullableTimeSpan(x.Value - y.Value); } } public static NullableBoolean operator > (NullableTimeSpan x, NullableTimeSpan y) { if (x.IsNull || y.IsNull) return NullableBoolean.Null; if (x.Value.CompareTo (y.Value) > 0) return new NullableBoolean (true); else return new NullableBoolean (false); } public static NullableBoolean operator >= (NullableTimeSpan x, NullableTimeSpan y) { if (x.IsNull || y.IsNull) return NullableBoolean.Null; if (x.Value.CompareTo (y.Value) >= 0) return new NullableBoolean (true); else return new NullableBoolean (false); } public static NullableBoolean operator < (NullableTimeSpan x, NullableTimeSpan y) { if (x.IsNull || y.IsNull) return NullableBoolean.Null; if (x.Value.CompareTo (y.Value) < 0) return new NullableBoolean (true); else return new NullableBoolean (false); } public static NullableBoolean operator <= (NullableTimeSpan x, NullableTimeSpan y) { if (x.IsNull || y.IsNull) return NullableBoolean.Null; if (x.Value.CompareTo (y.Value) <= 0) return new NullableBoolean (true); else return new NullableBoolean (false); } #endregion // Operators #region Conversion Operators public static explicit operator sys.TimeSpan(NullableTimeSpan x) { return x.Value; } public static explicit operator NullableTimeSpan(NullableString x) { if (x.IsNull) return NullableTimeSpan.Null; else return NullableTimeSpan.Parse (x.Value); } public static implicit operator NullableTimeSpan(sys.TimeSpan x) { return new NullableTimeSpan (x); } #endregion // Conversion Operators #region Conversions /// <summary> /// Converts to a NullableString representing the time span. /// </summary> /// <returns>A NullableString representative of the NullableTimeSpan.</returns> public NullableString ToNullableString () { return (NullableString) this; } /// <summary> /// Converts the NullableTimeSpan value to a string. /// </summary> /// <returns>A string representative of the NullableTimeSpan.</returns> public override string ToString () { if (this.IsNull) return Locale.GetText("Null"); else return _value.ToString (); } #endregion // Conversions } } |
From: Damien G. <dam...@us...> - 2005-09-26 13:34:32
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7283/src/Types Modified Files: NullableGuid.cs NullableString.cs Log Message: Add missing conversion cast from NullableGuid to NullableString. Index: NullableString.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableString.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** NullableString.cs 20 Feb 2004 00:42:23 -0000 1.15 --- NullableString.cs 26 Sep 2005 13:34:17 -0000 1.16 *************** *** 23,27 **** // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to avoid duplicate namespace with // other types in NullableTypes ! // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element // --- 23,28 ---- // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to avoid duplicate namespace with // other types in NullableTypes ! // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element ! // 26-Sep-2005 DamienG Upgrade Add cast support for NullableGuid. // *************** *** 1409,1412 **** --- 1410,1435 ---- /// <summary> + /// Converts the <see cref="NullableGuid"/> parameter to a + /// <see cref="NullableString"/> structure. + /// </summary> + /// <param name="x"> + /// A <see cref="NullableGuid"/> to be converted to a + /// <see cref="NullableString"/> structure. + /// </param> + /// <returns> + /// <see cref="Null"/> if <paramref name="x"/> is + /// <see cref="NullableGuid.Null"/> otherwise a new + /// <see cref="NullableString"/> structure that's the string representation + /// of <paramref name="x"/>. + /// </returns> + public static explicit operator NullableString(NullableGuid x) { + if (x.IsNull) + return NullableString.Null; + + return new NullableString(x.Value.ToString()); + } + + + /// <summary> /// Converts a <see cref="NullableString"/> to a <see cref="System.String"/>. /// </summary> Index: NullableGuid.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableGuid.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NullableGuid.cs 23 Sep 2005 09:31:50 -0000 1.5 --- NullableGuid.cs 26 Sep 2005 13:34:17 -0000 1.6 *************** *** 12,15 **** --- 12,16 ---- // from patrickvd // 05-Sep-2005 DamienG Upgrade Added new Empty handling as per NullableString. + // 26-Sep-2005 DamienG Bugfix Change ToNullableString to cast via NullableString. // *************** *** 278,285 **** public NullableString ToNullableString () { ! if (this.IsNull) ! return NullableString.Null; ! else ! return new NullableString(_value.ToString()); } --- 279,283 ---- public NullableString ToNullableString () { ! return (NullableString) this; } |
From: Damien G. <dam...@us...> - 2005-09-23 12:06:32
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29576/src/Tests Modified Files: NullableDateTimeTest.cs Log Message: Change the behaviour of NullableDateTime.Add to return a new NullableDateTime in line with .Subtract, +, - and DateTime as per issue 1281536. Also added missing .Add and .Subtract method unit tests. Index: NullableDateTimeTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableDateTimeTest.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** NullableDateTimeTest.cs 25 May 2004 22:05:07 -0000 1.13 --- NullableDateTimeTest.cs 23 Sep 2005 12:06:22 -0000 1.14 *************** *** 22,25 **** --- 22,26 ---- // improved to make it independent from user regional settings (problem reported // by imagina (hemmachat sf user) + // 23-Sep-2005 DamienG Change Add missing tests for .Add and .Subtract methods. // *************** *** 276,279 **** --- 277,297 ---- NullableDateTime.Parse(sx); } + + + public void AddSubtract() { + sys.DateTime dtx = new sys.DateTime(2014, 8, 13); + sys.TimeSpan tsx = new sys.TimeSpan(14, 9, 2, 8, 3); + + sys.DateTime dty = new sys.DateTime(2000, 01, 01); + sys.TimeSpan tsy = new sys.TimeSpan(1029, 123, 99, 18); + + nua.AssertEquals ("TestG#08", dtx.Add(tsx), new NullableDateTime(dtx).Add(tsx).Value); + nua.AssertEquals ("TestG#09", dty.Add(tsy), new NullableDateTime(dty).Add(tsy).Value); + + nua.AssertEquals ("TestG#10", dtx.Subtract(tsx), new NullableDateTime(dtx).Subtract(tsx).Value); + nua.AssertEquals ("TestG#11", dty.Subtract(tsy), new NullableDateTime(dty).Subtract(tsy).Value); + } + + #endregion // Method Tests - G# |
From: Damien G. <dam...@us...> - 2005-09-23 12:06:32
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29576/src/Types Modified Files: NullableDateTime.cs Log Message: Change the behaviour of NullableDateTime.Add to return a new NullableDateTime in line with .Subtract, +, - and DateTime as per issue 1281536. Also added missing .Add and .Subtract method unit tests. Index: NullableDateTime.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableDateTime.cs,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** NullableDateTime.cs 20 Feb 2004 00:42:22 -0000 1.21 --- NullableDateTime.cs 23 Sep 2005 12:06:22 -0000 1.22 *************** *** 27,30 **** --- 27,32 ---- // other types in NullableTypes // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element + // 23-Sep-2005 DamienG Change Change the .Add method to return a new NullableDateTime structure and not + // modify this one, as is consistent with DateTime. // *************** *** 436,449 **** /// <summary> ! /// Adds a specified time interval to this structure. /// </summary> /// <param name="t">A System.TimeSpan</param> ! public void Add(sys.TimeSpan t) { ! if (_notNull) ! _value += t; } /// <summary> ! /// Subtracts a specified time interval to this structure. /// </summary> /// <param name="t">A System.TimeSpan</param> --- 438,461 ---- /// <summary> ! /// Adds a specified time interval to this date and time in this structure ! /// yielding a new date and time. /// </summary> /// <param name="t">A System.TimeSpan</param> ! /// <returns> ! /// A NullableDateTime that is the sum of this structure and <paramref name="t"/>. ! /// </returns> ! /// <remarks> ! /// This method does not change the value of this NullableDateTime. Instead, a new NullableDateTime ! /// is returned whose value is the result of this operation. ! /// </remarks> ! public NullableDateTime Add(sys.TimeSpan t) { ! if (IsNull) ! return NullableDateTime.Null; ! return new NullableDateTime(_value + t); } /// <summary> ! /// Subtracts a specified time interval from the date and time in this structure ! /// yielding a new date and time. /// </summary> /// <param name="t">A System.TimeSpan</param> |
From: Damien G. <dam...@us...> - 2005-09-23 09:47:30
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31041/src/Types Modified Files: DbNullConvert.cs Log Message: Implement DBNullConvert.From for NullableGuid and add a unit test for it as per issue 1265825. Index: DbNullConvert.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/DbNullConvert.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DbNullConvert.cs 12 Feb 2005 03:44:34 -0000 1.4 --- DbNullConvert.cs 23 Sep 2005 09:47:22 -0000 1.5 *************** *** 15,18 **** --- 15,19 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces // 28-Jan-2005 DamienG Upgrade Added support for NullableGuid and added regions. + // 05-Sep-2005 DamienG Upgrade Added // *************** *** 645,648 **** --- 646,672 ---- /// </summary> /// <param name="x"> + /// A <see cref="NullableGuid"/> value. + /// </param> + /// <returns> + /// <see cref="System.DBNull"/> if <paramref name="x"/> is + /// <see cref="NullableGuid.Null"/> otherwise + /// the <see cref="NullableGuid.Value"/> of <paramref name="x"/>. + /// </returns> + public static object From(NullableGuid x) + { + if (x.IsNull) + return sys.DBNull.Value; + + return x.Value; + } + + /// <summary> + /// Converts the specified value to an + /// equivalent <see cref="System.Object"/> value that can be assigned to + /// a <see cref="System.Data.DataRow"/> Item value, a + /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a + /// <see cref="System.Data.IDataRecord"/> Item value. + /// </summary> + /// <param name="x"> /// A <see cref="NullableString"/> value. /// </param> |
From: Damien G. <dam...@us...> - 2005-09-23 09:47:30
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31041/src/Tests Modified Files: DBNullConvertTest.cs Log Message: Implement DBNullConvert.From for NullableGuid and add a unit test for it as per issue 1265825. Index: DBNullConvertTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/DBNullConvertTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DBNullConvertTest.cs 7 Oct 2003 20:32:21 -0000 1.2 --- DBNullConvertTest.cs 23 Sep 2005 09:47:21 -0000 1.3 *************** *** 9,12 **** --- 9,13 ---- // NullableTypes.HelperFunctions as for DBNullConvert class // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces + // 05-Sep-2005 DamienG Upgrade Added tests for NullableGuid conversion // *************** *** 425,428 **** --- 426,474 ---- [nu.Test] + public void ToNullableGuid() + { + _dbTable.Columns.Add("System.Guid", typeof(sys.Guid)); + + _dbTable.Rows.Add(new object[] {sys.Guid.Empty}); + nua.AssertEquals( + "TestA#101", + NullableGuid.Empty, + DBNullConvert.ToNullableGuid(_dbTable.Rows[_dbTable.Rows.Count-1][0])); + + System.Guid newGuid = System.Guid.NewGuid(); + _dbTable.Rows.Add(new object[] { newGuid }); + nua.AssertEquals( + "TestA#102", + new NullableGuid(newGuid), + DBNullConvert.ToNullableGuid(_dbTable.Rows[_dbTable.Rows.Count-1][0])); + + _dbTable.Rows.Add(new object[] {sys.DBNull.Value}); + nua.AssertEquals( + "TestA#103", + NullableGuid.Null, + DBNullConvert.ToNullableGuid(_dbTable.Rows[_dbTable.Rows.Count-1][0])); + + _dbTable.Rows.Add(new object[] {null}); + nua.AssertEquals( + "TestA#104", + NullableGuid.Null, + DBNullConvert.ToNullableGuid(_dbTable.Rows[_dbTable.Rows.Count-1][0])); + } + + + [nu.Test, nu.ExpectedException(typeof(sys.InvalidCastException))] + public void ToNullableGuidInvalidCastException() + { + DBNullConvert.ToNullableGuid("gino"); + } + + + [nu.Test, nu.ExpectedException(typeof(sys.ArgumentNullException))] + public void ToNullableGuidArgumentNullException() + { + DBNullConvert.ToNullableGuid(null); + } + + [nu.Test] public void ToNullableString() { _dbTable.Columns.Add("System.String", typeof(string)); *************** *** 596,599 **** --- 642,658 ---- } + [nu.Test] + public void FromNullableGuid() + { + nua.AssertEquals("TestB#091", + sys.DBNull.Value, + DBNullConvert.From(NullableString.Null)); + nua.AssertEquals("TestB#092", + System.Guid.Empty, + DBNullConvert.From(NullableGuid.Empty)); + nua.AssertEquals("TestB#093", + "4D38949B-1749-4496-9FD6-B3DA1275708C", + DBNullConvert.From(new NullableString("4D38949B-1749-4496-9FD6-B3DA1275708C"))); + } [nu.Test] |
From: Damien G. <dam...@us...> - 2005-09-23 09:32:04
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27004/src/Types Modified Files: NullableGuid.cs Log Message: Prevent NullableGuid.Equals throwing an exception and add a suitable test case. Bug:1265822 Index: NullableGuid.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableGuid.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NullableGuid.cs 12 Feb 2005 03:44:34 -0000 1.4 --- NullableGuid.cs 23 Sep 2005 09:31:50 -0000 1.5 *************** *** 9,12 **** --- 9,15 ---- // 28-Jan-2005 DamienG Completed Removed NullableBinary code, fixed ToNullableString, added missing constructor, // Added IXmlSerializable support + // 05-Sep-2005 DamienG Bugfix Fix for #265822 - NullableGuid Equals method throws NullableNullValueException + // from patrickvd + // 05-Sep-2005 DamienG Upgrade Added new Empty handling as per NullableString. // *************** *** 24,27 **** --- 27,32 ---- public static readonly NullableGuid Null; + public static readonly NullableGuid Empty = new NullableGuid(System.Guid.Empty); + #endregion // Fields *************** *** 80,83 **** --- 85,90 ---- else if (this.IsNull && ((NullableGuid)value).IsNull) return true; + else if (this.IsNull) + return false; else if (((NullableGuid)value).IsNull) return false; *************** *** 105,109 **** public override int GetHashCode() { ! return _value.GetHashCode(); } #endregion // Equivalence --- 112,118 ---- public override int GetHashCode() { ! System.Guid tmp = (IsNull) ? System.Guid.Empty : _value; ! ! return tmp.GetHashCode(); } #endregion // Equivalence |
From: Damien G. <dam...@us...> - 2005-09-23 09:32:03
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27004/src/Tests Modified Files: NullableGuidTest.cs Log Message: Prevent NullableGuid.Equals throwing an exception and add a suitable test case. Bug:1265822 Index: NullableGuidTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableGuidTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableGuidTest.cs 12 Feb 2005 03:44:34 -0000 1.1 --- NullableGuidTest.cs 23 Sep 2005 09:31:50 -0000 1.2 *************** *** 6,9 **** --- 6,10 ---- // Date Author Changes Reasons // 28-Jan-2005 DamienG Create + // 05-Sep-2005 DamienG Update Test to expose #265822 - NullableGuid Equals method throws NullableNullValueException // *************** *** 44,47 **** --- 45,51 ---- byte[] test2bytes = { 0xA5, 0x53, 0x12, 0xCB, 0x71, 0xE4, 0x6E, 0xE5 }; nua.AssertEquals("#A02", Test2.Value, new NullableGuid(0x1C432B6D, unchecked((short)0x9AF7), 0x4665, test2bytes).Value); + + NullableGuid EmptyGuid = new NullableGuid(System.Guid.Empty); + nua.AssertEquals("#A03", System.Guid.Empty, EmptyGuid.Value); } *************** *** 83,89 **** --- 87,96 ---- { NullableGuid t2 = new NullableGuid(Test2.Value); + NullableGuid tn = new NullableGuid(); nua.Assert("#E01", !Test1.Equals(Test2)); nua.Assert("#E02", !Test3.Equals(Test1)); nua.Assert("#E03", Test2.Equals(t2)); + nua.Assert("#E06", !Test2.Equals(tn)); + nua.Assert("#E07", !tn.Equals(Test2)); // Static Equals()-method |
From: \(luKa\) <luk...@us...> - 2005-03-24 12:27:46
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4142/src/Types Modified Files: NullableDecimal.cs Log Message: Index: NullableDecimal.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableDecimal.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** NullableDecimal.cs 20 Feb 2004 00:42:22 -0000 1.20 --- NullableDecimal.cs 24 Mar 2005 12:27:38 -0000 1.21 *************** *** 103,107 **** /// </summary> /// <remarks> ! /// Zero field is a constant of the <see cref="NullableDecimal"/> structure. /// </remarks> public static readonly NullableDecimal One = new NullableDecimal(decimal.One); --- 103,107 ---- /// </summary> /// <remarks> ! /// One field is a constant of the <see cref="NullableDecimal"/> structure. /// </remarks> public static readonly NullableDecimal One = new NullableDecimal(decimal.One); |
From: \(luKa\) <luk...@us...> - 2005-02-12 03:44:44
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24056/src/Types Modified Files: DbNullConvert.cs NullConvert.cs NullableGuid.cs Types.csproj Log Message: Index: DbNullConvert.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/DbNullConvert.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DbNullConvert.cs 7 Oct 2003 20:32:22 -0000 1.3 --- DbNullConvert.cs 12 Feb 2005 03:44:34 -0000 1.4 *************** *** 3,6 **** --- 3,7 ---- // // Authors: Luca Minudel (luk...@us...) + // Damien Guard (dam...@us...) // // Date Author Changes Reasons *************** *** 13,20 **** // NullableTypes.HelperFunctions // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces // ! namespace NullableTypes.HelperFunctions ! { using sys = System; using sysGlb = System.Globalization; --- 14,21 ---- // NullableTypes.HelperFunctions // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces + // 28-Jan-2005 DamienG Upgrade Added support for NullableGuid and added regions. // ! namespace NullableTypes.HelperFunctions { using sys = System; using sysGlb = System.Globalization; *************** *** 25,32 **** /// and vice versa. /// </summary> ! public sealed class DBNullConvert ! { private DBNullConvert() {} /// <summary> /// Converts an object value that is DBNull or System.Boolean to an --- 26,33 ---- /// and vice versa. /// </summary> ! public sealed class DBNullConvert { private DBNullConvert() {} + #region To converters /// <summary> /// Converts an object value that is DBNull or System.Boolean to an *************** *** 37,41 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 38,42 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 63,70 **** throw new sys.InvalidCastException( string.Format(sysGlb.CultureInfo.CurrentCulture, Locale.GetText( ! "Value is not a {0} neither a DBNull Value."), "System.Boolean")); } - /// <summary> /// Converts an object value that is DBNull or System.Byte to an --- 64,70 ---- throw new sys.InvalidCastException( string.Format(sysGlb.CultureInfo.CurrentCulture, Locale.GetText( ! "Value is not a {0} neither a DBNull Value."), "System.Boolean")); } /// <summary> /// Converts an object value that is DBNull or System.Byte to an *************** *** 75,79 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 75,79 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 104,107 **** --- 104,143 ---- } + /// <summary> + /// Converts an object value that is DBNull or System.Guid to an + /// equivalent NullableGuid value. + /// </summary> + /// <param name="x"> + /// A value of <see cref="System.Guid"/> type from either a + /// <see cref="System.Data.DataRow"/> Item value, a + /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a + /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. + /// </param> + /// <returns> + /// <see cref="NullableGuid.Null"/> if <paramref name="x"/> is + /// <see cref="System.DBNull"/> otherwise a + /// <see cref="NullableGuid"/> constructed from <paramref name="x"/>. + /// </returns> + /// <exception cref="System.ArgumentNullException"> + /// <paramref name="x"/> is null. + /// </exception> + /// <exception cref="System.InvalidCastException"> + /// <paramref name="x"/> is neither DBNull or of type + /// <see cref="System.Guid"/>. + /// </exception> + public static NullableGuid ToNullableGuid(object x) { + if (x == sys.DBNull.Value) + return NullableGuid.Null; + + if (x is sys.Guid) + return new NullableGuid((sys.Guid)x); + + if (x == null) + throw new sys.ArgumentNullException("x"); + + throw new sys.InvalidCastException( + string.Format(sysGlb.CultureInfo.CurrentCulture, Locale.GetText( + "Value is not a {0} neither a DBNull Value."), "System.Guid")); + } /// <summary> *************** *** 113,117 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 149,153 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 142,146 **** } - /// <summary> /// Converts an object value that is DBNull or System.Int32 to an --- 178,181 ---- *************** *** 151,155 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 186,190 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 180,184 **** } - /// <summary> /// Converts an object value that is DBNull or System.Int64 to an --- 215,218 ---- *************** *** 189,193 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 223,227 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 218,222 **** } - /// <summary> /// Converts an object value that is DBNull or System.Single to an --- 252,255 ---- *************** *** 227,231 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 260,264 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 256,260 **** } - /// <summary> /// Converts an object value that is DBNull or System.Double to an --- 289,292 ---- *************** *** 265,269 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 297,301 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 294,298 **** } - /// <summary> /// Converts an object value that is DBNull or System.DateTime to an --- 326,329 ---- *************** *** 303,307 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 334,338 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 332,336 **** } - /// <summary> /// Converts an object value that is DBNull or System.Decimal to an --- 363,366 ---- *************** *** 341,345 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 371,375 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 370,374 **** } - /// <summary> /// Converts an object value that is DBNull or System.String to an --- 400,403 ---- *************** *** 379,383 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 408,412 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 407,412 **** "Value is not a {0} neither a DBNull Value."), "System.String")); } ! /// <summary> /// Converts the specified value to an --- 436,442 ---- "Value is not a {0} neither a DBNull Value."), "System.String")); } + #endregion // To converters ! #region From converters /// <summary> /// Converts the specified value to an *************** *** 431,435 **** } - /// <summary> /// Converts the specified value to an --- 461,464 ---- *************** *** 454,458 **** } - /// <summary> /// Converts the specified value to an --- 483,486 ---- *************** *** 477,481 **** } - /// <summary> /// Converts the specified value to an --- 505,508 ---- *************** *** 500,504 **** } - /// <summary> /// Converts the specified value to an --- 527,530 ---- *************** *** 523,527 **** } - /// <summary> /// Converts the specified value to an --- 549,552 ---- *************** *** 546,550 **** } - /// <summary> /// Converts the specified value to an --- 571,574 ---- *************** *** 569,573 **** } - /// <summary> /// Converts the specified value to an --- 593,596 ---- *************** *** 592,596 **** } - /// <summary> /// Converts the specified value to an --- 615,618 ---- *************** *** 615,619 **** } - /// <summary> /// Converts the specified value to an --- 637,640 ---- *************** *** 637,640 **** return x.Value; } } ! } --- 658,662 ---- return x.Value; } + #endregion // From converters } ! } \ No newline at end of file Index: NullableGuid.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableGuid.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NullableGuid.cs 27 Jun 2003 15:33:30 -0000 1.3 --- NullableGuid.cs 12 Feb 2005 03:44:34 -0000 1.4 *************** *** 1,18 **** // ! // NullableTypes.? // // Authors: Luca Minudel (luk...@us...) ! // ... // // Date Author Changes Reasons // 07-Apr-2003 Luca Created Declared public members ! // ??-Apr-2003 ... ... // namespace NullableTypes { using sys = System; ! public struct NullableGuid : INullable, sys.IComparable ! { #region Fields sys.Guid _value; --- 1,22 ---- // ! // NullableTypes.NullableGuid // // Authors: Luca Minudel (luk...@us...) ! // Damien Guard (dam...@us...) // // Date Author Changes Reasons // 07-Apr-2003 Luca Created Declared public members ! // 28-Jan-2005 DamienG Completed Removed NullableBinary code, fixed ToNullableString, added missing constructor, ! // Added IXmlSerializable support // namespace NullableTypes { using sys = System; + using sysXml = System.Xml; + using sysXmlSrl = System.Xml.Serialization; + using sysXmlScm = System.Xml.Schema; ! [sys.Serializable] ! public struct NullableGuid : INullable, sys.IComparable, sysXmlSrl.IXmlSerializable { #region Fields sys.Guid _value; *************** *** 38,41 **** --- 42,50 ---- } + public NullableGuid(int a, short b, short c, byte[] d) { + _value = new sys.Guid(a, b, c, d); + _notNull = true; + } + public NullableGuid (int a, short b, short c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k) { _value = new sys.Guid (a, b, c, d, e, f, g, h, i, j, k); *************** *** 81,85 **** } - public static NullableBoolean operator == (NullableGuid x, NullableGuid y) { if (x.IsNull || y.IsNull) return NullableBoolean.Null; --- 90,93 ---- *************** *** 97,111 **** public override int GetHashCode() { ! byte [] bytes = this.ToByteArray (); ! ! int result = 10; ! foreach (byte b in bytes) { ! result = 91 * result + b.GetHashCode (); ! } ! return result; } ! #endregion // Equivalence #region Properties --- 105,174 ---- public override int GetHashCode() { ! return _value.GetHashCode(); ! } ! #endregion // Equivalence ! #region IXmlSerializable ! /// <summary> ! /// This member supports the .NET Framework infrastructure and is not intended to be used directly ! /// from your code. ! /// </summary> ! [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] ! sysXml.Schema.XmlSchema sysXmlSrl.IXmlSerializable.GetSchema() { ! // <?xml version="1.0"?> ! // <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" ! // targetNamespace="http://NullableTypes.SourceForge.Net/NullableGuidXMLSchema" ! // xmlns="http://NullableTypes.SourceForge.Net/NullableGuidXMLSchema" ! // elementFormDefault="qualified"> ! // <xs:element name="NullableGuid" type="xs:hexBinary" nillable="true" /> ! // </xs:schema> ! ! // Element: NullableGuid ! sysXmlScm.XmlSchemaElement rootElement = new sysXmlScm.XmlSchemaElement(); ! rootElement.Name = "NullableGuid"; ! rootElement.SchemaTypeName = ! new sysXml.XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); ! rootElement.IsNillable = true; ! ! // Xml Schema ! sysXmlScm.XmlSchema xsd = new sysXmlScm.XmlSchema(); ! xsd.Id = "NullableGuid"; ! xsd.Namespaces.Add("xs", "http://www.w3.org/2001/XMLSchema"); ! xsd.TargetNamespace = "http://NullableTypes.SourceForge.Net/NullableGuidXMLSchema"; ! xsd.Items.Add(rootElement); ! xsd.ElementFormDefault = sysXmlScm.XmlSchemaForm.Qualified; ! ! return xsd; } ! /// <summary> ! /// This member supports the .NET Framework infrastructure and is not intended to be used directly ! /// from your code. ! /// </summary> ! [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] ! void sysXmlSrl.IXmlSerializable.WriteXml(sysXml.XmlWriter writer) { ! if (!IsNull) ! writer.WriteString(sysXml.XmlConvert.ToString(_value)); ! else ! writer.WriteAttributeString("xsi", "nil", "http://www.w3.org/2001/XMLSchema-instance", "true"); ! } ! ! /// <summary> ! /// This member supports the .NET Framework infrastructure and is not intended to be used directly ! /// from your code. ! /// </summary> ! [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] ! void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; ! string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); ! ! if (nilValue == null || nilValue == "false" || nilValue == "0") { ! _value = sysXml.XmlConvert.ToGuid(elementValue); ! _notNull = true; ! } ! else ! _notNull = false; ! } ! #endregion // IXmlSerializable #region Properties *************** *** 156,165 **** if (x.IsNull || y.IsNull) return NullableBoolean.Null; ! if (x.Value.CompareTo (y.Value) >= 0) return new NullableBoolean (true); else return new NullableBoolean (false); - } --- 219,227 ---- if (x.IsNull || y.IsNull) return NullableBoolean.Null; ! if (x.Value.CompareTo (y.Value) >= 0) return new NullableBoolean (true); else return new NullableBoolean (false); } *************** *** 172,176 **** else return new NullableBoolean (false); - } --- 234,237 ---- *************** *** 187,194 **** #region Conversion Operators - public static explicit operator NullableGuid(NullableBinary x) { - return new NullableGuid (x.Value); - } - public static explicit operator sys.Guid(NullableGuid x) { return x.Value; --- 248,251 ---- *************** *** 211,220 **** } - public NullableBinary ToNullableBinary () { - return ((NullableBinary)this); - } - public NullableString ToNullableString () { ! return ((NullableString)this); } --- 268,276 ---- } public NullableString ToNullableString () { ! if (this.IsNull) ! return NullableString.Null; ! else ! return new NullableString(_value.ToString()); } *************** *** 226,231 **** } #endregion // Conversions ! ! } } - --- 282,285 ---- } #endregion // Conversions ! } } Index: Types.csproj =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/Types.csproj,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Types.csproj 8 Dec 2003 21:57:27 -0000 1.17 --- Types.csproj 12 Feb 2005 03:44:34 -0000 1.18 *************** *** 72,82 **** <Reference Name = "System.XML" ! AssemblyName = "System.Xml" ! HintPath = "D:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.XML.dll" ! /> ! <Reference ! Name = "System.Data" ! AssemblyName = "System.Data" ! HintPath = "D:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Data.dll" /> </References> --- 72,77 ---- <Reference Name = "System.XML" ! AssemblyName = "System.XML" ! HintPath = "H:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> </References> *************** *** 120,123 **** --- 115,123 ---- /> <File + RelPath = "NullableGuid.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "NullableInt16.cs" SubType = "Code" Index: NullConvert.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullConvert.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NullConvert.cs 7 Oct 2003 20:32:22 -0000 1.5 --- NullConvert.cs 12 Feb 2005 03:44:34 -0000 1.6 *************** *** 3,6 **** --- 3,7 ---- // // Authors: Luca Minudel (luk...@us...) + // Damien Guard (dam...@us...) // // Date Author Changes Reasons *************** *** 10,17 **** // and with a specified format. // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces // ! namespace NullableTypes.HelperFunctions ! { using sys = System; using sysGlb = System.Globalization; --- 11,18 ---- // and with a specified format. // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces + // 28-Jan-2005 DamienG Upgrade Added helpers for NullableGuid and added regions. // ! namespace NullableTypes.HelperFunctions { using sys = System; using sysGlb = System.Globalization; *************** *** 19,29 **** /// <summary> /// Converts non nullable .NET built-in types to and from NullableTypes using conventional values to ! /// simulate null values. Can be used to seamlessly integrate NullableTypes with Web server controls ! /// and WinForms controls. /// </summary> public sealed class NullConvert { private NullConvert() {} ! /// <summary> /// Converts the specified <see cref="NullableBoolean"/> value to an equivalent --- 20,29 ---- /// <summary> /// Converts non nullable .NET built-in types to and from NullableTypes using conventional values to ! /// simulate null values. Can be used to seamlessly integrate NullableTypes with WebForms and WinForms controls. /// </summary> public sealed class NullConvert { private NullConvert() {} ! #region From converters /// <summary> /// Converts the specified <see cref="NullableBoolean"/> value to an equivalent *************** *** 49,53 **** } - /// <summary> /// Converts the specified <see cref="NullableBoolean"/> value to an equivalent --- 49,52 ---- *************** *** 64,68 **** /// <paramref name="conventionalNullValue"/> if <paramref name="x"/> is /// <see cref="NullableBoolean.Null"/> otherwise the string representation of the ! /// <see cref="NullableBoolean.Value"/> of <paramref name="x"/>. /// </returns> public static string From(NullableBoolean x, string conventionalNullValue) { --- 63,67 ---- /// <paramref name="conventionalNullValue"/> if <paramref name="x"/> is /// <see cref="NullableBoolean.Null"/> otherwise the string representation of the ! /// <see cref="NullableBoolean.Value"/> of <paramref name="x"/>.. /// </returns> public static string From(NullableBoolean x, string conventionalNullValue) { *************** *** 73,77 **** } - /// <summary> /// Converts the specified <see cref="NullableByte"/> value to an equivalent --- 72,75 ---- *************** *** 97,101 **** } - /// <summary> /// Converts the specified <see cref="NullableByte"/> value to an equivalent --- 95,98 ---- *************** *** 139,142 **** --- 136,202 ---- } + /// <summary> + /// Converts the specified <see cref="NullableGuid"/> value to an equivalent + /// <see cref="System.Byte"/> value using a conventional <see cref="System.Byte"/> value to + /// represent the <see cref="NullableGuid.Null"/> value. + /// </summary> + /// <param name="x"> + /// The <see cref="NullableGuid"/> value to convert. + /// </param> + /// <param name="conventionalNullValue"> + /// The <see cref="System.Guid"/> value that conventionally represent the null value. + /// </param> + /// <returns> + /// <paramref name="conventionalNullValue"/> if <paramref name="x"/> is + /// <see cref="NullableGuid.Null"/> otherwise the <see cref="NullableGuid.Value"/> of + /// <paramref name="x"/>. + /// </returns> + public static sys.Guid From(NullableGuid x, sys.Guid conventionalNullValue) { + if (x.IsNull) + return conventionalNullValue; + + return x.Value; + } + + /// <summary> + /// Converts the specified <see cref="NullableGuid"/> value to an equivalent + /// <see cref="System.String"/> value using a conventional <see cref="System.String"/> value to + /// represent the <see cref="NullableGuid.Null"/> value. + /// </summary> + /// <param name="x"> + /// The <see cref="NullableGuid"/> value to convert. + /// </param> + /// <param name="conventionalNullValue"> + /// The <see cref="System.String"/> value that conventionally represent the + /// <see cref="NullableGuid.Null"/> value. + /// </param> + /// <param name="format"> + /// A string that specifies the return format of <paramref name="x"/> if it is not + /// <see cref="NullableGuid.Null"/>. + /// </param> + /// <returns> + /// <paramref name="conventionalNullValue"/> if <paramref name="x"/> is + /// <see cref="NullableGuid.Null"/> otherwise the equivalent string of the + /// <see cref="NullableGuid.Value"/> of <paramref name="x"/> formatted as specified by + /// <paramref name="format"/>. + /// </returns> + /// <exception cref="System.FormatException"> + /// <paramref name="x"/> is not <see cref="NullableGuid.Null"/> and the <paramref name="format"/> + /// is invalid for a Byte. + /// </exception> + /// <remarks> + /// If <paramref name="format"/> is a null reference (Nothing in Visual Basic) or an empty string (""), + /// general format specifier ("G") will be used. + /// <para> + /// The <see cref="System.Globalization.NumberFormatInfo"/> for the current culture is used when + /// applying fomatting. + /// </para> + /// </remarks> + public static string From(NullableGuid x, string conventionalNullValue, string format) { + if (x.IsNull) + return conventionalNullValue; + + return x.Value.ToString(format, sysGlb.CultureInfo.CurrentCulture); + } /// <summary> *************** *** 163,167 **** } - /// <summary> /// Converts the specified <see cref="NullableInt16"/> value to an equivalent --- 223,226 ---- *************** *** 205,209 **** } - /// <summary> /// Converts the specified <see cref="NullableInt32"/> value to an equivalent --- 264,267 ---- *************** *** 229,233 **** } - /// <summary> /// Converts the specified <see cref="NullableInt32"/> value to an equivalent --- 287,290 ---- *************** *** 271,275 **** } - /// <summary> /// Converts the specified <see cref="NullableInt64"/> value to an equivalent --- 328,331 ---- *************** *** 295,299 **** } - /// <summary> /// Converts the specified <see cref="NullableInt64"/> value to an equivalent --- 351,354 ---- *************** *** 337,341 **** } - /// <summary> /// Converts the specified <see cref="NullableSingle"/> value to an equivalent --- 392,395 ---- *************** *** 361,365 **** } - /// <summary> /// Converts the specified <see cref="NullableSingle"/> value to an equivalent --- 415,418 ---- *************** *** 403,407 **** } - /// <summary> /// Converts the specified <see cref="NullableDouble"/> value to an equivalent --- 456,459 ---- *************** *** 427,431 **** } - /// <summary> /// Converts the specified <see cref="NullableDouble"/> value to an equivalent --- 479,482 ---- *************** *** 469,473 **** } - /// <summary> /// Converts the specified <see cref="NullableDecimal"/> value to an equivalent --- 520,523 ---- *************** *** 493,497 **** } - /// <summary> /// Converts the specified <see cref="NullableDecimal"/> value to an equivalent --- 543,546 ---- *************** *** 535,539 **** } - /// <summary> /// Converts the specified <see cref="NullableDateTime"/> value to an equivalent --- 584,587 ---- *************** *** 559,563 **** } - /// <summary> /// Converts the specified <see cref="NullableDateTime"/> value to an equivalent --- 607,610 ---- *************** *** 603,607 **** } - /// <summary> /// Converts the specified <see cref="NullableString"/> value to an equivalent --- 650,653 ---- *************** *** 626,631 **** return x.Value; } ! /// <summary> /// Converts the specified <see cref="System.Boolean"/> value whose null value is simulated using a --- 672,678 ---- return x.Value; } + #endregion // From converters ! #region To converters /// <summary> /// Converts the specified <see cref="System.Boolean"/> value whose null value is simulated using a *************** *** 650,654 **** } - /// <summary> /// Converts the specified <see cref="System.Int32"/> value whose null value is simulated using a --- 697,700 ---- *************** *** 673,677 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a logical value to its --- 719,722 ---- *************** *** 709,713 **** } - /// <summary> /// Converts the specified <see cref="System.Byte"/> value whose null value is simulated using a --- 754,757 ---- *************** *** 733,737 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 777,780 ---- *************** *** 771,774 **** --- 814,839 ---- } + /// <summary> + /// Converts the specified <see cref="System.Guid"/> value whose null value is simulated using a + /// a conventional <see cref="System.Guid"/> value to an equivalent <see cref="NullableGuid"/>. + /// </summary> + /// <param name="x"> + /// The <see cref="System.Guid"/> value to convert. + /// </param> + /// <param name="conventionalNullValue"> + /// The <see cref="System.Guid"/> value that conventionally represent the null value. + /// </param> + /// <returns> + /// <see cref="NullableGuid.Null"/> if <paramref name="x"/> is equals to + /// <paramref name="conventionalNullValue"/> otherwise a <see cref="NullableGuid"/> constructed from + /// <paramref name="x"/>. + /// </returns> + public static NullableGuid ToNullableGuid(sys.Guid x, System.Guid conventionalNullValue) { + if (x == conventionalNullValue) + return NullableGuid.Null; + + return new NullableGuid(x); + + } /// <summary> *************** *** 795,799 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 860,863 ---- *************** *** 833,837 **** } - /// <summary> /// Converts the specified <see cref="System.Int32"/> value whose null value is simulated using a --- 897,900 ---- *************** *** 857,861 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 920,923 ---- *************** *** 895,899 **** } - /// <summary> /// Converts the specified <see cref="System.Int64"/> value whose null value is simulated using a --- 957,960 ---- *************** *** 919,923 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 980,983 ---- *************** *** 957,961 **** } - /// <summary> /// Converts the specified <see cref="System.Single"/> value whose null value is simulated using a --- 1017,1020 ---- *************** *** 987,991 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 1046,1049 ---- *************** *** 1029,1033 **** } - /// <summary> /// Converts the specified <see cref="System.Double"/> value whose null value is simulated using a --- 1087,1090 ---- *************** *** 1059,1063 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 1116,1119 ---- *************** *** 1101,1105 **** } - /// <summary> /// Converts the specified <see cref="System.Decimal"/> value whose null value is simulated using a --- 1157,1160 ---- *************** *** 1126,1130 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 1181,1184 ---- *************** *** 1168,1173 **** } - - /// <summary> /// Converts the specified <see cref="System.DateTime"/> value whose null value is simulated using a --- 1222,1225 ---- *************** *** 1193,1197 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 1245,1248 ---- *************** *** 1235,1239 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> to its <see cref="NullableString"/> equivalent. --- 1286,1289 ---- *************** *** 1266,1270 **** return new NullableString(x); } ! } ! } \ No newline at end of file --- 1316,1320 ---- return new NullableString(x); } ! #endregion // To converters } ! } |
From: \(luKa\) <luk...@us...> - 2005-02-12 03:44:43
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24056/src/Tests Modified Files: AssemblyInfo.cs NullableDoubleTest.cs NullableSingleTest.cs NullableStringTest.cs Tests.csproj Added Files: NullableGuidTest.cs Log Message: Index: Tests.csproj =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/Tests.csproj,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Tests.csproj 8 Dec 2003 21:57:27 -0000 1.26 --- Tests.csproj 12 Feb 2005 03:44:34 -0000 1.27 *************** *** 160,163 **** --- 160,168 ---- /> <File + RelPath = "NullableGuidTest.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "NullableInt16Test2.cs" SubType = "Code" Index: NullableStringTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableStringTest.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** NullableStringTest.cs 20 Feb 2004 00:42:22 -0000 1.13 --- NullableStringTest.cs 12 Feb 2005 03:44:34 -0000 1.14 *************** *** 19,22 **** --- 19,23 ---- // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil // value with a non empty element + // 28-Jan-2005 DamienG Bug Fix XmlSerializable test was broken - not nu.Test and not calling correct function. // *************** *** 752,768 **** public void XmlSerializable() { ! NullableString serializedDeserialized; ! serializedDeserialized = SerializeDeserialize(NullableString.Null); ! nua.Assert("TestK#01", serializedDeserialized.IsNull); ! nua.Assert("TestK#02", NullableString.Null.Equals(serializedDeserialized)); NullableString ns = new NullableString("Pino"); ! serializedDeserialized = SerializeDeserialize(ns); ! nua.Assert("TestK#03", !serializedDeserialized.IsNull); ! nua.AssertEquals("TestK#04", ns.Value, serializedDeserialized.Value); ! nua.Assert("TestK#05", ns.Equals(serializedDeserialized)); ! } --- 753,769 ---- + [nu.Test] public void XmlSerializable() { ! NullableString xmlSerializedDeserialized; ! xmlSerializedDeserialized = XmlSerializeDeserialize(NullableString.Null); ! nua.Assert("TestK#11", xmlSerializedDeserialized.IsNull); ! nua.Assert("TestK#12", NullableString.Null.Equals(xmlSerializedDeserialized)); NullableString ns = new NullableString("Pino"); ! xmlSerializedDeserialized = XmlSerializeDeserialize(ns); ! nua.Assert("TestK#13", !xmlSerializedDeserialized.IsNull); ! nua.AssertEquals("TestK#14", ns.Value, xmlSerializedDeserialized.Value); ! nua.Assert("TestK#15", ns.Equals(xmlSerializedDeserialized)); } Index: NullableSingleTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableSingleTest.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** NullableSingleTest.cs 20 Feb 2004 00:42:22 -0000 1.14 --- NullableSingleTest.cs 12 Feb 2005 03:44:34 -0000 1.15 *************** *** 21,24 **** --- 21,26 ---- // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil // value with a non empty element + // 12-Feb-2005 Luca Upgrade Code upgrade: improved test ParseFormatException to make it pass also with + // current culture German (Switzerland) de-CH LCID=2055 // *************** *** 392,395 **** --- 394,399 ---- string sx = "409'85"; NullableSingle.Parse(sx); + string sy = "409`85"; + NullableSingle.Parse(sy); } Index: NullableDoubleTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableDoubleTest.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** NullableDoubleTest.cs 20 Feb 2004 00:42:22 -0000 1.16 --- NullableDoubleTest.cs 12 Feb 2005 03:44:34 -0000 1.17 *************** *** 23,26 **** --- 23,28 ---- // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil // value with a non empty element + // 12-Feb-2005 Luca Upgrade Code upgrade: improved test ParseFormatException to make it pass also with + // current culture German (Switzerland) de-CH LCID=2055 // *************** *** 402,405 **** --- 404,410 ---- string sx = "409'85"; NullableDouble.Parse(sx); + string sy = "409`85"; + NullableDouble.Parse(sy); + } --- NEW FILE: NullableGuidTest.cs --- // // NullableTypes.Tests.NullableGuidTest // // Authors: Damien Guard (dam...@us...) // // Date Author Changes Reasons // 28-Jan-2005 DamienG Create // namespace NullableTypes.Tests { using nu = NUnit.Framework; using nua = NUnit.Framework.Assertion; using sys = System; using sysThr = System.Threading; using sysGlb = System.Globalization; using sysXml = System.Xml; using sysXmlScm = System.Xml.Schema; [nu.TestFixture] public class NullableGuidTest { private NullableGuid Test1; private NullableGuid Test2; private NullableGuid Test3; [nu.SetUp] public void SetUp() { Test1 = new NullableGuid("9180AF33-1239-4AD0-9D59-9A0BD5407F1A"); Test2 = new NullableGuid("1C432B6D-9AF7-4665-A553-12CB71E46EE5"); Test3 = new NullableGuid("E64EDB0F-E4E1-4B35-99CD-4BEDFB2E7AF0"); } // Test constructor [nu.Test] public void Create() { // Test constructors give same results nua.AssertEquals("#A01", Test1.Value, new NullableGuid(unchecked((int)0x9180AF33), 0x1239, 0x4AD0, 0x9D, 0x59, 0x9A, 0x0B, 0xD5, 0x40, 0x7F, 0x1A).Value); byte[] test2bytes = { 0xA5, 0x53, 0x12, 0xCB, 0x71, 0xE4, 0x6E, 0xE5 }; nua.AssertEquals("#A02", Test2.Value, new NullableGuid(0x1C432B6D, unchecked((short)0x9AF7), 0x4665, test2bytes).Value); } // Test public fields [nu.Test] public void PublicFields() { // Null nua.Assert("#B06", NullableGuid.Null.IsNull); } // Test properties [nu.Test] public void Properties() { // IsNull nua.Assert("#C03", !Test1.IsNull); nua.Assert("#C04", NullableGuid.Null.IsNull); // Value nua.AssertEquals("#C07", "e64edb0f-e4e1-4b35-99cd-4bedfb2e7af0", Test3.Value.ToString()); } // Public methods [nu.Test] public void CompareTo() { } [nu.Test] [nu.ExpectedException(typeof(sys.ArgumentException))] public void CompareToWrongType() { ((sys.IComparable)Test1).CompareTo(1); } [nu.Test] public void EqualsMethods() { NullableGuid t2 = new NullableGuid(Test2.Value); nua.Assert("#E01", !Test1.Equals(Test2)); nua.Assert("#E02", !Test3.Equals(Test1)); nua.Assert("#E03", Test2.Equals(t2)); // Static Equals()-method nua.Assert("#E04", NullableGuid.Equals(Test2, t2).Value); nua.Assert("#E05", !NullableGuid.Equals (Test1, Test3).Value); } [nu.Test] public void GetHashCodeTest() { // FIXME: Better way to test HashCode nua.AssertEquals("#F01", Test1.GetHashCode (), Test1.GetHashCode ()); nua.Assert("#F02", Test1.GetHashCode () != Test2.GetHashCode ()); nua.Assert("#F03", Test2.GetHashCode () == Test2.GetHashCode ()); } [nu.Test] public void GetTypeTest() { nua.AssertEquals("#G01", "NullableTypes.NullableGuid", Test1.GetType().ToString()); nua.AssertEquals("#G02", "System.Guid", Test1.Value.GetType().ToString()); } [nu.Test] public void NotEquals() { NullableGuid t2 = new NullableGuid(Test2.Value); nua.Assert("#J01", NullableGuid.NotEquals (Test1, Test2).Value); nua.Assert("#J02", NullableGuid.NotEquals (Test2, Test1).Value); nua.Assert("#J03", NullableGuid.NotEquals (Test3, Test1).Value); nua.Assert("#J04", !NullableGuid.NotEquals (Test2, t2).Value); nua.Assert("#J05", NullableGuid.NotEquals (NullableGuid.Null, Test3).IsNull); } [nu.Test] public void Conversions() { // ToNullableString() nua.AssertEquals("#O38", "9180af33-1239-4ad0-9d59-9a0bd5407f1a", Test1.ToNullableString().ToString()); // ToNullableString() with null nua.AssertEquals("#039", NullableGuid.Null.IsNull, NullableGuid.Null.ToNullableString().IsNull); } [nu.Test] public void ThanOrEqualOperators() { NullableGuid t2 = new NullableGuid(Test2.Value); // == -operator nua.Assert("#Q01", (Test2 == t2).Value); nua.Assert("#Q02", !(Test1 == Test2).Value); nua.Assert("#Q03", (Test1 == NullableGuid.Null).IsNull); // != -operator nua.Assert("#Q04", !(t2 != Test2).Value); nua.Assert("#Q05", !(Test2 != t2).Value); nua.Assert("#Q06", (Test1 != Test3).Value); nua.Assert("#Q07", (Test1 != NullableGuid.Null).IsNull); } #region Serialization - K# [nu.Test] public void SerializableAttribute() { NullableGuid serializedDeserialized; serializedDeserialized = SerializeDeserialize(NullableGuid.Null); nua.Assert("TestK#01", serializedDeserialized.IsNull); nua.Assert("TestK#02", NullableGuid.Null.Equals(serializedDeserialized)); serializedDeserialized = SerializeDeserialize(Test1); nua.Assert("TestK#03", !serializedDeserialized.IsNull); nua.AssertEquals("TestK#04", Test1.Value, serializedDeserialized.Value); nua.Assert("TestK#05", Test1.Equals(serializedDeserialized)); } private NullableGuid SerializeDeserialize(NullableGuid x) { System.Runtime.Serialization.Formatters.Soap.SoapFormatter serializer = new System.Runtime.Serialization.Formatters.Soap.SoapFormatter(); using (sys.IO.MemoryStream stream = new sys.IO.MemoryStream()) { serializer.Serialize(stream, x); // sys.Text.Decoder d = sys.Text.Encoding.Default.GetDecoder(); // char[] output = new char[d.GetCharCount(stream.GetBuffer(), 0, (int)stream.Length)]; // d.GetChars(stream.GetBuffer(), 0, (int)stream.Length, output, 0); // sys.Console.WriteLine(new string(output)); stream.Seek(0, sys.IO.SeekOrigin.Begin); // Return stream to start NullableGuid y = (NullableGuid)serializer.Deserialize(stream); stream.Close(); return y; } } [nu.Test] public void XmlSerializable() { NullableGuid xmlSerializedDeserialized; xmlSerializedDeserialized = XmlSerializeDeserialize(NullableGuid.Null); nua.Assert("TestK#01", xmlSerializedDeserialized.IsNull); nua.Assert("TestK#02", NullableGuid.Null.Equals(xmlSerializedDeserialized)); xmlSerializedDeserialized = XmlSerializeDeserialize(Test2); nua.Assert("TestK#03", !xmlSerializedDeserialized.IsNull); nua.AssertEquals("TestK#04", Test2.Value, xmlSerializedDeserialized.Value); nua.Assert("TestK#05", Test2.Equals(xmlSerializedDeserialized)); } private NullableGuid XmlSerializeDeserialize(NullableGuid x) { System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(NullableGuid)); using (sys.IO.MemoryStream stream = new sys.IO.MemoryStream()) { serializer.Serialize(stream, x); // sys.Text.Decoder d = sys.Text.Encoding.Default.GetDecoder(); // char[] output = new char[d.GetCharCount(stream.GetBuffer(), 0, (int)stream.Length)]; // d.GetChars(stream.GetBuffer(), 0, (int)stream.Length, output, 0); // sys.Console.WriteLine(new string(output)); stream.Seek(0, sys.IO.SeekOrigin.Begin); // Return stream to start NullableGuid y = (NullableGuid)serializer.Deserialize(stream); stream.Close(); return y; } } [nu.Test] public void XmlSerializableEmptyElementNil() { //<?xml version="1.0"?> //<NullableGuid xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></NullableGuid> System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(NullableGuid)); using (sys.IO.MemoryStream baseStream = new sys.IO.MemoryStream()) { using (sys.IO.StreamWriter stream = new System.IO.StreamWriter(baseStream)) { stream.WriteLine("<?xml version=\"1.0\"?>"); stream.WriteLine("<NullableGuid xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></NullableGuid>"); stream.Flush(); baseStream.Position = 0; // Return stream to start NullableGuid y = (NullableGuid)serializer.Deserialize(baseStream); nua.Assert(y.IsNull); baseStream.Close(); stream.Close(); } } } [nu.Test] public void XmlSerializableSchema() { sysXmlScm.XmlSchema xsd = ((sysXml.Serialization.IXmlSerializable)NullableGuid.Null).GetSchema(); xsd.Compile(new sysXmlScm.ValidationEventHandler(ValidationCallBack)); ValidateXmlAgainstXmlSchema(xsd, NullableGuid.Null); ValidateXmlAgainstXmlSchema(xsd, Test1); } private void ValidateXmlAgainstXmlSchema(sysXmlScm.XmlSchema xsd, NullableGuid x) { sysXml.Serialization.XmlSerializer serializer = new sysXml.Serialization.XmlSerializer(typeof(NullableGuid)); sys.IO.MemoryStream stream = null; sys.Xml.XmlValidatingReader validator = null; try { // Get the serialized NullableGuid instance stream = new sys.IO.MemoryStream(); serializer.Serialize(stream, x); stream.Seek(0, sys.IO.SeekOrigin.Begin); // Return stream to start // Add the default namespace sysXml.XmlDocument doc = new sysXml.XmlDocument(); doc.Load(stream); sysXml.XmlAttribute defaultNs = doc.CreateAttribute("xmlns"); defaultNs.Value = "http://NullableTypes.SourceForge.Net/NullableGuidXMLSchema"; doc.DocumentElement.Attributes.Append(defaultNs); // Validate validator = new sysXml.XmlValidatingReader(doc.OuterXml, sysXml.XmlNodeType.Document, null); validator.ValidationType = sys.Xml.ValidationType.Schema; validator.Schemas.Add(xsd); validator.ValidationEventHandler += new sys.Xml.Schema.ValidationEventHandler(ValidationCallBack); while(validator.Read()); } finally { if (validator != null) validator.Close(); if (stream != null) ((sys.IDisposable)stream).Dispose(); } } private static void ValidationCallBack(object sender, sysXmlScm.ValidationEventArgs args) { throw args.Exception; } #endregion //Serialization } } Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/AssemblyInfo.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** AssemblyInfo.cs 25 May 2004 22:05:07 -0000 1.10 --- AssemblyInfo.cs 12 Feb 2005 03:44:34 -0000 1.11 *************** *** 12,16 **** [assembly: AssemblyCompany("Luca Minudel")] [assembly: AssemblyProduct("NullableTypes")] // Product Name ! [assembly: AssemblyCopyright("© 2003-2004 Luca Minudel, MIT license")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] --- 12,16 ---- [assembly: AssemblyCompany("Luca Minudel")] [assembly: AssemblyProduct("NullableTypes")] // Product Name ! [assembly: AssemblyCopyright("© 2003-2005 Luca Minudel, MIT license")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] *************** *** 28,33 **** // by using the '*' as shown below: ! [assembly: AssemblyVersion("1.2.*")] ! [assembly: AssemblyInformationalVersion("1.2")] // odd beta version 1.1.* - stable will be 1.2 // --- 28,33 ---- // by using the '*' as shown below: ! [assembly: AssemblyVersion("1.3.*")] ! [assembly: AssemblyInformationalVersion("1.3.0")] // odd beta version 1.1.* - stable will be 1.2 // |
From: \(luKa\) <luk...@us...> - 2005-02-12 03:44:43
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types/internal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24056/src/Types/internal Modified Files: AssemblyInfo.cs AssemblySecurity.cs Log Message: Index: AssemblySecurity.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/internal/AssemblySecurity.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AssemblySecurity.cs 3 Jul 2003 22:23:52 -0000 1.1 --- AssemblySecurity.cs 12 Feb 2005 03:44:34 -0000 1.2 *************** *** 6,9 **** --- 6,11 ---- // Date Author Changes Reasons // 03-Jul-2003 Luca Create + // 12-Feb-2005 Luca Upgrade Reduced attack surface of NullableTypes assembly, + // reduced permissions required for NullableTypes callers. // *************** *** 11,14 **** --- 13,19 ---- using System.Security.Permissions; + + [assembly:System.Security.AllowPartiallyTrustedCallers] + // RequestMinimum [assembly:SecurityPermission(SecurityAction.RequestMinimum, Execution=true)] *************** *** 23,24 **** --- 28,52 ---- [assembly:RegistryPermission(SecurityAction.RequestRefuse, Unrestricted=true)] [assembly:UIPermission(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:System.Web.AspNetHostingPermission(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:System.Net.DnsPermission(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:System.Net.SocketPermission(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:System.Net.WebPermissionAttribute(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:FileDialogPermission(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:FileIOPermission(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:IsolatedStorageFilePermission(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:EnvironmentPermission(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:RegistryPermission(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:System.Diagnostics.EventLogPermission(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:System.Diagnostics.PerformanceCounterPermission(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:ReflectionPermission(SecurityAction.RequestRefuse, Unrestricted=true)] + [assembly:SecurityPermission(SecurityAction.RequestRefuse, UnmanagedCode=true)] + [assembly:SecurityPermission(SecurityAction.RequestRefuse, SkipVerification=true)] + [assembly:SecurityPermission(SecurityAction.RequestRefuse, SerializationFormatter=true)] + [assembly:SecurityPermission(SecurityAction.RequestRefuse, RemotingConfiguration=true)] + [assembly:SecurityPermission(SecurityAction.RequestRefuse, Infrastructure=true)] + [assembly:SecurityPermission(SecurityAction.RequestRefuse, ControlPrincipal=true)] + [assembly:SecurityPermission(SecurityAction.RequestRefuse, ControlPolicy=true)] + [assembly:SecurityPermission(SecurityAction.RequestRefuse, ControlDomainPolicy=true)] + [assembly:SecurityPermission(SecurityAction.RequestRefuse, ControlEvidence=true)] + [assembly:SecurityPermission(SecurityAction.RequestRefuse, ControlAppDomain=true)] + [assembly:SecurityPermission(SecurityAction.RequestRefuse, ControlThread=true)] Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/internal/AssemblyInfo.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** AssemblyInfo.cs 25 May 2004 22:05:08 -0000 1.19 --- AssemblyInfo.cs 12 Feb 2005 03:44:34 -0000 1.20 *************** *** 18,22 **** [assembly: AssemblyCompany("Luca Minudel")] [assembly: AssemblyProduct("NullableTypes")] // Product Name ! [assembly: AssemblyCopyright("Copyleft © 2003-2004, Luca Minudel, MIT license")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] --- 18,22 ---- [assembly: AssemblyCompany("Luca Minudel")] [assembly: AssemblyProduct("NullableTypes")] // Product Name ! [assembly: AssemblyCopyright("Copyleft © 2003-2005, Luca Minudel, MIT license")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] *************** *** 33,38 **** // by using the '*' as shown below: ! [assembly: AssemblyVersion("1.2.*")] ! [assembly: AssemblyInformationalVersion("1.2")] // odd beta version 1.1.* - stable will be 1.2 // // In order to sign your assembly you must specify a key to use. Refer to the --- 33,38 ---- // by using the '*' as shown below: ! [assembly: AssemblyVersion("1.3.*")] ! [assembly: AssemblyInformationalVersion("1.3.0")] // odd beta version 1.3.* - stable will be 1.4 // // In order to sign your assembly you must specify a key to use. Refer to the |
From: \(luKa\) <luk...@us...> - 2005-02-12 03:44:42
|
Update of /cvsroot/nullabletypes/NullableTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24056 Modified Files: ReleaseNotes.txt Log Message: Index: ReleaseNotes.txt =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/ReleaseNotes.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ReleaseNotes.txt 1 Jun 2004 18:40:32 -0000 1.14 --- ReleaseNotes.txt 12 Feb 2005 03:44:33 -0000 1.15 *************** *** 1,2 **** --- 1,22 ---- + NullableTypes ver. 1.3 + ---------------------------------------------------------- + This is the first beta after the official release v1.2. It adds + minor improvements. + It include binary, samples in C# and VB.NET, help and source code. + + Changes from ver. 1.2 + - Security: Reduced attack surface of NullableTypes assembly + - Security: Reduced permissions required for NullableTypes callers. + - Improved tests NullableSingleTest.ParseFormatException() and + NullableDoubleTest.ParseFormatException() to make them pass also + with the current culture 'German (Switzerland)' 'de-CH' 'LCID=2055' + - NullableStringTest2.XmlSerializable test was broken - not nu.Test and + not calling correct function. + - Added new type NullableGuid and added NullableGuid tests, + added NullableGuid conversions in DBNullConvert and NullConvert + + + + NullableTypes ver. 1.2 ---------------------------------------------------------- |
From: \(luKa\) <luk...@us...> - 2004-06-01 18:40:42
|
Update of /cvsroot/nullabletypes/NullableTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24793 Modified Files: NullableTypes.ndoc ReadMe.txt ReleaseNotes.txt Log Message: Index: NullableTypes.ndoc =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/NullableTypes.ndoc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** NullableTypes.ndoc 22 Oct 2003 01:44:00 -0000 1.12 --- NullableTypes.ndoc 1 Jun 2004 18:40:31 -0000 1.13 *************** *** 19,22 **** --- 19,70 ---- </namespaces> <documenters> + <documenter name="HtmlHelp2"> + <property name="CharacterSet" value="UTF8" /> + <property name="LangID" value="1033" /> + <property name="DeleteCHM" value="False" /> + <property name="AugmentXmlDataIslands" value="True" /> + <property name="RegisterTitleWithNamespace" value="False" /> + <property name="ParentCollectionNamespace" value="" /> + <property name="RegisterTitleAsCollection" value="False" /> + <property name="OutputDirectory" value="c:\NullableTypes-doc2\" /> + <property name="HtmlHelpName" value="NullableTypes" /> + <property name="IncludeFavorites" value="True" /> + <property name="Title" value="NullableTypes Class Library" /> + <property name="SplitTOCs" value="False" /> + <property name="DefaulTOC" value="" /> + <property name="IncludeHierarchy" value="True" /> + <property name="ShowVisualBasic" value="True" /> + <property name="RootPageContainsNamespaces" value="True" /> + <property name="SortTOCByNamespace" value="True" /> + <property name="OutputTarget" value="HtmlHelpAndWeb" /> + <property name="HeaderHtml" value="" /> + <property name="FooterHtml" value="" /> + <property name="FilesToInclude" value="" /> + <property name="LinkToSdkDocVersion" value="SDK_v1_1" /> + <property name="ShowMissingSummaries" value="True" /> + <property name="ShowMissingRemarks" value="False" /> + <property name="ShowMissingParams" value="True" /> + <property name="ShowMissingReturns" value="True" /> + <property name="ShowMissingValues" value="True" /> + <property name="DocumentInternals" value="False" /> + <property name="DocumentProtected" value="True" /> + <property name="DocumentPrivates" value="False" /> + <property name="DocumentProtectedInternalAsProtected" value="False" /> + <property name="DocumentEmptyNamespaces" value="False" /> + <property name="IncludeAssemblyVersion" value="True" /> + <property name="CopyrightText" value="Send comments on this topic and report documentation errors here. " /> + <property name="CopyrightHref" value="http://sourceforge.net/tracker/?atid=549980&group_id=77359" /> + <property name="ReferencesPath" value="" /> + <property name="SkipNamespacesWithoutSummaries" value="False" /> + <property name="UseNamespaceDocSummaries" value="False" /> + <property name="AutoPropertyBackerSummaries" value="True" /> + <property name="AutoDocumentConstructors" value="True" /> + <property name="DocumentAttributes" value="True" /> + <property name="ShowTypeIdInAttributes" value="False" /> + <property name="DocumentedAttributes" value="" /> + <property name="GetExternalSummaries" value="True" /> + <property name="EditorBrowsableFilter" value="Off" /> + <property name="UseNDocXmlFile" value="" /> + </documenter> <documenter name="JavaDoc"> <property name="OutputDirectory" value=".\docs\JavaDoc\" /> *************** *** 29,49 **** <property name="DocumentProtected" value="True" /> <property name="DocumentPrivates" value="False" /> <property name="DocumentEmptyNamespaces" value="False" /> <property name="IncludeAssemblyVersion" value="False" /> <property name="CopyrightText" value="" /> <property name="CopyrightHref" value="" /> <property name="SkipNamespacesWithoutSummaries" value="False" /> <property name="AutoPropertyBackerSummaries" value="False" /> <property name="AutoDocumentConstructors" value="True" /> <property name="DocumentAttributes" value="False" /> <property name="DocumentedAttributes" value="" /> <property name="GetExternalSummaries" value="True" /> </documenter> ! <documenter name="Latex"> ! <property name="OutputDirectory" value="Tex" /> <property name="TextFileFullName" value="Documentation.tex" /> <property name="TexFileBaseName" value="Documentation" /> <property name="LatexCompiler" value="latex" /> ! <property name="TexFileFullPath" value="Tex\Documentation.tex" /> <property name="ShowMissingSummaries" value="False" /> <property name="ShowMissingRemarks" value="False" /> --- 77,103 ---- <property name="DocumentProtected" value="True" /> <property name="DocumentPrivates" value="False" /> + <property name="DocumentProtectedInternalAsProtected" value="False" /> <property name="DocumentEmptyNamespaces" value="False" /> <property name="IncludeAssemblyVersion" value="False" /> <property name="CopyrightText" value="" /> <property name="CopyrightHref" value="" /> + <property name="ReferencesPath" value="" /> <property name="SkipNamespacesWithoutSummaries" value="False" /> + <property name="UseNamespaceDocSummaries" value="False" /> <property name="AutoPropertyBackerSummaries" value="False" /> <property name="AutoDocumentConstructors" value="True" /> <property name="DocumentAttributes" value="False" /> + <property name="ShowTypeIdInAttributes" value="False" /> <property name="DocumentedAttributes" value="" /> <property name="GetExternalSummaries" value="True" /> + <property name="EditorBrowsableFilter" value="Off" /> + <property name="UseNDocXmlFile" value="" /> </documenter> ! <documenter name="LaTeX"> ! <property name="OutputDirectory" value=".\doc\" /> <property name="TextFileFullName" value="Documentation.tex" /> <property name="TexFileBaseName" value="Documentation" /> <property name="LatexCompiler" value="latex" /> ! <property name="TexFileFullPath" value=".\doc\Documentation.tex" /> <property name="ShowMissingSummaries" value="False" /> <property name="ShowMissingRemarks" value="False" /> *************** *** 54,67 **** --- 108,164 ---- <property name="DocumentProtected" value="True" /> <property name="DocumentPrivates" value="False" /> + <property name="DocumentProtectedInternalAsProtected" value="False" /> <property name="DocumentEmptyNamespaces" value="False" /> <property name="IncludeAssemblyVersion" value="False" /> <property name="CopyrightText" value="" /> <property name="CopyrightHref" value="" /> + <property name="ReferencesPath" value="" /> + <property name="SkipNamespacesWithoutSummaries" value="False" /> + <property name="UseNamespaceDocSummaries" value="False" /> + <property name="AutoPropertyBackerSummaries" value="False" /> + <property name="AutoDocumentConstructors" value="True" /> + <property name="DocumentAttributes" value="False" /> + <property name="ShowTypeIdInAttributes" value="False" /> + <property name="DocumentedAttributes" value="" /> + <property name="GetExternalSummaries" value="True" /> + <property name="EditorBrowsableFilter" value="Off" /> + <property name="UseNDocXmlFile" value="" /> + </documenter> + <documenter name="LinearHtml"> + <property name="IncludeTypeMemberDetails" value="False" /> + <property name="OutputDirectory" value=".\doc\" /> + <property name="MethodParametersInTable" value="False" /> + <property name="TypeIncludeRegexp" value="" /> + <property name="NamespaceExcludeRegexp" value="" /> + <property name="Title" value="An NDoc Documented Class Library" /> + <property name="IncludeHierarchy" value="False" /> + <property name="SortTOCByNamespace" value="True" /> + <property name="HeaderHtml" value="" /> + <property name="FooterHtml" value="" /> + <property name="FilesToInclude" value="" /> + <property name="ShowMissingSummaries" value="False" /> + <property name="ShowMissingRemarks" value="False" /> + <property name="ShowMissingParams" value="False" /> + <property name="ShowMissingReturns" value="False" /> + <property name="ShowMissingValues" value="False" /> + <property name="DocumentInternals" value="False" /> + <property name="DocumentProtected" value="True" /> + <property name="DocumentPrivates" value="False" /> + <property name="DocumentProtectedInternalAsProtected" value="False" /> + <property name="DocumentEmptyNamespaces" value="False" /> + <property name="IncludeAssemblyVersion" value="False" /> + <property name="CopyrightText" value="" /> + <property name="CopyrightHref" value="" /> + <property name="ReferencesPath" value="" /> <property name="SkipNamespacesWithoutSummaries" value="False" /> + <property name="UseNamespaceDocSummaries" value="False" /> <property name="AutoPropertyBackerSummaries" value="False" /> <property name="AutoDocumentConstructors" value="True" /> <property name="DocumentAttributes" value="False" /> + <property name="ShowTypeIdInAttributes" value="False" /> <property name="DocumentedAttributes" value="" /> <property name="GetExternalSummaries" value="True" /> + <property name="EditorBrowsableFilter" value="Off" /> + <property name="UseNDocXmlFile" value="" /> </documenter> <documenter name="MSDN"> *************** *** 74,81 **** <property name="IncludeHierarchy" value="True" /> <property name="ShowVisualBasic" value="True" /> - <property name="OmitObjectTags" value="False" /> <property name="RootPageTOCName" value="" /> <property name="RootPageContainsNamespaces" value="True" /> <property name="SortTOCByNamespace" value="True" /> <property name="ShowMissingSummaries" value="True" /> <property name="ShowMissingRemarks" value="False" /> --- 171,182 ---- <property name="IncludeHierarchy" value="True" /> <property name="ShowVisualBasic" value="True" /> <property name="RootPageTOCName" value="" /> <property name="RootPageContainsNamespaces" value="True" /> <property name="SortTOCByNamespace" value="True" /> + <property name="OutputTarget" value="HtmlHelpAndWeb" /> + <property name="HeaderHtml" value="" /> + <property name="FooterHtml" value="" /> + <property name="FilesToInclude" value="" /> + <property name="LinkToSdkDocVersion" value="SDK_v1_1" /> <property name="ShowMissingSummaries" value="True" /> <property name="ShowMissingRemarks" value="False" /> *************** *** 86,99 **** --- 187,206 ---- <property name="DocumentProtected" value="True" /> <property name="DocumentPrivates" value="False" /> + <property name="DocumentProtectedInternalAsProtected" value="False" /> <property name="DocumentEmptyNamespaces" value="False" /> <property name="IncludeAssemblyVersion" value="True" /> <property name="CopyrightText" value="Send comments on this topic and report documentation errors here. " /> <property name="CopyrightHref" value="http://sourceforge.net/tracker/?atid=549980&group_id=77359" /> + <property name="ReferencesPath" value="" /> <property name="SkipNamespacesWithoutSummaries" value="False" /> + <property name="UseNamespaceDocSummaries" value="False" /> <property name="AutoPropertyBackerSummaries" value="True" /> <property name="AutoDocumentConstructors" value="True" /> <property name="DocumentAttributes" value="True" /> + <property name="ShowTypeIdInAttributes" value="False" /> <property name="DocumentedAttributes" value="" /> <property name="GetExternalSummaries" value="True" /> + <property name="EditorBrowsableFilter" value="Off" /> + <property name="UseNDocXmlFile" value="" /> </documenter> <documenter name="XML"> *************** *** 107,120 **** --- 214,233 ---- <property name="DocumentProtected" value="True" /> <property name="DocumentPrivates" value="False" /> + <property name="DocumentProtectedInternalAsProtected" value="False" /> <property name="DocumentEmptyNamespaces" value="False" /> <property name="IncludeAssemblyVersion" value="False" /> <property name="CopyrightText" value="" /> <property name="CopyrightHref" value="" /> + <property name="ReferencesPath" value="" /> <property name="SkipNamespacesWithoutSummaries" value="False" /> + <property name="UseNamespaceDocSummaries" value="False" /> <property name="AutoPropertyBackerSummaries" value="False" /> <property name="AutoDocumentConstructors" value="True" /> <property name="DocumentAttributes" value="False" /> + <property name="ShowTypeIdInAttributes" value="False" /> <property name="DocumentedAttributes" value="" /> <property name="GetExternalSummaries" value="True" /> + <property name="EditorBrowsableFilter" value="Off" /> + <property name="UseNDocXmlFile" value="" /> </documenter> </documenters> Index: ReleaseNotes.txt =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/ReleaseNotes.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ReleaseNotes.txt 25 May 2004 22:05:06 -0000 1.13 --- ReleaseNotes.txt 1 Jun 2004 18:40:32 -0000 1.14 *************** *** 28,33 **** - Compiled with VS.NET 2003 C# compiler (needed to make Obsolete attribute work for Operator) and .NET Framework 1.1 ! ...publisher policy ! ...- Documentation ported to .NET Framework 1.1 - C# Sample ported to VS.NET 2003 - VB.NET Sample ported to VS.NET 2003 --- 28,36 ---- - Compiled with VS.NET 2003 C# compiler (needed to make Obsolete attribute work for Operator) and .NET Framework 1.1 ! - Added Configuration settings to make NullableTypes work with ! .NET Framework 1.0 ! - Added Publisher policy to state backward compatibility with ! NullableTypes 1.0 ! - Documentation ported to .NET Framework 1.1 - C# Sample ported to VS.NET 2003 - VB.NET Sample ported to VS.NET 2003 Index: ReadMe.txt =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/ReadMe.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ReadMe.txt 25 May 2004 22:05:05 -0000 1.17 --- ReadMe.txt 1 Jun 2004 18:40:31 -0000 1.18 *************** *** 6,10 **** 2. NULLABLETYPES LICENSING 3. NULLABLETYPES ASSEMBLY ! 4. .NET AND VS.NET VERSIONS 5. NULLABLETYPES FAQ 6. OVERWHELMING TYPING --- 6,10 ---- 2. NULLABLETYPES LICENSING 3. NULLABLETYPES ASSEMBLY ! 4. VERSIONS COMPATIBILITY 5. NULLABLETYPES FAQ 6. OVERWHELMING TYPING *************** *** 68,82 **** ! 4. .NET AND VS.NET VERSIONS ============================== - NullableTypes source code has been written and compiled against .NET Framework v1.1. - Due to high degree of support for .NET Framework v1.0 forward compatibility (applications created - using v1.1 may run on v1.0) NullableTypes source code still compile with .NET Framework v1.0 and - NullableTypes assembly still run and pass tests on .NET Framework v1.0. - To run NullableTypes on .NET Framework v1.0 use the configuration settings in file - bin\NullableTypes.Tests.DLL.config to make your myAppllication.exe.config file or put them on your - Web.config file. ! NullableTypes projects and source code are created using VS.NET 2002 and have been converted to VS.NET 2003. --- 68,95 ---- ! 4. VERSIONS COMPATIBILITY ============================== ! .NET Framework compatibility ! NullableTypes 1.2 source code has been compiled against .NET Framework v1.1. ! NullableTypes 1.2 assembly reference the .NET Framework v1.1 but it can run also with .NET Framework v1.0. ! To run NullableTypes 1.2 assembly with .NET Framework v1.0, paste the configuration settings of file ! 'bin\NullableTypes.Tests.DLL.config' in your application configuration file (say MyApp.EXE.Config or ! Web.Config). ! Due to high degree of support for .NET Framework v1.0 forward compatibility (applications created ! using v1.1 may run on v1.0) NullableTypes 1.2 assembly run and pass tests on .NET Framework v1.0. Also ! NullableTypes 1.2 source code still compile with .NET Framework v1.0. ! ! NullableTypes Backward compatibility ! NullableTypes 1.2 assembly is backward compatibile with NullableTypes 1.0 assembly. ! To use a NullableTypes 1.2 assembly where a NullableTypes 1.0 assembly is expected, register the ! Publisher Policy with the 'policy-register.cmd' command in the 'bin\PublisherPolicy' folder or paste the ! configuration settings of file 'bin\PublisherPolicy\policy.1.0.NullableTypes.dll' in your application ! configuration file (say MyApp.EXE.Config or Web.Config). ! To test backward compatibility, after registering publisher policy in the GAC, rename ! 'NullableTypes.Tests.dll-v1.0' to 'NullableTypes.Tests.dll' in the 'bin' folder and do run tests again. ! ! VS.NET compatibility ! NullableTypes projects and source code are created using VS.NET 2002 and have been converted to VS.NET 2003. |
From: \(luKa\) <luk...@us...> - 2004-06-01 18:40:40
|
Update of /cvsroot/nullabletypes/NullableTypes/src/PublisherPolicy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24793/src/PublisherPolicy Added Files: build.cmd policy-register.cmd policy-unregister.cmd policy.1.0.NullableTypes.config Log Message: --- NEW FILE: policy-unregister.cmd --- if not '%VSCOMNTOOLS%' == '' call %VSCOMNTOOLS%VSVARS32.BAT if not "%VS71COMNTOOLS%" == "" call "%VS71COMNTOOLS%\VSVARS32.BAT" CLS gacutil /u policy.1.0.NullableTypes pause --- NEW FILE: policy-register.cmd --- if not '%VSCOMNTOOLS%' == '' call %VSCOMNTOOLS%VSVARS32.BAT if not "%VS71COMNTOOLS%" == "" call "%VS71COMNTOOLS%\VSVARS32.BAT" CLS gacutil /if policy.1.0.NullableTypes.dll pause --- NEW FILE: policy.1.0.NullableTypes.config --- <?xml version="1.0" encoding="Windows-1252"?> <configuration> <!-- =========================================================================================== --> <!-- Settings to make applications compiled against NullableTypes 1.0 run with NullableTypes 1.2 --> <!-- =========================================================================================== --> <!-- N.B.: do NOT edit/change this file! This file is an external resource file referenced by the publisher policy Assembly policy.1.0.NullableTypes.dll while it is registered in the GAC. --> <!-- Note: if you want to state machine-wide verson compatibility for NullableTypes 1.2, just register the publisher policy Assembly policy.1.0.NullableTypes.dll in the GAC. If you wanna state verson compatibility just for an application, paste these settings in your application configuration file (for an application named myExecutable.exe, the application configuration file must be named myExecutable.exe.config; for ASP.NET-hosted application, the configuration file is named Web.config). Uncomment the codeBase tag and set the correct absolute path for the href attribute when necessary. --> <runtime> <asm:assemblyBinding xmlns:asm="urn:schemas-microsoft-com:asm.v1"> <asm:dependentAssembly> <asm:assemblyIdentity name="NullableTypes" publicKeyToken="2fe76717e05fac0e" /> <asm:bindingRedirect oldVersion="1.0.1361.41067" newVersion="1.2.1604.27693" /> <!-- <asm:codeBase version="1.2.1604.27693" href="file://C:/NullableTypes-1.2/bin/NullableTypes.DLL" /> --> </asm:dependentAssembly> </asm:assemblyBinding> </runtime> </configuration> --- NEW FILE: build.cmd --- (This appears to be a binary file; contents omitted.) |
From: \(luKa\) <luk...@us...> - 2004-06-01 18:39:00
|
Update of /cvsroot/nullabletypes/NullableTypes/src/PublisherPolicy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24348/PublisherPolicy Log Message: Directory /cvsroot/nullabletypes/NullableTypes/src/PublisherPolicy added to the repository |
From: \(luKa\) <luk...@us...> - 2004-05-25 22:05:21
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6035/src/Tests Modified Files: AssemblyInfo.cs NullableDateTimeTest.cs Log Message: Index: NullableDateTimeTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableDateTimeTest.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** NullableDateTimeTest.cs 20 Feb 2004 00:42:22 -0000 1.12 --- NullableDateTimeTest.cs 25 May 2004 22:05:07 -0000 1.13 *************** *** 14,22 **** // full range persists // Code upgrade: Tidy up source ! // 06-Ott-2003 Luca Upgrade New test: XmlSerializableSchema // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to reflect changes in the target type // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil // value with a non empty element // --- 14,25 ---- // full range persists // Code upgrade: Tidy up source ! // 06-Oct-2003 Luca Upgrade New test: XmlSerializableSchema // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to reflect changes in the target type // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil // value with a non empty element + // 23-May-2004 Luca Upgrade Code upgrade: test NullableDateTimeConversionOperatorFromNullableString + // improved to make it independent from user regional settings (problem reported + // by imagina (hemmachat sf user) // *************** *** 27,30 **** --- 30,35 ---- using sysXml = System.Xml; using sysXmlScm = System.Xml.Schema; + using sysGlb = System.Globalization; + using sysThr = System.Threading; [nu.TestFixture] *************** *** 46,49 **** --- 51,55 ---- } + #region Field Tests - A# [nu.Test] *************** *** 450,458 **** [nu.Test] public void NullableDateTimeConversionOperatorFromNullableString() { ! NullableString x = new NullableString("2002-2-22"); ! sys.DateTime tx = new sys.DateTime(2002, 2, 22); ! nua.AssertEquals("TestI#02", new NullableDateTime(tx), ! (NullableDateTime)x); } --- 456,471 ---- [nu.Test] public void NullableDateTimeConversionOperatorFromNullableString() { ! sysGlb.CultureInfo currCult = sys.Threading.Thread.CurrentThread.CurrentCulture; ! try { ! sysThr.Thread.CurrentThread.CurrentCulture = sysGlb.CultureInfo.InvariantCulture; ! NullableString x = new NullableString("2002-2-22"); ! sys.DateTime tx = new sys.DateTime(2002, 2, 22); ! nua.AssertEquals("TestI#02", new NullableDateTime(tx), ! (NullableDateTime)x); ! } ! finally { ! sysThr.Thread.CurrentThread.CurrentCulture = currCult; ! } } Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/AssemblyInfo.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AssemblyInfo.cs 22 Oct 2003 01:42:11 -0000 1.9 --- AssemblyInfo.cs 25 May 2004 22:05:07 -0000 1.10 *************** *** 12,16 **** [assembly: AssemblyCompany("Luca Minudel")] [assembly: AssemblyProduct("NullableTypes")] // Product Name ! [assembly: AssemblyCopyright("© 2003 Luca Minudel, MIT license")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] --- 12,16 ---- [assembly: AssemblyCompany("Luca Minudel")] [assembly: AssemblyProduct("NullableTypes")] // Product Name ! [assembly: AssemblyCopyright("© 2003-2004 Luca Minudel, MIT license")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] *************** *** 28,33 **** // by using the '*' as shown below: ! [assembly: AssemblyVersion("1.1.*")] ! [assembly: AssemblyInformationalVersion("1.1.1")] // odd beta version 1.1.* - stable will be 1.2 // --- 28,33 ---- // by using the '*' as shown below: ! [assembly: AssemblyVersion("1.2.*")] ! [assembly: AssemblyInformationalVersion("1.2")] // odd beta version 1.1.* - stable will be 1.2 // |
From: \(luKa\) <luk...@us...> - 2004-05-25 22:05:20
|
Update of /cvsroot/nullabletypes/NullableTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6035 Modified Files: ReadMe.txt ReleaseNotes.txt license.txt Log Message: Index: ReleaseNotes.txt =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/ReleaseNotes.txt,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ReleaseNotes.txt 20 Feb 2004 00:42:21 -0000 1.12 --- ReleaseNotes.txt 25 May 2004 22:05:06 -0000 1.13 *************** *** 1,6 **** ! NullableTypes ver. 1.1.1 (beta) ---------------------------------------------------------- ! This beta follow the beta v1.1.0 It fix bugs introduced in the ! new features of beta v1.1.0. It include binary, samples in C# and VB.NET, help and source code. --- 1,6 ---- ! NullableTypes ver. 1.2 ---------------------------------------------------------- ! This official release follow the first official v1.0, it enable ! NullableTypes to work smoothly with Web Services as built-in types. It include binary, samples in C# and VB.NET, help and source code. *************** *** 21,65 **** ! Changes from ver. 1.1.0 (beta) ! - BUG FIX: Replaced Xml Schema Id in all NullableTypes to ! make VSDesigner auto-generated WS client Proxy compile ! - BUG FIX: Replaced Target Namespace for Xml Schema in all ! NullableTypes to avoid duplicate namespace when using ! 2 or more NullableTypes parameters in a WS method ! - BUG FIX: Fixed IXmlSerializable.ReadXml implementation in ! NullableBoolean ! - BUG FIX: Fixed IXmlSerializable.ReadXml implementation for ! all types to accept a nil value with a non empty element. - NullableBoolean Operator^ (XOR) marked Obsolete - NullableBoolean Xor method marked Obsolete - Compiled with VS.NET 2003 C# compiler (needed to make Obsolete attribute work for Operator) and .NET Framework 1.1 ! - Replaced literal values in MinValue and MaxValue inizialization ! in NullableInt16 and NullableInt32 with System.Int16 and System.Int32 ! MinValue and MaxValue constants - C# Sample ported to VS.NET 2003 - Changes from ver. 1.0 - - NullableTypes enabled to work with Web Services by - IXmlSerializable - - Changes from ver. 0.11 (beta) - - [Serializable] attribute added to NullableTypes - - Changed NullableBoolean specifications and implementation - of Operator &, Operator |, And(), Or() to reflect correct - NULL semantic - - Tests NullConvertTest.ToNullableDateTimeFromString, - NullableDateTimeTest2.TestParse, NullableSingleTest.Parse, - NullableDoubleTest.Parse and NullableStringTest2.CompareTo - have been fixed - - VB.NET Sample now include NullableTypes convertions to and - from a DataTable and to and from a TextBox samples - - Changes from ver. 0.10 (beta) - - New convertion functions in class NullConvert - - C# Sample now include NullableTypes conversions to and - from a DataTable and to and from a TextBox samples - - Changes from ver. 0.9 (beta) - - DBNullConvert moved to namespace NullableTypes.HelperFunctions - - New class NullConvert --- 21,39 ---- ! Changes from ver. 1.0 ! - NullableTypes enabled to work with Web Services by ! IXmlSerializable - NullableBoolean Operator^ (XOR) marked Obsolete - NullableBoolean Xor method marked Obsolete - Compiled with VS.NET 2003 C# compiler (needed to make Obsolete attribute work for Operator) and .NET Framework 1.1 ! ...publisher policy ! ...- Documentation ported to .NET Framework 1.1 - C# Sample ported to VS.NET 2003 + - VB.NET Sample ported to VS.NET 2003 + - Replaced literal values in MinValue and MaxValue inizialization + in NullableInt16 and NullableInt32 with System.Int16 and + System.Int32 MinValue and MaxValue constants + - CODE UPGRADE: NullableDateTimeConversionOperatorFromNullableString + test now work with Thai (Thailand,"th-TH",1054) regional settings. Index: license.txt =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/license.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** license.txt 8 Aug 2003 23:53:37 -0000 1.3 --- license.txt 25 May 2004 22:05:06 -0000 1.4 *************** *** 1,5 **** MIT License for NullableTypes ! Copyright (c) 2003 Luca Minudel Permission is hereby granted, free of charge, to any --- 1,5 ---- MIT License for NullableTypes ! Copyright (c) 2003-2004 Luca Minudel Permission is hereby granted, free of charge, to any Index: ReadMe.txt =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/ReadMe.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ReadMe.txt 20 Feb 2004 00:42:21 -0000 1.16 --- ReadMe.txt 25 May 2004 22:05:05 -0000 1.17 *************** *** 1,7 **** ========================================================== ! NullableTypes ver. 1.1.1 (Beta) ========================================================== - 0. THIS BETA 1. INTRO 2. NULLABLETYPES LICENSING --- 1,6 ---- ========================================================== ! NullableTypes ver. 1.2 ========================================================== 1. INTRO 2. NULLABLETYPES LICENSING *************** *** 16,33 **** - 0. THIS BETA - ============== - This beta follows the beta v1.1.0, it enable NullableTypes to work smoothly - with Web Services as built-in types and correct some bugs of beta v1.1.0. As usual this beta has been - released to find out bugs and expose implementation defects. - - To check that NullableTypes run correctly on your system, first of all do run tests (from the 'tests' - folder just execute 'RunTests.BAT' and click 'RUN' button). - To check that NullableTypes work well with Web Services try out NullableTypes with your Web Services - (use one of the NullableTypes as a parameter and as a return type, also use it as a member of a parameter - type or as a member of the return type). - - If you get a red bar running tests or if you discover a bug don't hesitate to drop an email to - luk...@us..., we love to get feedback. --- 15,18 ---- *************** *** 48,54 **** --- 33,45 ---- To check that NullableTypes run correctly on your system, first of all do run tests: from the 'tests' folder just execute 'RunTests.BAT' and click 'RUN' button. + If you get a red bar after running tests, if you discover a bug in NullableTypes software or if you see a mistake in the documentation don't hesitate to drop a bug report: we love to get feedback. + To check that NullableTypes work well with Web Services try out NullableTypes with your Web Services + (use one of the NullableTypes as a parameter and as a return type, also use it as a member of a parameter + type or as a member of the return type). + + [1] Test-Driven Development - Kent Beck - Three Rivers Institute - http://groups.yahoo.com/group/testdrivendevelopment/files/TDD17Jul2002.pdf |
From: \(luKa\) <luk...@us...> - 2004-05-25 22:05:20
|
Update of /cvsroot/nullabletypes/NullableTypes/samples/VB.NET In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6035/samples/VB.NET Modified Files: VB.NET.sln VB.NET.vbproj Log Message: Index: VB.NET.sln =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/samples/VB.NET/VB.NET.sln,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VB.NET.sln 15 Jul 2003 23:33:57 -0000 1.1 --- VB.NET.sln 25 May 2004 22:05:07 -0000 1.2 *************** *** 1,11 **** ! Microsoft Visual Studio Solution File, Format Version 7.00 Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VB.NET", "VB.NET.vbproj", "{3EA2840F-83B3-4E30-BA2A-70500A38D486}" EndProject Global GlobalSection(SolutionConfiguration) = preSolution ! ConfigName.0 = Debug ! ConfigName.1 = Release ! EndGlobalSection ! GlobalSection(ProjectDependencies) = postSolution EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution --- 1,11 ---- ! Microsoft Visual Studio Solution File, Format Version 8.00 Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VB.NET", "VB.NET.vbproj", "{3EA2840F-83B3-4E30-BA2A-70500A38D486}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution ! Debug = Debug ! Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution Index: VB.NET.vbproj =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/samples/VB.NET/VB.NET.vbproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VB.NET.vbproj 13 Sep 2003 13:11:51 -0000 1.2 --- VB.NET.vbproj 25 May 2004 22:05:07 -0000 1.3 *************** *** 2,7 **** <VisualBasic ProjectType = "Local" ! ProductVersion = "7.0.9466" ! SchemaVersion = "1.0" ProjectGuid = "{3EA2840F-83B3-4E30-BA2A-70500A38D486}" > --- 2,7 ---- <VisualBasic ProjectType = "Local" ! ProductVersion = "7.10.3077" ! SchemaVersion = "2.0" ProjectGuid = "{3EA2840F-83B3-4E30-BA2A-70500A38D486}" > |
From: \(luKa\) <luk...@us...> - 2004-05-25 22:05:20
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types/internal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6035/src/Types/internal Modified Files: AssemblyInfo.cs Log Message: Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/internal/AssemblyInfo.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** AssemblyInfo.cs 22 Oct 2003 01:42:11 -0000 1.18 --- AssemblyInfo.cs 25 May 2004 22:05:08 -0000 1.19 *************** *** 18,22 **** [assembly: AssemblyCompany("Luca Minudel")] [assembly: AssemblyProduct("NullableTypes")] // Product Name ! [assembly: AssemblyCopyright("Copyleft © 2003 Luca Minudel, MIT license")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] --- 18,22 ---- [assembly: AssemblyCompany("Luca Minudel")] [assembly: AssemblyProduct("NullableTypes")] // Product Name ! [assembly: AssemblyCopyright("Copyleft © 2003-2004, Luca Minudel, MIT license")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] *************** *** 33,38 **** // by using the '*' as shown below: ! [assembly: AssemblyVersion("1.1.*")] ! [assembly: AssemblyInformationalVersion("1.1.1")] // odd beta version 1.1.* - stable will be 1.2 // // In order to sign your assembly you must specify a key to use. Refer to the --- 33,38 ---- // by using the '*' as shown below: ! [assembly: AssemblyVersion("1.2.*")] ! [assembly: AssemblyInformationalVersion("1.2")] // odd beta version 1.1.* - stable will be 1.2 // // In order to sign your assembly you must specify a key to use. Refer to the |
From: <luk...@us...> - 2004-02-20 00:53:12
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8752/src/Types Modified Files: NullableBoolean.cs NullableByte.cs NullableDateTime.cs NullableDecimal.cs NullableDouble.cs NullableInt16.cs NullableInt32.cs NullableInt64.cs NullableSingle.cs NullableString.cs TypeCode.cs Log Message: Index: NullableBoolean.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableBoolean.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** NullableBoolean.cs 8 Dec 2003 21:48:41 -0000 1.22 --- NullableBoolean.cs 20 Feb 2004 00:42:22 -0000 1.23 *************** *** 26,29 **** --- 26,30 ---- // other types in NullableTypes // 08-Dic-2003 Luca Bug Fix Replaced ReadString() with ReadElementString() in IXmlSerializable.ReadXml + // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element // *************** *** 275,280 **** [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! if (!reader.IsEmptyElement) { ! _value = (sbyte)(sysXml.XmlConvert.ToBoolean(reader.ReadElementString()) ? 1 : -1); } else --- 276,284 ---- [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; ! string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); ! ! if (nilValue == null || nilValue == "false" || nilValue == "0") { ! _value = (sbyte)(sysXml.XmlConvert.ToBoolean(elementValue) ? 1 : -1); } else Index: NullableByte.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableByte.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** NullableByte.cs 8 Dec 2003 21:53:16 -0000 1.18 --- NullableByte.cs 20 Feb 2004 00:42:22 -0000 1.19 *************** *** 22,25 **** --- 22,26 ---- // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to avoid duplicate namespace with // other types in NullableTypes + // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element // *************** *** 242,247 **** [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! if (!reader.IsEmptyElement) { ! _value = sysXml.XmlConvert.ToByte(reader.ReadElementString()); _notNull = true; } --- 243,251 ---- [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; ! string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); ! ! if (nilValue == null || nilValue == "false" || nilValue == "0") { ! _value = sysXml.XmlConvert.ToByte(elementValue); _notNull = true; } Index: NullableDateTime.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableDateTime.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** NullableDateTime.cs 8 Dec 2003 21:57:27 -0000 1.20 --- NullableDateTime.cs 20 Feb 2004 00:42:22 -0000 1.21 *************** *** 26,29 **** --- 26,30 ---- // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to avoid duplicate namespace with // other types in NullableTypes + // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element // *************** *** 131,135 **** /// <param name="year">The year (1 through 9999).</param> /// <param name="month">The month (1 through 12).</param> ! /// <param name="day">The day (1 through the number of days in <code>month</code>.</param> public NullableDateTime(int year, int month, int day) { _value = new sys.DateTime(year, month, day); --- 132,136 ---- /// <param name="year">The year (1 through 9999).</param> /// <param name="month">The month (1 through 12).</param> ! /// <param name="day">The day (1 through the number of days in <paramref name="month"/>.</param> public NullableDateTime(int year, int month, int day) { _value = new sys.DateTime(year, month, day); *************** *** 143,147 **** /// <param name="year">The year (1 through 9999).</param> /// <param name="month">The month (1 through 12).</param> ! /// <param name="day">The day (1 through the number of days in <code>month</code>.</param> /// <param name="hour">The hours (0 through 23).</param> /// <param name="minute">The minutes (0 through 59).</param> --- 144,148 ---- /// <param name="year">The year (1 through 9999).</param> /// <param name="month">The month (1 through 12).</param> ! /// <param name="day">The day (1 through the number of days in <paramref name="month"/>.</param> /// <param name="hour">The hours (0 through 23).</param> /// <param name="minute">The minutes (0 through 59).</param> *************** *** 158,162 **** /// <param name="year">The year (1 through 9999).</param> /// <param name="month">The month (1 through 12).</param> ! /// <param name="day">The day (1 through the number of days in <code>month</code>.</param> /// <param name="hour">The hours (0 through 23).</param> /// <param name="minute">The minutes (0 through 59).</param> --- 159,163 ---- /// <param name="year">The year (1 through 9999).</param> /// <param name="month">The month (1 through 12).</param> ! /// <param name="day">The day (1 through the number of days in <paramref name="month"/>.</param> /// <param name="hour">The hours (0 through 23).</param> /// <param name="minute">The minutes (0 through 59).</param> *************** *** 276,281 **** [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! if (!reader.IsEmptyElement) { ! _value = sys.Xml.XmlConvert.ToDateTime(reader.ReadElementString()); _notNull = true; } --- 277,285 ---- [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; ! string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); ! ! if (nilValue == null || nilValue == "false" || nilValue == "0") { ! _value = sys.Xml.XmlConvert.ToDateTime(elementValue); _notNull = true; } *************** *** 292,296 **** /// </summary> /// <param name="value">An object to compare, or null reference</param> ! /// <returns>True if the instance is equal to <code>value</code>. /// False otherwise. /// </returns> --- 296,300 ---- /// </summary> /// <param name="value">An object to compare, or null reference</param> ! /// <returns>True if the instance is equal to <paramref name="value"/>. /// False otherwise. /// </returns> *************** *** 444,449 **** /// </summary> /// <param name="t">A System.TimeSpan</param> ! /// <returns>A NullableDateTime that is the difference of this structure ! /// and <code>t</code>.</returns> /// <remarks> /// This method does not change the value of this NullableDateTime. Instead, a new NullableDateTime --- 448,454 ---- /// </summary> /// <param name="t">A System.TimeSpan</param> ! /// <returns> ! /// A NullableDateTime that is the difference of this structure and <paramref name="t"/>. ! /// </returns> /// <remarks> /// This method does not change the value of this NullableDateTime. Instead, a new NullableDateTime *************** *** 461,467 **** /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <code>x</code> is greater than <code>y</code>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <code>x</code> is less than or equal to <code>y</code>. /// </returns> public static NullableBoolean GreaterThan(NullableDateTime x, NullableDateTime y) { --- 466,472 ---- /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <paramref name="x"/> is greater than <paramref name="y"/>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <paramref name="x"/> is less than or equal to <paramref name="y"/>. /// </returns> public static NullableBoolean GreaterThan(NullableDateTime x, NullableDateTime y) { *************** *** 474,480 **** /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <code>x</code> is greater than or equal to <code>y</code>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <code>x</code> is less than <code>y</code>. /// </returns> public static NullableBoolean GreaterThanOrEqual(NullableDateTime x, NullableDateTime y) { --- 479,485 ---- /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <paramref name="x"/> is greater than or equal to <paramref name="y"/>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <paramref name="x"/> is less than <paramref name="y"/>. /// </returns> public static NullableBoolean GreaterThanOrEqual(NullableDateTime x, NullableDateTime y) { *************** *** 487,493 **** /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <code>x</code> is less than <code>y</code>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <code>x</code> is greater than or equal to <code>y</code>. /// </returns> public static NullableBoolean LessThan(NullableDateTime x, NullableDateTime y) { --- 492,498 ---- /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <paramref name="x"/> is less than <paramref name="y"/>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <paramref name="x"/> is greater than or equal to <paramref name="y"/>. /// </returns> public static NullableBoolean LessThan(NullableDateTime x, NullableDateTime y) { *************** *** 500,506 **** /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <code>x</code> is less than or equal to <code>y</code>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <code>x</code> is greater than <code>y</code>. /// </returns> public static NullableBoolean LessThanOrEqual(NullableDateTime x, NullableDateTime y) { --- 505,511 ---- /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <paramref name="x"/> is less than or equal to <paramref name="y"/>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <paramref name="x"/> is greater than <paramref name="y"/>. /// </returns> public static NullableBoolean LessThanOrEqual(NullableDateTime x, NullableDateTime y) { *************** *** 518,527 **** /// a value representative of the instant in time.</returns> /// <exception cref="sys.ArgumentNullException"> ! /// <code>s</code> is null.</exception> /// <exception cref="sys.FormatException"> ! /// <code>s</code> is not a properly formatted date and time. /// </exception> /// <exception cref="sys.OverflowException"> ! /// <code>s</code>represents a time instant less than MinValue or /// greater than MaxValue. /// </exception> --- 523,532 ---- /// a value representative of the instant in time.</returns> /// <exception cref="sys.ArgumentNullException"> ! /// <paramref name="s"/> is null.</exception> /// <exception cref="sys.FormatException"> ! /// <paramref name="s"/> is not a properly formatted date and time. /// </exception> /// <exception cref="sys.OverflowException"> ! /// <paramref name="s"/> represents a time instant less than MinValue or /// greater than MaxValue. /// </exception> *************** *** 552,557 **** /// <param name="x">A NullableDateTime</param> /// <param name="t">A System.TimeSpan</param> ! /// <returns>A NullableDateTime that is the sum of <code>x</code> ! /// and <code>t</code>.</returns> public static NullableDateTime operator + (NullableDateTime x, sys.TimeSpan t) { if (x.IsNull) --- 557,563 ---- /// <param name="x">A NullableDateTime</param> /// <param name="t">A System.TimeSpan</param> ! /// <returns> ! /// A NullableDateTime that is the sum of <paramref name="x"/> and <paramref name="t"/>. ! /// </returns> public static NullableDateTime operator + (NullableDateTime x, sys.TimeSpan t) { if (x.IsNull) *************** *** 567,573 **** /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <code>x</code> is greater than <code>y</code>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <code>x</code> is less than or equal to <code>y</code>. /// </returns> public static NullableBoolean operator > (NullableDateTime x, NullableDateTime y) { --- 573,579 ---- /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <paramref name="x"/> is greater than <paramref name="y"/>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <paramref name="x"/> is less than or equal to <paramref name="y"/>. /// </returns> public static NullableBoolean operator > (NullableDateTime x, NullableDateTime y) { *************** *** 584,590 **** /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <code>x</code> is greater than or equal to <code>y</code>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <code>x</code> is less than <code>y</code>. /// </returns> public static NullableBoolean operator >= (NullableDateTime x, NullableDateTime y) { --- 590,596 ---- /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <paramref name="x"/> is greater than or equal to <paramref name="y"/>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <paramref name="x"/> is less than <paramref name="y"/>. /// </returns> public static NullableBoolean operator >= (NullableDateTime x, NullableDateTime y) { *************** *** 601,607 **** /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <code>x</code> is less than <code>y</code>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <code>x</code> is greater than or equal to <code>y</code>. /// </returns> public static NullableBoolean operator < (NullableDateTime x, NullableDateTime y) { --- 607,613 ---- /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <paramref name="x"/> is less than <paramref name="y"/>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <paramref name="x"/> is greater than or equal to <paramref name="y"/>. /// </returns> public static NullableBoolean operator < (NullableDateTime x, NullableDateTime y) { *************** *** 617,623 **** /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <code>x</code> is less than or equal to <code>y</code>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <code>x</code> is greater than <code>y</code>. /// </returns> public static NullableBoolean operator <= (NullableDateTime x, NullableDateTime y) { --- 623,629 ---- /// <param name="x">Instance to compare from.</param> /// <param name="y">Instance to compare to.</param> ! /// <returns>True if <paramref name="x"/> is less than or equal to <paramref name="y"/>, /// null value if one or both of the instances are NullableDatetime.Null, ! /// false if <paramref name="x"/> is greater than <paramref name="y"/>. /// </returns> public static NullableBoolean operator <= (NullableDateTime x, NullableDateTime y) { *************** *** 634,639 **** /// <param name="x">A NullableDateTime</param> /// <param name="t">A System.TimeSpan</param> ! /// <returns>A NullableDateTime that is the difference of <code>x</code> ! /// and <code>t</code>.</returns> public static NullableDateTime operator - (NullableDateTime x, sys.TimeSpan t) { if (x.IsNull) --- 640,646 ---- /// <param name="x">A NullableDateTime</param> /// <param name="t">A System.TimeSpan</param> ! /// <returns> ! /// A NullableDateTime that is the difference of <paramref name="x"/> and <paramref name="t"/>. ! /// </returns> public static NullableDateTime operator - (NullableDateTime x, sys.TimeSpan t) { if (x.IsNull) Index: NullableDecimal.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableDecimal.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** NullableDecimal.cs 8 Dec 2003 21:57:27 -0000 1.19 --- NullableDecimal.cs 20 Feb 2004 00:42:22 -0000 1.20 *************** *** 22,25 **** --- 22,26 ---- // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to avoid duplicate namespace with // other types in NullableTypes + // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element // *************** *** 268,273 **** /// <param name="hi">The high 32 bits of a 96-bit integer.</param> /// <param name="isNegative"> ! /// The sign of the number; <code>true</code> is negative, ! /// <code>false</code> is positive. /// </param> /// <param name="scale">A power of 10 ranging from 0 to 28.</param> --- 269,273 ---- /// <param name="hi">The high 32 bits of a 96-bit integer.</param> /// <param name="isNegative"> ! /// The sign of the number; true is negative, false is positive. /// </param> /// <param name="scale">A power of 10 ranging from 0 to 28.</param> *************** *** 432,437 **** [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! if (!reader.IsEmptyElement) { ! _value = sysXml.XmlConvert.ToDecimal(reader.ReadElementString()); _notNull = true; } --- 432,440 ---- [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; ! string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); ! ! if (nilValue == null || nilValue == "false" || nilValue == "0") { ! _value = sysXml.XmlConvert.ToDecimal(elementValue); _notNull = true; } Index: NullableDouble.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableDouble.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** NullableDouble.cs 8 Dec 2003 21:57:27 -0000 1.17 --- NullableDouble.cs 20 Feb 2004 00:42:22 -0000 1.18 *************** *** 20,23 **** --- 20,24 ---- // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to avoid duplicate namespace with // other types in NullableTypes + // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element // *************** *** 286,291 **** [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! if (!reader.IsEmptyElement) { ! _value = sysXml.XmlConvert.ToDouble(reader.ReadElementString()); _notNull = true; } --- 287,295 ---- [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; ! string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); ! ! if (nilValue == null || nilValue == "false" || nilValue == "0") { ! _value = sysXml.XmlConvert.ToDouble(elementValue); _notNull = true; } Index: NullableInt16.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableInt16.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** NullableInt16.cs 30 Jan 2004 16:31:03 -0000 1.13 --- NullableInt16.cs 20 Feb 2004 00:42:22 -0000 1.14 *************** *** 23,26 **** --- 23,27 ---- // other types in NullableTypes // 30-Dec-2003 Partha Upgrade Replaced hardcoded MInValue and MaxValue values with Int16.MinValue/MaxValue + // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element // *************** *** 190,195 **** [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! if (!reader.IsEmptyElement) { ! _value = sysXml.XmlConvert.ToInt16(reader.ReadElementString()); _notNull = true; } --- 191,199 ---- [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; ! string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); ! ! if (nilValue == null || nilValue == "false" || nilValue == "0") { ! _value = sysXml.XmlConvert.ToInt16(elementValue); _notNull = true; } Index: NullableInt32.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableInt32.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** NullableInt32.cs 30 Jan 2004 16:31:03 -0000 1.20 --- NullableInt32.cs 20 Feb 2004 00:42:22 -0000 1.21 *************** *** 17,25 **** // 05-Oct-2003 DamienG Upgrade New requirement: the type must be XmlSerializable // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code ! // 06-Dic-2003 Luca Bug Fix Replaced Xml Schema id "NullableInt32XmlSchema" with "NullableInt32" // because VSDesigner use it as type-name in the auto-generated WS client Proxy ! // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to avoid duplicate namespace with // other types in NullableTypes // 30-Dec-2003 Partha Upgrade Replaced hardcoded MInValue and MaxValue values with Int16.MinValue/MaxValue // --- 17,26 ---- // 05-Oct-2003 DamienG Upgrade New requirement: the type must be XmlSerializable // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code ! // 06-Dec-2003 Luca Bug Fix Replaced Xml Schema id "NullableInt32XmlSchema" with "NullableInt32" // because VSDesigner use it as type-name in the auto-generated WS client Proxy ! // 06-Dec-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to avoid duplicate namespace with // other types in NullableTypes // 30-Dec-2003 Partha Upgrade Replaced hardcoded MInValue and MaxValue values with Int16.MinValue/MaxValue + // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element // *************** *** 248,253 **** [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! if (!reader.IsEmptyElement) { ! _value = sysXml.XmlConvert.ToInt32(reader.ReadElementString()); _notNull = true; } --- 249,257 ---- [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; ! string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); ! ! if (nilValue == null || nilValue == "false" || nilValue == "0") { ! _value = sysXml.XmlConvert.ToInt32(elementValue); _notNull = true; } Index: NullableInt64.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableInt64.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** NullableInt64.cs 8 Dec 2003 21:57:27 -0000 1.12 --- NullableInt64.cs 20 Feb 2004 00:42:22 -0000 1.13 *************** *** 19,22 **** --- 19,23 ---- // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to avoid duplicate namespace with // other types in NullableTypes + // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element // *************** *** 245,250 **** [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! if (!reader.IsEmptyElement) { ! _value = sysXml.XmlConvert.ToInt64(reader.ReadElementString()); _notNull = true; } --- 246,254 ---- [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; ! string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); ! ! if (nilValue == null || nilValue == "false" || nilValue == "0") { ! _value = sysXml.XmlConvert.ToInt64(elementValue); _notNull = true; } Index: NullableSingle.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableSingle.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** NullableSingle.cs 8 Dec 2003 21:57:27 -0000 1.19 --- NullableSingle.cs 20 Feb 2004 00:42:22 -0000 1.20 *************** *** 20,23 **** --- 20,24 ---- // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to avoid duplicate namespace with // other types in NullableTypes + // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element // *************** *** 307,312 **** [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! if (!reader.IsEmptyElement) { ! _value = sysXml.XmlConvert.ToSingle(reader.ReadElementString()); _notNull = true; } --- 308,316 ---- [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; ! string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); ! ! if (nilValue == null || nilValue == "false" || nilValue == "0") { ! _value = sysXml.XmlConvert.ToSingle(elementValue); _notNull = true; } *************** *** 758,765 **** /// <remarks> /// The <paramref name="s"/> parameter can contain ! /// <see cref="System.Globalization.NumberFormatInfo.CurrentInfo.PositiveInfinitySymbol"/>, ! /// <see cref="System.Globalization.NumberFormatInfo.CurrentInfo.NegativeInfinitySymbol"/> /// and ! /// <see cref="System.Globalization.NumberFormatInfo.CurrentInfo.NaNSymbol"/>. /// </remarks> /// <seealso cref="System.Single.Parse"/> --- 762,769 ---- /// <remarks> /// The <paramref name="s"/> parameter can contain ! /// <see cref="System.Globalization.NumberFormatInfo.PositiveInfinitySymbol"/>, ! /// <see cref="System.Globalization.NumberFormatInfo.NegativeInfinitySymbol"/> /// and ! /// <see cref="System.Globalization.NumberFormatInfo.NaNSymbol"/>. /// </remarks> /// <seealso cref="System.Single.Parse"/> Index: NullableString.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableString.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** NullableString.cs 8 Dec 2003 21:57:27 -0000 1.14 --- NullableString.cs 20 Feb 2004 00:42:23 -0000 1.15 *************** *** 23,26 **** --- 23,27 ---- // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to avoid duplicate namespace with // other types in NullableTypes + // 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element // *************** *** 381,387 **** [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! if (!reader.IsEmptyElement) { ! _value = reader.ReadElementString(); ! } else _value = null; --- 382,390 ---- [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; ! string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); ! ! if (nilValue == null || nilValue == "false" || nilValue == "0") ! _value = elementValue; else _value = null; Index: TypeCode.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/TypeCode.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TypeCode.cs 30 Jun 2003 12:38:57 -0000 1.2 --- TypeCode.cs 20 Feb 2004 00:42:23 -0000 1.3 *************** *** 21,27 **** ///<summary> ///Represents a boolean value that is either ! ///<see cref="NullableBoolean.True"/>, ! ///<see cref="NullableBoolean.False"/> or ! ///<see cref="NullableBoolean.Null"/>. ///</summary> NullableBoolean = 3, // Boolean --- 21,27 ---- ///<summary> ///Represents a boolean value that is either ! ///<see cref="NullableTypes.NullableBoolean.True"/>, ! ///<see cref="NullableTypes.NullableBoolean.False"/> or ! ///<see cref="NullableTypes.NullableBoolean.Null"/>. ///</summary> NullableBoolean = 3, // Boolean *************** *** 29,33 **** /// <summary> /// Represents a byte value that is either an 8-bit unsigned integer in the ! /// range of 0 through 255 or <see cref="NullableByte.Null"/>. /// </summary> NullableByte = 6, // Byte --- 29,33 ---- /// <summary> /// Represents a byte value that is either an 8-bit unsigned integer in the ! /// range of 0 through 255 or <see cref="NullableTypes.NullableByte.Null"/>. /// </summary> NullableByte = 6, // Byte *************** *** 35,39 **** /// <summary> /// Represents an Int16 that is either a 16-bit signed integer or ! /// <see cref="NullableInt16.Null"/>. /// </summary> NullableInt16 = 7, // Signed 16-bit integer --- 35,39 ---- /// <summary> /// Represents an Int16 that is either a 16-bit signed integer or ! /// <see cref="NullableTypes.NullableInt16.Null"/>. /// </summary> NullableInt16 = 7, // Signed 16-bit integer *************** *** 41,45 **** /// <summary> /// Represents an Int32 that is either a 32-bit signed integer or ! /// <see cref="NullableInt32.Null"/>. /// </summary> NullableInt32 = 9, // Signed 32-bit integer --- 41,45 ---- /// <summary> /// Represents an Int32 that is either a 32-bit signed integer or ! /// <see cref="NullableTypes.NullableInt32.Null"/>. /// </summary> NullableInt32 = 9, // Signed 32-bit integer *************** *** 47,51 **** /// <summary> /// Represents an Int64 that is either a 64-bit signed integer or ! /// <see cref="NullableInt64.Null"/>. /// </summary> NullableInt64 = 11, // Signed 64-bit integer --- 47,51 ---- /// <summary> /// Represents an Int64 that is either a 64-bit signed integer or ! /// <see cref="NullableTypes.NullableInt64.Null"/>. /// </summary> NullableInt64 = 11, // Signed 64-bit integer *************** *** 53,57 **** /// <summary> /// Represents a Single value that is either a single-precision floating point ! /// number or <see cref="NullableSingle.Null"/>. /// </summary> NullableSingle = 13, // IEEE 32-bit float --- 53,57 ---- /// <summary> /// Represents a Single value that is either a single-precision floating point ! /// number or <see cref="NullableTypes.NullableSingle.Null"/>. /// </summary> NullableSingle = 13, // IEEE 32-bit float *************** *** 59,63 **** /// <summary> /// Represents a Double value that is either a double-precision floating point ! /// number or <see cref="NullableDouble.Null"/>. /// </summary> NullableDouble = 14, // IEEE 64-bit double --- 59,63 ---- /// <summary> /// Represents a Double value that is either a double-precision floating point ! /// number or <see cref="NullableTypes.NullableDouble.Null"/>. /// </summary> NullableDouble = 14, // IEEE 64-bit double *************** *** 65,69 **** /// <summary> /// Represents a Decimal that is either a decimal number value or ! /// <see cref="NullableDecimal.Null"/>. /// </summary> NullableDecimal = 15, // Decimal --- 65,69 ---- /// <summary> /// Represents a Decimal that is either a decimal number value or ! /// <see cref="NullableTypes.NullableDecimal.Null"/>. /// </summary> NullableDecimal = 15, // Decimal *************** *** 71,75 **** /// <summary> /// Represents a DateTime that is either a date and time data or ! /// <see cref="NullableDateTime.Null"/>. /// </summary> NullableDateTime = 16, // DateTime --- 71,75 ---- /// <summary> /// Represents a DateTime that is either a date and time data or ! /// <see cref="NullableTypes.NullableDateTime.Null"/>. /// </summary> NullableDateTime = 16, // DateTime *************** *** 77,81 **** /// <summary> /// Represents a String that is either a variable-length stream of characters ! /// or <see cref="NullableString.Null"/>. /// </summary> NullableString = 18 // Unicode character string --- 77,81 ---- /// <summary> /// Represents a String that is either a variable-length stream of characters ! /// or <see cref="NullableTypes.NullableString.Null"/>. /// </summary> NullableString = 18 // Unicode character string |
From: <luk...@us...> - 2004-02-20 00:53:11
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8752/src/Tests Modified Files: NullableBooleanTest.cs NullableByteTest.cs NullableDateTimeTest.cs NullableDecimalTest.cs NullableDoubleTest.cs NullableInt16Test2.cs NullableInt32Test.cs NullableInt64Test.cs NullableSingleTest.cs NullableStringTest.cs Log Message: Index: NullableBooleanTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableBooleanTest.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** NullableBooleanTest.cs 8 Dec 2003 21:48:41 -0000 1.14 --- NullableBooleanTest.cs 20 Feb 2004 00:42:22 -0000 1.15 *************** *** 17,20 **** --- 17,22 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to reflect changes in the target type + // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil + // value with a non empty element // *************** *** 1145,1148 **** --- 1147,1183 ---- [nu.Test] + public void XmlSerializableEmptyElementNil() { + // Bug reported by Shaun Bowe (sb...@us...) + // http://sourceforge.net/forum/message.php?msg_id=2399265 + + //<?xml version="1.0"?> + //<NullableBoolean xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></NullableBoolean> + + System.Xml.Serialization.XmlSerializer serializer = + new System.Xml.Serialization.XmlSerializer(typeof(NullableBoolean)); + + using (sys.IO.MemoryStream baseStream = new sys.IO.MemoryStream()) { + using (sys.IO.StreamWriter stream = new System.IO.StreamWriter(baseStream)) { + stream.WriteLine("<?xml version=\"1.0\"?>"); + stream.WriteLine("<NullableBoolean xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></NullableBoolean>"); + stream.Flush(); + + // baseStream.Position = 0; + // sys.IO.StreamReader streamReader = new System.IO.StreamReader(baseStream); + // sys.Console.WriteLine(streamReader.ReadToEnd()); + + baseStream.Position = 0; // Return stream to start + NullableBoolean y = (NullableBoolean)serializer.Deserialize(baseStream); + + nua.Assert(y.IsNull); + + baseStream.Close(); + stream.Close(); + } + } + } + + + [nu.Test] public void XmlSerializableSchema() { sysXmlScm.XmlSchema xsd = Index: NullableByteTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableByteTest.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NullableByteTest.cs 8 Dec 2003 21:48:41 -0000 1.9 --- NullableByteTest.cs 20 Feb 2004 00:42:22 -0000 1.10 *************** *** 17,20 **** --- 17,22 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to reflect changes in the target type + // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil + // value with a non empty element // *************** *** 1057,1060 **** --- 1059,1095 ---- [nu.Test] + public void XmlSerializableEmptyElementNil() { + // Bug reported by Shaun Bowe (sb...@us...) + // http://sourceforge.net/forum/message.php?msg_id=2399265 + + //<?xml version="1.0"?> + //<NullableByte xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></NullableByte> + + System.Xml.Serialization.XmlSerializer serializer = + new System.Xml.Serialization.XmlSerializer(typeof(NullableByte)); + + using (sys.IO.MemoryStream baseStream = new sys.IO.MemoryStream()) { + using (sys.IO.StreamWriter stream = new System.IO.StreamWriter(baseStream)) { + stream.WriteLine("<?xml version=\"1.0\"?>"); + stream.WriteLine("<NullableByte xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></NullableByte>"); + stream.Flush(); + + // baseStream.Position = 0; + // sys.IO.StreamReader streamReader = new System.IO.StreamReader(baseStream); + // sys.Console.WriteLine(streamReader.ReadToEnd()); + + baseStream.Position = 0; // Return stream to start + NullableByte y = (NullableByte)serializer.Deserialize(baseStream); + + nua.Assert(y.IsNull); + + baseStream.Close(); + stream.Close(); + } + } + } + + + [nu.Test] public void XmlSerializableSchema() { sysXmlScm.XmlSchema xsd = Index: NullableDateTimeTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableDateTimeTest.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** NullableDateTimeTest.cs 8 Dec 2003 21:48:41 -0000 1.11 --- NullableDateTimeTest.cs 20 Feb 2004 00:42:22 -0000 1.12 *************** *** 17,20 **** --- 17,22 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to reflect changes in the target type + // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil + // value with a non empty element // *************** *** 555,558 **** --- 557,592 ---- [nu.Test] + public void XmlSerializableEmptyElementNil() { + // Bug reported by Shaun Bowe (sb...@us...) + // http://sourceforge.net/forum/message.php?msg_id=2399265 + + //<?xml version="1.0"?> + //<NullableDateTime xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></NullableDateTime> + + System.Xml.Serialization.XmlSerializer serializer = + new System.Xml.Serialization.XmlSerializer(typeof(NullableDateTime)); + + using (sys.IO.MemoryStream baseStream = new sys.IO.MemoryStream()) { + using (sys.IO.StreamWriter stream = new System.IO.StreamWriter(baseStream)) { + stream.WriteLine("<?xml version=\"1.0\"?>"); + stream.WriteLine("<NullableDateTime xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></NullableDateTime>"); + stream.Flush(); + + // baseStream.Position = 0; + // sys.IO.StreamReader streamReader = new System.IO.StreamReader(baseStream); + // sys.Console.WriteLine(streamReader.ReadToEnd()); + + baseStream.Position = 0; // Return stream to start + NullableDateTime y = (NullableDateTime)serializer.Deserialize(baseStream); + + nua.Assert(y.IsNull); + + baseStream.Close(); + stream.Close(); + } + } + } + + [nu.Test] public void XmlSerializableSchema() { sysXmlScm.XmlSchema xsd = Index: NullableDecimalTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableDecimalTest.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** NullableDecimalTest.cs 8 Dec 2003 21:48:41 -0000 1.16 --- NullableDecimalTest.cs 20 Feb 2004 00:42:22 -0000 1.17 *************** *** 21,24 **** --- 21,26 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to reflect changes in the target type + // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil + // value with a non empty element // *************** *** 1254,1257 **** --- 1256,1293 ---- } + + [nu.Test] + public void XmlSerializableEmptyElementNil() { + // Bug reported by Shaun Bowe (sb...@us...) + // http://sourceforge.net/forum/message.php?msg_id=2399265 + + //<?xml version="1.0"?> + //<NullableDecimal xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></NullableDecimal> + + System.Xml.Serialization.XmlSerializer serializer = + new System.Xml.Serialization.XmlSerializer(typeof(NullableDecimal)); + + using (sys.IO.MemoryStream baseStream = new sys.IO.MemoryStream()) { + using (sys.IO.StreamWriter stream = new System.IO.StreamWriter(baseStream)) { + stream.WriteLine("<?xml version=\"1.0\"?>"); + stream.WriteLine("<NullableDecimal xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></NullableDecimal>"); + stream.Flush(); + + // baseStream.Position = 0; + // sys.IO.StreamReader streamReader = new System.IO.StreamReader(baseStream); + // sys.Console.WriteLine(streamReader.ReadToEnd()); + + baseStream.Position = 0; // Return stream to start + NullableDecimal y = (NullableDecimal)serializer.Deserialize(baseStream); + + nua.Assert(y.IsNull); + + baseStream.Close(); + stream.Close(); + } + } + } + + [nu.Test] public void XmlSerializableSchema() { Index: NullableDoubleTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableDoubleTest.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** NullableDoubleTest.cs 8 Dec 2003 21:48:41 -0000 1.15 --- NullableDoubleTest.cs 20 Feb 2004 00:42:22 -0000 1.16 *************** *** 21,24 **** --- 21,26 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to reflect changes in the target type + // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil + // value with a non empty element // *************** *** 999,1002 **** --- 1001,1037 ---- [nu.Test] + public void XmlSerializableEmptyElementNil() { + // Bug reported by Shaun Bowe (sb...@us...) + // http://sourceforge.net/forum/message.php?msg_id=2399265 + + //<?xml version="1.0"?> + //<NullableDouble xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></NullableDouble> + + System.Xml.Serialization.XmlSerializer serializer = + new System.Xml.Serialization.XmlSerializer(typeof(NullableDouble)); + + using (sys.IO.MemoryStream baseStream = new sys.IO.MemoryStream()) { + using (sys.IO.StreamWriter stream = new System.IO.StreamWriter(baseStream)) { + stream.WriteLine("<?xml version=\"1.0\"?>"); + stream.WriteLine("<NullableDouble xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></NullableDouble>"); + stream.Flush(); + + // baseStream.Position = 0; + // sys.IO.StreamReader streamReader = new System.IO.StreamReader(baseStream); + // sys.Console.WriteLine(streamReader.ReadToEnd()); + + baseStream.Position = 0; // Return stream to start + NullableDouble y = (NullableDouble)serializer.Deserialize(baseStream); + + nua.Assert(y.IsNull); + + baseStream.Close(); + stream.Close(); + } + } + } + + + [nu.Test] public void XmlSerializableSchema() { sysXmlScm.XmlSchema xsd = Index: NullableInt16Test2.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableInt16Test2.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NullableInt16Test2.cs 8 Dec 2003 21:48:41 -0000 1.8 --- NullableInt16Test2.cs 20 Feb 2004 00:42:22 -0000 1.9 *************** *** 16,19 **** --- 16,21 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to reflect changes in the target type + // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil + // value with a non empty element // *************** *** 1164,1167 **** --- 1166,1204 ---- [nu.Test] + public void XmlSerializableEmptyElementNil() { + // Bug reported by Shaun Bowe (sb...@us...) + // http://sourceforge.net/forum/message.php?msg_id=2399265 + + //<?xml version="1.0"?> + //<NullableInt16 xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></NullableInt16> + + System.Xml.Serialization.XmlSerializer serializer = + new System.Xml.Serialization.XmlSerializer(typeof(NullableInt16)); + + using (sys.IO.MemoryStream baseStream = new sys.IO.MemoryStream()) { + using (sys.IO.StreamWriter stream = new System.IO.StreamWriter(baseStream)) { + stream.WriteLine("<?xml version=\"1.0\"?>"); + stream.WriteLine("<NullableInt16 xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></NullableInt16>"); + stream.Flush(); + + // baseStream.Position = 0; + // sys.IO.StreamReader streamReader = new System.IO.StreamReader(baseStream); + // sys.Console.WriteLine(streamReader.ReadToEnd()); + + baseStream.Position = 0; // Return stream to start + NullableInt16 y = (NullableInt16)serializer.Deserialize(baseStream); + + nua.Assert(y.IsNull); + + baseStream.Close(); + stream.Close(); + } + } + + } + + + + [nu.Test] public void XmlSerializableSchema() { sysXmlScm.XmlSchema xsd = Index: NullableInt32Test.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableInt32Test.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NullableInt32Test.cs 8 Dec 2003 21:48:41 -0000 1.9 --- NullableInt32Test.cs 20 Feb 2004 00:42:22 -0000 1.10 *************** *** 16,19 **** --- 16,21 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to reflect changes in the target type + // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil + // value with a non empty element // *************** *** 1159,1162 **** --- 1161,1196 ---- } + [nu.Test] + public void XmlSerializableEmptyElementNil() { + // Bug reported by Shaun Bowe (sb...@us...) + // http://sourceforge.net/forum/message.php?msg_id=2399265 + + //<?xml version="1.0"?> + //<NullableInt32 xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></NullableInt32> + + System.Xml.Serialization.XmlSerializer serializer = + new System.Xml.Serialization.XmlSerializer(typeof(NullableInt32)); + + using (sys.IO.MemoryStream baseStream = new sys.IO.MemoryStream()) { + using (sys.IO.StreamWriter stream = new System.IO.StreamWriter(baseStream)) { + stream.WriteLine("<?xml version=\"1.0\"?>"); + stream.WriteLine("<NullableInt32 xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></NullableInt32>"); + stream.Flush(); + + // baseStream.Position = 0; + // sys.IO.StreamReader streamReader = new System.IO.StreamReader(baseStream); + // sys.Console.WriteLine(streamReader.ReadToEnd()); + + baseStream.Position = 0; // Return stream to start + NullableInt32 y = (NullableInt32)serializer.Deserialize(baseStream); + + nua.Assert(y.IsNull); + + baseStream.Close(); + stream.Close(); + } + } + } + [nu.Test] Index: NullableInt64Test.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableInt64Test.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** NullableInt64Test.cs 8 Dec 2003 21:48:41 -0000 1.6 --- NullableInt64Test.cs 20 Feb 2004 00:42:22 -0000 1.7 *************** *** 16,19 **** --- 16,21 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to reflect changes in the target type + // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil + // value with a non empty element // *************** *** 1147,1150 **** --- 1149,1186 ---- [nu.Test] + public void XmlSerializableEmptyElementNil() { + // Bug reported by Shaun Bowe (sb...@us...) + // http://sourceforge.net/forum/message.php?msg_id=2399265 + + //<?xml version="1.0"?> + //<NullableInt64 xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></NullableInt64> + + System.Xml.Serialization.XmlSerializer serializer = + new System.Xml.Serialization.XmlSerializer(typeof(NullableInt64)); + + using (sys.IO.MemoryStream baseStream = new sys.IO.MemoryStream()) { + using (sys.IO.StreamWriter stream = new System.IO.StreamWriter(baseStream)) { + stream.WriteLine("<?xml version=\"1.0\"?>"); + stream.WriteLine("<NullableInt64 xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></NullableInt64>"); + stream.Flush(); + + // baseStream.Position = 0; + // sys.IO.StreamReader streamReader = new System.IO.StreamReader(baseStream); + // sys.Console.WriteLine(streamReader.ReadToEnd()); + + baseStream.Position = 0; // Return stream to start + NullableInt64 y = (NullableInt64)serializer.Deserialize(baseStream); + + nua.Assert(y.IsNull); + + baseStream.Close(); + stream.Close(); + } + } + + } + + + [nu.Test] public void XmlSerializableSchema() { sysXmlScm.XmlSchema xsd = Index: NullableSingleTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableSingleTest.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** NullableSingleTest.cs 8 Dec 2003 21:48:41 -0000 1.13 --- NullableSingleTest.cs 20 Feb 2004 00:42:22 -0000 1.14 *************** *** 19,22 **** --- 19,24 ---- // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces and removed commented out code // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to reflect changes in the target type + // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil + // value with a non empty element // *************** *** 965,968 **** --- 967,1001 ---- + [nu.Test] + public void XmlSerializableEmptyElementNil() { + // Bug reported by Shaun Bowe (sb...@us...) + // http://sourceforge.net/forum/message.php?msg_id=2399265 + + //<?xml version="1.0"?> + //<NullableSingle xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></NullableSingle> + + System.Xml.Serialization.XmlSerializer serializer = + new System.Xml.Serialization.XmlSerializer(typeof(NullableSingle)); + + using (sys.IO.MemoryStream baseStream = new sys.IO.MemoryStream()) { + using (sys.IO.StreamWriter stream = new System.IO.StreamWriter(baseStream)) { + stream.WriteLine("<?xml version=\"1.0\"?>"); + stream.WriteLine("<NullableSingle xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></NullableSingle>"); + stream.Flush(); + + // baseStream.Position = 0; + // sys.IO.StreamReader streamReader = new System.IO.StreamReader(baseStream); + // sys.Console.WriteLine(streamReader.ReadToEnd()); + + baseStream.Position = 0; // Return stream to start + NullableSingle y = (NullableSingle)serializer.Deserialize(baseStream); + + nua.Assert(y.IsNull); + + baseStream.Close(); + stream.Close(); + } + } + } [nu.Test] Index: NullableStringTest.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Tests/NullableStringTest.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** NullableStringTest.cs 8 Dec 2003 21:48:41 -0000 1.12 --- NullableStringTest.cs 20 Feb 2004 00:42:22 -0000 1.13 *************** *** 17,20 **** --- 17,22 ---- // Code upgrade: Replaced tabs with spaces and removed commented out code // 06-Dic-2003 Luca Bug Fix Replaced Target Namespace for Xml Schema to reflect changes in the target type + // 18-Feb-2004 Luca Upgrade New test: XmlSerializableEmptyElementNil for xml deserialization of a nil + // value with a non empty element // *************** *** 785,788 **** --- 787,824 ---- } + + [nu.Test] + public void XmlSerializableEmptyElementNil() { + // Bug reported by Shaun Bowe (sb...@us...) + // http://sourceforge.net/forum/message.php?msg_id=2399265 + + //<?xml version="1.0"?> + //<NullableString xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></NullableString> + + System.Xml.Serialization.XmlSerializer serializer = + new System.Xml.Serialization.XmlSerializer(typeof(NullableString)); + + using (sys.IO.MemoryStream baseStream = new sys.IO.MemoryStream()) { + using (sys.IO.StreamWriter stream = new System.IO.StreamWriter(baseStream)) { + stream.WriteLine("<?xml version=\"1.0\"?>"); + stream.WriteLine("<NullableString xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></NullableString>"); + stream.Flush(); + + // baseStream.Position = 0; + // sys.IO.StreamReader streamReader = new System.IO.StreamReader(baseStream); + // sys.Console.WriteLine(streamReader.ReadToEnd()); + + baseStream.Position = 0; // Return stream to start + NullableString y = (NullableString)serializer.Deserialize(baseStream); + + nua.Assert(y.IsNull); + + baseStream.Close(); + stream.Close(); + } + } + } + + [nu.Test] public void XmlSerializableSchema() { |
From: <luk...@us...> - 2004-02-20 00:53:11
|
Update of /cvsroot/nullabletypes/NullableTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8752 Modified Files: ReadMe.txt ReleaseNotes.txt Added Files: NullableTypes.Tests.DLL.config Log Message: --- NEW FILE: NullableTypes.Tests.DLL.config --- <?xml version="1.0" encoding="Windows-1252"?> <configuration> <!-- Settings to make NullableTypes (built using .NET Framework 1.1) run also on .NET Framework 1.0 --> <!-- ============================================================================================== --> <startup> <supportedRuntime version="v1.1.4322" /> <supportedRuntime version="v1.0.3705" /> </startup> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v1.0.3705"> <!-- Settings for NullableTypes.dll Assembly --> <dependentAssembly> <assemblyIdentity name="System.Xml" publicKeyToken="b77a5c561934e089" culture=""/> <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/> </dependentAssembly> <!-- Settings for NullableTypes.Tests.dll Assembly --> <dependentAssembly> <assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089" culture=""/> <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Runtime.Serialization.Formatters.Soap" publicKeyToken="b03f5f7f11d50a3a" culture=""/> <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration> Index: ReadMe.txt =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/ReadMe.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ReadMe.txt 30 Jan 2004 16:31:02 -0000 1.15 --- ReadMe.txt 20 Feb 2004 00:42:21 -0000 1.16 *************** *** 80,86 **** ============================== NullableTypes source code has been written and compiled against .NET Framework v1.1. ! Due to high degree of support for .NET Framework v1.1 backward compatibility (most applications created ! using v1.0 will run on v1.1) NullableTypes source code still compile with .NET Framework v1.0 and NullableTypes assembly still run and pass tests on .NET Framework v1.0. NullableTypes projects and source code are created using VS.NET 2002 and have been converted to VS.NET 2003. --- 80,89 ---- ============================== NullableTypes source code has been written and compiled against .NET Framework v1.1. ! Due to high degree of support for .NET Framework v1.0 forward compatibility (applications created ! using v1.1 may run on v1.0) NullableTypes source code still compile with .NET Framework v1.0 and NullableTypes assembly still run and pass tests on .NET Framework v1.0. + To run NullableTypes on .NET Framework v1.0 use the configuration settings in file + bin\NullableTypes.Tests.DLL.config to make your myAppllication.exe.config file or put them on your + Web.config file. NullableTypes projects and source code are created using VS.NET 2002 and have been converted to VS.NET 2003. *************** *** 142,147 **** - Massimo Prota (porting to Linux/Mono, VB.NET sample) ! Thanks also goes to Massimo Roccaforte, Roni Burd, Partha Choudhury and Alberto Tronchin for ! their suggestions and to Damien Guard for his help implementing Web Services support. At the end thanks also goes to the open-source community that developed these tools: --- 145,151 ---- - Massimo Prota (porting to Linux/Mono, VB.NET sample) ! Thanks also goes to Massimo Roccaforte, Roni Burd, Partha Choudhury, Shaun Bowe and ! Alberto Tronchin for their suggestions and to Damien Guard for his help implementing Web Services ! support. At the end thanks also goes to the open-source community that developed these tools: Index: ReleaseNotes.txt =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/ReleaseNotes.txt,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ReleaseNotes.txt 30 Jan 2004 16:31:02 -0000 1.11 --- ReleaseNotes.txt 20 Feb 2004 00:42:21 -0000 1.12 *************** *** 28,32 **** 2 or more NullableTypes parameters in a WS method - BUG FIX: Fixed IXmlSerializable.ReadXml implementation in ! NullableBoolean - NullableBoolean Operator^ (XOR) marked Obsolete - NullableBoolean Xor method marked Obsolete --- 28,34 ---- 2 or more NullableTypes parameters in a WS method - BUG FIX: Fixed IXmlSerializable.ReadXml implementation in ! NullableBoolean ! - BUG FIX: Fixed IXmlSerializable.ReadXml implementation for ! all types to accept a nil value with a non empty element. - NullableBoolean Operator^ (XOR) marked Obsolete - NullableBoolean Xor method marked Obsolete |