Add readonly to members of System.Drawing.Primitives (dotnet/corefx#40407)
authorFons Sonnemans <fons.sonnemans@reflectionit.nl>
Mon, 21 Oct 2019 16:10:37 +0000 (18:10 +0200)
committerStephen Toub <stoub@microsoft.com>
Mon, 21 Oct 2019 16:10:37 +0000 (12:10 -0400)
Commit migrated from https://github.com/dotnet/corefx/commit/4746f754a5a46c465d083c8999335d62e607f25d

src/libraries/System.Drawing.Primitives/ref/System.Drawing.Primitives.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/Point.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/PointF.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/Rectangle.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/RectangleF.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/Size.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/SizeF.cs

index 577cfbc..4d3b068 100644 (file)
@@ -374,14 +374,14 @@ namespace System.Drawing
         public Point(int dw) { throw null; }
         public Point(int x, int y) { throw null; }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public bool IsEmpty { get { throw null; } }
-        public int X { get { throw null; } set { } }
-        public int Y { get { throw null; } set { } }
+        public readonly bool IsEmpty { get { throw null; } }
+        public int X { readonly get { throw null; } set { } }
+        public int Y { readonly get { throw null; } set { } }
         public static System.Drawing.Point Add(System.Drawing.Point pt, System.Drawing.Size sz) { throw null; }
         public static System.Drawing.Point Ceiling(System.Drawing.PointF value) { throw null; }
-        public bool Equals(System.Drawing.Point other) { throw null; }
-        public override bool Equals(object? obj) { throw null; }
-        public override int GetHashCode() { throw null; }
+        public readonly bool Equals(System.Drawing.Point other) { throw null; }
+        public override readonly bool Equals(object? obj) { throw null; }
+        public override readonly int GetHashCode() { throw null; }
         public void Offset(System.Drawing.Point p) { }
         public void Offset(int dx, int dy) { }
         public static System.Drawing.Point operator +(System.Drawing.Point pt, System.Drawing.Size sz) { throw null; }
@@ -392,7 +392,7 @@ namespace System.Drawing
         public static System.Drawing.Point operator -(System.Drawing.Point pt, System.Drawing.Size sz) { throw null; }
         public static System.Drawing.Point Round(System.Drawing.PointF value) { throw null; }
         public static System.Drawing.Point Subtract(System.Drawing.Point pt, System.Drawing.Size sz) { throw null; }
-        public override string ToString() { throw null; }
+        public override readonly string ToString() { throw null; }
         public static System.Drawing.Point Truncate(System.Drawing.PointF value) { throw null; }
     }
     public partial struct PointF : System.IEquatable<System.Drawing.PointF>
@@ -401,14 +401,14 @@ namespace System.Drawing
         public static readonly System.Drawing.PointF Empty;
         public PointF(float x, float y) { throw null; }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public bool IsEmpty { get { throw null; } }
-        public float X { get { throw null; } set { } }
-        public float Y { get { throw null; } set { } }
+        public readonly bool IsEmpty { get { throw null; } }
+        public float X { readonly get { throw null; } set { } }
+        public float Y { readonly get { throw null; } set { } }
         public static System.Drawing.PointF Add(System.Drawing.PointF pt, System.Drawing.Size sz) { throw null; }
         public static System.Drawing.PointF Add(System.Drawing.PointF pt, System.Drawing.SizeF sz) { throw null; }
-        public bool Equals(System.Drawing.PointF other) { throw null; }
-        public override bool Equals(object? obj) { throw null; }
-        public override int GetHashCode() { throw null; }
+        public readonly bool Equals(System.Drawing.PointF other) { throw null; }
+        public override readonly bool Equals(object? obj) { throw null; }
+        public override readonly int GetHashCode() { throw null; }
         public static System.Drawing.PointF operator +(System.Drawing.PointF pt, System.Drawing.Size sz) { throw null; }
         public static System.Drawing.PointF operator +(System.Drawing.PointF pt, System.Drawing.SizeF sz) { throw null; }
         public static bool operator ==(System.Drawing.PointF left, System.Drawing.PointF right) { throw null; }
@@ -417,7 +417,7 @@ namespace System.Drawing
         public static System.Drawing.PointF operator -(System.Drawing.PointF pt, System.Drawing.SizeF sz) { throw null; }
         public static System.Drawing.PointF Subtract(System.Drawing.PointF pt, System.Drawing.Size sz) { throw null; }
         public static System.Drawing.PointF Subtract(System.Drawing.PointF pt, System.Drawing.SizeF sz) { throw null; }
-        public override string ToString() { throw null; }
+        public override readonly string ToString() { throw null; }
     }
     public partial struct Rectangle : System.IEquatable<System.Drawing.Rectangle>
     {
@@ -426,31 +426,31 @@ namespace System.Drawing
         public Rectangle(System.Drawing.Point location, System.Drawing.Size size) { throw null; }
         public Rectangle(int x, int y, int width, int height) { throw null; }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public int Bottom { get { throw null; } }
-        public int Height { get { throw null; } set { } }
+        public readonly int Bottom { get { throw null; } }
+        public int Height { readonly get { throw null; } set { } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public bool IsEmpty { get { throw null; } }
+        public readonly bool IsEmpty { get { throw null; } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public int Left { get { throw null; } }
+        public readonly int Left { get { throw null; } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public System.Drawing.Point Location { get { throw null; } set { } }
+        public System.Drawing.Point Location { readonly get { throw null; } set { } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public int Right { get { throw null; } }
+        public readonly int Right { get { throw null; } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public System.Drawing.Size Size { get { throw null; } set { } }
+        public System.Drawing.Size Size { readonly get { throw null; } set { } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public int Top { get { throw null; } }
-        public int Width { get { throw null; } set { } }
-        public int X { get { throw null; } set { } }
-        public int Y { get { throw null; } set { } }
+        public readonly int Top { get { throw null; } }
+        public int Width { readonly get { throw null; } set { } }
+        public int X { readonly get { throw null; } set { } }
+        public int Y { readonly get { throw null; } set { } }
         public static System.Drawing.Rectangle Ceiling(System.Drawing.RectangleF value) { throw null; }
-        public bool Contains(System.Drawing.Point pt) { throw null; }
-        public bool Contains(System.Drawing.Rectangle rect) { throw null; }
-        public bool Contains(int x, int y) { throw null; }
-        public bool Equals(System.Drawing.Rectangle other) { throw null; }
-        public override bool Equals(object? obj) { throw null; }
+        public readonly bool Contains(System.Drawing.Point pt) { throw null; }
+        public readonly bool Contains(System.Drawing.Rectangle rect) { throw null; }
+        public readonly bool Contains(int x, int y) { throw null; }
+        public readonly bool Equals(System.Drawing.Rectangle other) { throw null; }
+        public override readonly bool Equals(object? obj) { throw null; }
         public static System.Drawing.Rectangle FromLTRB(int left, int top, int right, int bottom) { throw null; }
-        public override int GetHashCode() { throw null; }
+        public override readonly int GetHashCode() { throw null; }
         public static System.Drawing.Rectangle Inflate(System.Drawing.Rectangle rect, int x, int y) { throw null; }
         public void Inflate(System.Drawing.Size size) { }
         public void Inflate(int width, int height) { }
@@ -462,7 +462,7 @@ namespace System.Drawing
         public static bool operator ==(System.Drawing.Rectangle left, System.Drawing.Rectangle right) { throw null; }
         public static bool operator !=(System.Drawing.Rectangle left, System.Drawing.Rectangle right) { throw null; }
         public static System.Drawing.Rectangle Round(System.Drawing.RectangleF value) { throw null; }
-        public override string ToString() { throw null; }
+        public override readonly string ToString() { throw null; }
         public static System.Drawing.Rectangle Truncate(System.Drawing.RectangleF value) { throw null; }
         public static System.Drawing.Rectangle Union(System.Drawing.Rectangle a, System.Drawing.Rectangle b) { throw null; }
     }
@@ -473,42 +473,42 @@ namespace System.Drawing
         public RectangleF(System.Drawing.PointF location, System.Drawing.SizeF size) { throw null; }
         public RectangleF(float x, float y, float width, float height) { throw null; }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public float Bottom { get { throw null; } }
-        public float Height { get { throw null; } set { } }
+        public readonly float Bottom { get { throw null; } }
+        public float Height { readonly get { throw null; } set { } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public bool IsEmpty { get { throw null; } }
+        public readonly bool IsEmpty { get { throw null; } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public float Left { get { throw null; } }
+        public readonly float Left { get { throw null; } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public System.Drawing.PointF Location { get { throw null; } set { } }
+        public System.Drawing.PointF Location { readonly get { throw null; } set { } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public float Right { get { throw null; } }
+        public readonly float Right { get { throw null; } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public System.Drawing.SizeF Size { get { throw null; } set { } }
+        public System.Drawing.SizeF Size { readonly get { throw null; } set { } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public float Top { get { throw null; } }
-        public float Width { get { throw null; } set { } }
-        public float X { get { throw null; } set { } }
-        public float Y { get { throw null; } set { } }
-        public bool Contains(System.Drawing.PointF pt) { throw null; }
-        public bool Contains(System.Drawing.RectangleF rect) { throw null; }
-        public bool Contains(float x, float y) { throw null; }
-        public bool Equals(System.Drawing.RectangleF other) { throw null; }
-        public override bool Equals(object? obj) { throw null; }
+        public readonly float Top { get { throw null; } }
+        public float Width { readonly get { throw null; } set { } }
+        public float X { readonly get { throw null; } set { } }
+        public float Y { readonly get { throw null; } set { } }
+        public readonly bool Contains(System.Drawing.PointF pt) { throw null; }
+        public readonly bool Contains(System.Drawing.RectangleF rect) { throw null; }
+        public readonly bool Contains(float x, float y) { throw null; }
+        public readonly bool Equals(System.Drawing.RectangleF other) { throw null; }
+        public override readonly bool Equals(object? obj) { throw null; }
         public static System.Drawing.RectangleF FromLTRB(float left, float top, float right, float bottom) { throw null; }
-        public override int GetHashCode() { throw null; }
+        public override readonly int GetHashCode() { throw null; }
         public static System.Drawing.RectangleF Inflate(System.Drawing.RectangleF rect, float x, float y) { throw null; }
         public void Inflate(System.Drawing.SizeF size) { }
         public void Inflate(float x, float y) { }
         public void Intersect(System.Drawing.RectangleF rect) { }
         public static System.Drawing.RectangleF Intersect(System.Drawing.RectangleF a, System.Drawing.RectangleF b) { throw null; }
-        public bool IntersectsWith(System.Drawing.RectangleF rect) { throw null; }
+        public readonly bool IntersectsWith(System.Drawing.RectangleF rect) { throw null; }
         public void Offset(System.Drawing.PointF pos) { }
         public void Offset(float x, float y) { }
         public static bool operator ==(System.Drawing.RectangleF left, System.Drawing.RectangleF right) { throw null; }
         public static implicit operator System.Drawing.RectangleF (System.Drawing.Rectangle r) { throw null; }
         public static bool operator !=(System.Drawing.RectangleF left, System.Drawing.RectangleF right) { throw null; }
-        public override string ToString() { throw null; }
+        public override readonly string ToString() { throw null; }
         public static System.Drawing.RectangleF Union(System.Drawing.RectangleF a, System.Drawing.RectangleF b) { throw null; }
     }
     public partial struct Size : System.IEquatable<System.Drawing.Size>
@@ -517,15 +517,15 @@ namespace System.Drawing
         public static readonly System.Drawing.Size Empty;
         public Size(System.Drawing.Point pt) { throw null; }
         public Size(int width, int height) { throw null; }
-        public int Height { get { throw null; } set { } }
+        public int Height { readonly get { throw null; } set { } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public bool IsEmpty { get { throw null; } }
-        public int Width { get { throw null; } set { } }
+        public readonly bool IsEmpty { get { throw null; } }
+        public int Width { readonly get { throw null; } set { } }
         public static System.Drawing.Size Add(System.Drawing.Size sz1, System.Drawing.Size sz2) { throw null; }
         public static System.Drawing.Size Ceiling(System.Drawing.SizeF value) { throw null; }
-        public bool Equals(System.Drawing.Size other) { throw null; }
-        public override bool Equals(object? obj) { throw null; }
-        public override int GetHashCode() { throw null; }
+        public readonly bool Equals(System.Drawing.Size other) { throw null; }
+        public override readonly bool Equals(object? obj) { throw null; }
+        public override readonly int GetHashCode() { throw null; }
         public static System.Drawing.Size operator +(System.Drawing.Size sz1, System.Drawing.Size sz2) { throw null; }
         public static System.Drawing.Size operator /(System.Drawing.Size left, int right) { throw null; }
         public static System.Drawing.SizeF operator /(System.Drawing.Size left, float right) { throw null; }
@@ -540,7 +540,7 @@ namespace System.Drawing
         public static System.Drawing.Size operator -(System.Drawing.Size sz1, System.Drawing.Size sz2) { throw null; }
         public static System.Drawing.Size Round(System.Drawing.SizeF value) { throw null; }
         public static System.Drawing.Size Subtract(System.Drawing.Size sz1, System.Drawing.Size sz2) { throw null; }
-        public override string ToString() { throw null; }
+        public override readonly string ToString() { throw null; }
         public static System.Drawing.Size Truncate(System.Drawing.SizeF value) { throw null; }
     }
     public partial struct SizeF : System.IEquatable<System.Drawing.SizeF>
@@ -550,14 +550,14 @@ namespace System.Drawing
         public SizeF(System.Drawing.PointF pt) { throw null; }
         public SizeF(System.Drawing.SizeF size) { throw null; }
         public SizeF(float width, float height) { throw null; }
-        public float Height { get { throw null; } set { } }
+        public float Height { readonly get { throw null; } set { } }
         [System.ComponentModel.BrowsableAttribute(false)]
-        public bool IsEmpty { get { throw null; } }
-        public float Width { get { throw null; } set { } }
+        public readonly bool IsEmpty { get { throw null; } }
+        public float Width { readonly get { throw null; } set { } }
         public static System.Drawing.SizeF Add(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; }
-        public bool Equals(System.Drawing.SizeF other) { throw null; }
-        public override bool Equals(object? obj) { throw null; }
-        public override int GetHashCode() { throw null; }
+        public readonly bool Equals(System.Drawing.SizeF other) { throw null; }
+        public override readonly bool Equals(object? obj) { throw null; }
+        public override readonly int GetHashCode() { throw null; }
         public static System.Drawing.SizeF operator +(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; }
         public static System.Drawing.SizeF operator /(System.Drawing.SizeF left, float right) { throw null; }
         public static bool operator ==(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; }
@@ -567,9 +567,9 @@ namespace System.Drawing
         public static System.Drawing.SizeF operator *(float left, System.Drawing.SizeF right) { throw null; }
         public static System.Drawing.SizeF operator -(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; }
         public static System.Drawing.SizeF Subtract(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; }
-        public System.Drawing.PointF ToPointF() { throw null; }
-        public System.Drawing.Size ToSize() { throw null; }
-        public override string ToString() { throw null; }
+        public readonly System.Drawing.PointF ToPointF() { throw null; }
+        public readonly System.Drawing.Size ToSize() { throw null; }
+        public override readonly string ToString() { throw null; }
     }
     public static partial class SystemColors
     {
index eff3cf4..333e38f 100644 (file)
@@ -52,14 +52,14 @@ namespace System.Drawing
         /// Gets a value indicating whether this <see cref='System.Drawing.Point'/> is empty.
         /// </summary>
         [Browsable(false)]
-        public bool IsEmpty => x == 0 && y == 0;
+        public readonly bool IsEmpty => x == 0 && y == 0;
 
         /// <summary>
         /// Gets the x-coordinate of this <see cref='System.Drawing.Point'/>.
         /// </summary>
         public int X
         {
-            get => x;
+            readonly get => x;
             set => x = value;
         }
 
@@ -68,7 +68,7 @@ namespace System.Drawing
         /// </summary>
         public int Y
         {
-            get => y;
+            readonly get => y;
             set => y = value;
         }
 
@@ -135,14 +135,14 @@ namespace System.Drawing
         /// Specifies whether this <see cref='System.Drawing.Point'/> contains the same coordinates as the specified
         /// <see cref='object'/>.
         /// </summary>
-        public override bool Equals(object? obj) => obj is Point && Equals((Point)obj);
+        public override readonly bool Equals(object? obj) => obj is Point && Equals((Point)obj);
 
-        public bool Equals(Point other) => this == other;
+        public readonly bool Equals(Point other) => this == other;
 
         /// <summary>
         /// Returns a hash code.
         /// </summary>
-        public override int GetHashCode() => HashCode.Combine(X, Y);
+        public override readonly int GetHashCode() => HashCode.Combine(X, Y);
 
         /// <summary>
         /// Translates this <see cref='System.Drawing.Point'/> by the specified amount.
@@ -164,7 +164,7 @@ namespace System.Drawing
         /// <summary>
         /// Converts this <see cref='System.Drawing.Point'/> to a human readable string.
         /// </summary>
-        public override string ToString() => "{X=" + X.ToString() + ",Y=" + Y.ToString() + "}";
+        public override readonly string ToString() => "{X=" + X.ToString() + ",Y=" + Y.ToString() + "}";
 
         private static short HighInt16(int n) => unchecked((short)((n >> 16) & 0xffff));
 
index 1ca26b2..4f3f0e4 100644 (file)
@@ -33,14 +33,14 @@ namespace System.Drawing
         /// Gets a value indicating whether this <see cref='System.Drawing.PointF'/> is empty.
         /// </summary>
         [Browsable(false)]
-        public bool IsEmpty => x == 0f && y == 0f;
+        public readonly bool IsEmpty => x == 0f && y == 0f;
 
         /// <summary>
         /// Gets the x-coordinate of this <see cref='System.Drawing.PointF'/>.
         /// </summary>
         public float X
         {
-            get => x;
+            readonly get => x;
             set => x = value;
         }
 
@@ -49,7 +49,7 @@ namespace System.Drawing
         /// </summary>
         public float Y
         {
-            get => y;
+            readonly get => y;
             set => y = value;
         }
 
@@ -107,12 +107,12 @@ namespace System.Drawing
         /// </summary>
         public static PointF Subtract(PointF pt, SizeF sz) => new PointF(pt.X - sz.Width, pt.Y - sz.Height);
 
-        public override bool Equals(object? obj) => obj is PointF && Equals((PointF)obj);
+        public override readonly bool Equals(object? obj) => obj is PointF && Equals((PointF)obj);
 
-        public bool Equals(PointF other) => this == other;
+        public readonly bool Equals(PointF other) => this == other;
 
-        public override int GetHashCode() => HashCode.Combine(X, Y);
+        public override readonly int GetHashCode() => HashCode.Combine(X.GetHashCode(), Y.GetHashCode());
 
-        public override string ToString() => "{X=" + x.ToString() + ", Y=" + y.ToString() + "}";
+        public override readonly string ToString() => "{X=" + x.ToString() + ", Y=" + y.ToString() + "}";
     }
 }
index fe45289..1640674 100644 (file)
@@ -56,7 +56,7 @@ namespace System.Drawing
         [Browsable(false)]
         public Point Location
         {
-            get => new Point(X, Y);
+            readonly get => new Point(X, Y);
             set
             {
                 X = value.X;
@@ -70,7 +70,7 @@ namespace System.Drawing
         [Browsable(false)]
         public Size Size
         {
-            get => new Size(Width, Height);
+            readonly get => new Size(Width, Height);
             set
             {
                 Width = value.Width;
@@ -84,7 +84,7 @@ namespace System.Drawing
         /// </summary>
         public int X
         {
-            get => x;
+            readonly get => x;
             set => x = value;
         }
 
@@ -94,7 +94,7 @@ namespace System.Drawing
         /// </summary>
         public int Y
         {
-            get => y;
+            readonly get => y;
             set => y = value;
         }
 
@@ -103,7 +103,7 @@ namespace System.Drawing
         /// </summary>
         public int Width
         {
-            get => width;
+            readonly get => width;
             set => width = value;
         }
 
@@ -112,7 +112,7 @@ namespace System.Drawing
         /// </summary>
         public int Height
         {
-            get => height;
+            readonly get => height;
             set => height = value;
         }
 
@@ -121,43 +121,43 @@ namespace System.Drawing
         /// <see cref='System.Drawing.Rectangle'/> .
         /// </summary>
         [Browsable(false)]
-        public int Left => X;
+        public readonly int Left => X;
 
         /// <summary>
         /// Gets the y-coordinate of the upper-left corner of the rectangular region defined by this
         /// <see cref='System.Drawing.Rectangle'/>.
         /// </summary>
         [Browsable(false)]
-        public int Top => Y;
+        public readonly int Top => Y;
 
         /// <summary>
         /// Gets the x-coordinate of the lower-right corner of the rectangular region defined by this
         /// <see cref='System.Drawing.Rectangle'/>.
         /// </summary>
         [Browsable(false)]
-        public int Right => unchecked(X + Width);
+        public readonly int Right => unchecked(X + Width);
 
         /// <summary>
         /// Gets the y-coordinate of the lower-right corner of the rectangular region defined by this
         /// <see cref='System.Drawing.Rectangle'/>.
         /// </summary>
         [Browsable(false)]
-        public int Bottom => unchecked(Y + Height);
+        public readonly int Bottom => unchecked(Y + Height);
 
         /// <summary>
         /// Tests whether this <see cref='System.Drawing.Rectangle'/> has a <see cref='System.Drawing.Rectangle.Width'/>
         /// or a <see cref='System.Drawing.Rectangle.Height'/> of 0.
         /// </summary>
         [Browsable(false)]
-        public bool IsEmpty => height == 0 && width == 0 && x == 0 && y == 0;
+        public readonly bool IsEmpty => height == 0 && width == 0 && x == 0 && y == 0;
 
         /// <summary>
         /// Tests whether <paramref name="obj"/> is a <see cref='System.Drawing.Rectangle'/> with the same location
         /// and size of this Rectangle.
         /// </summary>
-        public override bool Equals(object? obj) => obj is Rectangle && Equals((Rectangle)obj);
+        public override readonly bool Equals(object? obj) => obj is Rectangle && Equals((Rectangle)obj);
 
-        public bool Equals(Rectangle other) => this == other;
+        public readonly bool Equals(Rectangle other) => this == other;
 
         /// <summary>
         /// Tests whether two <see cref='System.Drawing.Rectangle'/> objects have equal location and size.
@@ -219,19 +219,19 @@ namespace System.Drawing
         /// Determines if the specified point is contained within the rectangular region defined by this
         /// <see cref='System.Drawing.Rectangle'/> .
         /// </summary>
-        public bool Contains(int x, int y) => X <= x && x < X + Width && Y <= y && y < Y + Height;
+        public readonly bool Contains(int x, int y) => X <= x && x < X + Width && Y <= y && y < Y + Height;
 
         /// <summary>
         /// Determines if the specified point is contained within the rectangular region defined by this
         /// <see cref='System.Drawing.Rectangle'/> .
         /// </summary>
-        public bool Contains(Point pt) => Contains(pt.X, pt.Y);
+        public readonly bool Contains(Point pt) => Contains(pt.X, pt.Y);
 
         /// <summary>
         /// Determines if the rectangular region represented by <paramref name="rect"/> is entirely contained within the
         /// rectangular region represented by this <see cref='System.Drawing.Rectangle'/> .
         /// </summary>
-        public bool Contains(Rectangle rect) =>
+        public readonly bool Contains(Rectangle rect) =>
             (X <= rect.X) && (rect.X + rect.Width <= X + Width) &&
             (Y <= rect.Y) && (rect.Y + rect.Height <= Y + Height);
 
@@ -302,7 +302,7 @@ namespace System.Drawing
         /// <summary>
         /// Determines if this rectangle intersects with rect.
         /// </summary>
-        public bool IntersectsWith(Rectangle rect) =>
+        public readonly bool IntersectsWith(Rectangle rect) =>
             (rect.X < X + Width) && (X < rect.X + rect.Width) &&
             (rect.Y < Y + Height) && (Y < rect.Y + rect.Height);
 
@@ -339,7 +339,7 @@ namespace System.Drawing
         /// <summary>
         /// Converts the attributes of this <see cref='System.Drawing.Rectangle'/> to a human readable string.
         /// </summary>
-        public override string ToString() =>
+        public override readonly string ToString() =>
             "{X=" + X.ToString() + ",Y=" + Y.ToString() +
             ",Width=" + Width.ToString() + ",Height=" + Height.ToString() + "}";
     }
index a9d5206..accaa23 100644 (file)
@@ -60,7 +60,7 @@ namespace System.Drawing
         [Browsable(false)]
         public PointF Location
         {
-            get => new PointF(X, Y);
+            readonly get => new PointF(X, Y);
             set
             {
                 X = value.X;
@@ -74,7 +74,7 @@ namespace System.Drawing
         [Browsable(false)]
         public SizeF Size
         {
-            get => new SizeF(Width, Height);
+            readonly get => new SizeF(Width, Height);
             set
             {
                 Width = value.Width;
@@ -88,7 +88,7 @@ namespace System.Drawing
         /// </summary>
         public float X
         {
-            get => x;
+            readonly get => x;
             set => x = value;
         }
 
@@ -98,7 +98,7 @@ namespace System.Drawing
         /// </summary>
         public float Y
         {
-            get => y;
+            readonly get => y;
             set => y = value;
         }
 
@@ -107,7 +107,7 @@ namespace System.Drawing
         /// </summary>
         public float Width
         {
-            get => width;
+            readonly get => width;
             set => width = value;
         }
 
@@ -116,7 +116,7 @@ namespace System.Drawing
         /// </summary>
         public float Height
         {
-            get => height;
+            readonly get => height;
             set => height = value;
         }
 
@@ -125,42 +125,42 @@ namespace System.Drawing
         /// <see cref='System.Drawing.RectangleF'/> .
         /// </summary>
         [Browsable(false)]
-        public float Left => X;
+        public readonly float Left => X;
 
         /// <summary>
         /// Gets the y-coordinate of the upper-left corner of the rectangular region defined by this
         /// <see cref='System.Drawing.RectangleF'/>.
         /// </summary>
         [Browsable(false)]
-        public float Top => Y;
+        public readonly float Top => Y;
 
         /// <summary>
         /// Gets the x-coordinate of the lower-right corner of the rectangular region defined by this
         /// <see cref='System.Drawing.RectangleF'/>.
         /// </summary>
         [Browsable(false)]
-        public float Right => X + Width;
+        public readonly float Right => X + Width;
 
         /// <summary>
         /// Gets the y-coordinate of the lower-right corner of the rectangular region defined by this
         /// <see cref='System.Drawing.RectangleF'/>.
         /// </summary>
         [Browsable(false)]
-        public float Bottom => Y + Height;
+        public readonly float Bottom => Y + Height;
 
         /// <summary>
         /// Tests whether this <see cref='System.Drawing.RectangleF'/> has a <see cref='System.Drawing.RectangleF.Width'/> or a <see cref='System.Drawing.RectangleF.Height'/> of 0.
         /// </summary>
         [Browsable(false)]
-        public bool IsEmpty => (Width <= 0) || (Height <= 0);
+        public readonly bool IsEmpty => (Width <= 0) || (Height <= 0);
 
         /// <summary>
         /// Tests whether <paramref name="obj"/> is a <see cref='System.Drawing.RectangleF'/> with the same location and
         /// size of this <see cref='System.Drawing.RectangleF'/>.
         /// </summary>
-        public override bool Equals(object? obj) => obj is RectangleF && Equals((RectangleF)obj);
+        public override readonly bool Equals(object? obj) => obj is RectangleF && Equals((RectangleF)obj);
 
-        public bool Equals(RectangleF other) => this == other;
+        public readonly bool Equals(RectangleF other) => this == other;
 
         /// <summary>
         /// Tests whether two <see cref='System.Drawing.RectangleF'/> objects have equal location and size.
@@ -177,25 +177,25 @@ namespace System.Drawing
         /// Determines if the specified point is contained within the rectangular region defined by this
         /// <see cref='System.Drawing.Rectangle'/> .
         /// </summary>
-        public bool Contains(float x, float y) => X <= x && x < X + Width && Y <= y && y < Y + Height;
+        public readonly bool Contains(float x, float y) => X <= x && x < X + Width && Y <= y && y < Y + Height;
 
         /// <summary>
         /// Determines if the specified point is contained within the rectangular region defined by this
         /// <see cref='System.Drawing.Rectangle'/> .
         /// </summary>
-        public bool Contains(PointF pt) => Contains(pt.X, pt.Y);
+        public readonly bool Contains(PointF pt) => Contains(pt.X, pt.Y);
 
         /// <summary>
         /// Determines if the rectangular region represented by <paramref name="rect"/> is entirely contained within
         /// the rectangular region represented by this <see cref='System.Drawing.Rectangle'/> .
         /// </summary>
-        public bool Contains(RectangleF rect) =>
+        public readonly bool Contains(RectangleF rect) =>
             (X <= rect.X) && (rect.X + rect.Width <= X + Width) && (Y <= rect.Y) && (rect.Y + rect.Height <= Y + Height);
 
         /// <summary>
         /// Gets the hash code for this <see cref='System.Drawing.RectangleF'/>.
         /// </summary>
-        public override int GetHashCode() => HashCode.Combine(X, Y, Width, Height);
+        public override readonly int GetHashCode() => HashCode.Combine(X, Y, Width, Height);
 
         /// <summary>
         /// Inflates this <see cref='System.Drawing.Rectangle'/> by the specified amount.
@@ -298,7 +298,7 @@ namespace System.Drawing
         /// Converts the <see cref='System.Drawing.RectangleF.Location'/> and <see cref='System.Drawing.RectangleF.Size'/>
         /// of this <see cref='System.Drawing.RectangleF'/> to a human-readable string.
         /// </summary>
-        public override string ToString() =>
+        public override readonly string ToString() =>
             "{X=" + X.ToString() + ",Y=" + Y.ToString() +
             ",Width=" + Width.ToString() + ",Height=" + Height.ToString() + "}";
     }
index 0ad652e..5b7f33b 100644 (file)
@@ -123,14 +123,14 @@ namespace System.Drawing
         /// Tests whether this <see cref='System.Drawing.Size'/> has zero width and height.
         /// </summary>
         [Browsable(false)]
-        public bool IsEmpty => width == 0 && height == 0;
+        public readonly bool IsEmpty => width == 0 && height == 0;
 
         /// <summary>
         /// Represents the horizontal component of this <see cref='System.Drawing.Size'/>.
         /// </summary>
         public int Width
         {
-            get => width;
+            readonly get => width;
             set => width = value;
         }
 
@@ -139,7 +139,7 @@ namespace System.Drawing
         /// </summary>
         public int Height
         {
-            get => height;
+            readonly get => height;
             set => height = value;
         }
 
@@ -176,19 +176,19 @@ namespace System.Drawing
         /// Tests to see whether the specified object is a <see cref='System.Drawing.Size'/>  with the same dimensions
         /// as this <see cref='System.Drawing.Size'/>.
         /// </summary>
-        public override bool Equals(object? obj) => obj is Size && Equals((Size)obj);
+        public override readonly bool Equals(object? obj) => obj is Size && Equals((Size)obj);
 
-        public bool Equals(Size other) => this == other;
+        public readonly bool Equals(Size other) => this == other;
 
         /// <summary>
         /// Returns a hash code.
         /// </summary>
-        public override int GetHashCode() => HashCode.Combine(Width, Height);
+        public override readonly int GetHashCode() => HashCode.Combine(Width, Height);
 
         /// <summary>
         /// Creates a human-readable string that represents this <see cref='System.Drawing.Size'/>.
         /// </summary>
-        public override string ToString() => "{Width=" + width.ToString() + ", Height=" + height.ToString() + "}";
+        public override readonly string ToString() => "{Width=" + width.ToString() + ", Height=" + height.ToString() + "}";
 
         /// <summary>
         /// Multiplies <see cref="Size"/> by an <see cref="int"/> producing <see cref="Size"/>.
index d378b76..37fddfe 100644 (file)
@@ -103,14 +103,14 @@ namespace System.Drawing
         /// Tests whether this <see cref='System.Drawing.SizeF'/> has zero width and height.
         /// </summary>
         [Browsable(false)]
-        public bool IsEmpty => width == 0 && height == 0;
+        public readonly bool IsEmpty => width == 0 && height == 0;
 
         /// <summary>
         /// Represents the horizontal component of this <see cref='System.Drawing.SizeF'/>.
         /// </summary>
         public float Width
         {
-            get => width;
+            readonly get => width;
             set => width = value;
         }
 
@@ -119,7 +119,7 @@ namespace System.Drawing
         /// </summary>
         public float Height
         {
-            get => height;
+            readonly get => height;
             set => height = value;
         }
 
@@ -137,20 +137,20 @@ namespace System.Drawing
         /// Tests to see whether the specified object is a <see cref='System.Drawing.SizeF'/>  with the same dimensions
         /// as this <see cref='System.Drawing.SizeF'/>.
         /// </summary>
-        public override bool Equals(object? obj) => obj is SizeF && Equals((SizeF)obj);
+        public override readonly bool Equals(object? obj) => obj is SizeF && Equals((SizeF)obj);
 
-        public bool Equals(SizeF other) => this == other;
+        public readonly bool Equals(SizeF other) => this == other;
 
-        public override int GetHashCode() => HashCode.Combine(Width, Height);
+        public override readonly int GetHashCode() => HashCode.Combine(Width, Height);
 
-        public PointF ToPointF() => (PointF)this;
+        public readonly PointF ToPointF() => (PointF)this;
 
-        public Size ToSize() => Size.Truncate(this);
+        public readonly Size ToSize() => Size.Truncate(this);
 
         /// <summary>
         /// Creates a human-readable string that represents this <see cref='System.Drawing.SizeF'/>.
         /// </summary>
-        public override string ToString() => "{Width=" + width.ToString() + ", Height=" + height.ToString() + "}";
+        public override readonly string ToString() => "{Width=" + width.ToString() + ", Height=" + height.ToString() + "}";
 
         /// <summary>
         /// Multiplies <see cref="SizeF"/> by a <see cref="float"/> producing <see cref="SizeF"/>.