Skip to content

Commit 343b609

Browse files
Merge branch 'master' into DiscoverDecoderAsync
2 parents b466c5b + 4a48355 commit 343b609

File tree

12 files changed

+131
-60
lines changed

12 files changed

+131
-60
lines changed

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

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,14 @@ jobs:
5252
git fetch --prune --unshallow
5353
git submodule -q update --init --recursive
5454
55-
- name: Fetch Tags for GitVersion
56-
run: |
57-
git fetch --tags
58-
59-
- name: Fetch master for GitVersion
60-
if: github.ref != 'refs/heads/master'
61-
run: git branch --create-reflog master origin/master
62-
63-
- name: Install GitVersion
64-
uses: gittools/actions/gitversion/setup@v0.9.3
65-
with:
66-
versionSpec: "5.3.x"
67-
68-
- name: Use GitVersion
69-
id: gitversion # step id used as reference for output values
70-
uses: gittools/actions/gitversion/execute@v0.9.3
71-
7255
- name: Setup DotNet SDK
7356
uses: actions/setup-dotnet@v1
7457
with:
75-
dotnet-version: "3.1.101"
58+
dotnet-version: "3.1.x"
7659

7760
- name: Build
7861
shell: pwsh
79-
run: ./ci-build.ps1 "${{steps.gitversion.outputs.nuGetVersion}}" "${{matrix.options.framework}}"
62+
run: ./ci-build.ps1 "${{matrix.options.framework}}"
8063

8164
- name: Test
8265
shell: pwsh
@@ -112,33 +95,18 @@ jobs:
11295
git fetch --prune --unshallow
11396
git submodule -q update --init --recursive
11497
115-
- name: Fetch Tags for GitVersion
116-
run: |
117-
git fetch --tags
118-
119-
- name: Fetch master for GitVersion
120-
if: github.ref != 'refs/heads/master'
121-
run: git branch --create-reflog master origin/master
122-
123-
- name: Install GitVersion
124-
uses: gittools/actions/gitversion/setup@v0.9.3
125-
with:
126-
versionSpec: "5.3.x"
127-
128-
- name: Use GitVersion
129-
id: gitversion # step id used as reference for output values
130-
uses: gittools/actions/gitversion/execute@v0.9.3
131-
13298
- name: Setup DotNet SDK
13399
uses: actions/setup-dotnet@v1
134100
with:
135-
dotnet-version: "3.1.101"
101+
dotnet-version: "3.1.x"
136102

137103
- name: Pack
138104
shell: pwsh
139-
run: ./ci-pack.ps1 "${{steps.gitversion.outputs.nuGetVersion}}"
105+
run: ./ci-pack.ps1
140106

141107
- name: Publish to MyGet
142108
shell: pwsh
143-
run: nuget.exe push .\artifacts\*.nupkg ${{secrets.MYGET_TOKEN}} -Source https://www.myget.org/F/sixlabors/api/v2/package
109+
run: |
110+
nuget.exe push .\artifacts\*.nupkg ${{secrets.MYGET_TOKEN}} -Source https://www.myget.org/F/sixlabors/api/v2/package
111+
nuget.exe push .\artifacts\*.snupkg ${{secrets.MYGET_TOKEN}} -Source https://www.myget.org/F/sixlabors/api/v3/index.json
144112
# TODO: If github.ref starts with 'refs/tags' then it was tag push and we can optionally push out package to nuget.org

Directory.Build.props

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
<DebugType Condition="'$(codecov)' != ''">full</DebugType>
2626
<NullableContextOptions>disable</NullableContextOptions>
2727
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
28-
<SignAssembly>false</SignAssembly>
2928
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
3029
</PropertyGroup>
3130

@@ -93,6 +92,12 @@
9392
<VersionSuffix></VersionSuffix>
9493
</PropertyGroup>
9594

95+
<!--MinVer Properties for versioning-->
96+
<PropertyGroup>
97+
<MinVerTagPrefix>v</MinVerTagPrefix>
98+
<MinVerVerbosity>normal</MinVerVerbosity>
99+
</PropertyGroup>
100+
96101
<!-- Default settings that are otherwise undefined -->
97102
<PropertyGroup>
98103
<Copyright>Copyright © Six Labors</Copyright>

Directory.Build.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
<PackageReference Update="StyleCop.Analyzers" PrivateAssets="All" Version="1.1.118" />
2424

2525
<!--Src Dependencies-->
26+
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
27+
<PackageReference Update="MinVer" PrivateAssets="All" Version="2.3.0" />
2628
<PackageReference Update="System.Buffers" Version="4.5.0" />
2729
<PackageReference Update="System.IO.Compression" Version="4.3.0" />
2830
<PackageReference Update="System.IO.UnmanagedMemoryStream" Version="4.3.0" />

GitVersion.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

ci-build.ps1

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
param(
2-
[Parameter(Mandatory, Position = 0)]
3-
[string]$version,
4-
[Parameter(Mandatory = $true, Position = 1)]
2+
[Parameter(Mandatory = $true, Position = 0)]
53
[string]$targetFramework
64
)
75

@@ -10,4 +8,4 @@ dotnet clean -c Release
108
$repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY"
119

1210
# Building for a specific framework.
13-
dotnet build -c Release -f $targetFramework /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl
11+
dotnet build -c Release -f $targetFramework /p:RepositoryUrl=$repositoryUrl

ci-pack.ps1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
param(
2-
[Parameter(Mandatory, Position = 0)]
3-
[string]$version
4-
)
5-
61
dotnet clean -c Release
72

83
$repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY"
94

105
# Building for packing and publishing.
11-
dotnet pack -c Release --output "$PSScriptRoot/artifacts" /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl
6+
dotnet pack -c Release --output "$PSScriptRoot/artifacts" /p:RepositoryUrl=$repositoryUrl

src/Directory.Build.props

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@
2626
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2727
</PropertyGroup>
2828

29+
<!--Add deterministic builds in CI-->
30+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
31+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
32+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
33+
</PropertyGroup>
34+
35+
<PropertyGroup>
36+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
37+
<!-- Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
38+
<IncludeSymbols>true</IncludeSymbols>
39+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
40+
</PropertyGroup>
41+
2942
<ItemGroup>
3043
<!-- DynamicProxyGenAssembly2 is needed so Moq can use our internals -->
3144
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7" />

src/Directory.Build.targets

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@
2020
<GeneratedInternalsVisibleToFile Condition="'$(GeneratedInternalsVisibleToFile)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).InternalsVisibleTo$(DefaultLanguageSourceExtension)</GeneratedInternalsVisibleToFile>
2121
</PropertyGroup>
2222

23+
<!-- Workaround for running Coverlet with Determenistic builds -->
24+
<!-- https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/DeterministicBuild.md -->
25+
<Target Name="CoverletGetPathMap"
26+
DependsOnTargets="InitializeSourceRootMappedPaths"
27+
Returns="@(_LocalTopLevelSourceRoot)"
28+
Condition="'$(DeterministicSourcePaths)' == 'true'">
29+
<ItemGroup>
30+
<_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/>
31+
</ItemGroup>
32+
</Target>
33+
2334
<ItemDefinitionGroup>
2435
<InternalsVisibleTo>
2536
<Visible>false</Visible>
@@ -51,7 +62,7 @@
5162
<!-- Empty target so that `dotnet test` will work on the solution -->
5263
<!-- https://github.com/Microsoft/vstest/issues/411 -->
5364
<Target Name="VSTest" Condition="'$(IsTestProject)' == 'true'"/>
54-
65+
5566
<ItemGroup>
5667
<!--Shared config files that have to exist at root level.-->
5768
<ConfigFilesToCopy Include="..\..\shared-infrastructure\.editorconfig;..\..\shared-infrastructure\.gitattributes" />

src/ImageSharp/Image.FromFile.cs

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

44
using System;
55
using System.IO;
6+
using System.Threading.Tasks;
67
using SixLabors.ImageSharp.Formats;
78
using SixLabors.ImageSharp.PixelFormats;
89

@@ -89,6 +90,17 @@ public static IImageInfo Identify(Configuration configuration, string filePath,
8990
public static Image Load(string path)
9091
=> Load(Configuration.Default, path);
9192

93+
/// <summary>
94+
/// Create a new instance of the <see cref="Image"/> class from the given file.
95+
/// </summary>
96+
/// <param name="path">The file path to the image.</param>
97+
/// <exception cref="NotSupportedException">
98+
/// Thrown if the stream is not readable nor seekable.
99+
/// </exception>
100+
/// <returns>A <see cref="Task{Image}"/> representing the asynchronous operation.</returns>
101+
public static Task<Image> LoadAsync(string path)
102+
=> LoadAsync(Configuration.Default, path);
103+
92104
/// <summary>
93105
/// Create a new instance of the <see cref="Image"/> class from the given file.
94106
/// </summary>
@@ -114,6 +126,25 @@ public static Image Load(string path, out IImageFormat format)
114126
public static Image Load(Configuration configuration, string path)
115127
=> Load(configuration, path, out _);
116128

129+
/// <summary>
130+
/// Create a new instance of the <see cref="Image"/> class from the given file.
131+
/// </summary>
132+
/// <param name="configuration">The configuration for the decoder.</param>
133+
/// <param name="path">The file path to the image.</param>
134+
/// <exception cref="ArgumentNullException">The configuration is null.</exception>
135+
/// <exception cref="ArgumentNullException">The path is null.</exception>
136+
/// <exception cref="UnknownImageFormatException">Image format not recognised.</exception>
137+
/// <exception cref="InvalidImageContentException">Image contains invalid content.</exception>
138+
/// <returns>A <see cref="Task{Image}"/> representing the asynchronous operation.</returns>
139+
public static async Task<Image> LoadAsync(Configuration configuration, string path)
140+
{
141+
using (Stream stream = configuration.FileSystem.OpenRead(path))
142+
{
143+
(Image img, _) = await LoadWithFormatAsync(configuration, stream).ConfigureAwait(false);
144+
return img;
145+
}
146+
}
147+
117148
/// <summary>
118149
/// Create a new instance of the <see cref="Image"/> class from the given file.
119150
/// </summary>
@@ -137,6 +168,29 @@ public static Image Load(Configuration configuration, string path, IImageDecoder
137168
}
138169
}
139170

171+
/// <summary>
172+
/// Create a new instance of the <see cref="Image"/> class from the given file.
173+
/// </summary>
174+
/// <param name="configuration">The Configuration.</param>
175+
/// <param name="path">The file path to the image.</param>
176+
/// <param name="decoder">The decoder.</param>
177+
/// <exception cref="ArgumentNullException">The configuration is null.</exception>
178+
/// <exception cref="ArgumentNullException">The path is null.</exception>
179+
/// <exception cref="ArgumentNullException">The decoder is null.</exception>
180+
/// <exception cref="UnknownImageFormatException">Image format not recognised.</exception>
181+
/// <exception cref="InvalidImageContentException">Image contains invalid content.</exception>
182+
/// <returns>A <see cref="Task{Image}"/> representing the asynchronous operation.</returns>
183+
public static Task<Image> LoadAsync(Configuration configuration, string path, IImageDecoder decoder)
184+
{
185+
Guard.NotNull(configuration, nameof(configuration));
186+
Guard.NotNull(path, nameof(path));
187+
188+
using (Stream stream = configuration.FileSystem.OpenRead(path))
189+
{
190+
return LoadAsync(configuration, stream, decoder);
191+
}
192+
}
193+
140194
/// <summary>
141195
/// Create a new instance of the <see cref="Image"/> class from the given file.
142196
/// </summary>

src/ImageSharp/ImageSharp.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
<RootNamespace>SixLabors.ImageSharp</RootNamespace>
2020
</PropertyGroup>
2121

22+
<ItemGroup>
23+
<PackageReference Include="Microsoft.SourceLink.GitHub"/>
24+
<PackageReference Include="MinVer" PrivateAssets="All" />
25+
</ItemGroup>
26+
2227
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
2328
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" />
2429
</ItemGroup>

0 commit comments

Comments
 (0)