Skip to content

Commit 8c5c577

Browse files
Merge pull request #2951 from stefannikolei/sn/ref/explicit_types
Enforce Explicit Types and Target Type new
2 parents 833f3ce + d943f52 commit 8c5c577

File tree

600 files changed

+2788
-2791
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

600 files changed

+2788
-2791
lines changed

src/ImageSharp/Advanced/ParallelExecutionSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public ParallelExecutionSettings MultiplyMinimumPixelsPerTask(int multiplier)
7979
{
8080
Guard.MustBeGreaterThan(multiplier, 0, nameof(multiplier));
8181

82-
return new ParallelExecutionSettings(
82+
return new(
8383
this.MaxDegreeOfParallelism,
8484
this.MinimumPixelsProcessedPerTask * multiplier,
8585
this.MemoryAllocator);
@@ -92,6 +92,6 @@ public ParallelExecutionSettings MultiplyMinimumPixelsPerTask(int multiplier)
9292
/// <returns>The <see cref="ParallelExecutionSettings"/>.</returns>
9393
public static ParallelExecutionSettings FromConfiguration(Configuration configuration)
9494
{
95-
return new ParallelExecutionSettings(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
95+
return new(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
9696
}
9797
}

src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public void Invoke(int i)
139139
}
140140

141141
int yMax = Math.Min(yMin + this.stepY, this.maxY);
142-
var rows = new RowInterval(yMin, yMax);
142+
RowInterval rows = new RowInterval(yMin, yMax);
143143

144144
// Skip the safety copy when invoking a potentially impure method on a readonly field
145145
Unsafe.AsRef(in this.operation).Invoke(in rows);
@@ -185,7 +185,7 @@ public void Invoke(int i)
185185
}
186186

187187
int yMax = Math.Min(yMin + this.stepY, this.maxY);
188-
var rows = new RowInterval(yMin, yMax);
188+
RowInterval rows = new RowInterval(yMin, yMax);
189189

190190
using IMemoryOwner<TBuffer> buffer = this.allocator.Allocate<TBuffer>(this.bufferLength);
191191

src/ImageSharp/Advanced/ParallelRowIterator.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static partial class ParallelRowIterator
2626
public static void IterateRows<T>(Configuration configuration, Rectangle rectangle, in T operation)
2727
where T : struct, IRowOperation
2828
{
29-
var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
29+
ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
3030
IterateRows(rectangle, in parallelSettings, in operation);
3131
}
3232

@@ -65,8 +65,8 @@ public static void IterateRows<T>(
6565
}
6666

6767
int verticalStep = DivideCeil(rectangle.Height, numOfSteps);
68-
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
69-
var wrappingOperation = new RowOperationWrapper<T>(top, bottom, verticalStep, in operation);
68+
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
69+
RowOperationWrapper<T> wrappingOperation = new(top, bottom, verticalStep, in operation);
7070

7171
Parallel.For(
7272
0,
@@ -88,7 +88,7 @@ public static void IterateRows<T, TBuffer>(Configuration configuration, Rectangl
8888
where T : struct, IRowOperation<TBuffer>
8989
where TBuffer : unmanaged
9090
{
91-
var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
91+
ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
9292
IterateRows<T, TBuffer>(rectangle, in parallelSettings, in operation);
9393
}
9494

@@ -135,8 +135,8 @@ public static void IterateRows<T, TBuffer>(
135135
}
136136

137137
int verticalStep = DivideCeil(height, numOfSteps);
138-
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
139-
var wrappingOperation = new RowOperationWrapper<T, TBuffer>(top, bottom, verticalStep, bufferLength, allocator, in operation);
138+
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
139+
RowOperationWrapper<T, TBuffer> wrappingOperation = new(top, bottom, verticalStep, bufferLength, allocator, in operation);
140140

141141
Parallel.For(
142142
0,
@@ -156,7 +156,7 @@ public static void IterateRows<T, TBuffer>(
156156
public static void IterateRowIntervals<T>(Configuration configuration, Rectangle rectangle, in T operation)
157157
where T : struct, IRowIntervalOperation
158158
{
159-
var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
159+
ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
160160
IterateRowIntervals(rectangle, in parallelSettings, in operation);
161161
}
162162

@@ -186,14 +186,14 @@ public static void IterateRowIntervals<T>(
186186
// Avoid TPL overhead in this trivial case:
187187
if (numOfSteps == 1)
188188
{
189-
var rows = new RowInterval(top, bottom);
189+
RowInterval rows = new(top, bottom);
190190
Unsafe.AsRef(in operation).Invoke(in rows);
191191
return;
192192
}
193193

194194
int verticalStep = DivideCeil(rectangle.Height, numOfSteps);
195-
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
196-
var wrappingOperation = new RowIntervalOperationWrapper<T>(top, bottom, verticalStep, in operation);
195+
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
196+
RowIntervalOperationWrapper<T> wrappingOperation = new(top, bottom, verticalStep, in operation);
197197

198198
Parallel.For(
199199
0,
@@ -215,7 +215,7 @@ public static void IterateRowIntervals<T, TBuffer>(Configuration configuration,
215215
where T : struct, IRowIntervalOperation<TBuffer>
216216
where TBuffer : unmanaged
217217
{
218-
var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
218+
ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
219219
IterateRowIntervals<T, TBuffer>(rectangle, in parallelSettings, in operation);
220220
}
221221

@@ -250,7 +250,7 @@ public static void IterateRowIntervals<T, TBuffer>(
250250
// Avoid TPL overhead in this trivial case:
251251
if (numOfSteps == 1)
252252
{
253-
var rows = new RowInterval(top, bottom);
253+
RowInterval rows = new(top, bottom);
254254
using IMemoryOwner<TBuffer> buffer = allocator.Allocate<TBuffer>(bufferLength);
255255

256256
Unsafe.AsRef(in operation).Invoke(in rows, buffer.Memory.Span);
@@ -259,8 +259,8 @@ public static void IterateRowIntervals<T, TBuffer>(
259259
}
260260

261261
int verticalStep = DivideCeil(height, numOfSteps);
262-
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
263-
var wrappingOperation = new RowIntervalOperationWrapper<T, TBuffer>(top, bottom, verticalStep, bufferLength, allocator, in operation);
262+
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
263+
RowIntervalOperationWrapper<T, TBuffer> wrappingOperation = new(top, bottom, verticalStep, bufferLength, allocator, in operation);
264264

265265
Parallel.For(
266266
0,

src/ImageSharp/Color/Color.WebSafePalette.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp;
88
/// </content>
99
public partial struct Color
1010
{
11-
private static readonly Lazy<Color[]> WebSafePaletteLazy = new Lazy<Color[]>(CreateWebSafePalette, true);
11+
private static readonly Lazy<Color[]> WebSafePaletteLazy = new(CreateWebSafePalette, true);
1212

1313
/// <summary>
1414
/// Gets a collection of named, web safe colors as defined in the CSS Color Module Level 4.

src/ImageSharp/ColorProfiles/CieLab.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public Vector4 ToScaledVector4()
8888
v3 += this.AsVector3Unsafe();
8989
v3 += new Vector3(0, 128F, 128F);
9090
v3 /= new Vector3(100F, 255F, 255F);
91-
return new Vector4(v3, 1F);
91+
return new(v3, 1F);
9292
}
9393

9494
/// <inheritdoc/>
@@ -97,7 +97,7 @@ public static CieLab FromScaledVector4(Vector4 source)
9797
Vector3 v3 = source.AsVector3();
9898
v3 *= new Vector3(100F, 255, 255);
9999
v3 -= new Vector3(0, 128F, 128F);
100-
return new CieLab(v3);
100+
return new(v3);
101101
}
102102

103103
/// <inheritdoc/>
@@ -145,7 +145,7 @@ public static CieLab FromProfileConnectingSpace(ColorConversionOptions options,
145145
float a = 500F * (fx - fy);
146146
float b = 200F * (fy - fz);
147147

148-
return new CieLab(l, a, b);
148+
return new(l, a, b);
149149
}
150150

151151
/// <inheritdoc/>

src/ImageSharp/ColorProfiles/CieLch.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
2525
/// <param name="h">The hue in degrees.</param>
2626
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2727
public CieLch(float l, float c, float h)
28-
: this(new Vector3(l, c, h))
28+
: this(new(l, c, h))
2929
{
3030
}
3131

@@ -100,7 +100,7 @@ public Vector4 ToScaledVector4()
100100
v3 += this.AsVector3Unsafe();
101101
v3 += new Vector3(0, 200, 0);
102102
v3 /= new Vector3(100, 400, 360);
103-
return new Vector4(v3, 1F);
103+
return new(v3, 1F);
104104
}
105105

106106
/// <inheritdoc/>
@@ -109,7 +109,7 @@ public static CieLch FromScaledVector4(Vector4 source)
109109
Vector3 v3 = source.AsVector3();
110110
v3 *= new Vector3(100, 400, 360);
111111
v3 -= new Vector3(0, 200, 0);
112-
return new CieLch(v3, true);
112+
return new(v3, true);
113113
}
114114

115115
/// <inheritdoc/>
@@ -155,7 +155,7 @@ public static CieLch FromProfileConnectingSpace(ColorConversionOptions options,
155155
hDegrees += 360;
156156
}
157157

158-
return new CieLch(l, c, hDegrees);
158+
return new(l, c, hDegrees);
159159
}
160160

161161
/// <inheritdoc/>
@@ -181,7 +181,7 @@ public CieLab ToProfileConnectingSpace(ColorConversionOptions options)
181181
float a = c * MathF.Cos(hRadians);
182182
float b = c * MathF.Sin(hRadians);
183183

184-
return new CieLab(l, a, b);
184+
return new(l, a, b);
185185
}
186186

187187
/// <inheritdoc/>

src/ImageSharp/ColorProfiles/CieLchuv.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
2525
/// <param name="h">The hue in degrees.</param>
2626
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2727
public CieLchuv(float l, float c, float h)
28-
: this(new Vector3(l, c, h))
28+
: this(new(l, c, h))
2929
{
3030
}
3131

@@ -97,7 +97,7 @@ public Vector4 ToScaledVector4()
9797
v3 += this.AsVector3Unsafe();
9898
v3 += new Vector3(0, 200, 0);
9999
v3 /= new Vector3(100, 400, 360);
100-
return new Vector4(v3, 1F);
100+
return new(v3, 1F);
101101
}
102102

103103
/// <inheritdoc/>
@@ -106,7 +106,7 @@ public static CieLchuv FromScaledVector4(Vector4 source)
106106
Vector3 v3 = source.AsVector3();
107107
v3 *= new Vector3(100, 400, 360);
108108
v3 -= new Vector3(0, 200, 0);
109-
return new CieLchuv(v3, true);
109+
return new(v3, true);
110110
}
111111

112112
/// <inheritdoc/>
@@ -154,7 +154,7 @@ public static CieLchuv FromProfileConnectingSpace(ColorConversionOptions options
154154
hDegrees += 360;
155155
}
156156

157-
return new CieLchuv(l, c, hDegrees);
157+
return new(l, c, hDegrees);
158158
}
159159

160160
/// <inheritdoc/>

src/ImageSharp/ColorProfiles/CieLuv.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public static CieLuv FromProfileConnectingSpace(ColorConversionOptions options,
134134
v = 0;
135135
}
136136

137-
return new CieLuv((float)l, (float)u, (float)v);
137+
return new((float)l, (float)u, (float)v);
138138
}
139139

140140
/// <inheritdoc/>
@@ -188,7 +188,7 @@ public CieXyz ToProfileConnectingSpace(ColorConversionOptions options)
188188
z = 0;
189189
}
190190

191-
return new CieXyz((float)x, (float)y, (float)z);
191+
return new((float)x, (float)y, (float)z);
192192
}
193193

194194
/// <inheritdoc/>

src/ImageSharp/ColorProfiles/CieXyy.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ public static CieXyy FromProfileConnectingSpace(ColorConversionOptions options,
122122

123123
if (float.IsNaN(x) || float.IsNaN(y))
124124
{
125-
return new CieXyy(0, 0, source.Y);
125+
return new(0, 0, source.Y);
126126
}
127127

128-
return new CieXyy(x, y, source.Y);
128+
return new(x, y, source.Y);
129129
}
130130

131131
/// <inheritdoc/>
@@ -144,14 +144,14 @@ public CieXyz ToProfileConnectingSpace(ColorConversionOptions options)
144144
{
145145
if (MathF.Abs(this.Y) < Constants.Epsilon)
146146
{
147-
return new CieXyz(0, 0, this.Yl);
147+
return new(0, 0, this.Yl);
148148
}
149149

150150
float x = (this.X * this.Yl) / this.Y;
151151
float y = this.Yl;
152152
float z = ((1 - this.X - this.Y) * y) / this.Y;
153153

154-
return new CieXyz(x, y, z);
154+
return new(x, y, z);
155155
}
156156

157157
/// <inheritdoc/>

src/ImageSharp/ColorProfiles/CieXyz.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ internal Vector4 ToVector4()
8888
{
8989
Vector3 v3 = default;
9090
v3 += this.AsVector3Unsafe();
91-
return new Vector4(v3, 1F);
91+
return new(v3, 1F);
9292
}
9393

9494
/// <inheritdoc/>
@@ -97,21 +97,21 @@ public Vector4 ToScaledVector4()
9797
Vector3 v3 = default;
9898
v3 += this.AsVector3Unsafe();
9999
v3 *= 32768F / 65535;
100-
return new Vector4(v3, 1F);
100+
return new(v3, 1F);
101101
}
102102

103103
internal static CieXyz FromVector4(Vector4 source)
104104
{
105105
Vector3 v3 = source.AsVector3();
106-
return new CieXyz(v3);
106+
return new(v3);
107107
}
108108

109109
/// <inheritdoc/>
110110
public static CieXyz FromScaledVector4(Vector4 source)
111111
{
112112
Vector3 v3 = source.AsVector3();
113113
v3 *= 65535 / 32768F;
114-
return new CieXyz(v3);
114+
return new(v3);
115115
}
116116

117117
/// <inheritdoc/>

src/ImageSharp/ColorProfiles/Cmyk.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
2626
/// <param name="k">The keyline black component.</param>
2727
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2828
public Cmyk(float c, float m, float y, float k)
29-
: this(new Vector4(c, m, y, k))
29+
: this(new(c, m, y, k))
3030
{
3131
}
3232

@@ -138,12 +138,12 @@ public static Cmyk FromProfileConnectingSpace(ColorConversionOptions options, in
138138

139139
if (k.X >= 1F - Constants.Epsilon)
140140
{
141-
return new Cmyk(0, 0, 0, 1F);
141+
return new(0, 0, 0, 1F);
142142
}
143143

144144
cmy = (cmy - k) / (Vector3.One - k);
145145

146-
return new Cmyk(cmy.X, cmy.Y, cmy.Z, k.X);
146+
return new(cmy.X, cmy.Y, cmy.Z, k.X);
147147
}
148148

149149
/// <inheritdoc/>

0 commit comments

Comments
 (0)