Skip to content

Commit 137990c

Browse files
committed
Update SharedInfra
1 parent ed1b3ee commit 137990c

File tree

162 files changed

+1132
-1134
lines changed

Some content is hidden

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

162 files changed

+1132
-1134
lines changed

.editorconfig

Lines changed: 6 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
@@ -174,6 +177,9 @@ csharp_using_directive_placement = outside_namespace:warning
174177
csharp_prefer_static_local_function = true:warning
175178
# Primary constructor preferences
176179
csharp_style_prefer_primary_constructors = false:none
180+
# Collection preferences
181+
dotnet_style_prefer_collection_expression = true:error
182+
resharper_use_collection_expression_highlighting =true:error
177183

178184
##########################################
179185
# Unnecessary Code Rules

samples/DrawShapesWithImageSharp/ImageSharpLogo.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public static void SaveLogo(float size, string path)
1717
// the point are based on a 1206x1206 shape so size requires scaling from there
1818
float scalingFactor = size / 1206;
1919

20-
var center = new Vector2(603);
20+
Vector2 center = new(603);
2121

2222
// segment whose center of rotation should be
23-
var segmentOffset = new Vector2(301.16968f, 301.16974f);
23+
Vector2 segmentOffset = new(301.16968f, 301.16974f);
2424
IPath segment = new Polygon(
2525
new LinearLineSegment(new Vector2(230.54f, 361.0261f), new Vector2(5.8641942f, 361.46031f)),
2626
new CubicBezierLineSegment(
@@ -30,28 +30,28 @@ public static void SaveLogo(float size, string path)
3030
new Vector2(78.26f, 97.0461f))).Translate(center - segmentOffset);
3131

3232
// we need to create 6 of theses all rotated about the center point
33-
var segments = new List<IPath>();
33+
List<IPath> segments = [];
3434
for (int i = 0; i < 6; i++)
3535
{
3636
float angle = i * ((float)Math.PI / 3);
3737
IPath s = segment.Transform(Matrix3x2.CreateRotation(angle, center));
3838
segments.Add(s);
3939
}
4040

41-
var colors = new List<Color>()
42-
{
41+
List<Color> colors =
42+
[
4343
Color.ParseHex("35a849"),
4444
Color.ParseHex("fcee21"),
4545
Color.ParseHex("ed7124"),
4646
Color.ParseHex("cb202d"),
4747
Color.ParseHex("5f2c83"),
48-
Color.ParseHex("085ba7"),
49-
};
48+
Color.ParseHex("085ba7")
49+
];
5050

51-
var scaler = Matrix3x2.CreateScale(scalingFactor, Vector2.Zero);
51+
Matrix3x2 scaler = Matrix3x2.CreateScale(scalingFactor, Vector2.Zero);
5252

5353
int dimensions = (int)Math.Ceiling(size);
54-
using (var img = new Image<Rgba32>(dimensions, dimensions))
54+
using (Image<Rgba32> img = new(dimensions, dimensions))
5555
{
5656
img.Mutate(i => i.Fill(Color.Black));
5757
img.Mutate(i => i.Fill(Color.ParseHex("e1e1e1ff"), new EllipsePolygon(center, 600f).Transform(scaler)));

samples/DrawShapesWithImageSharp/Program.cs

Lines changed: 28 additions & 29 deletions
Large diffs are not rendered by default.

shared-infrastructure

src/ImageSharp.Drawing/Processing/Extensions/FillPathBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static IImageProcessingContext Fill(
6767
Brush brush,
6868
Action<PathBuilder> region)
6969
{
70-
var pb = new PathBuilder();
70+
PathBuilder pb = new();
7171
region(pb);
7272

7373
return source.Fill(options, brush, pb.Build());

src/ImageSharp.Drawing/Processing/PatternBrush.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public PatternBrush(Color foreColor, Color backColor, bool[,] pattern)
5454
/// <param name="pattern">The pattern.</param>
5555
internal PatternBrush(Color foreColor, Color backColor, in DenseMatrix<bool> pattern)
5656
{
57-
var foreColorVector = foreColor.ToScaledVector4();
58-
var backColorVector = backColor.ToScaledVector4();
57+
Vector4 foreColorVector = foreColor.ToScaledVector4();
58+
Vector4 backColorVector = backColor.ToScaledVector4();
5959
this.pattern = new DenseMatrix<Color>(pattern.Columns, pattern.Rows);
6060
this.patternVector = new DenseMatrix<Vector4>(pattern.Columns, pattern.Rows);
6161
for (int i = 0; i < pattern.Data.Length; i++)

src/ImageSharp.Drawing/Processing/Pens.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ namespace SixLabors.ImageSharp.Drawing.Processing;
88
/// </summary>
99
public static class Pens
1010
{
11-
private static readonly float[] DashDotPattern = { 3f, 1f, 1f, 1f };
12-
private static readonly float[] DashDotDotPattern = { 3f, 1f, 1f, 1f, 1f, 1f };
13-
private static readonly float[] DottedPattern = { 1f, 1f };
14-
private static readonly float[] DashedPattern = { 3f, 1f };
15-
internal static readonly float[] EmptyPattern = Array.Empty<float>();
11+
private static readonly float[] DashDotPattern = [3f, 1f, 1f, 1f];
12+
private static readonly float[] DashDotDotPattern = [3f, 1f, 1f, 1f, 1f, 1f];
13+
private static readonly float[] DottedPattern = [1f, 1f];
14+
private static readonly float[] DashedPattern = [3f, 1f];
15+
internal static readonly float[] EmptyPattern = [];
1616

1717
/// <summary>
1818
/// Create a solid pen without any drawing patterns

src/ImageSharp.Drawing/Processing/Processors/Drawing/ClipPathProcessor{TPixel}.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public void Execute()
4141
RectangleF bounds = this.definition.Region.Bounds;
4242

4343
// add some clamping offsets to the brush to account for the target drawing location due to the cloned image not fill the image as expected
44-
var offsetX = 0;
45-
var offsetY = 0;
44+
int offsetX = 0;
45+
int offsetY = 0;
4646
if (bounds.X < 0)
4747
{
4848
offsetX = -(int)MathF.Floor(bounds.X);
@@ -53,10 +53,10 @@ public void Execute()
5353
offsetY = -(int)MathF.Floor(bounds.Y);
5454
}
5555

56-
var brush = new ImageBrush(clone, bounds, new Point(offsetX, offsetY));
56+
ImageBrush brush = new(clone, bounds, new Point(offsetX, offsetY));
5757

5858
// Grab hold of an image processor that can fill paths with a brush to allow it to do the hard pixel pushing for us
59-
var processor = new FillPathProcessor(this.definition.Options, brush, this.definition.Region);
59+
FillPathProcessor processor = new(this.definition.Options, brush, this.definition.Region);
6060
using IImageProcessor<TPixel> p = processor.CreatePixelSpecificProcessor(this.configuration, this.source, this.sourceRectangle);
6161

6262
// Fill the shape using the image brush

src/ImageSharp.Drawing/Processing/Processors/Drawing/FillPathProcessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuratio
5252

5353
if (shape is RectangularPolygon rectPoly)
5454
{
55-
var rectF = new RectangleF(rectPoly.Location, rectPoly.Size);
56-
var rect = (Rectangle)rectF;
55+
RectangleF rectF = new(rectPoly.Location, rectPoly.Size);
56+
Rectangle rect = (Rectangle)rectF;
5757
if (!this.Options.GraphicsOptions.Antialias || rectF == rect)
5858
{
5959
// Cast as in and back are the same or we are using anti-aliasing
@@ -63,7 +63,7 @@ public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuratio
6363
}
6464

6565
// Clone the definition so we can pass the transformed path.
66-
var definition = new FillPathProcessor(this.Options, this.Brush, shape);
66+
FillPathProcessor definition = new(this.Options, this.Brush, shape);
6767
return new FillPathProcessor<TPixel>(configuration, definition, source, sourceRectangle);
6868
}
6969
}

src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private static RichTextOptions ConfigureOptions(RichTextOptions options)
118118
// and not adjust the origin. Any translation should be applied to the path.
119119
if (options.Path is not null && options.Origin != Vector2.Zero)
120120
{
121-
return new(options)
121+
return new RichTextOptions(options)
122122
{
123123
Origin = Vector2.Zero,
124124
Path = options.Path.Translate(options.Origin)

0 commit comments

Comments
 (0)