Multi-culture implementation ValueSerializers, Parse and ToString for types from...
authorMikhail Filippov <mikhail@filippov.me>
Mon, 18 Sep 2017 14:56:44 +0000 (17:56 +0300)
committerMarek Safar <marek.safar@gmail.com>
Mon, 18 Sep 2017 14:56:44 +0000 (16:56 +0200)
24 files changed:
mcs/class/WindowsBase/System.Windows.Converters/Int32RectValueSerializer.cs
mcs/class/WindowsBase/System.Windows.Converters/PointValueSerializer.cs
mcs/class/WindowsBase/System.Windows.Converters/RectValueSerializer.cs
mcs/class/WindowsBase/System.Windows.Converters/VectorValueSerializer.cs
mcs/class/WindowsBase/System.Windows.Media/Matrix.cs
mcs/class/WindowsBase/System.Windows/Int32Rect.cs
mcs/class/WindowsBase/System.Windows/NumericListTokenizer.cs [new file with mode: 0644]
mcs/class/WindowsBase/System.Windows/Point.cs
mcs/class/WindowsBase/System.Windows/Rect.cs
mcs/class/WindowsBase/System.Windows/Size.cs
mcs/class/WindowsBase/System.Windows/Vector.cs
mcs/class/WindowsBase/Test/System.Windows/Int32RectConverterTest.cs
mcs/class/WindowsBase/Test/System.Windows/Int32RectTest.cs
mcs/class/WindowsBase/Test/System.Windows/Int32RectValueSerializerTest.cs [new file with mode: 0644]
mcs/class/WindowsBase/Test/System.Windows/PointConverterTest.cs
mcs/class/WindowsBase/Test/System.Windows/PointTest.cs
mcs/class/WindowsBase/Test/System.Windows/PointValueSerializerTest.cs [new file with mode: 0644]
mcs/class/WindowsBase/Test/System.Windows/RectConverterTest.cs
mcs/class/WindowsBase/Test/System.Windows/RectTest.cs
mcs/class/WindowsBase/Test/System.Windows/RectValueSerializerTest.cs [new file with mode: 0644]
mcs/class/WindowsBase/Test/System.Windows/VectorConverterTest.cs
mcs/class/WindowsBase/Test/System.Windows/VectorValueSerializerTest.cs [new file with mode: 0644]
mcs/class/WindowsBase/WindowsBase.dll.sources
mcs/class/WindowsBase/WindowsBase_test.dll.sources

index a6681780275aaf59355fe2336cfd717b03fc97b9..0f59ec563aad5945c5548a74b8bda45780696334 100644 (file)
@@ -23,7 +23,7 @@
 //     Chris Toshok (toshok@ximian.com)
 //
 
-using System;
+using System.Globalization;
 using System.Windows.Markup;
 
 namespace System.Windows.Converters {
@@ -32,22 +32,26 @@ namespace System.Windows.Converters {
        {
                public override bool CanConvertFromString (string value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       return true;
                }
 
                public override bool CanConvertToString (object value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       return value is Int32Rect;
                }
 
                public override object ConvertFromString (string value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       if (value == null)
+                               throw new ArgumentNullException ("value");
+                       return Int32Rect.Parse (value);
                }
 
                public override string ConvertToString (object value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       if (value is Int32Rect int32Rect)
+                               return int32Rect.ToString (CultureInfo.InvariantCulture);
+                       return base.ConvertToString (value, context);
                }
        }
 
index 86f5ae77d167c799798c289b31dee975f34f8d13..2e0b0cd3d0fd229c74e54a2ff5958ec8b307d956 100644 (file)
@@ -23,7 +23,7 @@
 //     Chris Toshok (toshok@ximian.com)
 //
 
-using System;
+using System.Globalization;
 using System.Windows.Markup;
 
 namespace System.Windows.Converters {
@@ -32,22 +32,26 @@ namespace System.Windows.Converters {
        {
                public override bool CanConvertFromString (string value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       return true;
                }
 
                public override bool CanConvertToString (object value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       return value is Point;
                }
 
                public override object ConvertFromString (string value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       if (value == null)
+                               throw new ArgumentNullException ("value");
+                       return Point.Parse (value);
                }
 
                public override string ConvertToString (object value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       if (value is Point point)
+                               return point.ToString (CultureInfo.InvariantCulture);
+                       return base.ConvertToString (value, context);
                }
        }
 
index 1a607763929e75cb8b38c589a91ea12f85a2c0bd..24b4c3d60bc97f5b52cd0abba15acd759eaaffab 100644 (file)
@@ -22,8 +22,7 @@
 // Authors:
 //     Chris Toshok (toshok@ximian.com)
 //
-
-using System;
+using System.Globalization;
 using System.Windows.Markup;
 
 namespace System.Windows.Converters {
@@ -32,22 +31,26 @@ namespace System.Windows.Converters {
        {
                public override bool CanConvertFromString (string value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       return true;
                }
 
                public override bool CanConvertToString (object value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       return value is Rect;
                }
 
                public override object ConvertFromString (string value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       if (value == null)
+                               throw new ArgumentNullException ("value");
+                       return Rect.Parse (value);
                }
 
                public override string ConvertToString (object value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       if (value is Rect rect)
+                               return rect.ToString (CultureInfo.InvariantCulture);
+                       return base.ConvertToString (value, context);
                }
        }
 
index c9feb17a7d4cb556da962234341b70cf3a3f0074..376e4dc21ce77549e45bfb427bee97ff7726ab24 100644 (file)
@@ -23,7 +23,7 @@
 //     Chris Toshok (toshok@ximian.com)
 //
 
-using System;
+using System.Globalization;
 using System.Windows.Markup;
 
 namespace System.Windows.Converters {
@@ -32,22 +32,26 @@ namespace System.Windows.Converters {
        {
                public override bool CanConvertFromString (string value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       return true;
                }
 
                public override bool CanConvertToString (object value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       return value is Vector;
                }
 
                public override object ConvertFromString (string value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       if (value == null)
+                               throw new ArgumentNullException ("value");
+                       return Vector.Parse (value);
                }
 
                public override string ConvertToString (object value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       if (value is Vector vector)
+                               return vector.ToString (CultureInfo.InvariantCulture);
+                       return base.ConvertToString (value, context);
                }
        }
 
index e9c60b528db3bbaa88eab8cad06d50165b7df2c8..49e0548887875bd81ec0f23cf7ac2ccfcc2aeb2c 100644 (file)
@@ -186,22 +186,24 @@ namespace System.Windows.Media {
                        }
                        else
                        {
-                               var parts = source.Split (',');
-                               if (parts.Length != 6)
-                                       throw new FormatException (string.Format ("Invalid Matrix format: {0}", source));
+                               var tokenizer = new NumericListTokenizer (source, CultureInfo.InvariantCulture);
                                double m11;
                                double m12;
                                double m21;
                                double m22;
                                double offsetX;
                                double offsetY;
-                               if (double.TryParse (parts[0], NumberStyles.Float, CultureInfo.InvariantCulture, out m11)
-                                   && double.TryParse (parts[1], NumberStyles.Float, CultureInfo.InvariantCulture, out m12)
-                                   && double.TryParse (parts[2], NumberStyles.Float, CultureInfo.InvariantCulture, out m21)
-                                   && double.TryParse (parts[3], NumberStyles.Float, CultureInfo.InvariantCulture, out m22)
-                                   && double.TryParse (parts[4], NumberStyles.Float, CultureInfo.InvariantCulture, out offsetX)
-                                   && double.TryParse (parts[5], NumberStyles.Float, CultureInfo.InvariantCulture, out offsetY))
+                               if (double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out m11)
+                                   && double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out m12)
+                                   && double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out m21)
+                                   && double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out m22)
+                                   && double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out offsetX)
+                                   && double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out offsetY))
                                {
+                                       if (!tokenizer.HasNoMoreTokens ())
+                                       {
+                                               throw new InvalidOperationException ("Invalid Matrix format: " + source);
+                                       }
                                        value = new Matrix (m11, m12, m21, m22, offsetX, offsetY);
                                }
                                else
@@ -336,12 +338,6 @@ namespace System.Windows.Media {
                        Prepend (m);
                }
 
-               string IFormattable.ToString (string format,
-                                             IFormatProvider provider)
-               {
-                       return ToString (provider);
-               }
-
                public override string ToString ()
                {
                        return ToString (null);
@@ -349,9 +345,33 @@ namespace System.Windows.Media {
 
                public string ToString (IFormatProvider provider)
                {
-                       return IsIdentity
-                               ? "Identity"
-                               : string.Concat (_m11, ",", _m12, ",", _m21, ",", _m22, ",", _offsetX, ",", _offsetY);
+                       return ToString (null, provider);
+               }
+
+               string IFormattable.ToString (string format,
+                       IFormatProvider provider)
+               {
+                       return ToString (provider);
+               }
+
+               private string ToString (string format, IFormatProvider provider)
+               {
+                       if (IsIdentity)
+                               return "Identity";
+
+                       if (provider == null)
+                               provider = CultureInfo.CurrentCulture;
+
+                       if (format == null)
+                               format = string.Empty;
+
+                       var separator = NumericListTokenizer.GetSeparator (provider);
+
+                       var matrixFormat = string.Format (
+                               "{{0:{0}}}{1}{{1:{0}}}{1}{{2:{0}}}{1}{{3:{0}}}{1}{{4:{0}}}{1}{{5:{0}}}",
+                               format, separator);
+                       return string.Format (provider, matrixFormat,
+                               _m11, _m12, _m21, _m22, _offsetX, _offsetY);
                }
 
                public Point Transform (Point point)
index f2b464be1e5b68808a2d0b9f6168842dae539650..815fee0b1b20146ec6afbcfa9b764aa50df63f04 100644 (file)
@@ -26,8 +26,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.ComponentModel;
+using System.Globalization;
 using System.Windows.Converters;
 using System.Windows.Markup;
 
@@ -109,29 +109,84 @@ namespace System.Windows {
 
                public override int GetHashCode ()
                {
-                       throw new NotImplementedException ();
+                       unchecked
+                       {
+                               var hashCode = _x;
+                               hashCode = (hashCode * 397) ^ _y;
+                               hashCode = (hashCode * 397) ^ _width;
+                               hashCode = (hashCode * 397) ^ _height;
+                               return hashCode;
+                       }
                }
 
                public static Int32Rect Parse (string source)
                {
-                       throw new NotImplementedException ();
+                       if (source == null)
+                               throw new ArgumentNullException ("source");
+                       Int32Rect value;
+                       if (source.Trim () == "Empty")
+                       {
+                               value = Empty;
+                       }
+                       else
+                       {
+                               var tokenizer = new NumericListTokenizer (source, CultureInfo.InvariantCulture);
+                               int x;
+                               int y;
+                               int width;
+                               int height;
+                               if (int.TryParse (tokenizer.GetNextToken (), NumberStyles.Integer, CultureInfo.InvariantCulture, out x)
+                                   && int.TryParse (tokenizer.GetNextToken (), NumberStyles.Integer, CultureInfo.InvariantCulture, out y)
+                                   && int.TryParse (tokenizer.GetNextToken (), NumberStyles.Integer, CultureInfo.InvariantCulture, out width)
+                                   && int.TryParse (tokenizer.GetNextToken (), NumberStyles.Integer, CultureInfo.InvariantCulture, out height))
+                               {
+                                       if (!tokenizer.HasNoMoreTokens ())
+                                       {
+                                               throw new InvalidOperationException ("Invalid Int32Rect format: " + source);
+                                       }
+                                       value = new Int32Rect (x, y, width, height);
+                               }
+                               else
+                               {
+                                       throw new FormatException (string.Format ("Invalid Int32Rect format: {0}", source));
+                               }
+                       }
+                       return value;
                }
 
                public override string ToString ()
                {
-                       if (IsEmpty)
-                               return "Empty";
-                       return String.Format ("{0},{1},{2},{3}", _x, _y, _width, _height);
+                       return ToString (null);
                }
 
                public string ToString (IFormatProvider provider)
                {
-                       throw new NotImplementedException ();
+                       return ToString (null, provider);
                }
 
                string IFormattable.ToString (string format, IFormatProvider provider)
                {
-                       throw new NotImplementedException ();
+                       return ToString (provider);
+               }
+
+               private string ToString (string format, IFormatProvider provider)
+               {
+                       if (IsEmpty)
+                               return "Empty";
+
+                       if (provider == null)
+                               provider = CultureInfo.CurrentCulture;
+
+                       if (format == null)
+                               format = string.Empty;
+
+                       var separator = NumericListTokenizer.GetSeparator (provider);
+
+                       var rectFormat = string.Format (
+                               "{{0:{0}}}{1}{{1:{0}}}{1}{{2:{0}}}{1}{{3:{0}}}",
+                               format, separator);
+                       return string.Format (provider, rectFormat,
+                               _x, _y, _width, _height);
                }
        }
 }
diff --git a/mcs/class/WindowsBase/System.Windows/NumericListTokenizer.cs b/mcs/class/WindowsBase/System.Windows/NumericListTokenizer.cs
new file mode 100644 (file)
index 0000000..81905ec
--- /dev/null
@@ -0,0 +1,102 @@
+using System.Globalization;
+
+namespace System.Windows
+{
+       /// <summary>
+       /// Helper class for parsing serialized data structures from the System.Windows namespace.
+       /// </summary>
+       internal class NumericListTokenizer
+       {
+               private readonly string _str;
+               private readonly char _separator;
+               private int _position;
+
+               private enum Symbol
+               {
+                       Token,
+                       Separator,
+                       Whitspace,
+                       EndOfLine
+               }
+
+               public NumericListTokenizer (string str, IFormatProvider formatProvider)
+               {
+                       _str = str ?? throw new ArgumentNullException (nameof(str));
+                       _separator = GetSeparator (formatProvider ?? throw new ArgumentNullException (nameof(formatProvider)));
+               }
+
+               public static char GetSeparator (IFormatProvider formatProvider)
+               {
+                       // By convention, string representations of target classes always use ';' as a separator
+                       // if the decimal number separator is ','. Otherwise, the separator is ','.
+                       return NumberFormatInfo.GetInstance (formatProvider).NumberDecimalSeparator != "," ? ',' : ';';
+               }
+
+               private Symbol GetCurrentSymbol ()
+               {
+                       if (_position >= _str.Length)
+                               return Symbol.EndOfLine;
+                       if (_str[_position] == _separator)
+                               return Symbol.Separator;
+                       if (char.IsWhiteSpace (_str, _position))
+                               return Symbol.Whitspace;
+                       return Symbol.Token;
+               }
+
+               private void SkipAllWhitespaces ()
+               {
+                       while (GetCurrentSymbol () == Symbol.Whitspace)
+                       {
+                               _position++;
+                       }
+               }
+
+               private void SkipNextDelimeter ()
+               {
+                       SkipAllWhitespaces ();
+                       switch (GetCurrentSymbol ())
+                       {
+                               case Symbol.Token:
+                                       return;
+                               case Symbol.Separator:
+                                       _position++;
+                                       SkipAllWhitespaces ();
+                                       return;
+                               default:
+                                       throw new InvalidOperationException ("Separator not found");
+                       }
+               }
+
+               public bool HasNoMoreTokens ()
+               {
+                       SkipAllWhitespaces ();
+                       return GetCurrentSymbol () == Symbol.EndOfLine;
+               }
+
+               public string GetNextToken ()
+               {
+                       var length = 0;
+                       if (_position == 0)
+                       {
+                               SkipAllWhitespaces ();
+                       }
+                       else
+                       {
+                               SkipNextDelimeter ();
+                       }
+
+                       while (GetCurrentSymbol () == Symbol.Token)
+                       {
+                               _position++;
+                               length++;
+                       }
+
+                       if (length == 0)
+                       {
+                               throw new InvalidOperationException ("Next token not found");
+                       }
+
+                       return _str.Substring (_position - length, length);
+               }
+       }
+}
\ No newline at end of file
index 206b0edd3ab7302b161d03cd78e98c01758da003..af57f92829d43bcffa045a95f4e6dafa3eaff50e 100644 (file)
@@ -147,15 +147,21 @@ namespace System.Windows {
 
                public static Point Parse (string source)
                {
-                       string[] points = source.Split(',');
-
-                       if (points.Length<2)
-                               throw new InvalidOperationException ("source does not contain two numbers");
-                       if (points.Length > 2)
-                               throw new InvalidOperationException ("source contains too many delimiters");
-
-                       CultureInfo ci = CultureInfo.InvariantCulture;
-                       return new Point (Convert.ToDouble(points[0],ci), Convert.ToDouble(points[1],ci));      
+                       if (source == null)
+                               throw new ArgumentNullException ("source");
+                       var tokenizer = new NumericListTokenizer (source, CultureInfo.InvariantCulture);
+                       double x;
+                       double y;
+                       if (!double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out x) ||
+                           !double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out y))
+                       {
+                               throw new FormatException (string.Format ("Invalid Point format: {0}", source));
+                       }
+                       if (!tokenizer.HasNoMoreTokens ())
+                       {
+                               throw new InvalidOperationException ("Invalid Point format: " + source);
+                       }
+                       return new Point(x, y);
                }
 
                public override string ToString ()
@@ -170,18 +176,13 @@ namespace System.Windows {
 
                private string ToString(string format,IFormatProvider formatProvider)
                {
-                       CultureInfo ci = (CultureInfo)formatProvider;
-
-                       if (ci == null)
-                               ci = CultureInfo.CurrentCulture;
-                       string seperator = ci.NumberFormat.NumberDecimalSeparator;
-                       if (seperator.Equals(","))
-                               seperator = ";";
-                       else
-                               seperator = ",";
-                       object[] ob = { this._x, seperator, this._y };
-
-                       return string.Format(formatProvider, "{0:" + format + "}{1}{2:" + format + "}", ob);
+                       if (formatProvider == null)
+                               formatProvider = CultureInfo.CurrentCulture;
+                       if (format == null)
+                               format = string.Empty;
+                       var separator = NumericListTokenizer.GetSeparator (formatProvider);
+                       var pointFormat  = string.Format ("{{0:{0}}}{1}{{1:{0}}}", format, separator);
+                       return string.Format (formatProvider, pointFormat, _x, _y);
                }
 
                string IFormattable.ToString (string format, IFormatProvider formatProvider)
index fd38ec6c25ed169cbff90534070b583eb93b99be..6e2e3d9adbcf1e0b69d3189f4535b5fcc47c11a5 100644 (file)
 //     Sebastien Pouliot  <sebastien@ximian.com>
 //
 
-using System;
 using System.ComponentModel;
 using System.Globalization;
-using System.Text;
 using System.Windows.Converters;
 using System.Windows.Markup;
 using System.Windows.Media;
@@ -121,7 +119,14 @@ namespace System.Windows {
 
                public override int GetHashCode ()
                {
-                       throw new NotImplementedException ();
+                       unchecked
+                       {
+                               var hashCode = _x.GetHashCode ();
+                               hashCode = (hashCode * 397) ^ _y.GetHashCode ();
+                               hashCode = (hashCode * 397) ^ _width.GetHashCode ();
+                               hashCode = (hashCode * 397) ^ _height.GetHashCode ();
+                               return hashCode;
+                       }
                }
 
                public bool Contains (Rect rect)
@@ -296,7 +301,37 @@ namespace System.Windows {
 
                public static Rect Parse (string source)
                {
-                       throw new NotImplementedException ();
+                       if (source == null)
+                               throw new ArgumentNullException ("source");
+                       Rect value;
+                       if (source.Trim () == "Empty")
+                       {
+                               value = Empty;
+                       }
+                       else
+                       {
+                               var tokenizer = new NumericListTokenizer (source, CultureInfo.InvariantCulture);
+                               double x;
+                               double y;
+                               double width;
+                               double height;
+                               if (double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out x)
+                                       && double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out y)
+                                       && double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out width)
+                                       && double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out height))
+                               {
+                                       if (!tokenizer.HasNoMoreTokens ())
+                                       {
+                                               throw new InvalidOperationException ("Invalid Rect format: " + source);
+                                       }
+                                       value = new Rect (x, y, width, height);
+                               }
+                               else
+                               {
+                                       throw new FormatException (string.Format ("Invalid Rect format: {0}", source));
+                               }
+                       }
+                       return value;
                }
 
                public override string ToString ()
@@ -325,17 +360,12 @@ namespace System.Windows {
                        if (format == null)
                                format = string.Empty;
 
-                       string separator = ",";
-                       NumberFormatInfo numberFormat =
-                               provider.GetFormat (typeof (NumberFormatInfo)) as NumberFormatInfo;
-                       if (numberFormat != null &&
-                           numberFormat.NumberDecimalSeparator == separator)
-                               separator = ";";
+                       var separator = NumericListTokenizer.GetSeparator (provider);
 
-                       string rectFormat = String.Format (
+                       var rectFormat = string.Format (
                                "{{0:{0}}}{1}{{1:{0}}}{1}{{2:{0}}}{1}{{3:{0}}}",
                                format, separator);
-                       return String.Format (provider, rectFormat,
+                       return string.Format (provider, rectFormat,
                                _x, _y, _width, _height);
                }
 
index d42beb95b7388ddf4ccaa2307d76d4af27784fcd..69f497228f0031f609b98b33e9a7896a2074063d 100644 (file)
@@ -78,46 +78,50 @@ namespace System.Windows {
                        Size value;
                        if (source.Trim () == "Empty")
                        {
-                               value = Empty;
+                               return Empty;
                        }
-                       else
+                       var tokenizer = new NumericListTokenizer (source, CultureInfo.InvariantCulture);
+                       double width;
+                       double height;
+                       if (!double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out width) ||
+                           !double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out height))
                        {
-                               var parts = source.Split (',');
-                               if (parts.Length != 2)
-                                       throw new FormatException (string.Format ("Invalid Size format: {0}", source));
-                               double width;
-                               double height;
-                               if (double.TryParse (parts[0], NumberStyles.Float, CultureInfo.InvariantCulture, out width)
-                                       && double.TryParse (parts[1], NumberStyles.Float, CultureInfo.InvariantCulture, out height))
-                               {
-                                       value = new Size (width, height);
-                               }
-                               else
-                               {
-                                       throw new FormatException (string.Format ("Invalid Size format: {0}", source));
-                               }
+                               throw new FormatException (string.Format ("Invalid Size format: {0}", source));
                        }
-                       return value;
+                       if (!tokenizer.HasNoMoreTokens ())
+                       {
+                               throw new InvalidOperationException ("Invalid Size format: " + source);
+                       }
+                       return new Size(width, height);
                }
 
                public override string ToString ()
                {
-                       return ConvertToString (null);
+                       return ConvertToString (null, null);
                }
 
                public string ToString (IFormatProvider provider)
                {
-                       return ConvertToString (provider);
+                       return ConvertToString (null, provider);
                }
 
                string IFormattable.ToString (string format, IFormatProvider provider)
                {
-                       return ConvertToString (provider);
+                       return ConvertToString (format, provider);
                }
 
-               private string ConvertToString (IFormatProvider provider)
+               private string ConvertToString (string format, IFormatProvider provider)
                {
-                       return IsEmpty ? "Empty" : string.Concat (_width, ",", _height);
+                       if (IsEmpty)
+                               return "Empty";
+
+                       if (provider == null)
+                               provider = CultureInfo.CurrentCulture;
+                       if (format == null)
+                               format = string.Empty;
+                       var separator = NumericListTokenizer.GetSeparator (provider);
+                       var vectorFormat  = string.Format ("{{0:{0}}}{1}{{1:{0}}}", format, separator);
+                       return string.Format (provider, vectorFormat, _width, _height);
                }
 
                public bool IsEmpty {
index 5ed53c3e249cbab2c7ca461a8082147f3b16218a..88b23054fdb220d7613a848e75a4096bdce2ed03 100644 (file)
@@ -23,8 +23,8 @@
 //     Chris Toshok (toshok@novell.com)
 //
 
-using System;
 using System.ComponentModel;
+using System.Globalization;
 using System.Windows.Converters;
 using System.Windows.Markup;
 using System.Windows.Media;
@@ -57,12 +57,10 @@ namespace System.Windows {
 
                public override int GetHashCode ()
                {
-                       throw new NotImplementedException ();
-               }
-
-               string IFormattable.ToString (string format, IFormatProvider provider)
-               {
-                       return string.Format (provider, "{0:" + format + "},{1:" + format + "}", _x, _y);
+                       unchecked
+                       {
+                               return (_x.GetHashCode () * 397) ^ _y.GetHashCode ();
+                       }
                }
 
                public static bool Equals (Vector vector1, Vector vector2)
@@ -150,17 +148,47 @@ namespace System.Windows {
 
                public static Vector Parse (string source)
                {
-                       throw new NotImplementedException ();
+                       if (source == null)
+                               throw new ArgumentNullException ("source");
+                       var tokenizer = new NumericListTokenizer (source, CultureInfo.InvariantCulture);
+                       double x;
+                       double y;
+                       if (!double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out x) ||
+                           !double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out y))
+                       {
+                               throw new FormatException (string.Format ("Invalid Vector format: {0}", source));
+                       }
+                       if (!tokenizer.HasNoMoreTokens ())
+                       {
+                               throw new InvalidOperationException("Invalid Vector format: " + source);
+                       }
+                       return new Vector(x, y);
                }
 
                public override string ToString ()
                {
-                       return String.Format ("{0},{1}", _x, _y);
+                       return ToString(null);
                }
 
                public string ToString (IFormatProvider provider)
                {
-                       throw new NotImplementedException ();
+                       return ToString (null, provider);
+               }
+
+               string IFormattable.ToString (string format, IFormatProvider provider)
+               {
+                       return ToString (format, provider);
+               }
+
+               private string ToString(string format,IFormatProvider formatProvider)
+               {
+                       if (formatProvider == null)
+                               formatProvider = CultureInfo.CurrentCulture;
+                       if (format == null)
+                               format = string.Empty;
+                       var separator = NumericListTokenizer.GetSeparator (formatProvider);
+                       var vectorFormat  = string.Format ("{{0:{0}}}{1}{{1:{0}}}", format, separator);
+                       return string.Format (formatProvider, vectorFormat, _x, _y);
                }
 
                public double Length {
index a5519a462d2e23d384c69cb475d3ecb18a201e7d..64375844ccd8dfac57e4121a643e488f1ae5f5c0 100644 (file)
@@ -54,7 +54,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void ConvertFrom ()
                {
                        Int32RectConverter r = new Int32RectConverter ();
@@ -79,7 +78,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void ConvertFrom_negative ()
                {
                        Int32RectConverter r = new Int32RectConverter ();
index 8275f1813b8611bd88151fe3406cc6502b8b4e5d..ffd571f3a191ec257f7a6d9e5cef916f3ecb043e 100644 (file)
@@ -142,7 +142,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void Parse ()
                {
                        Int32Rect r = Int32Rect.Parse ("1, 2, 3, 4");
@@ -150,7 +149,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void ParseNegative ()
                {
                        Int32Rect.Parse ("1, 2, -3, -4");
diff --git a/mcs/class/WindowsBase/Test/System.Windows/Int32RectValueSerializerTest.cs b/mcs/class/WindowsBase/Test/System.Windows/Int32RectValueSerializerTest.cs
new file mode 100644 (file)
index 0000000..86c2fbd
--- /dev/null
@@ -0,0 +1,69 @@
+using System;
+using System.Windows;
+using System.Windows.Converters;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows {
+
+       [TestFixture]
+       public class Int32RectValueSerializerTest
+       {
+               [Test]
+               public void CanConvertFromString ()
+               {
+                       var serializer = new Int32RectValueSerializer ();
+                       Assert.IsTrue (serializer.CanConvertFromString ("", null));
+               }
+
+               [Test]
+               public void CanConvertToString ()
+               {
+                       var serializer = new Int32RectValueSerializer ();
+                       Assert.IsTrue (serializer.CanConvertToString (new Int32Rect (0, 0, 0, 0), null));
+                       Assert.IsFalse (serializer.CanConvertToString ("", null));
+               }
+
+               [Test]
+               public void ConvertFromString ()
+               {
+                       var serializer = new Int32RectValueSerializer ();
+                       object obj = serializer.ConvertFromString ("3,4,5,6", null);
+                       Assert.AreEqual (typeof (Int32Rect), obj.GetType ());
+                       Assert.AreEqual (new Int32Rect (3, 4, 5, 6), obj);
+               }
+
+               [Test]
+               public void RoundTripConvert()
+               {
+                       var serializer = new Int32RectValueSerializer ();
+                       var size = new Int32Rect (7, 8, 9, 10);
+                       var obj = serializer.ConvertFromString (serializer.ConvertToString (size, null), null);
+                       Assert.AreEqual (size, obj);
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void ConvertFromStringShouldThrowExceptionWhenStringHasInvalidFormat ()
+               {
+                       var serializer = new Int32RectValueSerializer ();
+                       serializer.ConvertFromString ("a,b,c,d", null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConvertFromStringShouldThrowExceptionWhenStringIsNull ()
+               {
+                       var serializer = new Int32RectValueSerializer ();
+                       serializer.ConvertFromString (null, null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void ConvertToStringShouldThrowExceptionWhenInvalidType ()
+               {
+                       var serializer = new Int32RectValueSerializer ();
+                       serializer.ConvertToString (10, null);
+               }
+       }
+
+}
index a5c335953d57b70bc1db0ea14800089143d6a2d5..93d33bc678a06fdd31deb6ebb3e9d39d62966915 100644 (file)
@@ -52,7 +52,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void ConvertFrom ()
                {
                        PointConverter r = new PointConverter ();
@@ -77,7 +76,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void ConvertTo ()
                {
                        PointConverter r = new PointConverter ();
index 521b227d046854591251f6704e13ae443e447460..001f74243eefba11f5d1cde942bef415d7527cec 100644 (file)
@@ -51,20 +51,18 @@ namespace MonoTests.System.Windows {
                        Assert.IsFalse (p.Equals (new object()));
                }
 
-        [Test]
-               [Category ("NotWorking")]
-        public void getHashCodeTest()
-        {
-                       Point p1 = new Point(-5, -4);
-                       Point p2 = new Point(5, 4);
-                       Point p3 = new Point(5, 4);
-
-                       Assert.AreEqual(p2.GetHashCode(), p3.GetHashCode());
-                       Assert.AreEqual(p1.GetHashCode(),p2.GetHashCode());
-        }
+                       [Test]
+                       public void GetHashCodeTest()
+                       {
+                               Point p1 = new Point(-5, -4);
+                               Point p2 = new Point(5, 4);
+                               Point p3 = new Point(5, 4);
+
+                               Assert.AreEqual (p2.GetHashCode (), p3.GetHashCode ());
+                               Assert.AreEqual (p1.GetHashCode (),p2.GetHashCode ());
+                       }
 
                [Test]
-               [Category ("NotWorking")]
                public void ToStringTest ()
                {
                        Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-us");
@@ -85,7 +83,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void Parse ()
                {
                        Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("fr-fr");
diff --git a/mcs/class/WindowsBase/Test/System.Windows/PointValueSerializerTest.cs b/mcs/class/WindowsBase/Test/System.Windows/PointValueSerializerTest.cs
new file mode 100644 (file)
index 0000000..a9687d4
--- /dev/null
@@ -0,0 +1,69 @@
+using System;
+using System.Windows;
+using System.Windows.Converters;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows {
+
+       [TestFixture]
+       public class PointValueSerializerTest
+       {
+               [Test]
+               public void CanConvertFromString ()
+               {
+                       var serializer = new PointValueSerializer ();
+                       Assert.IsTrue (serializer.CanConvertFromString ("", null));
+               }
+
+               [Test]
+               public void CanConvertToString ()
+               {
+                       var serializer = new PointValueSerializer ();
+                       Assert.IsTrue (serializer.CanConvertToString (new Point (0, 0), null));
+                       Assert.IsFalse (serializer.CanConvertToString ("", null));
+               }
+
+               [Test]
+               public void ConvertFromString ()
+               {
+                       var serializer = new PointValueSerializer ();
+                       object obj = serializer.ConvertFromString ("3.14,4.15", null);
+                       Assert.AreEqual (typeof (Point), obj.GetType ());
+                       Assert.AreEqual (new Point (3.14, 4.15), obj);
+               }
+
+               [Test]
+               public void RoundTripConvert()
+               { 
+                       var serializer = new PointValueSerializer ();
+                       var Point = new Point (1.234, 2.678);
+                       var obj = serializer.ConvertFromString (serializer.ConvertToString (Point, null), null);
+                       Assert.AreEqual (Point, obj);
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void ConvertFromStringShouldThrowExceptionWhenStringHasInvalidFormat ()
+               {
+                       var serializer = new PointValueSerializer ();
+                       serializer.ConvertFromString ("a,b", null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConvertFromStringShouldThrowExceptionWhenStringIsNull ()
+               {
+                       var serializer = new PointValueSerializer ();
+                       serializer.ConvertFromString (null, null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void ConvertToStringShouldThrowExceptionWhenInvalidType ()
+               {
+                       var serializer = new PointValueSerializer ();
+                       serializer.ConvertToString (10, null);
+               }
+       }
+
+}
index 0fa463fe71e49bcc9a4ca2a53c879646f854672f..3d2b6b12a72e4e2a0699e0053ee4f28333d977d0 100644 (file)
@@ -54,7 +54,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void ConvertFrom ()
                {
                        RectConverter r = new RectConverter ();
@@ -79,7 +78,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                [ExpectedException (typeof (ArgumentException))]
                public void ConvertFrom_negative ()
                {
@@ -88,7 +86,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void ConvertTo ()
                {
                        RectConverter r = new RectConverter ();
index 6fddadb2f9167de43dcc81e91ce1875d9548c3f6..c1d0dae4d7b56044ff08b2b2cffaaa5edcea08fb 100644 (file)
@@ -327,7 +327,6 @@ namespace MonoTests.System.Windows {
                }
                
                [Test]
-               [Category ("NotWorking")]
                public void ToString_FormatException ()
                {
                        // This test does not currently work because
@@ -343,7 +342,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void Parse ()
                {
                        Rect r = Rect.Parse ("1 , 2, 3, 4");
@@ -351,7 +349,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void Parse2 ()
                {
                        Rect r = Rect.Parse ("1 2 3 4");
@@ -359,7 +356,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void Parse3 ()
                {
                        Rect r = Rect.Parse ("  1 2 3 4  ");
@@ -367,14 +363,12 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void ParseWithBothSeparators ()
                {
                        Rect.Parse ("1.0, 3 2.0, 5.0");
                }
 
                [Test]
-               [Category ("NotWorking")]
                [ExpectedException (typeof (ArgumentException))]
                public void ParseNegative ()
                {
@@ -382,7 +376,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                [ExpectedException (typeof (InvalidOperationException))] // "Premature string termination encountered."
                public void Parse3Doubles ()
                {
@@ -390,7 +383,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                [ExpectedException (typeof (FormatException))]
                public void ParseInvalidString1 ()
                {
@@ -398,7 +390,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                [ExpectedException (typeof (InvalidOperationException))]
                public void ParseInvalidString3 ()
                {
@@ -406,7 +397,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                [ExpectedException (typeof (FormatException))]
                public void ParseInvalidString4 ()
                {
@@ -414,7 +404,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                [ExpectedException (typeof (InvalidOperationException))]
                public void ParseInvalidString5 ()
                {
@@ -422,14 +411,12 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void ParseInvalidString6 ()
                {
                        Rect.Parse ("\n1.0, 2.0, 5.0, 2");
                }
 
                [Test]
-               [Category ("NotWorking")]
                [ExpectedException (typeof (InvalidOperationException))]
                public void ParseInvalidString7 ()
                {
diff --git a/mcs/class/WindowsBase/Test/System.Windows/RectValueSerializerTest.cs b/mcs/class/WindowsBase/Test/System.Windows/RectValueSerializerTest.cs
new file mode 100644 (file)
index 0000000..41d6d83
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Windows;
+using System.Windows.Converters;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows {
+
+       [TestFixture]
+       public class RectValueSerializerTest
+       {
+               [Test]
+               public void CanConvertFromString ()
+               {
+                       var serializer = new RectValueSerializer ();
+                       Assert.IsTrue (serializer.CanConvertFromString ("", null));
+               }
+
+               [Test]
+               public void CanConvertToString ()
+               {
+                       var serializer = new RectValueSerializer ();
+                       Assert.IsTrue (serializer.CanConvertToString (new Rect (0, 0, 0, 0), null));
+                       Assert.IsFalse (serializer.CanConvertToString ("", null));
+               }
+
+               [Test]
+               public void ConvertFromString ()
+               {
+                       var serializer = new RectValueSerializer ();
+                       object obj = serializer.ConvertFromString ("3.14,4.15,5.16,6.17", null);
+                       Assert.AreEqual (typeof (Rect), obj.GetType ());
+                       Assert.AreEqual (new Rect (3.14, 4.15, 5.16, 6.17), obj);
+               }
+
+               [Test]
+               public void RoundTripConvert()
+               { 
+                       var serializer = new RectValueSerializer ();
+                       var rect = new Rect (1.234, 2.678, 3.123, 4.567);
+                       var obj = serializer.ConvertFromString (serializer.ConvertToString (rect, null), null);
+                       Assert.AreEqual (rect, obj);
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void ConvertFromStringShouldThrowExceptionWhenStringHasInvalidFormat ()
+               {
+                       var serializer = new RectValueSerializer ();
+                       serializer.ConvertFromString ("a,b,c,d", null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConvertFromStringShouldThrowExceptionWhenStringIsNull ()
+               {
+                       var serializer = new RectValueSerializer ();
+                       serializer.ConvertFromString (null, null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void ConvertToStringShouldThrowExceptionWhenInvalidType ()
+               {
+                       var serializer = new RectValueSerializer ();
+                       serializer.ConvertToString (10, null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void ConvertToStringShouldThrowExceptionWhenHeightOrWidthIsNegative ()
+               {
+                       var serializer = new RectValueSerializer ();
+                       var result = serializer.ConvertFromString ("1,2,-1,-2", null);
+               }
+       }
+
+}
index 2e394a88152e07d1952ff1022e9b9c659f5d45d0..8c2a74496356cf5ce1862fededde8fea5ab4612b 100644 (file)
@@ -52,7 +52,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void ConvertFrom ()
                {
                        VectorConverter r = new VectorConverter ();
@@ -77,7 +76,6 @@ namespace MonoTests.System.Windows {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void ConvertTo ()
                {
                        VectorConverter r = new VectorConverter ();
diff --git a/mcs/class/WindowsBase/Test/System.Windows/VectorValueSerializerTest.cs b/mcs/class/WindowsBase/Test/System.Windows/VectorValueSerializerTest.cs
new file mode 100644 (file)
index 0000000..8044668
--- /dev/null
@@ -0,0 +1,69 @@
+using System;
+using System.Windows;
+using System.Windows.Converters;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows {
+
+       [TestFixture]
+       public class VectorValueSerializerTest
+       {
+               [Test]
+               public void CanConvertFromString ()
+               {
+                       var serializer = new VectorValueSerializer ();
+                       Assert.IsTrue (serializer.CanConvertFromString ("", null));
+               }
+
+               [Test]
+               public void CanConvertToString ()
+               {
+                       var serializer = new VectorValueSerializer ();
+                       Assert.IsTrue (serializer.CanConvertToString (new Vector (0, 0), null));
+                       Assert.IsFalse (serializer.CanConvertToString ("", null));
+               }
+
+               [Test]
+               public void ConvertFromString ()
+               {
+                       var serializer = new VectorValueSerializer ();
+                       object obj = serializer.ConvertFromString ("3.14,4.15", null);
+                       Assert.AreEqual (typeof (Vector), obj.GetType ());
+                       Assert.AreEqual (new Vector (3.14, 4.15), obj);
+               }
+
+               [Test]
+               public void RoundTripConvert()
+               { 
+                       var serializer = new VectorValueSerializer ();
+                       var Vector = new Vector (1.234, 2.678);
+                       var obj = serializer.ConvertFromString (serializer.ConvertToString (Vector, null), null);
+                       Assert.AreEqual (Vector, obj);
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void ConvertFromStringShouldThrowExceptionWhenStringHasInvalidFormat ()
+               {
+                       var serializer = new VectorValueSerializer ();
+                       serializer.ConvertFromString ("a,b", null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConvertFromStringShouldThrowExceptionWhenStringIsNull ()
+               {
+                       var serializer = new VectorValueSerializer ();
+                       serializer.ConvertFromString (null, null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void ConvertToStringShouldThrowExceptionWhenInvalidType ()
+               {
+                       var serializer = new VectorValueSerializer ();
+                       serializer.ConvertToString (10, null);
+               }
+       }
+
+}
index c36c7ce5608ab796e4a659abf9e57fae4d39ae48..649a1a450e38295eec0186b80bef937683b5918e 100644 (file)
@@ -102,6 +102,7 @@ System.Windows/RectConverter.cs
 System.Windows/Size.cs
 System.Windows/SizeConverter.cs
 System.Windows/SplashScreen.cs
+System.Windows/NumericListTokenizer.cs
 System.Windows/ValidateValueCallback.cs
 System.Windows/Vector.cs
 System.Windows/VectorConverter.cs
index 5fba4fc771069f5e0a6d9d4a0e42338e1ab55547..fa7855a690f33613fb46449ff29d8e919b2e5664 100644 (file)
@@ -25,16 +25,20 @@ System.Windows/DependencyObjectTypeTest.cs
 System.Windows/DependencyPropertyTest.cs
 System.Windows/Int32RectTest.cs
 System.Windows/Int32RectConverterTest.cs
+System.Windows/Int32RectValueSerializerTest.cs
 System.Windows/PointTest.cs
 System.Windows/PointConverterTest.cs
+System.Windows/PointValueSerializerTest.cs
 System.Windows/PropertyMetadataTest.cs
 System.Windows/RectTest.cs
 System.Windows/RectConverterTest.cs
+System.Windows/RectValueSerializerTest.cs
 System.Windows/SizeTest.cs
 System.Windows/SizeConverterTest.cs
 System.Windows/SizeValueSerializerTest.cs
 System.Windows/VectorTest.cs
 System.Windows/VectorConverterTest.cs
+System.Windows/VectorValueSerializerTest.cs
 System.Windows.Markup/ConstructorArgumentAttributeTest.cs
 System.Windows.Markup/ContentPropertyAttributeTest.cs
 System.Windows.Markup/ContentWrapperAttributeTest.cs