Skip to content

Commit a954d58

Browse files
committed
Enabled EnforceCodeStyleInBuild and fixed the errors.
1 parent 20d5b8f commit a954d58

File tree

8 files changed

+56
-60
lines changed

8 files changed

+56
-60
lines changed

.editorconfig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ csharp_style_pattern_matching_over_as_with_null_check = true:error
3131

3232
csharp_style_prefer_range_operator = false
3333
dotnet_style_prefer_simplified_boolean_expressions = true:error
34-
csharp_style_prefer_switch_expression = true:error
34+
csharp_style_prefer_switch_expression = true:suggestion
3535

3636
dotnet_style_predefined_type_for_locals_parameters_members = true:error
3737

@@ -44,8 +44,6 @@ csharp_style_var_for_built_in_types = true:error
4444
csharp_style_var_when_type_is_apparent = true:error
4545
csharp_style_var_elsewhere = true:error
4646

47-
csharp_style_unused_value_assignment_preference = true:error
48-
4947
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
5048
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
5149
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style

Magick.NET.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<Copyright>Copyright 2013-2025 Dirk Lemstra</Copyright>
66
<LangVersion>preview</LangVersion>
77
<Nullable>enable</Nullable>
8+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
89
</PropertyGroup>
910

1011
<PropertyGroup Condition="$(Configuration.Contains('Debug'))">

Magick.NET.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ EndProject
7373
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "files", "files", "{D6C3708D-A8A1-4E8C-8E9A-73B12C322033}"
7474
ProjectSection(SolutionItems) = preProject
7575
.dockerignore = .dockerignore
76+
.editorconfig = .editorconfig
7677
.gitattributes = .gitattributes
7778
.gitignore = .gitignore
7879
BUILDING.md = BUILDING.md

samples/Magick.NET.Samples/Watermark.cs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,28 @@
33

44
using ImageMagick;
55

6-
namespace Magick.NET.Samples
6+
namespace Magick.NET.Samples;
7+
8+
public static class WatermarkSamples
79
{
8-
public static class WatermarkSamples
10+
public static void CreateWatermark()
911
{
10-
public static void CreateWatermark()
11-
{
12-
// Read image that needs a watermark
13-
using var image = new MagickImage(SampleFiles.FujiFilmFinePixS1ProJpg);
12+
// Read image that needs a watermark
13+
using var image = new MagickImage(SampleFiles.FujiFilmFinePixS1ProJpg);
1414

15-
// Read the watermark that will be put on top of the image
16-
using var watermark = new MagickImage(SampleFiles.SnakewarePng);
15+
// Read the watermark that will be put on top of the image
16+
using var watermark = new MagickImage(SampleFiles.SnakewarePng);
1717

18-
// Draw the watermark in the bottom right corner
19-
image.Composite(watermark, Gravity.Southeast, CompositeOperator.Over);
18+
// Draw the watermark in the bottom right corner
19+
image.Composite(watermark, Gravity.Southeast, CompositeOperator.Over);
2020

21-
// Optionally make the watermark more transparent
22-
watermark.Evaluate(Channels.Alpha, EvaluateOperator.Divide, 4);
21+
// Optionally make the watermark more transparent
22+
watermark.Evaluate(Channels.Alpha, EvaluateOperator.Divide, 4);
2323

24-
// Or draw the watermark at a specific location
25-
image.Composite(watermark, 200, 50, CompositeOperator.Over);
24+
// Or draw the watermark at a specific location
25+
image.Composite(watermark, 200, 50, CompositeOperator.Over);
2626

27-
// Save the result
28-
image.Write(SampleFiles.OutputDirectory + "FujiFilmFinePixS1Pro.watermark.jpg");
29-
}
27+
// Save the result
28+
image.Write(SampleFiles.OutputDirectory + "FujiFilmFinePixS1Pro.watermark.jpg");
3029
}
3130
}

src/Magick.NET.Core/Helpers/MemoryStreamExtensions.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33

44
using System.IO;
55

6-
namespace ImageMagick
6+
namespace ImageMagick;
7+
8+
internal static class MemoryStreamExtensions
79
{
8-
internal static class MemoryStreamExtensions
9-
{
10-
public static void WriteBytes(this MemoryStream stream, byte[] bytes)
11-
=> stream.Write(bytes, 0, bytes.Length);
12-
}
10+
public static void WriteBytes(this MemoryStream stream, byte[] bytes)
11+
=> stream.Write(bytes, 0, bytes.Length);
1312
}

src/Magick.NET/Native/INativeMagickImage.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33

44
using System;
55

6-
namespace ImageMagick
6+
namespace ImageMagick;
7+
8+
internal interface INativeMagickImage
79
{
8-
internal interface INativeMagickImage
9-
{
10-
IntPtr Fx(string expression, Channels channels);
10+
IntPtr Fx(string expression, Channels channels);
1111

12-
void RemoveArtifact(string name);
12+
void RemoveArtifact(string name);
1313

14-
void SetArtifact(string name, string value);
15-
}
14+
void SetArtifact(string name, string value);
1615
}

tests/Magick.NET.Tests/Coders/ThePangoCoder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void ShouldUseTextAntiAliasSetting()
4545
[Fact]
4646
public void IsThreadSafe()
4747
{
48-
string LoadImage()
48+
static string LoadImage()
4949
{
5050
using var image = new MagickImage("pango:1");
5151
return image.Signature;

tests/Magick.NET.Tests/TestHelpers/TestReadOnlySequence.cs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,40 @@
66
using System;
77
using System.Buffers;
88

9-
namespace Magick.NET.Tests
9+
namespace Magick.NET.Tests;
10+
11+
internal sealed class TestReadOnlySequence : ReadOnlySequenceSegment<byte>
1012
{
11-
internal sealed class TestReadOnlySequence : ReadOnlySequenceSegment<byte>
13+
private TestReadOnlySequence(byte[] value, int start, int length)
1214
{
13-
private TestReadOnlySequence(byte[] value, int start, int length)
14-
{
15-
Memory = new ReadOnlyMemory<byte>(value, start, length);
16-
}
17-
18-
public static ReadOnlySequence<byte> Create(byte[] data, int sequenceSize)
19-
{
20-
var first = new TestReadOnlySequence(data, 0, sequenceSize);
21-
var length = sequenceSize;
22-
var last = first.Append(data, sequenceSize, length);
15+
Memory = new ReadOnlyMemory<byte>(value, start, length);
16+
}
2317

24-
for (var i = sequenceSize + sequenceSize; i < data.Length; i += sequenceSize)
25-
{
26-
length = Math.Min(data.Length - i, sequenceSize);
27-
last = last.Append(data, i, length);
28-
}
18+
public static ReadOnlySequence<byte> Create(byte[] data, int sequenceSize)
19+
{
20+
var first = new TestReadOnlySequence(data, 0, sequenceSize);
21+
var length = sequenceSize;
22+
var last = first.Append(data, sequenceSize, length);
2923

30-
return new ReadOnlySequence<byte>(first, 0, last, length);
24+
for (var i = sequenceSize + sequenceSize; i < data.Length; i += sequenceSize)
25+
{
26+
length = Math.Min(data.Length - i, sequenceSize);
27+
last = last.Append(data, i, length);
3128
}
3229

33-
private TestReadOnlySequence Append(byte[] value, int start, int length)
30+
return new ReadOnlySequence<byte>(first, 0, last, length);
31+
}
32+
33+
private TestReadOnlySequence Append(byte[] value, int start, int length)
34+
{
35+
var next = new TestReadOnlySequence(value, start, length)
3436
{
35-
var next = new TestReadOnlySequence(value, start, length)
36-
{
37-
RunningIndex = RunningIndex + Memory.Length,
38-
};
37+
RunningIndex = RunningIndex + Memory.Length,
38+
};
3939

40-
Next = next;
40+
Next = next;
4141

42-
return next;
43-
}
42+
return next;
4443
}
4544
}
4645

0 commit comments

Comments
 (0)