Skip to content

Commit 9aa76de

Browse files
committed
Fix Obsolete warnings.
1 parent 9497be8 commit 9aa76de

22 files changed

Lines changed: 312 additions & 72 deletions

sources/Maths/Maths/Box2D.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public Box2D<T> GetScaled(Vector2D<T> scale, Vector2D<T> anchor)
151151
public Box2D<T> GetScaled<TScale>(Vector2D<TScale> scale, Vector2D<T> anchor)
152152
where TScale : INumber<TScale>
153153
{
154-
return this.As<TScale>().GetScaled(scale, anchor.As<TScale>()).As<T>();
154+
return this.AsTruncating<TScale>().GetScaled(scale, anchor.AsTruncating<TScale>()).AsTruncating<T>();
155155
}
156156

157157
/// <summary>
@@ -210,10 +210,44 @@ public override int GetHashCode()
210210
/// </summary>
211211
/// <typeparam name="TOther">The type to cast to</typeparam>
212212
/// <returns>The casted box</returns>
213+
[Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)]
213214
public Box2D<TOther> As<TOther>()
214215
where TOther : INumber<TOther>
215216
{
216217
return new(Min.As<TOther>(), Max.As<TOther>());
217218
}
219+
220+
/// <summary>
221+
/// Returns this box casted to <typeparamref name="TOther"></typeparamref>
222+
/// </summary>
223+
/// <typeparam name="TOther">The type to cast to</typeparam>
224+
/// <returns>The casted box</returns>
225+
public Box2D<TOther> AsChecked<TOther>()
226+
where TOther : INumber<TOther>
227+
{
228+
return new(Min.AsChecked<TOther>(), Max.AsChecked<TOther>());
229+
}
230+
231+
/// <summary>
232+
/// Returns this box casted to <typeparamref name="TOther"></typeparamref>
233+
/// </summary>
234+
/// <typeparam name="TOther">The type to cast to</typeparam>
235+
/// <returns>The casted box</returns>
236+
public Box2D<TOther> AsSaturating<TOther>()
237+
where TOther : INumber<TOther>
238+
{
239+
return new(Min.AsSaturating<TOther>(), Max.AsSaturating<TOther>());
240+
}
241+
242+
/// <summary>
243+
/// Returns this box casted to <typeparamref name="TOther"></typeparamref>
244+
/// </summary>
245+
/// <typeparam name="TOther">The type to cast to</typeparam>
246+
/// <returns>The casted box</returns>
247+
public Box2D<TOther> AsTruncating<TOther>()
248+
where TOther : INumber<TOther>
249+
{
250+
return new(Min.AsTruncating<TOther>(), Max.AsTruncating<TOther>());
251+
}
218252
}
219253
}

sources/Maths/Maths/Box3D.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ public Box3D<T> GetScaled(Vector3D<T> scale, Vector3D<T> anchor)
160160
public Box3D<T> GetScaled<TScale>(Vector3D<TScale> scale, Vector3D<T> anchor)
161161
where TScale : INumberBase<TScale>
162162
{
163-
var convertedAnchor = anchor.As<TScale>();
164-
var min = (scale * (Min.As<TScale>() - convertedAnchor)) + convertedAnchor;
165-
var max = (scale * (Max.As<TScale>() - convertedAnchor)) + convertedAnchor;
166-
return new Box3D<T>(min.As<T>(), max.As<T>());
163+
var convertedAnchor = anchor.AsTruncating<TScale>();
164+
var min = (scale * (Min.AsTruncating<TScale>() - convertedAnchor)) + convertedAnchor;
165+
var max = (scale * (Max.AsTruncating<TScale>() - convertedAnchor)) + convertedAnchor;
166+
return new Box3D<T>(min.AsTruncating<T>(), max.AsTruncating<T>());
167167
}
168168

169169
/// <summary>
@@ -222,6 +222,7 @@ public override int GetHashCode()
222222
/// </summary>
223223
/// <typeparam name="TOther">The type to cast to</typeparam>
224224
/// <returns>The casted box</returns>
225+
[Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)]
225226
public Box3D<TOther> As<TOther>()
226227
where TOther : INumber<TOther>
227228
{

sources/Maths/Maths/Circle.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,13 @@ public override int GetHashCode()
168168
{
169169
return !value1.Equals(value2);
170170
}
171-
171+
172172
/// <summary>
173173
/// Returns this circle casted to <typeparamref name="TOther"></typeparamref>
174174
/// </summary>
175175
/// <typeparam name="TOther">The type to cast to</typeparam>
176176
/// <returns>The casted circle</returns>
177+
[Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)]
177178
public Circle<TOther> As<TOther>() where TOther : IRootFunctions<TOther>
178179
{
179180
return new(Center.As<TOther>(), Scalar.As<T, TOther>(Radius));

sources/Maths/Maths/Cube.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ public Cube<T> GetScaled(Vector3D<T> scale, Vector3D<T> anchor)
172172
public Cube<T> GetScaled<TScale>(Vector3D<TScale> scale, Vector3D<T> anchor)
173173
where TScale : INumberBase<TScale>
174174
{
175-
var convertedAnchor = anchor.As<TScale>();
176-
var min = (scale * (Origin.As<TScale>() - convertedAnchor)) + convertedAnchor;
177-
var max = (scale * (Max.As<TScale>() - convertedAnchor)) + convertedAnchor;
178-
return new(min.As<T>(), (max - min).As<T>());
175+
var convertedAnchor = anchor.AsTruncating<TScale>();
176+
var min = (scale * (Origin.AsTruncating<TScale>() - convertedAnchor)) + convertedAnchor;
177+
var max = (scale * (Max.AsTruncating<TScale>() - convertedAnchor)) + convertedAnchor;
178+
return new(min.AsTruncating<T>(), (max - min).AsTruncating<T>());
179179
}
180180

181181
/// <summary>
@@ -230,12 +230,13 @@ public override int GetHashCode()
230230
{
231231
return !value1.Equals(value2);
232232
}
233-
233+
234234
/// <summary>
235235
/// Returns this circle casted to <typeparamref name="TOther"></typeparamref>
236236
/// </summary>
237237
/// <typeparam name="TOther">The type to cast to</typeparam>
238238
/// <returns>The casted cube</returns>
239+
[Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)]
239240
public Cube<TOther> As<TOther>()
240241
where TOther : INumber<TOther>
241242
{

sources/Maths/Maths/Matrix2X2.gen.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,27 +117,42 @@ public override string ToString() =>
117117
/// <inheridoc/>
118118
public override int GetHashCode() => HashCode.Combine(Row1, Row2);
119119

120-
/// <summary>Converts the components of this vector to another type.</summary>
120+
/// <summary>Converts the components of this matrix to another type.</summary>
121121
public static Matrix2X2<T> CreateChecked<TOther>(Matrix2X2<TOther> other)
122122
where TOther : INumberBase<TOther> =>
123123
new(Vector2D<T>.CreateChecked(other.Row1), Vector2D<T>.CreateChecked(other.Row2));
124124

125-
/// <summary>Converts the components of this vector to another type.</summary>
125+
/// <summary>Converts the components of this matrix to another type.</summary>
126126
public static Matrix2X2<T> CreateSaturating<TOther>(Matrix2X2<TOther> other)
127127
where TOther : INumberBase<TOther> =>
128128
new(Vector2D<T>.CreateSaturating(other.Row1), Vector2D<T>.CreateSaturating(other.Row2));
129129

130-
/// <summary>Converts the components of this vector to another type.</summary>
130+
/// <summary>Converts the components of this matrix to another type.</summary>
131131
public static Matrix2X2<T> CreateTruncating<TOther>(Matrix2X2<TOther> other)
132132
where TOther : INumberBase<TOther> =>
133133
new(Vector2D<T>.CreateTruncating(other.Row1), Vector2D<T>.CreateTruncating(other.Row2));
134134

135-
/// <summary>Converts the components of this vector to another type.</summary>
136-
[Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)]
135+
/// <summary>Converts the components of this matrix to another type.</summary>
136+
[Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)]
137137
public Matrix2X2<TOther> As<TOther>()
138138
where TOther : INumberBase<TOther> =>
139139
new(Row1.As<TOther>(), Row2.As<TOther>());
140140

141+
/// <summary>Converts the components of this matrix to another type.</summary>
142+
public Matrix2X2<TOther> AsChecked<TOther>()
143+
where TOther : INumberBase<TOther> =>
144+
Matrix2X2<TOther>.CreateChecked(this);
145+
146+
/// <summary>Converts the components of this matrix to another type.</summary>
147+
public Matrix2X2<TOther> AsSaturating<TOther>()
148+
where TOther : INumberBase<TOther> =>
149+
Matrix2X2<TOther>.CreateSaturating(this);
150+
151+
/// <summary>Converts the components of this matrix to another type.</summary>
152+
public Matrix2X2<TOther> AsTruncating<TOther>()
153+
where TOther : INumberBase<TOther> =>
154+
Matrix2X2<TOther>.CreateTruncating(this);
155+
141156
/// <summary>Computes the transpose of the matrix.</summary>
142157
public Matrix2X2<T> Transpose() =>
143158
new(new(M11, M21),

sources/Maths/Maths/Matrix2X3.gen.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,42 @@ public override string ToString() =>
122122
/// <inheridoc/>
123123
public override int GetHashCode() => HashCode.Combine(Row1, Row2);
124124

125-
/// <summary>Converts the components of this vector to another type.</summary>
125+
/// <summary>Converts the components of this matrix to another type.</summary>
126126
public static Matrix2X3<T> CreateChecked<TOther>(Matrix2X3<TOther> other)
127127
where TOther : INumberBase<TOther> =>
128128
new(Vector3D<T>.CreateChecked(other.Row1), Vector3D<T>.CreateChecked(other.Row2));
129129

130-
/// <summary>Converts the components of this vector to another type.</summary>
130+
/// <summary>Converts the components of this matrix to another type.</summary>
131131
public static Matrix2X3<T> CreateSaturating<TOther>(Matrix2X3<TOther> other)
132132
where TOther : INumberBase<TOther> =>
133133
new(Vector3D<T>.CreateSaturating(other.Row1), Vector3D<T>.CreateSaturating(other.Row2));
134134

135-
/// <summary>Converts the components of this vector to another type.</summary>
135+
/// <summary>Converts the components of this matrix to another type.</summary>
136136
public static Matrix2X3<T> CreateTruncating<TOther>(Matrix2X3<TOther> other)
137137
where TOther : INumberBase<TOther> =>
138138
new(Vector3D<T>.CreateTruncating(other.Row1), Vector3D<T>.CreateTruncating(other.Row2));
139139

140-
/// <summary>Converts the components of this vector to another type.</summary>
141-
[Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)]
140+
/// <summary>Converts the components of this matrix to another type.</summary>
141+
[Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)]
142142
public Matrix2X3<TOther> As<TOther>()
143143
where TOther : INumberBase<TOther> =>
144144
new(Row1.As<TOther>(), Row2.As<TOther>());
145145

146+
/// <summary>Converts the components of this matrix to another type.</summary>
147+
public Matrix2X3<TOther> AsChecked<TOther>()
148+
where TOther : INumberBase<TOther> =>
149+
Matrix2X3<TOther>.CreateChecked(this);
150+
151+
/// <summary>Converts the components of this matrix to another type.</summary>
152+
public Matrix2X3<TOther> AsSaturating<TOther>()
153+
where TOther : INumberBase<TOther> =>
154+
Matrix2X3<TOther>.CreateSaturating(this);
155+
156+
/// <summary>Converts the components of this matrix to another type.</summary>
157+
public Matrix2X3<TOther> AsTruncating<TOther>()
158+
where TOther : INumberBase<TOther> =>
159+
Matrix2X3<TOther>.CreateTruncating(this);
160+
146161
/// <summary>Computes the transpose of the matrix.</summary>
147162
public Matrix3X2<T> Transpose() =>
148163
new(new(M11, M21),

sources/Maths/Maths/Matrix2X4.gen.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,42 @@ public override string ToString() =>
136136
/// <inheridoc/>
137137
public override int GetHashCode() => HashCode.Combine(Row1, Row2);
138138

139-
/// <summary>Converts the components of this vector to another type.</summary>
139+
/// <summary>Converts the components of this matrix to another type.</summary>
140140
public static Matrix2X4<T> CreateChecked<TOther>(Matrix2X4<TOther> other)
141141
where TOther : INumberBase<TOther> =>
142142
new(Vector4D<T>.CreateChecked(other.Row1), Vector4D<T>.CreateChecked(other.Row2));
143143

144-
/// <summary>Converts the components of this vector to another type.</summary>
144+
/// <summary>Converts the components of this matrix to another type.</summary>
145145
public static Matrix2X4<T> CreateSaturating<TOther>(Matrix2X4<TOther> other)
146146
where TOther : INumberBase<TOther> =>
147147
new(Vector4D<T>.CreateSaturating(other.Row1), Vector4D<T>.CreateSaturating(other.Row2));
148148

149-
/// <summary>Converts the components of this vector to another type.</summary>
149+
/// <summary>Converts the components of this matrix to another type.</summary>
150150
public static Matrix2X4<T> CreateTruncating<TOther>(Matrix2X4<TOther> other)
151151
where TOther : INumberBase<TOther> =>
152152
new(Vector4D<T>.CreateTruncating(other.Row1), Vector4D<T>.CreateTruncating(other.Row2));
153153

154-
/// <summary>Converts the components of this vector to another type.</summary>
155-
[Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)]
154+
/// <summary>Converts the components of this matrix to another type.</summary>
155+
[Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)]
156156
public Matrix2X4<TOther> As<TOther>()
157157
where TOther : INumberBase<TOther> =>
158158
new(Row1.As<TOther>(), Row2.As<TOther>());
159159

160+
/// <summary>Converts the components of this matrix to another type.</summary>
161+
public Matrix2X4<TOther> AsChecked<TOther>()
162+
where TOther : INumberBase<TOther> =>
163+
Matrix2X4<TOther>.CreateChecked(this);
164+
165+
/// <summary>Converts the components of this matrix to another type.</summary>
166+
public Matrix2X4<TOther> AsSaturating<TOther>()
167+
where TOther : INumberBase<TOther> =>
168+
Matrix2X4<TOther>.CreateSaturating(this);
169+
170+
/// <summary>Converts the components of this matrix to another type.</summary>
171+
public Matrix2X4<TOther> AsTruncating<TOther>()
172+
where TOther : INumberBase<TOther> =>
173+
Matrix2X4<TOther>.CreateTruncating(this);
174+
160175
/// <summary>Computes the transpose of the matrix.</summary>
161176
public Matrix4X2<T> Transpose() =>
162177
new(new(M11, M21),

sources/Maths/Maths/Matrix3X2.gen.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,42 @@ public override string ToString() =>
127127
/// <inheridoc/>
128128
public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3);
129129

130-
/// <summary>Converts the components of this vector to another type.</summary>
130+
/// <summary>Converts the components of this matrix to another type.</summary>
131131
public static Matrix3X2<T> CreateChecked<TOther>(Matrix3X2<TOther> other)
132132
where TOther : INumberBase<TOther> =>
133133
new(Vector2D<T>.CreateChecked(other.Row1), Vector2D<T>.CreateChecked(other.Row2), Vector2D<T>.CreateChecked(other.Row3));
134134

135-
/// <summary>Converts the components of this vector to another type.</summary>
135+
/// <summary>Converts the components of this matrix to another type.</summary>
136136
public static Matrix3X2<T> CreateSaturating<TOther>(Matrix3X2<TOther> other)
137137
where TOther : INumberBase<TOther> =>
138138
new(Vector2D<T>.CreateSaturating(other.Row1), Vector2D<T>.CreateSaturating(other.Row2), Vector2D<T>.CreateSaturating(other.Row3));
139139

140-
/// <summary>Converts the components of this vector to another type.</summary>
140+
/// <summary>Converts the components of this matrix to another type.</summary>
141141
public static Matrix3X2<T> CreateTruncating<TOther>(Matrix3X2<TOther> other)
142142
where TOther : INumberBase<TOther> =>
143143
new(Vector2D<T>.CreateTruncating(other.Row1), Vector2D<T>.CreateTruncating(other.Row2), Vector2D<T>.CreateTruncating(other.Row3));
144144

145-
/// <summary>Converts the components of this vector to another type.</summary>
146-
[Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)]
145+
/// <summary>Converts the components of this matrix to another type.</summary>
146+
[Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)]
147147
public Matrix3X2<TOther> As<TOther>()
148148
where TOther : INumberBase<TOther> =>
149149
new(Row1.As<TOther>(), Row2.As<TOther>(), Row3.As<TOther>());
150150

151+
/// <summary>Converts the components of this matrix to another type.</summary>
152+
public Matrix3X2<TOther> AsChecked<TOther>()
153+
where TOther : INumberBase<TOther> =>
154+
Matrix3X2<TOther>.CreateChecked(this);
155+
156+
/// <summary>Converts the components of this matrix to another type.</summary>
157+
public Matrix3X2<TOther> AsSaturating<TOther>()
158+
where TOther : INumberBase<TOther> =>
159+
Matrix3X2<TOther>.CreateSaturating(this);
160+
161+
/// <summary>Converts the components of this matrix to another type.</summary>
162+
public Matrix3X2<TOther> AsTruncating<TOther>()
163+
where TOther : INumberBase<TOther> =>
164+
Matrix3X2<TOther>.CreateTruncating(this);
165+
151166
/// <summary>Computes the transpose of the matrix.</summary>
152167
public Matrix2X3<T> Transpose() =>
153168
new(new(M11, M21, M31),

sources/Maths/Maths/Matrix3X3.gen.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,27 +156,42 @@ public override string ToString() =>
156156
/// <inheridoc/>
157157
public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3);
158158

159-
/// <summary>Converts the components of this vector to another type.</summary>
159+
/// <summary>Converts the components of this matrix to another type.</summary>
160160
public static Matrix3X3<T> CreateChecked<TOther>(Matrix3X3<TOther> other)
161161
where TOther : INumberBase<TOther> =>
162162
new(Vector3D<T>.CreateChecked(other.Row1), Vector3D<T>.CreateChecked(other.Row2), Vector3D<T>.CreateChecked(other.Row3));
163163

164-
/// <summary>Converts the components of this vector to another type.</summary>
164+
/// <summary>Converts the components of this matrix to another type.</summary>
165165
public static Matrix3X3<T> CreateSaturating<TOther>(Matrix3X3<TOther> other)
166166
where TOther : INumberBase<TOther> =>
167167
new(Vector3D<T>.CreateSaturating(other.Row1), Vector3D<T>.CreateSaturating(other.Row2), Vector3D<T>.CreateSaturating(other.Row3));
168168

169-
/// <summary>Converts the components of this vector to another type.</summary>
169+
/// <summary>Converts the components of this matrix to another type.</summary>
170170
public static Matrix3X3<T> CreateTruncating<TOther>(Matrix3X3<TOther> other)
171171
where TOther : INumberBase<TOther> =>
172172
new(Vector3D<T>.CreateTruncating(other.Row1), Vector3D<T>.CreateTruncating(other.Row2), Vector3D<T>.CreateTruncating(other.Row3));
173173

174-
/// <summary>Converts the components of this vector to another type.</summary>
175-
[Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)]
174+
/// <summary>Converts the components of this matrix to another type.</summary>
175+
[Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)]
176176
public Matrix3X3<TOther> As<TOther>()
177177
where TOther : INumberBase<TOther> =>
178178
new(Row1.As<TOther>(), Row2.As<TOther>(), Row3.As<TOther>());
179179

180+
/// <summary>Converts the components of this matrix to another type.</summary>
181+
public Matrix3X3<TOther> AsChecked<TOther>()
182+
where TOther : INumberBase<TOther> =>
183+
Matrix3X3<TOther>.CreateChecked(this);
184+
185+
/// <summary>Converts the components of this matrix to another type.</summary>
186+
public Matrix3X3<TOther> AsSaturating<TOther>()
187+
where TOther : INumberBase<TOther> =>
188+
Matrix3X3<TOther>.CreateSaturating(this);
189+
190+
/// <summary>Converts the components of this matrix to another type.</summary>
191+
public Matrix3X3<TOther> AsTruncating<TOther>()
192+
where TOther : INumberBase<TOther> =>
193+
Matrix3X3<TOther>.CreateTruncating(this);
194+
180195
/// <summary>Computes the transpose of the matrix.</summary>
181196
public Matrix3X3<T> Transpose() =>
182197
new(new(M11, M21, M31),

0 commit comments

Comments
 (0)