Skip to content

Commit 2167475

Browse files
Merge pull request #2958 from stefannikolei/sn/ref/target_type_new
Use Target Type new only when apparent
2 parents 8c5c577 + 4378e8d commit 2167475

File tree

704 files changed

+2575
-2562
lines changed

Some content is hidden

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

704 files changed

+2575
-2562
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ csharp_style_deconstructed_variable_declaration = true:warning
161161
csharp_style_prefer_index_operator = true:warning
162162
csharp_style_prefer_range_operator = true:warning
163163
csharp_style_implicit_object_creation_when_type_is_apparent = true:error
164+
# ReSharper inspection severities
165+
resharper_arrange_object_creation_when_type_evident_highlighting = error
166+
resharper_arrange_object_creation_when_type_not_evident_highlighting = error
164167
# "Null" checking preferences
165168
csharp_style_throw_expression = true:warning
166169
csharp_style_conditional_delegate_call = true:warning

shared-infrastructure

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(
82+
return new ParallelExecutionSettings(
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(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
95+
return new ParallelExecutionSettings(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-
RowInterval rows = new RowInterval(yMin, yMax);
142+
RowInterval rows = new(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-
RowInterval rows = new RowInterval(yMin, yMax);
188+
RowInterval rows = new(yMin, yMax);
189189

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

src/ImageSharp/Color/Color.WernerPalette.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[]> WernerPaletteLazy = new Lazy<Color[]>(CreateWernerPalette, true);
11+
private static readonly Lazy<Color[]> WernerPaletteLazy = new(CreateWernerPalette, true);
1212

1313
/// <summary>
1414
/// Gets a collection of colors as defined in the original second edition of Werner’s Nomenclature of Colours 1821.

src/ImageSharp/Color/Color.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ public static Color FromPixel<TPixel>(TPixel source)
8181
PixelTypeInfo info = TPixel.GetPixelTypeInfo();
8282
if (info.ComponentInfo.HasValue && info.ComponentInfo.Value.GetMaximumComponentPrecision() <= (int)PixelComponentBitDepth.Bit32)
8383
{
84-
return new(source.ToScaledVector4());
84+
return new Color(source.ToScaledVector4());
8585
}
8686

87-
return new(source);
87+
return new Color(source);
8888
}
8989

9090
/// <summary>
@@ -120,7 +120,7 @@ public static void FromPixel<TPixel>(ReadOnlySpan<TPixel> source, Span<Color> de
120120
{
121121
for (int i = 0; i < destination.Length; i++)
122122
{
123-
destination[i] = new(source[i]);
123+
destination[i] = new Color(source[i]);
124124
}
125125
}
126126
}

src/ImageSharp/ColorProfiles/CieLab.cs

Lines changed: 4 additions & 4 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(v3, 1F);
91+
return new Vector4(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(v3);
100+
return new CieLab(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(l, a, b);
148+
return new CieLab(l, a, b);
149149
}
150150

151151
/// <inheritdoc/>
@@ -182,7 +182,7 @@ public CieXyz ToProfileConnectingSpace(ColorConversionOptions options)
182182
Vector3 wxyz = new(whitePoint.X, whitePoint.Y, whitePoint.Z);
183183
Vector3 xyzr = new(xr, yr, zr);
184184

185-
return new(xyzr * wxyz);
185+
return new CieXyz(xyzr * wxyz);
186186
}
187187

188188
/// <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(l, c, h))
28+
: this(new Vector3(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(v3, 1F);
103+
return new Vector4(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(v3, true);
112+
return new CieLch(v3, true);
113113
}
114114

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

158-
return new(l, c, hDegrees);
158+
return new CieLch(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(l, a, b);
184+
return new CieLab(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(l, c, h))
28+
: this(new Vector3(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(v3, 1F);
100+
return new Vector4(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(v3, true);
109+
return new CieLchuv(v3, true);
110110
}
111111

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

157-
return new(l, c, hDegrees);
157+
return new CieLchuv(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((float)l, (float)u, (float)v);
137+
return new CieLuv((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((float)x, (float)y, (float)z);
191+
return new CieXyz((float)x, (float)y, (float)z);
192192
}
193193

194194
/// <inheritdoc/>

0 commit comments

Comments
 (0)