diff --git a/.editorconfig b/.editorconfig index 238e9887bd..1583d3e469 100644 --- a/.editorconfig +++ b/.editorconfig @@ -144,6 +144,8 @@ dotnet_diagnostic.CS1591.severity = suggestion dotnet_diagnostic.CA1304.severity = warning # CA1802: Use literals where appropriate dotnet_diagnostic.CA1802.severity = warning +# CA1815: Override equals and operator equals on value types +dotnet_diagnostic.CA1815.severity = warning # CA1820: Test for empty strings using string length dotnet_diagnostic.CA1820.severity = warning # CA1821: Remove empty finalizers diff --git a/src/Android/Avalonia.Android/AndroidInputMethod.cs b/src/Android/Avalonia.Android/AndroidInputMethod.cs index 8d56086470..c885a7768c 100644 --- a/src/Android/Avalonia.Android/AndroidInputMethod.cs +++ b/src/Android/Avalonia.Android/AndroidInputMethod.cs @@ -167,7 +167,7 @@ namespace Avalonia.Android } } - public readonly struct ComposingRegion + public readonly record struct ComposingRegion { private readonly int _start = -1; private readonly int _end = -1; diff --git a/src/Avalonia.Base/Animation/Cue.cs b/src/Avalonia.Base/Animation/Cue.cs index 6578148b07..c48f2ab6b0 100644 --- a/src/Avalonia.Base/Animation/Cue.cs +++ b/src/Avalonia.Base/Animation/Cue.cs @@ -8,7 +8,7 @@ namespace Avalonia.Animation /// Determines the time index for a . /// [TypeConverter(typeof(CueTypeConverter))] - public readonly struct Cue : IEquatable, IEquatable + public readonly record struct Cue : IEquatable, IEquatable { /// /// The normalized percent value, ranging from 0.0 to 1.0 @@ -49,15 +49,6 @@ namespace Avalonia.Animation } } - /// - /// Checks for equality between two s. - /// - /// The second cue. - public bool Equals(Cue other) - { - return CueValue == other.CueValue; - } - /// /// Checks for equality between a /// and a value. diff --git a/src/Avalonia.Base/Data/BindingValue.cs b/src/Avalonia.Base/Data/BindingValue.cs index 4e07ebf445..3bc172f596 100644 --- a/src/Avalonia.Base/Data/BindingValue.cs +++ b/src/Avalonia.Base/Data/BindingValue.cs @@ -80,7 +80,7 @@ namespace Avalonia.Data /// - For an unset value, use or simply `default` /// - For other types, call one of the static factory methods /// - public readonly struct BindingValue + public readonly record struct BindingValue { private readonly T _value; diff --git a/src/Avalonia.Base/Input/PointerPoint.cs b/src/Avalonia.Base/Input/PointerPoint.cs index c51f286053..bd36b73b26 100644 --- a/src/Avalonia.Base/Input/PointerPoint.cs +++ b/src/Avalonia.Base/Input/PointerPoint.cs @@ -5,7 +5,7 @@ namespace Avalonia.Input /// /// Provides basic properties for the input pointer associated with a single mouse, pen/stylus, or touch contact. /// - public struct PointerPoint + public record struct PointerPoint { public PointerPoint(IPointer pointer, Point position, PointerPointProperties properties) { @@ -33,7 +33,7 @@ namespace Avalonia.Input /// /// Provides extended properties for a PointerPoint object. /// - public struct PointerPointProperties + public record struct PointerPointProperties { /// /// Gets a value that indicates whether the pointer input was triggered by the primary action mode of an input device. diff --git a/src/Avalonia.Base/Input/Raw/RawPointerEventArgs.cs b/src/Avalonia.Base/Input/Raw/RawPointerEventArgs.cs index b8f6f99ae8..854dd4b83b 100644 --- a/src/Avalonia.Base/Input/Raw/RawPointerEventArgs.cs +++ b/src/Avalonia.Base/Input/Raw/RawPointerEventArgs.cs @@ -130,7 +130,7 @@ namespace Avalonia.Input.Raw internal IInputElement? InputHitTestResult { get; set; } } - public struct RawPointerPoint + public record struct RawPointerPoint { /// /// Pointer position, in client DIPs. diff --git a/src/Avalonia.Base/Input/TextInput/ITextInputMethodClient.cs b/src/Avalonia.Base/Input/TextInput/ITextInputMethodClient.cs index 4a60f8a046..531cf3c704 100644 --- a/src/Avalonia.Base/Input/TextInput/ITextInputMethodClient.cs +++ b/src/Avalonia.Base/Input/TextInput/ITextInputMethodClient.cs @@ -46,7 +46,7 @@ namespace Avalonia.Input.TextInput void SelectInSurroundingText(int start, int end); } - public struct TextInputMethodSurroundingText + public record struct TextInputMethodSurroundingText { public string Text { get; set; } public int CursorOffset { get; set; } diff --git a/src/Avalonia.Base/Logging/ParametrizedLogger.cs b/src/Avalonia.Base/Logging/ParametrizedLogger.cs index 6b7331b504..a82af41a75 100644 --- a/src/Avalonia.Base/Logging/ParametrizedLogger.cs +++ b/src/Avalonia.Base/Logging/ParametrizedLogger.cs @@ -5,7 +5,7 @@ namespace Avalonia.Logging /// /// Logger sink parametrized for given logging level. /// - public readonly struct ParametrizedLogger + public readonly record struct ParametrizedLogger { private readonly ILogSink _sink; private readonly LogEventLevel _level; diff --git a/src/Avalonia.Base/Matrix.cs b/src/Avalonia.Base/Matrix.cs index df6439b1b3..a72710ffd4 100644 --- a/src/Avalonia.Base/Matrix.cs +++ b/src/Avalonia.Base/Matrix.cs @@ -571,7 +571,7 @@ namespace Avalonia return true; } - public struct Decomposed + public record struct Decomposed { public Vector Translate; public Vector Scale; diff --git a/src/Avalonia.Base/Media/BoxShadow.cs b/src/Avalonia.Base/Media/BoxShadow.cs index 2139516be6..fa94dd83eb 100644 --- a/src/Avalonia.Base/Media/BoxShadow.cs +++ b/src/Avalonia.Base/Media/BoxShadow.cs @@ -171,5 +171,11 @@ namespace Avalonia.Media public Rect TransformBounds(in Rect rect) => IsInset ? rect : rect.Translate(new Vector(OffsetX, OffsetY)).Inflate(Spread + Blur); + + public static bool operator ==(BoxShadow left, BoxShadow right) => + left.Equals(right); + + public static bool operator !=(BoxShadow left, BoxShadow right) => + !(left == right); } } diff --git a/src/Avalonia.Base/Media/BoxShadows.cs b/src/Avalonia.Base/Media/BoxShadows.cs index ab2694389f..4265e4efbc 100644 --- a/src/Avalonia.Base/Media/BoxShadows.cs +++ b/src/Avalonia.Base/Media/BoxShadows.cs @@ -62,7 +62,9 @@ namespace Avalonia.Media } [EditorBrowsable(EditorBrowsableState.Never)] +#pragma warning disable CA1815 // Override equals and operator equals on value types public struct BoxShadowsEnumerator +#pragma warning restore CA1815 // Override equals and operator equals on value types { private int _index; private BoxShadows _shadows; @@ -149,5 +151,11 @@ namespace Avalonia.Media return hashCode; } } + + public static bool operator ==(BoxShadows left, BoxShadows right) => + left.Equals(right); + + public static bool operator !=(BoxShadows left, BoxShadows right) => + !(left == right); } } diff --git a/src/Avalonia.Base/Media/DrawingContext.cs b/src/Avalonia.Base/Media/DrawingContext.cs index d0f3b9e21a..eabd7c8274 100644 --- a/src/Avalonia.Base/Media/DrawingContext.cs +++ b/src/Avalonia.Base/Media/DrawingContext.cs @@ -261,7 +261,7 @@ namespace Avalonia.Media DrawRectangle(brush, null, rect, cornerRadius, cornerRadius); } - public readonly struct PushedState : IDisposable + public readonly record struct PushedState : IDisposable { private readonly int _level; private readonly DrawingContext _context; diff --git a/src/Avalonia.Base/Media/FontMetrics.cs b/src/Avalonia.Base/Media/FontMetrics.cs index 1cd01675db..6d952a6b93 100644 --- a/src/Avalonia.Base/Media/FontMetrics.cs +++ b/src/Avalonia.Base/Media/FontMetrics.cs @@ -3,7 +3,7 @@ /// /// The font metrics is holding information about a font's ascent, descent, etc. in design em units. /// - public readonly struct FontMetrics + public readonly record struct FontMetrics { /// /// Gets the font design units per em. diff --git a/src/Avalonia.Base/Media/GlyphMetrics.cs b/src/Avalonia.Base/Media/GlyphMetrics.cs index 2ee1f87d38..e9b5a112ac 100644 --- a/src/Avalonia.Base/Media/GlyphMetrics.cs +++ b/src/Avalonia.Base/Media/GlyphMetrics.cs @@ -1,6 +1,6 @@ namespace Avalonia.Media; -public readonly struct GlyphMetrics +public readonly record struct GlyphMetrics { /// /// Distance from the x-origin to the left extremum of the glyph. diff --git a/src/Avalonia.Base/Media/GlyphRunMetrics.cs b/src/Avalonia.Base/Media/GlyphRunMetrics.cs index 983f029c7a..492b5214cd 100644 --- a/src/Avalonia.Base/Media/GlyphRunMetrics.cs +++ b/src/Avalonia.Base/Media/GlyphRunMetrics.cs @@ -1,6 +1,6 @@ namespace Avalonia.Media { - public readonly struct GlyphRunMetrics + public readonly record struct GlyphRunMetrics { public GlyphRunMetrics(double width, double widthIncludingTrailingWhitespace, double height, int trailingWhitespaceLength, int newLineLength, int firstCluster, int lastCluster) diff --git a/src/Avalonia.Base/Media/TextCollapsingCreateInfo.cs b/src/Avalonia.Base/Media/TextCollapsingCreateInfo.cs index 78f15b724a..40ba613717 100644 --- a/src/Avalonia.Base/Media/TextCollapsingCreateInfo.cs +++ b/src/Avalonia.Base/Media/TextCollapsingCreateInfo.cs @@ -2,7 +2,7 @@ namespace Avalonia.Media { - public readonly struct TextCollapsingCreateInfo + public readonly record struct TextCollapsingCreateInfo { public readonly double Width; public readonly TextRunProperties TextRunProperties; diff --git a/src/Avalonia.Base/Media/TextFormatting/ShapedBuffer.cs b/src/Avalonia.Base/Media/TextFormatting/ShapedBuffer.cs index 644c0ecbe1..902b897240 100644 --- a/src/Avalonia.Base/Media/TextFormatting/ShapedBuffer.cs +++ b/src/Avalonia.Base/Media/TextFormatting/ShapedBuffer.cs @@ -262,7 +262,7 @@ namespace Avalonia.Media.TextFormatting } } - public readonly struct GlyphInfo + public readonly record struct GlyphInfo { public GlyphInfo(ushort glyphIndex, int glyphCluster, double glyphAdvance = 0, Vector glyphOffset = default) { diff --git a/src/Avalonia.Base/Media/TextFormatting/SplitResult.cs b/src/Avalonia.Base/Media/TextFormatting/SplitResult.cs index 03b93cfaf0..53021c4656 100644 --- a/src/Avalonia.Base/Media/TextFormatting/SplitResult.cs +++ b/src/Avalonia.Base/Media/TextFormatting/SplitResult.cs @@ -1,6 +1,8 @@ namespace Avalonia.Media.TextFormatting { +#pragma warning disable CA1815 // Override equals and operator equals on value types public readonly struct SplitResult +#pragma warning restore CA1815 // Override equals and operator equals on value types { public SplitResult(T first, T? second) { diff --git a/src/Avalonia.Base/Media/TextFormatting/TextLineMetrics.cs b/src/Avalonia.Base/Media/TextFormatting/TextLineMetrics.cs index 40a7f6167a..cb21e27696 100644 --- a/src/Avalonia.Base/Media/TextFormatting/TextLineMetrics.cs +++ b/src/Avalonia.Base/Media/TextFormatting/TextLineMetrics.cs @@ -4,7 +4,7 @@ /// Represents a metric for a objects, /// that holds information about ascent, descent, line gap, size and origin of the text line. /// - public readonly struct TextLineMetrics + public readonly record struct TextLineMetrics { public TextLineMetrics(bool hasOverflowed, double height, int newlineLength, double start, double textBaseline, int trailingWhitespaceLength, double width, diff --git a/src/Avalonia.Base/Media/TextFormatting/TextMetrics.cs b/src/Avalonia.Base/Media/TextFormatting/TextMetrics.cs index dc21c9b6f2..c83ae89320 100644 --- a/src/Avalonia.Base/Media/TextFormatting/TextMetrics.cs +++ b/src/Avalonia.Base/Media/TextFormatting/TextMetrics.cs @@ -3,7 +3,7 @@ /// /// A metric that holds information about text specific measurements. /// - public readonly struct TextMetrics + public readonly record struct TextMetrics { public TextMetrics(IGlyphTypeface glyphTypeface, double fontRenderingEmSize) { diff --git a/src/Avalonia.Base/Media/TextFormatting/TextRange.cs b/src/Avalonia.Base/Media/TextFormatting/TextRange.cs index 1177c758f4..e8bab55aff 100644 --- a/src/Avalonia.Base/Media/TextFormatting/TextRange.cs +++ b/src/Avalonia.Base/Media/TextFormatting/TextRange.cs @@ -5,7 +5,7 @@ namespace Avalonia.Media.TextFormatting /// /// References a portion of a text buffer. /// - public readonly struct TextRange + public readonly record struct TextRange { public TextRange(int start, int length) { diff --git a/src/Avalonia.Base/Media/TextFormatting/TextRunBounds.cs b/src/Avalonia.Base/Media/TextFormatting/TextRunBounds.cs index bdc7a1ca89..707c9048dc 100644 --- a/src/Avalonia.Base/Media/TextFormatting/TextRunBounds.cs +++ b/src/Avalonia.Base/Media/TextFormatting/TextRunBounds.cs @@ -3,7 +3,7 @@ /// /// The bounding rectangle of text run /// - public readonly struct TextRunBounds + public readonly record struct TextRunBounds { /// /// Constructing TextRunBounds diff --git a/src/Avalonia.Base/Media/TextFormatting/TextShaperOptions.cs b/src/Avalonia.Base/Media/TextFormatting/TextShaperOptions.cs index 80bbbcdbfe..610fc3dbc9 100644 --- a/src/Avalonia.Base/Media/TextFormatting/TextShaperOptions.cs +++ b/src/Avalonia.Base/Media/TextFormatting/TextShaperOptions.cs @@ -5,7 +5,7 @@ namespace Avalonia.Media.TextFormatting /// /// Options to customize text shaping. /// - public readonly struct TextShaperOptions + public readonly record struct TextShaperOptions { public TextShaperOptions( IGlyphTypeface typeface, diff --git a/src/Avalonia.Base/Media/TextFormatting/Unicode/Codepoint.cs b/src/Avalonia.Base/Media/TextFormatting/Unicode/Codepoint.cs index 9e5186552e..e6408bcfa6 100644 --- a/src/Avalonia.Base/Media/TextFormatting/Unicode/Codepoint.cs +++ b/src/Avalonia.Base/Media/TextFormatting/Unicode/Codepoint.cs @@ -3,7 +3,7 @@ using System.Runtime.CompilerServices; namespace Avalonia.Media.TextFormatting.Unicode { - public readonly struct Codepoint + public readonly record struct Codepoint { private readonly uint _value; diff --git a/src/Avalonia.Base/Media/TextFormatting/Unicode/LineBreak.cs b/src/Avalonia.Base/Media/TextFormatting/Unicode/LineBreak.cs index 59c4df0a2e..0e470341f3 100644 --- a/src/Avalonia.Base/Media/TextFormatting/Unicode/LineBreak.cs +++ b/src/Avalonia.Base/Media/TextFormatting/Unicode/LineBreak.cs @@ -24,7 +24,7 @@ namespace Avalonia.Media.TextFormatting.Unicode /// Information about a potential line break position /// [DebuggerDisplay("{PositionMeasure}/{PositionWrap} @ {Required}")] - public readonly struct LineBreak + public readonly record struct LineBreak { /// /// Constructor diff --git a/src/Avalonia.Base/Media/TextHitTestResult.cs b/src/Avalonia.Base/Media/TextHitTestResult.cs index c8922f06c8..d19adc2807 100644 --- a/src/Avalonia.Base/Media/TextHitTestResult.cs +++ b/src/Avalonia.Base/Media/TextHitTestResult.cs @@ -5,7 +5,7 @@ namespace Avalonia.Media /// /// Holds a hit test result from a . /// - public readonly struct TextHitTestResult + public readonly record struct TextHitTestResult { public TextHitTestResult(CharacterHit characterHit, int textPosition, bool isInside, bool isTrailing) { diff --git a/src/Avalonia.Base/Media/Transformation/TransformOperation.cs b/src/Avalonia.Base/Media/Transformation/TransformOperation.cs index a8c0fe9b12..542d71963d 100644 --- a/src/Avalonia.Base/Media/Transformation/TransformOperation.cs +++ b/src/Avalonia.Base/Media/Transformation/TransformOperation.cs @@ -5,7 +5,7 @@ namespace Avalonia.Media.Transformation /// /// Represents a single primitive transform (like translation, rotation, scale, etc.). /// - public struct TransformOperation + public record struct TransformOperation { public OperationType Type; public Matrix Matrix; @@ -196,7 +196,7 @@ namespace Avalonia.Media.Transformation } [StructLayout(LayoutKind.Explicit)] - public struct DataLayout + public record struct DataLayout { [FieldOffset(0)] public SkewLayout Skew; @@ -206,25 +206,25 @@ namespace Avalonia.Media.Transformation [FieldOffset(0)] public RotateLayout Rotate; - public struct SkewLayout + public record struct SkewLayout { public double X; public double Y; } - public struct ScaleLayout + public record struct ScaleLayout { public double X; public double Y; } - public struct TranslateLayout + public record struct TranslateLayout { public double X; public double Y; } - public struct RotateLayout + public record struct RotateLayout { public double Angle; } diff --git a/src/Avalonia.Base/Media/Transformation/TransformOperations.cs b/src/Avalonia.Base/Media/Transformation/TransformOperations.cs index 334bb93562..46ca41386a 100644 --- a/src/Avalonia.Base/Media/Transformation/TransformOperations.cs +++ b/src/Avalonia.Base/Media/Transformation/TransformOperations.cs @@ -165,7 +165,7 @@ namespace Avalonia.Media.Transformation return Math.Max(from._operations.Count, to._operations.Count); } - public readonly struct Builder + public readonly record struct Builder { private readonly List _operations; diff --git a/src/Avalonia.Base/Media/UnicodeRange.cs b/src/Avalonia.Base/Media/UnicodeRange.cs index 344b85bae9..f87f38b444 100644 --- a/src/Avalonia.Base/Media/UnicodeRange.cs +++ b/src/Avalonia.Base/Media/UnicodeRange.cs @@ -7,7 +7,7 @@ namespace Avalonia.Media /// /// The descripes a set of Unicode characters. /// - public readonly struct UnicodeRange + public readonly record struct UnicodeRange { public readonly static UnicodeRange Default = Parse("0-10FFFD"); @@ -102,7 +102,7 @@ namespace Avalonia.Media } } - public readonly struct UnicodeRangeSegment + public readonly record struct UnicodeRangeSegment { private static Regex s_regex = new Regex(@"^(?:[uU]\+)?(?:([0-9a-fA-F](?:[0-9a-fA-F?]{1,5})?))$"); diff --git a/src/Avalonia.Base/Platform/IRuntimePlatform.cs b/src/Avalonia.Base/Platform/IRuntimePlatform.cs index 3f8983479f..91d2a1e0cf 100644 --- a/src/Avalonia.Base/Platform/IRuntimePlatform.cs +++ b/src/Avalonia.Base/Platform/IRuntimePlatform.cs @@ -21,7 +21,7 @@ namespace Avalonia.Platform } [Unstable] - public struct RuntimePlatformInfo + public record struct RuntimePlatformInfo { public OperatingSystemType OperatingSystem { get; set; } diff --git a/src/Avalonia.Base/Rendering/Composition/Transport/BatchStream.cs b/src/Avalonia.Base/Rendering/Composition/Transport/BatchStream.cs index 8b68900994..a3cad3cebd 100644 --- a/src/Avalonia.Base/Rendering/Composition/Transport/BatchStream.cs +++ b/src/Avalonia.Base/Rendering/Composition/Transport/BatchStream.cs @@ -21,7 +21,7 @@ internal class BatchStreamData public Queue> Structs { get; } = new(); } -public struct BatchStreamSegment +public record struct BatchStreamSegment { public TData Data { get; set; } public int ElementCount { get; set; } diff --git a/src/Avalonia.Base/Styling/SelectorMatch.cs b/src/Avalonia.Base/Styling/SelectorMatch.cs index 26b525347e..2eac04301a 100644 --- a/src/Avalonia.Base/Styling/SelectorMatch.cs +++ b/src/Avalonia.Base/Styling/SelectorMatch.cs @@ -43,7 +43,7 @@ namespace Avalonia.Styling /// A selector match describes whether and how a matches a control, and /// in addition whether the selector can ever match a control of the same type. /// - public readonly struct SelectorMatch + public readonly record struct SelectorMatch { /// /// A selector match with the result of . diff --git a/src/Avalonia.Base/Utilities/SmallDictionary.cs b/src/Avalonia.Base/Utilities/SmallDictionary.cs index 7d6a21c136..8aaf2200df 100644 --- a/src/Avalonia.Base/Utilities/SmallDictionary.cs +++ b/src/Avalonia.Base/Utilities/SmallDictionary.cs @@ -5,7 +5,7 @@ using System.Diagnostics.CodeAnalysis; namespace Avalonia.Utilities; -public struct InlineDictionary : IEnumerable> where TKey : class where TValue : class +public record struct InlineDictionary : IEnumerable> where TKey : class where TValue : class { object? _data; TValue? _value; diff --git a/src/Avalonia.Base/Utilities/StringTokenizer.cs b/src/Avalonia.Base/Utilities/StringTokenizer.cs index 748eb09209..726c9735ef 100644 --- a/src/Avalonia.Base/Utilities/StringTokenizer.cs +++ b/src/Avalonia.Base/Utilities/StringTokenizer.cs @@ -8,7 +8,7 @@ namespace Avalonia.Utilities #if !BUILDTASK public #endif - struct StringTokenizer : IDisposable + record struct StringTokenizer : IDisposable { private const char DefaultSeparatorChar = ','; diff --git a/src/Avalonia.Base/Utilities/SynchronousCompletionAsyncResult.cs b/src/Avalonia.Base/Utilities/SynchronousCompletionAsyncResult.cs index fb8d3ed224..e574462e2c 100644 --- a/src/Avalonia.Base/Utilities/SynchronousCompletionAsyncResult.cs +++ b/src/Avalonia.Base/Utilities/SynchronousCompletionAsyncResult.cs @@ -8,7 +8,7 @@ namespace Avalonia.Utilities /// A task-like operation that is guaranteed to finish continuations synchronously, /// can be used for parametrized one-shot events /// - public struct SynchronousCompletionAsyncResult : INotifyCompletion + public record struct SynchronousCompletionAsyncResult : INotifyCompletion { private readonly SynchronousCompletionAsyncResultSource? _source; private readonly T? _result; diff --git a/src/Avalonia.Base/Utilities/ValueSpan.cs b/src/Avalonia.Base/Utilities/ValueSpan.cs index 7a10d865ef..4c2de2776d 100644 --- a/src/Avalonia.Base/Utilities/ValueSpan.cs +++ b/src/Avalonia.Base/Utilities/ValueSpan.cs @@ -3,7 +3,7 @@ /// /// Pairing of value and positions sharing that value. /// - public readonly struct ValueSpan + public readonly record struct ValueSpan { public ValueSpan(int start, int length, T value) { diff --git a/src/Avalonia.Controls/AcrylicPlatformCompensationLevels.cs b/src/Avalonia.Controls/AcrylicPlatformCompensationLevels.cs index e1f1c4029e..2402de56ee 100644 --- a/src/Avalonia.Controls/AcrylicPlatformCompensationLevels.cs +++ b/src/Avalonia.Controls/AcrylicPlatformCompensationLevels.cs @@ -5,7 +5,7 @@ /// It controls the base opacity level of the 'tracing paper' layer that compensates /// for low blur radius. /// - public struct AcrylicPlatformCompensationLevels + public record struct AcrylicPlatformCompensationLevels { public AcrylicPlatformCompensationLevels(double transparent, double blurred, double acrylic) { diff --git a/src/Avalonia.Controls/Primitives/PopupPositioning/IPopupPositioner.cs b/src/Avalonia.Controls/Primitives/PopupPositioning/IPopupPositioner.cs index 17dfec118f..2e70947457 100644 --- a/src/Avalonia.Controls/Primitives/PopupPositioning/IPopupPositioner.cs +++ b/src/Avalonia.Controls/Primitives/PopupPositioning/IPopupPositioner.cs @@ -64,7 +64,7 @@ namespace Avalonia.Controls.Primitives.PopupPositioning /// surface. /// [Unstable] - public struct PopupPositionerParameters + public record struct PopupPositionerParameters { private PopupGravity _gravity; private PopupAnchor _anchor; diff --git a/src/Avalonia.Controls/Selection/ISelectionModel.cs b/src/Avalonia.Controls/Selection/ISelectionModel.cs index 3f4ae48263..4c2a355bb5 100644 --- a/src/Avalonia.Controls/Selection/ISelectionModel.cs +++ b/src/Avalonia.Controls/Selection/ISelectionModel.cs @@ -39,7 +39,7 @@ namespace Avalonia.Controls.Selection return new BatchUpdateOperation(model); } - public struct BatchUpdateOperation : IDisposable + public record struct BatchUpdateOperation : IDisposable { private readonly ISelectionModel _owner; private bool _isDisposed; diff --git a/src/Avalonia.Controls/Selection/SelectionModel.cs b/src/Avalonia.Controls/Selection/SelectionModel.cs index 154f1868f3..9bbddfcbb2 100644 --- a/src/Avalonia.Controls/Selection/SelectionModel.cs +++ b/src/Avalonia.Controls/Selection/SelectionModel.cs @@ -738,7 +738,7 @@ namespace Avalonia.Controls.Selection } } - public struct BatchUpdateOperation : IDisposable + public record struct BatchUpdateOperation : IDisposable { private readonly SelectionModel _owner; private bool _isDisposed; diff --git a/src/Avalonia.Controls/TextBlock.cs b/src/Avalonia.Controls/TextBlock.cs index 08156ae00f..7a0da1ecc5 100644 --- a/src/Avalonia.Controls/TextBlock.cs +++ b/src/Avalonia.Controls/TextBlock.cs @@ -827,7 +827,7 @@ namespace Avalonia.Controls InvalidateTextLayout(); } - protected readonly struct SimpleTextSource : ITextSource + protected readonly record struct SimpleTextSource : ITextSource { private readonly CharacterBufferRange _text; private readonly TextRunProperties _defaultProperties; diff --git a/src/Avalonia.FreeDesktop/IX11InputMethod.cs b/src/Avalonia.FreeDesktop/IX11InputMethod.cs index 5d91118978..9fa9c1809e 100644 --- a/src/Avalonia.FreeDesktop/IX11InputMethod.cs +++ b/src/Avalonia.FreeDesktop/IX11InputMethod.cs @@ -11,7 +11,9 @@ namespace Avalonia.FreeDesktop (ITextInputMethodImpl method, IX11InputMethodControl control) CreateClient(IntPtr xid); } +#pragma warning disable CA1815 // Override equals and operator equals on value types public struct X11InputMethodForwardedKey +#pragma warning restore CA1815 // Override equals and operator equals on value types { public int KeyVal { get; set; } public KeyModifiers Modifiers { get; set; } diff --git a/src/Avalonia.OpenGL/GlVersion.cs b/src/Avalonia.OpenGL/GlVersion.cs index 042ff4c2f0..16ed18e45a 100644 --- a/src/Avalonia.OpenGL/GlVersion.cs +++ b/src/Avalonia.OpenGL/GlVersion.cs @@ -6,7 +6,7 @@ namespace Avalonia.OpenGL OpenGLES } - public struct GlVersion + public record struct GlVersion { public GlProfileType Type { get; } public int Major { get; } diff --git a/src/Avalonia.X11/X11Structs.cs b/src/Avalonia.X11/X11Structs.cs index 7e46606c36..26515762b4 100644 --- a/src/Avalonia.X11/X11Structs.cs +++ b/src/Avalonia.X11/X11Structs.cs @@ -1768,7 +1768,9 @@ namespace Avalonia.X11 { } [StructLayout(LayoutKind.Sequential)] +#pragma warning disable CA1815 // Override equals and operator equals on value types public unsafe struct XImage +#pragma warning restore CA1815 // Override equals and operator equals on value types { public int width, height; /* size of image */ public int xoffset; /* number of pixels offset in X direction */ @@ -1799,7 +1801,7 @@ namespace Avalonia.X11 { internal IntPtr green_mask; internal IntPtr blue_mask; internal int colormap_size; - internal int bits_per_rgb; + internal int bits_per_rgb; } internal enum XIMFeedback diff --git a/src/Windows/Avalonia.Direct2D1/OptionalDispose.cs b/src/Windows/Avalonia.Direct2D1/OptionalDispose.cs index e302e71102..1cdf7661df 100644 --- a/src/Windows/Avalonia.Direct2D1/OptionalDispose.cs +++ b/src/Windows/Avalonia.Direct2D1/OptionalDispose.cs @@ -2,7 +2,7 @@ namespace Avalonia.Direct2D1 { - public readonly struct OptionalDispose : IDisposable where T : IDisposable + public readonly record struct OptionalDispose : IDisposable where T : IDisposable { private readonly bool _dispose; diff --git a/src/Windows/Avalonia.Win32/WinRT/WinRTColor.cs b/src/Windows/Avalonia.Win32/WinRT/WinRTColor.cs index 786d698daa..35f0737d5f 100644 --- a/src/Windows/Avalonia.Win32/WinRT/WinRTColor.cs +++ b/src/Windows/Avalonia.Win32/WinRT/WinRTColor.cs @@ -3,7 +3,7 @@ namespace Avalonia.Win32.WinRT { [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct WinRTColor + public record struct WinRTColor { public byte A; public byte R;