Browse Source
Merge pull request #1308 from AvaloniaUI/readonly-struct
Use readonly structs where possible.
pull/1542/merge
Jeremy Koritzinsky
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with
19 additions and
18 deletions
-
.travis.yml
-
build/SharedVersion.props
-
src/Avalonia.Visuals/Matrix.cs
-
src/Avalonia.Visuals/Media/Color.cs
-
src/Avalonia.Visuals/Media/DrawingContext.cs
-
src/Avalonia.Visuals/Media/Immutable/ImmutableSolidColorBrush.cs
-
src/Avalonia.Visuals/Point.cs
-
src/Avalonia.Visuals/Rect.cs
-
src/Avalonia.Visuals/RelativePoint.cs
-
src/Avalonia.Visuals/RelativeRect.cs
-
src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs
-
src/Avalonia.Visuals/Size.cs
-
src/Avalonia.Visuals/Thickness.cs
-
src/Avalonia.Visuals/Vector.cs
-
src/Avalonia.Visuals/VisualTree/TransformedBounds.cs
-
src/Shared/RenderHelpers/ArcToHelper.cs
-
src/Windows/Avalonia.Direct2D1/OptionalDispose.cs
|
|
|
@ -9,7 +9,7 @@ env: |
|
|
|
- DOTNET_CLI_TELEMETRY_OPTOUT=1 |
|
|
|
mono: |
|
|
|
- 5.2.0 |
|
|
|
dotnet: 2.0.0 |
|
|
|
dotnet: 2.1.200 |
|
|
|
script: |
|
|
|
- ./build.sh --target "Travis" --platform "NetCoreOnly" --configuration "Release" |
|
|
|
notifications: |
|
|
|
|
|
|
|
@ -9,5 +9,6 @@ |
|
|
|
<RepositoryUrl>https://github.com/AvaloniaUI/Avalonia/</RepositoryUrl> |
|
|
|
<GenerateDocumentationFile>true</GenerateDocumentationFile> |
|
|
|
<NoWarn>CS1591</NoWarn> |
|
|
|
<LangVersion>latest</LangVersion> |
|
|
|
</PropertyGroup> |
|
|
|
</Project> |
|
|
|
@ -11,7 +11,7 @@ namespace Avalonia |
|
|
|
/// <summary>
|
|
|
|
/// A 2x3 matrix.
|
|
|
|
/// </summary>
|
|
|
|
public struct Matrix |
|
|
|
public readonly struct Matrix |
|
|
|
{ |
|
|
|
private readonly double _m11; |
|
|
|
private readonly double _m12; |
|
|
|
|
|
|
|
@ -11,7 +11,7 @@ namespace Avalonia.Media |
|
|
|
/// <summary>
|
|
|
|
/// An ARGB color.
|
|
|
|
/// </summary>
|
|
|
|
public struct Color |
|
|
|
public readonly struct Color |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the Alpha component of the color.
|
|
|
|
|
|
|
|
@ -19,7 +19,7 @@ namespace Avalonia.Media |
|
|
|
? new Stack<TransformContainer>() |
|
|
|
: TransformStackPool.Pop(); |
|
|
|
|
|
|
|
struct TransformContainer |
|
|
|
readonly struct TransformContainer |
|
|
|
{ |
|
|
|
public readonly Matrix LocalTransform; |
|
|
|
public readonly Matrix ContainerTransform; |
|
|
|
@ -147,7 +147,7 @@ namespace Avalonia.Media |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public struct PushedState : IDisposable |
|
|
|
public readonly struct PushedState : IDisposable |
|
|
|
{ |
|
|
|
private readonly int _level; |
|
|
|
private readonly DrawingContext _context; |
|
|
|
|
|
|
|
@ -6,7 +6,7 @@ namespace Avalonia.Media.Immutable |
|
|
|
/// <summary>
|
|
|
|
/// Fills an area with a solid color.
|
|
|
|
/// </summary>
|
|
|
|
public struct ImmutableSolidColorBrush : ISolidColorBrush |
|
|
|
public readonly struct ImmutableSolidColorBrush : ISolidColorBrush |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="ImmutableSolidColorBrush"/> class.
|
|
|
|
|
|
|
|
@ -11,7 +11,7 @@ namespace Avalonia |
|
|
|
/// <summary>
|
|
|
|
/// Defines a point.
|
|
|
|
/// </summary>
|
|
|
|
public struct Point |
|
|
|
public readonly struct Point |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// The X position.
|
|
|
|
|
|
|
|
@ -11,7 +11,7 @@ namespace Avalonia |
|
|
|
/// <summary>
|
|
|
|
/// Defines a rectangle.
|
|
|
|
/// </summary>
|
|
|
|
public struct Rect |
|
|
|
public readonly struct Rect |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// An empty rectangle.
|
|
|
|
|
|
|
|
@ -28,7 +28,7 @@ namespace Avalonia |
|
|
|
/// <summary>
|
|
|
|
/// Defines a point that may be defined relative to a containing element.
|
|
|
|
/// </summary>
|
|
|
|
public struct RelativePoint : IEquatable<RelativePoint> |
|
|
|
public readonly struct RelativePoint : IEquatable<RelativePoint> |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// A point at the top left of the containing element.
|
|
|
|
@ -45,7 +45,7 @@ namespace Avalonia |
|
|
|
/// </summary>
|
|
|
|
public static readonly RelativePoint BottomRight = new RelativePoint(1, 1, RelativeUnit.Relative); |
|
|
|
|
|
|
|
private Point _point; |
|
|
|
private readonly Point _point; |
|
|
|
|
|
|
|
private readonly RelativeUnit _unit; |
|
|
|
|
|
|
|
|
|
|
|
@ -11,7 +11,7 @@ namespace Avalonia |
|
|
|
/// <summary>
|
|
|
|
/// Defines a rectangle that may be defined relative to a containing element.
|
|
|
|
/// </summary>
|
|
|
|
public struct RelativeRect : IEquatable<RelativeRect> |
|
|
|
public readonly struct RelativeRect : IEquatable<RelativeRect> |
|
|
|
{ |
|
|
|
private static readonly char[] PercentChar = { '%' }; |
|
|
|
|
|
|
|
|
|
|
|
@ -320,7 +320,7 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public struct UpdateState : IDisposable |
|
|
|
public readonly struct UpdateState : IDisposable |
|
|
|
{ |
|
|
|
public UpdateState( |
|
|
|
DeferredDrawingContextImpl owner, |
|
|
|
|
|
|
|
@ -11,7 +11,7 @@ namespace Avalonia |
|
|
|
/// <summary>
|
|
|
|
/// Defines a size.
|
|
|
|
/// </summary>
|
|
|
|
public struct Size |
|
|
|
public readonly struct Size |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// A size representing infinity.
|
|
|
|
|
|
|
|
@ -11,7 +11,7 @@ namespace Avalonia |
|
|
|
/// <summary>
|
|
|
|
/// Describes the thickness of a frame around a rectangle.
|
|
|
|
/// </summary>
|
|
|
|
public struct Thickness |
|
|
|
public readonly struct Thickness |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// The thickness on the left.
|
|
|
|
|
|
|
|
@ -10,7 +10,7 @@ namespace Avalonia |
|
|
|
/// <summary>
|
|
|
|
/// Defines a vector.
|
|
|
|
/// </summary>
|
|
|
|
public struct Vector |
|
|
|
public readonly struct Vector |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// The X vector.
|
|
|
|
|
|
|
|
@ -8,7 +8,7 @@ namespace Avalonia.VisualTree |
|
|
|
/// <summary>
|
|
|
|
/// Holds information about the bounds of a control, together with a transform and a clip.
|
|
|
|
/// </summary>
|
|
|
|
public struct TransformedBounds |
|
|
|
public readonly struct TransformedBounds |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="TransformedBounds"/> struct.
|
|
|
|
|
|
|
|
@ -982,7 +982,7 @@ namespace Avalonia.RenderHelpers |
|
|
|
/// At some point I did not trust the WPF Matrix struct, and wrote my own simple one -_-
|
|
|
|
/// This is supposed to be replaced with proper WPF Matrices everywhere
|
|
|
|
/// </summary>
|
|
|
|
private struct SimpleMatrix |
|
|
|
private readonly struct SimpleMatrix |
|
|
|
{ |
|
|
|
private readonly double _a, _b, _c, _d; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
namespace Avalonia.Direct2D1 |
|
|
|
{ |
|
|
|
public struct OptionalDispose<T> : IDisposable where T : IDisposable |
|
|
|
public readonly struct OptionalDispose<T> : IDisposable where T : IDisposable |
|
|
|
{ |
|
|
|
private readonly bool _dispose; |
|
|
|
|
|
|
|
|