From fdc873e1d1268e091f32d6f19a4ae73d9f9b589f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 6 Feb 2020 23:10:28 +0100 Subject: [PATCH] Add readonly modifiers to APIs in Rectangle --- src/ImageSharp/Primitives/Rectangle.cs | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ImageSharp/Primitives/Rectangle.cs b/src/ImageSharp/Primitives/Rectangle.cs index 95b01fd9d6..5b2e9411cc 100644 --- a/src/ImageSharp/Primitives/Rectangle.cs +++ b/src/ImageSharp/Primitives/Rectangle.cs @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp public Point Location { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => new Point(this.X, this.Y); + readonly get => new Point(this.X, this.Y); [MethodImpl(MethodImplOptions.AggressiveInlining)] set @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp public Size Size { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => new Size(this.Width, this.Height); + readonly get => new Size(this.Width, this.Height); [MethodImpl(MethodImplOptions.AggressiveInlining)] set @@ -112,17 +112,17 @@ namespace SixLabors.ImageSharp /// Gets a value indicating whether this is empty. /// [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEmpty => this.Equals(Empty); + public readonly bool IsEmpty => this.Equals(Empty); /// /// Gets the y-coordinate of the top edge of this . /// - public int Top => this.Y; + public readonly int Top => this.Y; /// /// Gets the x-coordinate of the right edge of this . /// - public int Right + public readonly int Right { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => unchecked(this.X + this.Width); @@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp /// /// Gets the y-coordinate of the bottom edge of this . /// - public int Bottom + public readonly int Bottom { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => unchecked(this.Y + this.Height); @@ -140,7 +140,7 @@ namespace SixLabors.ImageSharp /// /// Gets the x-coordinate of the left edge of this . /// - public int Left => this.X; + public readonly int Left => this.X; /// /// Creates a with the coordinates of the specified . @@ -327,7 +327,7 @@ namespace SixLabors.ImageSharp /// The out value for Y. /// The out value for the width. /// The out value for the height. - public void Deconstruct(out int x, out int y, out int width, out int height) + public readonly void Deconstruct(out int x, out int y, out int width, out int height) { x = this.X; y = this.Y; @@ -383,7 +383,7 @@ namespace SixLabors.ImageSharp /// The y-coordinate of the given point. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Contains(int x, int y) => this.X <= x && x < this.Right && this.Y <= y && y < this.Bottom; + public readonly bool Contains(int x, int y) => this.X <= x && x < this.Right && this.Y <= y && y < this.Bottom; /// /// Determines if the specified point is contained within the rectangular region defined by this . @@ -391,7 +391,7 @@ namespace SixLabors.ImageSharp /// The point. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Contains(Point point) => this.Contains(point.X, point.Y); + public readonly bool Contains(Point point) => this.Contains(point.X, point.Y); /// /// Determines if the rectangular region represented by is entirely contained @@ -400,7 +400,7 @@ namespace SixLabors.ImageSharp /// The rectangle. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Contains(Rectangle rectangle) => + public readonly bool Contains(Rectangle rectangle) => (this.X <= rectangle.X) && (rectangle.Right <= this.Right) && (this.Y <= rectangle.Y) && (rectangle.Bottom <= this.Bottom); @@ -411,7 +411,7 @@ namespace SixLabors.ImageSharp /// The other Rectange. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool IntersectsWith(Rectangle rectangle) => + public readonly bool IntersectsWith(Rectangle rectangle) => (rectangle.X < this.Right) && (this.X < rectangle.Right) && (rectangle.Y < this.Bottom) && (this.Y < rectangle.Bottom); @@ -438,13 +438,13 @@ namespace SixLabors.ImageSharp } /// - public override int GetHashCode() + public override readonly int GetHashCode() { return HashCode.Combine(this.X, this.Y, this.Width, this.Height); } /// - public override string ToString() + public override readonly string ToString() { return $"Rectangle [ X={this.X}, Y={this.Y}, Width={this.Width}, Height={this.Height} ]"; } @@ -454,10 +454,10 @@ namespace SixLabors.ImageSharp /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(Rectangle other) => + public readonly bool Equals(Rectangle other) => this.X.Equals(other.X) && this.Y.Equals(other.Y) && this.Width.Equals(other.Width) && this.Height.Equals(other.Height); } -} \ No newline at end of file +}