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
parent
commit
33a1e8b8cf
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .travis.yml
  2. 1
      build/SharedVersion.props
  3. 2
      src/Avalonia.Visuals/Matrix.cs
  4. 2
      src/Avalonia.Visuals/Media/Color.cs
  5. 4
      src/Avalonia.Visuals/Media/DrawingContext.cs
  6. 2
      src/Avalonia.Visuals/Media/Immutable/ImmutableSolidColorBrush.cs
  7. 2
      src/Avalonia.Visuals/Point.cs
  8. 2
      src/Avalonia.Visuals/Rect.cs
  9. 4
      src/Avalonia.Visuals/RelativePoint.cs
  10. 2
      src/Avalonia.Visuals/RelativeRect.cs
  11. 2
      src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs
  12. 2
      src/Avalonia.Visuals/Size.cs
  13. 2
      src/Avalonia.Visuals/Thickness.cs
  14. 2
      src/Avalonia.Visuals/Vector.cs
  15. 2
      src/Avalonia.Visuals/VisualTree/TransformedBounds.cs
  16. 2
      src/Shared/RenderHelpers/ArcToHelper.cs
  17. 2
      src/Windows/Avalonia.Direct2D1/OptionalDispose.cs

2
.travis.yml

@ -9,7 +9,7 @@ env:
- DOTNET_CLI_TELEMETRY_OPTOUT=1 - DOTNET_CLI_TELEMETRY_OPTOUT=1
mono: mono:
- 5.2.0 - 5.2.0
dotnet: 2.0.0 dotnet: 2.1.200
script: script:
- ./build.sh --target "Travis" --platform "NetCoreOnly" --configuration "Release" - ./build.sh --target "Travis" --platform "NetCoreOnly" --configuration "Release"
notifications: notifications:

1
build/SharedVersion.props

@ -9,5 +9,6 @@
<RepositoryUrl>https://github.com/AvaloniaUI/Avalonia/</RepositoryUrl> <RepositoryUrl>https://github.com/AvaloniaUI/Avalonia/</RepositoryUrl>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
<LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

2
src/Avalonia.Visuals/Matrix.cs

@ -11,7 +11,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// A 2x3 matrix. /// A 2x3 matrix.
/// </summary> /// </summary>
public struct Matrix public readonly struct Matrix
{ {
private readonly double _m11; private readonly double _m11;
private readonly double _m12; private readonly double _m12;

2
src/Avalonia.Visuals/Media/Color.cs

@ -11,7 +11,7 @@ namespace Avalonia.Media
/// <summary> /// <summary>
/// An ARGB color. /// An ARGB color.
/// </summary> /// </summary>
public struct Color public readonly struct Color
{ {
/// <summary> /// <summary>
/// Gets or sets the Alpha component of the color. /// Gets or sets the Alpha component of the color.

4
src/Avalonia.Visuals/Media/DrawingContext.cs

@ -19,7 +19,7 @@ namespace Avalonia.Media
? new Stack<TransformContainer>() ? new Stack<TransformContainer>()
: TransformStackPool.Pop(); : TransformStackPool.Pop();
struct TransformContainer readonly struct TransformContainer
{ {
public readonly Matrix LocalTransform; public readonly Matrix LocalTransform;
public readonly Matrix ContainerTransform; 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 int _level;
private readonly DrawingContext _context; private readonly DrawingContext _context;

2
src/Avalonia.Visuals/Media/Immutable/ImmutableSolidColorBrush.cs

@ -6,7 +6,7 @@ namespace Avalonia.Media.Immutable
/// <summary> /// <summary>
/// Fills an area with a solid color. /// Fills an area with a solid color.
/// </summary> /// </summary>
public struct ImmutableSolidColorBrush : ISolidColorBrush public readonly struct ImmutableSolidColorBrush : ISolidColorBrush
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ImmutableSolidColorBrush"/> class. /// Initializes a new instance of the <see cref="ImmutableSolidColorBrush"/> class.

2
src/Avalonia.Visuals/Point.cs

@ -11,7 +11,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Defines a point. /// Defines a point.
/// </summary> /// </summary>
public struct Point public readonly struct Point
{ {
/// <summary> /// <summary>
/// The X position. /// The X position.

2
src/Avalonia.Visuals/Rect.cs

@ -11,7 +11,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Defines a rectangle. /// Defines a rectangle.
/// </summary> /// </summary>
public struct Rect public readonly struct Rect
{ {
/// <summary> /// <summary>
/// An empty rectangle. /// An empty rectangle.

4
src/Avalonia.Visuals/RelativePoint.cs

@ -28,7 +28,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Defines a point that may be defined relative to a containing element. /// Defines a point that may be defined relative to a containing element.
/// </summary> /// </summary>
public struct RelativePoint : IEquatable<RelativePoint> public readonly struct RelativePoint : IEquatable<RelativePoint>
{ {
/// <summary> /// <summary>
/// A point at the top left of the containing element. /// A point at the top left of the containing element.
@ -45,7 +45,7 @@ namespace Avalonia
/// </summary> /// </summary>
public static readonly RelativePoint BottomRight = new RelativePoint(1, 1, RelativeUnit.Relative); public static readonly RelativePoint BottomRight = new RelativePoint(1, 1, RelativeUnit.Relative);
private Point _point; private readonly Point _point;
private readonly RelativeUnit _unit; private readonly RelativeUnit _unit;

2
src/Avalonia.Visuals/RelativeRect.cs

@ -11,7 +11,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Defines a rectangle that may be defined relative to a containing element. /// Defines a rectangle that may be defined relative to a containing element.
/// </summary> /// </summary>
public struct RelativeRect : IEquatable<RelativeRect> public readonly struct RelativeRect : IEquatable<RelativeRect>
{ {
private static readonly char[] PercentChar = { '%' }; private static readonly char[] PercentChar = { '%' };

2
src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs

@ -320,7 +320,7 @@ namespace Avalonia.Rendering.SceneGraph
} }
} }
public struct UpdateState : IDisposable public readonly struct UpdateState : IDisposable
{ {
public UpdateState( public UpdateState(
DeferredDrawingContextImpl owner, DeferredDrawingContextImpl owner,

2
src/Avalonia.Visuals/Size.cs

@ -11,7 +11,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Defines a size. /// Defines a size.
/// </summary> /// </summary>
public struct Size public readonly struct Size
{ {
/// <summary> /// <summary>
/// A size representing infinity. /// A size representing infinity.

2
src/Avalonia.Visuals/Thickness.cs

@ -11,7 +11,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Describes the thickness of a frame around a rectangle. /// Describes the thickness of a frame around a rectangle.
/// </summary> /// </summary>
public struct Thickness public readonly struct Thickness
{ {
/// <summary> /// <summary>
/// The thickness on the left. /// The thickness on the left.

2
src/Avalonia.Visuals/Vector.cs

@ -10,7 +10,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Defines a vector. /// Defines a vector.
/// </summary> /// </summary>
public struct Vector public readonly struct Vector
{ {
/// <summary> /// <summary>
/// The X vector. /// The X vector.

2
src/Avalonia.Visuals/VisualTree/TransformedBounds.cs

@ -8,7 +8,7 @@ namespace Avalonia.VisualTree
/// <summary> /// <summary>
/// Holds information about the bounds of a control, together with a transform and a clip. /// Holds information about the bounds of a control, together with a transform and a clip.
/// </summary> /// </summary>
public struct TransformedBounds public readonly struct TransformedBounds
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TransformedBounds"/> struct. /// Initializes a new instance of the <see cref="TransformedBounds"/> struct.

2
src/Shared/RenderHelpers/ArcToHelper.cs

@ -982,7 +982,7 @@ namespace Avalonia.RenderHelpers
/// At some point I did not trust the WPF Matrix struct, and wrote my own simple one -_- /// 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 /// This is supposed to be replaced with proper WPF Matrices everywhere
/// </summary> /// </summary>
private struct SimpleMatrix private readonly struct SimpleMatrix
{ {
private readonly double _a, _b, _c, _d; private readonly double _a, _b, _c, _d;

2
src/Windows/Avalonia.Direct2D1/OptionalDispose.cs

@ -2,7 +2,7 @@
namespace Avalonia.Direct2D1 namespace Avalonia.Direct2D1
{ {
public struct OptionalDispose<T> : IDisposable where T : IDisposable public readonly struct OptionalDispose<T> : IDisposable where T : IDisposable
{ {
private readonly bool _dispose; private readonly bool _dispose;

Loading…
Cancel
Save