• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dapplo / Dapplo.Windows / 22078775535

16 Feb 2026 10:03PM UTC coverage: 34.168% (-1.5%) from 35.711%
22078775535

push

github

Lakritzator
Fixed test-case (I modified the code via another solution, didn't see the test)

581 of 1830 branches covered (31.75%)

Branch coverage included in aggregate %.

1616 of 4600 relevant lines covered (35.13%)

23.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.39
/src/Dapplo.Windows.Common/Structs/NativePoint.cs
1
// Copyright (c) Dapplo and contributors. All rights reserved.
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3

4
using System;
5
using System.ComponentModel;
6
using System.Diagnostics.CodeAnalysis;
7
using System.Diagnostics.Contracts;
8
using System.Runtime.InteropServices;
9
#if !NETSTANDARD2_0
10
using System.Windows;
11
#endif
12
using Dapplo.Windows.Common.TypeConverters;
13

14
namespace Dapplo.Windows.Common.Structs;
15

16
/// <summary>
17
///     NativePoint represents the native POINT structure for calling native methods.
18
///     It has conversions from and to System.Drawing.Point or System.Windows.Point
19
/// </summary>
20
[StructLayout(LayoutKind.Sequential)]
21
[Serializable]
22
[TypeConverter(typeof(NativePointTypeConverter))]
23
[SuppressMessage("ReSharper", "ConvertToAutoPropertyWithPrivateSetter")]
24
public readonly struct NativePoint : IEquatable<NativePoint>
25
{
26
    private readonly int _x;
27
    private readonly int _y;
28

29
    /// <summary>
30
    ///     The X coordinate
31
    /// </summary>
32
    public int X => _x;
87✔
33

34
    /// <summary>
35
    ///     The Y coordinate
36
    /// </summary>
37
    public int Y => _y;
87✔
38

39
    /// <summary>
40
    ///     Constructor with x and y coordinates
41
    /// </summary>
42
    /// <param name="x">int</param>
43
    /// <param name="y">int</param>
44
    public NativePoint(int x, int y)
45
    {
46
        _x = x;
105✔
47
        _y = y;
105✔
48
    }
105✔
49

50
#if !NETSTANDARD2_0
51
    /// <summary>
52
    ///     Implicit cast from NativePoint to Point
53
    /// </summary>
54
    /// <param name="point">NativePoint</param>
55
    public static implicit operator Point(NativePoint point)
56
    {
57
        return new Point(point.X, point.Y);
2✔
58
    }
59
#endif
60

61
    /// <summary>
62
    ///     Implicit cast from NativePoint to System.Drawing.Point
63
    /// </summary>
64
    /// <param name="point">NativePoint</param>
65
    public static implicit operator System.Drawing.Point(NativePoint point)
66
    {
67
        return new System.Drawing.Point(point.X, point.Y);
×
68
    }
69

70
    /// <summary>
71
    ///     Implicit cast from System.Drawing.Point to NativePoint
72
    /// </summary>
73
    /// <param name="point">System.Drawing.Point</param>
74
    public static implicit operator NativePoint(System.Drawing.Point point)
75
    {
76
        return new NativePoint(point.X, point.Y);
1✔
77
    }
78

79
    /// <summary>
80
    ///     Implicit cast from System.Drawing.PointF to NativePoint
81
    /// </summary>
82
    /// <param name="point">System.Drawing.PointF</param>
83
    public static implicit operator NativePoint(System.Drawing.PointF point)
84
    {
85
        return new NativePoint((int) point.X, (int) point.Y);
×
86
    }
87

88
    /// <summary>
89
    /// Implicit cast from NativePointFloat to NativePoint
90
    /// </summary>
91
    /// <param name="nativePointFloat">NativePointFloat</param>
92
    public static implicit operator NativePoint(NativePointFloat nativePointFloat)
93
    {
94
        return new NativePoint((int)nativePointFloat.X, (int)nativePointFloat.Y);
2✔
95
    }
96

97
    /// <summary>
98
    /// Equal
99
    /// </summary>
100
    /// <param name="point1">NativePoint</param>
101
    /// <param name="point2">NativePoint</param>
102
    /// <returns>rue if equal</returns>
103
    public static bool operator ==(NativePoint point1, NativePoint point2)
104
    {
105
        return point1.Equals(point2);
×
106
    }
107

108
    /// <summary>
109
    /// Not equal
110
    /// </summary>
111
    /// <param name="point1">NativePoint</param>
112
    /// <param name="point2">NativePoint</param>
113
    /// <returns>false if the values are equal</returns>
114
    public static bool operator !=(NativePoint point1, NativePoint point2)
115
    {
116
        return !point1.Equals(point2);
×
117
    }
118

119
    /// <inheritdoc />
120
    [Pure]
121
    public override int GetHashCode()
122
    {
123
        unchecked
124
        {
125
            return (_x * 397) ^ _y;
×
126
        }
127
    }
128

129
    /// <inheritdoc />
130
    [Pure]
131
    public override string ToString() => $"{{X: {_x}; >: {_y};}}";
×
132

133
    /// <inheritdoc />
134
    [Pure]
135
    public override bool Equals(object obj) =>
136
        obj switch
2!
137
        {
2✔
138
            NativePoint point => Equals(point),
2✔
139
            System.Drawing.Point drawingPoint => Equals(drawingPoint),
×
140
            _ => false
×
141
        };
2✔
142

143
    /// <inheritdoc />
144
    [Pure]
145
    public bool Equals(NativePoint other) => _x == other._x && _y == other._y;
10!
146

147
    /// <summary>
148
    /// Decontructor for tuples
149
    /// </summary>
150
    /// <param name="x">int</param>
151
    /// <param name="y">int</param>
152
    public void Deconstruct(out int x, out int y)
153
    {
154
        x = X;
×
155
        y = Y;
×
156
    }
×
157

158
    /// <summary>
159
    ///     Empty NativePoint
160
    /// </summary>
161
    public static NativePoint Empty { get; } = new NativePoint();
×
162
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc