Skip to content

Commit 2d7cf48

Browse files
Merge pull request #2812 from kasperk81/refactor
cleanup projects and environment variables
2 parents 123d5c3 + 62744c6 commit 2d7cf48

File tree

22 files changed

+217
-191
lines changed

22 files changed

+217
-191
lines changed

.github/workflows/build-and-test.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,31 @@ jobs:
1919
isARM:
2020
- ${{ contains(github.event.pull_request.labels.*.name, 'arch:arm32') || contains(github.event.pull_request.labels.*.name, 'arch:arm64') }}
2121
options:
22+
- os: ubuntu-latest
23+
framework: net9.0
24+
sdk: 9.0.x
25+
sdk-preview: true
26+
runtime: -x64
27+
codecov: false
28+
- os: macos-13 # macos-latest runs on arm64 runners where libgdiplus is unavailable
29+
framework: net9.0
30+
sdk: 9.0.x
31+
sdk-preview: true
32+
runtime: -x64
33+
codecov: false
34+
- os: windows-latest
35+
framework: net9.0
36+
sdk: 9.0.x
37+
sdk-preview: true
38+
runtime: -x64
39+
codecov: false
40+
- os: buildjet-4vcpu-ubuntu-2204-arm
41+
framework: net9.0
42+
sdk: 9.0.x
43+
sdk-preview: true
44+
runtime: -x64
45+
codecov: false
46+
2247
- os: ubuntu-latest
2348
framework: net8.0
2449
sdk: 8.0.x
@@ -100,7 +125,7 @@ jobs:
100125
uses: actions/setup-dotnet@v4
101126
with:
102127
dotnet-version: |
103-
8.0.x
128+
9.0.x
104129
105130
- name: DotNet Build
106131
if: ${{ matrix.options.sdk-preview != true }}

src/ImageSharp.ruleset

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<RuleSet Name="ImageSharp" ToolsVersion="17.0">
33
<Include Path="..\shared-infrastructure\sixlabors.ruleset" Action="Default" />
4+
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp.NetAnalyzers" RuleNamespace="Microsoft.CodeAnalysis.CSharp.NetAnalyzers">
5+
<Rule Id="CA2022" Action="Info" />
6+
</Rules>
47
</RuleSet>

src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using SixLabors.ImageSharp.Metadata.Profiles.Icc;
1717
using SixLabors.ImageSharp.Metadata.Profiles.Iptc;
1818
using SixLabors.ImageSharp.Metadata.Profiles.Xmp;
19-
using SixLabors.ImageSharp.PixelFormats;
2019

2120
namespace SixLabors.ImageSharp.Formats.Jpeg;
2221

@@ -1473,7 +1472,7 @@ private void ProcessStartOfScanMarker(BufferedReadStream stream, int remaining)
14731472

14741473
this.Frame.ComponentOrder[i / 2] = (byte)componentIndex;
14751474

1476-
IJpegComponent component = this.Frame.Components[componentIndex];
1475+
JpegComponent component = this.Frame.Components[componentIndex];
14771476

14781477
// 1 byte: Huffman table selectors.
14791478
// 4 bits - dc

src/ImageSharp/Formats/Webp/Lossy/Vp8Encoding.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -667,12 +667,12 @@ public static void EncPredChroma8(Span<byte> dst, Span<byte> left, Span<byte> to
667667

668668
// V block.
669669
dst = dst[8..];
670-
if (top != default)
670+
if (!top.IsEmpty)
671671
{
672672
top = top[8..];
673673
}
674674

675-
if (left != default)
675+
if (!left.IsEmpty)
676676
{
677677
left = left[16..];
678678
}
@@ -701,7 +701,7 @@ public static void EncPredLuma4(Span<byte> dst, Span<byte> top, int topOffset, S
701701

702702
private static void VerticalPred(Span<byte> dst, Span<byte> top, int size)
703703
{
704-
if (top != default)
704+
if (!top.IsEmpty)
705705
{
706706
for (int j = 0; j < size; j++)
707707
{
@@ -716,7 +716,7 @@ private static void VerticalPred(Span<byte> dst, Span<byte> top, int size)
716716

717717
public static void HorizontalPred(Span<byte> dst, Span<byte> left, int size)
718718
{
719-
if (left != default)
719+
if (!left.IsEmpty)
720720
{
721721
left = left[1..]; // in the reference implementation, left starts at - 1.
722722
for (int j = 0; j < size; j++)
@@ -732,9 +732,9 @@ public static void HorizontalPred(Span<byte> dst, Span<byte> left, int size)
732732

733733
public static void TrueMotion(Span<byte> dst, Span<byte> left, Span<byte> top, int size)
734734
{
735-
if (left != default)
735+
if (!left.IsEmpty)
736736
{
737-
if (top != default)
737+
if (!top.IsEmpty)
738738
{
739739
Span<byte> clip = Clip1.AsSpan(255 - left[0]); // left [0] instead of left[-1], original left starts at -1
740740
for (int y = 0; y < size; y++)
@@ -759,7 +759,7 @@ public static void TrueMotion(Span<byte> dst, Span<byte> left, Span<byte> top, i
759759
// is equivalent to VE prediction where you just copy the top samples.
760760
// Note that if top samples are not available, the default value is
761761
// then 129, and not 127 as in the VerticalPred case.
762-
if (top != default)
762+
if (!top.IsEmpty)
763763
{
764764
VerticalPred(dst, top, size);
765765
}
@@ -774,14 +774,14 @@ private static void DcMode(Span<byte> dst, Span<byte> left, Span<byte> top, int
774774
{
775775
int dc = 0;
776776
int j;
777-
if (top != default)
777+
if (!top.IsEmpty)
778778
{
779779
for (j = 0; j < size; j++)
780780
{
781781
dc += top[j];
782782
}
783783

784-
if (left != default)
784+
if (!left.IsEmpty)
785785
{
786786
// top and left present.
787787
left = left[1..]; // in the reference implementation, left starts at -1.
@@ -798,7 +798,7 @@ private static void DcMode(Span<byte> dst, Span<byte> left, Span<byte> top, int
798798

799799
dc = (dc + round) >> shift;
800800
}
801-
else if (left != default)
801+
else if (!left.IsEmpty)
802802
{
803803
// left but no top.
804804
left = left[1..]; // in the reference implementation, left starts at -1.

src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private static void UpSampleScalar(Span<byte> topY, Span<byte> bottomY, Span<byt
4848
uint uv0 = ((3 * tluv) + luv + 0x00020002u) >> 2;
4949
YuvToBgr(topY[0], (int)(uv0 & 0xff), (int)(uv0 >> 16), topDst);
5050

51-
if (bottomY != default)
51+
if (!bottomY.IsEmpty)
5252
{
5353
uv0 = ((3 * luv) + tluv + 0x00020002u) >> 2;
5454
YuvToBgr(bottomY[0], (int)uv0 & 0xff, (int)(uv0 >> 16), bottomDst);
@@ -69,7 +69,7 @@ private static void UpSampleScalar(Span<byte> topY, Span<byte> bottomY, Span<byt
6969
YuvToBgr(topY[xMul2 - 1], (int)(uv0 & 0xff), (int)(uv0 >> 16), topDst[((xMul2 - 1) * xStep)..]);
7070
YuvToBgr(topY[xMul2 - 0], (int)(uv1 & 0xff), (int)(uv1 >> 16), topDst[((xMul2 - 0) * xStep)..]);
7171

72-
if (bottomY != default)
72+
if (!bottomY.IsEmpty)
7373
{
7474
uv0 = (diag03 + luv) >> 1;
7575
uv1 = (diag12 + uv) >> 1;
@@ -85,7 +85,7 @@ private static void UpSampleScalar(Span<byte> topY, Span<byte> bottomY, Span<byt
8585
{
8686
uv0 = ((3 * tluv) + luv + 0x00020002u) >> 2;
8787
YuvToBgr(topY[len - 1], (int)(uv0 & 0xff), (int)(uv0 >> 16), topDst[((len - 1) * xStep)..]);
88-
if (bottomY != default)
88+
if (!bottomY.IsEmpty)
8989
{
9090
uv0 = ((3 * luv) + tluv + 0x00020002u) >> 2;
9191
YuvToBgr(bottomY[len - 1], (int)(uv0 & 0xff), (int)(uv0 >> 16), bottomDst[((len - 1) * xStep)..]);
@@ -120,7 +120,7 @@ private static void UpSampleSse41(Span<byte> topY, Span<byte> bottomY, Span<byte
120120
int u0t = (topU[0] + uDiag) >> 1;
121121
int v0t = (topV[0] + vDiag) >> 1;
122122
YuvToBgr(topY[0], u0t, v0t, topDst);
123-
if (bottomY != default)
123+
if (!bottomY.IsEmpty)
124124
{
125125
int u0b = (curU[0] + uDiag) >> 1;
126126
int v0b = (curV[0] + vDiag) >> 1;
@@ -134,7 +134,7 @@ private static void UpSampleSse41(Span<byte> topY, Span<byte> bottomY, Span<byte
134134
ref byte topVRef = ref MemoryMarshal.GetReference(topV);
135135
ref byte curURef = ref MemoryMarshal.GetReference(curU);
136136
ref byte curVRef = ref MemoryMarshal.GetReference(curV);
137-
if (bottomY != default)
137+
if (!bottomY.IsEmpty)
138138
{
139139
for (pos = 1, uvPos = 0; pos + 32 + 1 <= len; pos += 32, uvPos += 16)
140140
{
@@ -160,12 +160,12 @@ private static void UpSampleSse41(Span<byte> topY, Span<byte> bottomY, Span<byte
160160
Span<byte> tmpTopDst = ru[(4 * 32)..];
161161
Span<byte> tmpBottomDst = tmpTopDst[(4 * 32)..];
162162
Span<byte> tmpTop = tmpBottomDst[(4 * 32)..];
163-
Span<byte> tmpBottom = (bottomY == default) ? null : tmpTop[32..];
163+
Span<byte> tmpBottom = bottomY.IsEmpty ? null : tmpTop[32..];
164164
UpSampleLastBlock(topU[uvPos..], curU[uvPos..], leftOver, ru);
165165
UpSampleLastBlock(topV[uvPos..], curV[uvPos..], leftOver, rv);
166166

167167
topY[pos..len].CopyTo(tmpTop);
168-
if (bottomY != default)
168+
if (!bottomY.IsEmpty)
169169
{
170170
bottomY[pos..len].CopyTo(tmpBottom);
171171
ConvertYuvToBgrWithBottomYSse41(tmpTop, tmpBottom, tmpTopDst, tmpBottomDst, ru, rv, 0, xStep);
@@ -176,7 +176,7 @@ private static void UpSampleSse41(Span<byte> topY, Span<byte> bottomY, Span<byte
176176
}
177177

178178
tmpTopDst[..((len - pos) * xStep)].CopyTo(topDst[(pos * xStep)..]);
179-
if (bottomY != default)
179+
if (!bottomY.IsEmpty)
180180
{
181181
tmpBottomDst[..((len - pos) * xStep)].CopyTo(bottomDst[(pos * xStep)..]);
182182
}

src/ImageSharp/ImageSharp.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<PackageTags>Image Resize Crop Gif Jpg Jpeg Bitmap Pbm Png Tga Tiff WebP NetCore</PackageTags>
1414
<Description>A new, fully featured, fully managed, cross-platform, 2D graphics API for .NET</Description>
1515
<Configurations>Debug;Release</Configurations>
16+
<IsTrimmable>true</IsTrimmable>
1617
</PropertyGroup>
1718

1819
<!-- This enables the nullable analysis and treats all nullable warnings as error-->
@@ -29,14 +30,12 @@
2930
<Choose>
3031
<When Condition="$(SIXLABORS_TESTING_PREVIEW) == true">
3132
<PropertyGroup>
32-
<TargetFrameworks>net8.0</TargetFrameworks>
33-
<IsTrimmable>true</IsTrimmable>
33+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
3434
</PropertyGroup>
3535
</When>
3636
<Otherwise>
3737
<PropertyGroup>
3838
<TargetFrameworks>net8.0</TargetFrameworks>
39-
<IsTrimmable>true</IsTrimmable>
4039
</PropertyGroup>
4140
</Otherwise>
4241
</Choose>

src/ImageSharp/Image{TPixel}.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ internal Image(Configuration configuration, ImageMetadata metadata, IEnumerable<
160160
/// <summary>
161161
/// Gets the root frame.
162162
/// </summary>
163-
private IPixelSource<TPixel> PixelSourceUnsafe => this.frames.RootFrameUnsafe;
163+
private ImageFrame<TPixel> PixelSourceUnsafe => this.frames.RootFrameUnsafe;
164164

165165
/// <summary>
166166
/// Gets or sets the pixel at the specified position.
@@ -324,7 +324,7 @@ public bool DangerousTryGetSinglePixelMemory(out Memory<TPixel> memory)
324324
}
325325

326326
/// <summary>
327-
/// Clones the current image
327+
/// Clones the current image.
328328
/// </summary>
329329
/// <returns>Returns a new image with all the same metadata as the original.</returns>
330330
public Image<TPixel> Clone() => this.Clone(this.Configuration);

src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private static bool HasValue(IExifValue exifValue)
241241
return true;
242242
}
243243

244-
private static uint GetLength(IList<IExifValue> values)
244+
private static uint GetLength(List<IExifValue> values)
245245
{
246246
if (values.Count == 0)
247247
{

src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public IccChromaticityTagDataEntry ReadChromaticityTagDataEntry()
144144
ushort channelCount = this.ReadUInt16();
145145
var colorant = (IccColorantEncoding)this.ReadUInt16();
146146

147-
if (Enum.IsDefined(typeof(IccColorantEncoding), colorant) && colorant != IccColorantEncoding.Unknown)
147+
if (Enum.IsDefined(colorant) && colorant != IccColorantEncoding.Unknown)
148148
{
149149
// The type is known and so are the values (they are constant)
150150
// channelCount should always be 3 but it doesn't really matter if it's not

src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ public bool CheckIsValid()
155155
}
156156

157157
return arrayValid &&
158-
Enum.IsDefined(typeof(IccColorSpaceType), this.Header.DataColorSpace) &&
159-
Enum.IsDefined(typeof(IccColorSpaceType), this.Header.ProfileConnectionSpace) &&
160-
Enum.IsDefined(typeof(IccRenderingIntent), this.Header.RenderingIntent) &&
158+
Enum.IsDefined(this.Header.DataColorSpace) &&
159+
Enum.IsDefined(this.Header.ProfileConnectionSpace) &&
160+
Enum.IsDefined(this.Header.RenderingIntent) &&
161161
this.Header.Size is >= minSize and < maxSize;
162162
}
163163

0 commit comments

Comments
 (0)