Skip to content

Commit f62a0ab

Browse files
Merge pull request #463 from SixLabors/js/license-keys
Update to latest refs and target frameworks
2 parents eadc8db + 30f2923 commit f62a0ab

23 files changed

+163
-105
lines changed

.editorconfig

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:war
104104
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
105105
dotnet_style_parentheses_in_other_operators = always_for_clarity:suggestion
106106
# Expression-level preferences
107-
dotnet_style_object_initializer = true:warning
108-
dotnet_style_collection_initializer = true:warning
107+
dotnet_style_object_initializer = true:error
108+
dotnet_style_collection_initializer = true:error
109109
dotnet_style_explicit_tuple_names = true:warning
110110
dotnet_style_prefer_inferred_tuple_names = true:warning
111111
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
@@ -135,9 +135,9 @@ csharp_style_prefer_null_check_over_type_check = true:warning
135135
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules
136136
[*.{cs,csx,cake}]
137137
# 'var' preferences
138-
csharp_style_var_for_built_in_types = false:warning
139-
csharp_style_var_when_type_is_apparent = false:warning
140-
csharp_style_var_elsewhere = false:warning
138+
csharp_style_var_for_built_in_types = false:error
139+
csharp_style_var_when_type_is_apparent = false:error
140+
csharp_style_var_elsewhere = false:error
141141
# Expression-bodied members
142142
csharp_style_expression_bodied_methods = true:warning
143143
csharp_style_expression_bodied_constructors = true:warning
@@ -160,7 +160,10 @@ csharp_style_pattern_local_over_anonymous_function = true:warning
160160
csharp_style_deconstructed_variable_declaration = true:warning
161161
csharp_style_prefer_index_operator = true:warning
162162
csharp_style_prefer_range_operator = true:warning
163-
csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
163+
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
@@ -172,6 +175,11 @@ dotnet_diagnostic.IDE0063.severity = suggestion
172175
csharp_using_directive_placement = outside_namespace:warning
173176
# Modifier preferences
174177
csharp_prefer_static_local_function = true:warning
178+
# Primary constructor preferences
179+
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
175183

176184
##########################################
177185
# Unnecessary Code Rules

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,13 @@
133133
*.pnm filter=lfs diff=lfs merge=lfs -text
134134
*.wbmp filter=lfs diff=lfs merge=lfs -text
135135
*.exr filter=lfs diff=lfs merge=lfs -text
136+
*.ico filter=lfs diff=lfs merge=lfs -text
137+
*.cur filter=lfs diff=lfs merge=lfs -text
138+
*.ani filter=lfs diff=lfs merge=lfs -text
139+
*.heic filter=lfs diff=lfs merge=lfs -text
140+
*.hif filter=lfs diff=lfs merge=lfs -text
141+
*.avif filter=lfs diff=lfs merge=lfs -text
142+
###############################################################################
143+
# Handle ICC files by git lfs
144+
###############################################################################
145+
*.icc filter=lfs diff=lfs merge=lfs -text

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

Lines changed: 67 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,49 +12,94 @@ on:
1212
- release/*
1313
types: [ labeled, opened, synchronize, reopened ]
1414
jobs:
15+
# Prime a single LFS cache and expose the exact key for the matrix
16+
WarmLFS:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
lfs_key: ${{ steps.expose-key.outputs.lfs_key }}
20+
steps:
21+
- name: Git Config
22+
shell: bash
23+
run: |
24+
git config --global core.autocrlf false
25+
git config --global core.longpaths true
26+
27+
- name: Git Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
submodules: recursive
32+
33+
# Deterministic list of LFS object IDs, then compute a portable key:
34+
# - `git lfs ls-files -l` lists all tracked LFS objects with their SHA-256
35+
# - `awk '{print $1}'` extracts just the SHA field
36+
# - `sort` sorts in byte order (hex hashes sort the same everywhere)
37+
# This ensures the file content is identical regardless of OS or locale
38+
- name: Git Create LFS id list
39+
shell: bash
40+
run: git lfs ls-files -l | awk '{print $1}' | sort > .lfs-assets-id
41+
42+
- name: Git Expose LFS cache key
43+
id: expose-key
44+
shell: bash
45+
env:
46+
LFS_KEY: lfs-${{ hashFiles('.lfs-assets-id') }}-v1
47+
run: echo "lfs_key=$LFS_KEY" >> "$GITHUB_OUTPUT"
48+
49+
- name: Git Setup LFS Cache
50+
uses: actions/cache@v4
51+
with:
52+
path: .git/lfs
53+
key: ${{ steps.expose-key.outputs.lfs_key }}
54+
55+
- name: Git Pull LFS
56+
shell: bash
57+
run: git lfs pull
58+
1559
Build:
60+
needs: WarmLFS
1661
strategy:
1762
matrix:
1863
isARM:
1964
- ${{ contains(github.event.pull_request.labels.*.name, 'arch:arm32') || contains(github.event.pull_request.labels.*.name, 'arch:arm64') }}
2065
options:
2166
- os: ubuntu-latest
22-
framework: net7.0
23-
sdk: 7.0.x
67+
framework: net9.0
68+
sdk: 9.0.x
2469
sdk-preview: true
2570
runtime: -x64
2671
codecov: false
2772
- os: macos-latest
28-
framework: net7.0
29-
sdk: 7.0.x
73+
framework: net9.0
74+
sdk: 9.0.x
3075
sdk-preview: true
3176
runtime: -x64
3277
codecov: false
3378
- os: windows-latest
34-
framework: net7.0
35-
sdk: 7.0.x
79+
framework: net9.0
80+
sdk: 9.0.x
3681
sdk-preview: true
3782
runtime: -x64
3883
codecov: false
3984
- os: buildjet-4vcpu-ubuntu-2204-arm
40-
framework: net7.0
41-
sdk: 7.0.x
85+
framework: net9.0
86+
sdk: 9.0.x
4287
sdk-preview: true
4388
runtime: -x64
4489
codecov: false
4590
- os: ubuntu-latest
46-
framework: net6.0
47-
sdk: 6.0.x
91+
framework: net8.0
92+
sdk: 8.0.x
4893
runtime: -x64
4994
codecov: false
5095
- os: macos-latest
51-
framework: net6.0
52-
sdk: 6.0.x
96+
framework: net8.0
97+
sdk: 8.0.x
5398
runtime: -x64
5499
codecov: false
55100
- os: windows-latest
56-
framework: net6.0
57-
sdk: 6.0.x
101+
framework: net8.0
102+
sdk: 8.0.x
58103
runtime: -x64
59104
codecov: true
60105
exclude:
@@ -66,8 +111,10 @@ jobs:
66111

67112
steps:
68113
- name: Install libgdi+, which is required for tests running on ubuntu
69-
if: ${{ matrix.options.os == 'buildjet-4vcpu-ubuntu-2204-arm' }}
70-
run: sudo apt-get -y install libgdiplus libgif-dev libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev
114+
if: ${{ contains(matrix.options.os, 'ubuntu') }}
115+
run: |
116+
sudo apt-get update
117+
sudo apt-get -y install libgdiplus libgif-dev libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev
71118
72119
- name: Git Config
73120
shell: bash
@@ -81,16 +128,12 @@ jobs:
81128
fetch-depth: 0
82129
submodules: recursive
83130

84-
# See https://github.com/actions/checkout/issues/165#issuecomment-657673315
85-
- name: Git Create LFS FileList
86-
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
87-
131+
# Use the warmed key from WarmLFS. Do not recompute or recreate .lfs-assets-id here.
88132
- name: Git Setup LFS Cache
89133
uses: actions/cache@v4
90-
id: lfs-cache
91134
with:
92135
path: .git/lfs
93-
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
136+
key: ${{ needs.WarmLFS.outputs.lfs_key }}
94137

95138
- name: Git Pull LFS
96139
run: git lfs pull
@@ -111,14 +154,14 @@ jobs:
111154
uses: actions/setup-dotnet@v4
112155
with:
113156
dotnet-version: |
114-
6.0.x
157+
8.0.x
115158
116159
- name: DotNet Setup Preview
117160
if: ${{ matrix.options.sdk-preview == true }}
118161
uses: actions/setup-dotnet@v4
119162
with:
120163
dotnet-version: |
121-
7.0.x
164+
9.0.x
122165
123166
- name: DotNet Build
124167
if: ${{ matrix.options.sdk-preview != true }}

samples/DrawWithImageSharp/DrawWithImageSharp.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
<Choose>
1414
<When Condition="$(SIXLABORS_TESTING_PREVIEW) == true">
1515
<PropertyGroup>
16-
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
16+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
1717
</PropertyGroup>
1818
</When>
1919
<Otherwise>
2020
<PropertyGroup>
21-
<TargetFrameworks>net6.0</TargetFrameworks>
21+
<TargetFrameworks>net8.0</TargetFrameworks>
2222
</PropertyGroup>
2323
</Otherwise>
2424
</Choose>

samples/ListFonts/ListFonts.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
<Choose>
88
<When Condition="$(SIXLABORS_TESTING_PREVIEW) == true">
99
<PropertyGroup>
10-
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
10+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
1111
</PropertyGroup>
1212
</When>
1313
<Otherwise>
1414
<PropertyGroup>
15-
<TargetFrameworks>net6.0</TargetFrameworks>
15+
<TargetFrameworks>net8.0</TargetFrameworks>
1616
</PropertyGroup>
1717
</Otherwise>
1818
</Choose>

src/SixLabors.Fonts/BigEndianBinaryReader.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ public int ReadOffset(int size)
377377
/// </summary>
378378
/// <param name="data">Buffer to read into.</param>
379379
/// <param name="size">Number of bytes to read.</param>
380+
/// <exception cref="EndOfStreamException">The end of the stream was reached before reading could complete.</exception>
380381
private void ReadInternal(byte[] data, int size)
381382
{
382383
int index = 0;

src/SixLabors.Fonts/FontCollection.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace SixLabors.Fonts;
1212
/// </summary>
1313
public sealed class FontCollection : IFontCollection, IFontMetricsCollection
1414
{
15-
private readonly HashSet<string> searchDirectories = new();
16-
private readonly HashSet<FontMetrics> metricsCollection = new();
15+
private readonly HashSet<string> searchDirectories = [];
16+
private readonly HashSet<FontMetrics> metricsCollection = [];
1717

1818
/// <summary>
1919
/// Initializes a new instance of the <see cref="FontCollection"/> class.
@@ -208,15 +208,15 @@ private FontFamily AddImpl(Stream stream, CultureInfo culture, out FontDescripti
208208
return ((IFontMetricsCollection)this).AddMetrics(metrics, culture);
209209
}
210210

211-
private IEnumerable<FontFamily> AddCollectionImpl(
211+
private HashSet<FontFamily> AddCollectionImpl(
212212
string path,
213213
CultureInfo culture,
214214
out IEnumerable<FontDescription> descriptions)
215215
{
216216
FileFontMetrics[] fonts = FileFontMetrics.LoadFontCollection(path);
217217

218218
FontDescription[] description = new FontDescription[fonts.Length];
219-
HashSet<FontFamily> families = new();
219+
HashSet<FontFamily> families = [];
220220
for (int i = 0; i < fonts.Length; i++)
221221
{
222222
description[i] = fonts[i].Description;
@@ -228,7 +228,7 @@ private IEnumerable<FontFamily> AddCollectionImpl(
228228
return families;
229229
}
230230

231-
private IEnumerable<FontFamily> AddCollectionImpl(
231+
private HashSet<FontFamily> AddCollectionImpl(
232232
Stream stream,
233233
CultureInfo culture,
234234
out IEnumerable<FontDescription> descriptions)
@@ -237,7 +237,7 @@ private IEnumerable<FontFamily> AddCollectionImpl(
237237
using BigEndianBinaryReader reader = new(stream, true);
238238
TtcHeader ttcHeader = TtcHeader.Read(reader);
239239
List<FontDescription> result = new((int)ttcHeader.NumFonts);
240-
HashSet<FontFamily> installedFamilies = new();
240+
HashSet<FontFamily> installedFamilies = [];
241241
for (int i = 0; i < ttcHeader.NumFonts; ++i)
242242
{
243243
stream.Position = startPos + ttcHeader.OffsetTable[i];
@@ -251,12 +251,11 @@ private IEnumerable<FontFamily> AddCollectionImpl(
251251
return installedFamilies;
252252
}
253253

254-
private IEnumerable<FontFamily> FamiliesByCultureImpl(CultureInfo culture)
255-
=> this.metricsCollection
254+
private FontFamily[] FamiliesByCultureImpl(CultureInfo culture)
255+
=> [.. this.metricsCollection
256256
.Select(x => x.Description.FontFamily(culture))
257257
.Distinct()
258-
.Select(x => new FontFamily(x, this, culture))
259-
.ToArray();
258+
.Select(x => new FontFamily(x, this, culture))];
260259

261260
private bool TryGetImpl(string name, CultureInfo culture, out FontFamily family)
262261
{

src/SixLabors.Fonts/IO/ZlibInflateStream.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,7 @@ public override void Flush()
122122
/// <inheritdoc/>
123123
public override int Read(byte[] buffer, int offset, int count)
124124
{
125-
if (this.deflateStream is null)
126-
{
127-
throw new ObjectDisposedException("inner stream");
128-
}
125+
ObjectDisposedException.ThrowIf(this.deflateStream is null, this.GetType());
129126

130127
// We don't check CRC on reading
131128
int read = this.deflateStream.Read(buffer, offset, count);
@@ -135,7 +132,7 @@ public override int Read(byte[] buffer, int offset, int count)
135132
this.crcRead = new byte[4];
136133
for (int i = 0; i < 4; i++)
137134
{
138-
// we dont really check/use this
135+
// we don't really check/use this
139136
this.crcRead[i] = (byte)this.rawStream.ReadByte();
140137
}
141138
}

src/SixLabors.Fonts/SixLabors.Fonts.csproj

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@
2626

2727
<PropertyGroup>
2828
<!--Bump to V2 prior to tagged release.-->
29-
<MinVerMinimumMajorMinor>2.0</MinVerMinimumMajorMinor>
29+
<MinVerMinimumMajorMinor>3.0</MinVerMinimumMajorMinor>
3030
</PropertyGroup>
3131

3232
<Choose>
3333
<When Condition="$(SIXLABORS_TESTING_PREVIEW) == true">
3434
<PropertyGroup>
35-
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
35+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
3636
<IsTrimmable>true</IsTrimmable>
3737
</PropertyGroup>
3838
</When>
3939
<Otherwise>
4040
<PropertyGroup>
41-
<TargetFrameworks>net6.0</TargetFrameworks>
41+
<TargetFrameworks>net8.0</TargetFrameworks>
4242
<IsTrimmable>true</IsTrimmable>
4343
</PropertyGroup>
4444
</Otherwise>
@@ -55,15 +55,5 @@
5555
<None Include="..\..\shared-infrastructure\branding\icons\fonts\sixlabors.fonts.128.png" Pack="true" PackagePath="" />
5656
</ItemGroup>
5757

58-
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETStandard' ">
59-
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.0" />
60-
</ItemGroup>
61-
62-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
63-
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
64-
<PackageReference Include="System.Buffers" Version="4.5.1" />
65-
<PackageReference Include="System.Memory" Version="4.5.4" />
66-
</ItemGroup>
67-
6858
<Import Project="..\..\shared-infrastructure\src\SharedInfrastructure\SharedInfrastructure.projitems" Label="Shared" />
6959
</Project>

0 commit comments

Comments
 (0)