diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 19cfb5d7d0..1e4aaaa85c 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -52,31 +52,14 @@ jobs: git fetch --prune --unshallow git submodule -q update --init --recursive - - name: Fetch Tags for GitVersion - run: | - git fetch --tags - - - name: Fetch master for GitVersion - if: github.ref != 'refs/heads/master' - run: git branch --create-reflog master origin/master - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.9.3 - with: - versionSpec: "5.3.x" - - - name: Use GitVersion - id: gitversion # step id used as reference for output values - uses: gittools/actions/gitversion/execute@v0.9.3 - - name: Setup DotNet SDK uses: actions/setup-dotnet@v1 with: - dotnet-version: "3.1.101" + dotnet-version: "3.1.x" - name: Build shell: pwsh - run: ./ci-build.ps1 "${{steps.gitversion.outputs.nuGetVersion}}" "${{matrix.options.framework}}" + run: ./ci-build.ps1 "${{matrix.options.framework}}" - name: Test shell: pwsh @@ -112,33 +95,18 @@ jobs: git fetch --prune --unshallow git submodule -q update --init --recursive - - name: Fetch Tags for GitVersion - run: | - git fetch --tags - - - name: Fetch master for GitVersion - if: github.ref != 'refs/heads/master' - run: git branch --create-reflog master origin/master - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.9.3 - with: - versionSpec: "5.3.x" - - - name: Use GitVersion - id: gitversion # step id used as reference for output values - uses: gittools/actions/gitversion/execute@v0.9.3 - - name: Setup DotNet SDK uses: actions/setup-dotnet@v1 with: - dotnet-version: "3.1.101" + dotnet-version: "3.1.x" - name: Pack shell: pwsh - run: ./ci-pack.ps1 "${{steps.gitversion.outputs.nuGetVersion}}" + run: ./ci-pack.ps1 - name: Publish to MyGet shell: pwsh - run: nuget.exe push .\artifacts\*.nupkg ${{secrets.MYGET_TOKEN}} -Source https://www.myget.org/F/sixlabors/api/v2/package + run: | + nuget.exe push .\artifacts\*.nupkg ${{secrets.MYGET_TOKEN}} -Source https://www.myget.org/F/sixlabors/api/v2/package + nuget.exe push .\artifacts\*.snupkg ${{secrets.MYGET_TOKEN}} -Source https://www.myget.org/F/sixlabors/api/v3/index.json # TODO: If github.ref starts with 'refs/tags' then it was tag push and we can optionally push out package to nuget.org diff --git a/Directory.Build.props b/Directory.Build.props index 2afb2eaa1b..14c9da79d6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -25,7 +25,6 @@ full disable true - false true @@ -93,6 +92,12 @@ + + + v + normal + + Copyright © Six Labors diff --git a/Directory.Build.targets b/Directory.Build.targets index 0f02d7e320..cc14bbdbf7 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -23,6 +23,8 @@ + + diff --git a/GitVersion.yml b/GitVersion.yml deleted file mode 100644 index f2a251c55a..0000000000 --- a/GitVersion.yml +++ /dev/null @@ -1,7 +0,0 @@ -continuous-delivery-fallback-tag: ci -branches: - master: - tag: unstable - mode: ContinuousDeployment - pull-request: - tag: pr diff --git a/ci-build.ps1 b/ci-build.ps1 index 17c6e6603b..d45af6ff4d 100644 --- a/ci-build.ps1 +++ b/ci-build.ps1 @@ -1,7 +1,5 @@ param( - [Parameter(Mandatory, Position = 0)] - [string]$version, - [Parameter(Mandatory = $true, Position = 1)] + [Parameter(Mandatory = $true, Position = 0)] [string]$targetFramework ) @@ -10,4 +8,4 @@ dotnet clean -c Release $repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY" # Building for a specific framework. -dotnet build -c Release -f $targetFramework /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl +dotnet build -c Release -f $targetFramework /p:RepositoryUrl=$repositoryUrl diff --git a/ci-pack.ps1 b/ci-pack.ps1 index a4e846db95..09f45347ef 100644 --- a/ci-pack.ps1 +++ b/ci-pack.ps1 @@ -1,11 +1,6 @@ -param( - [Parameter(Mandatory, Position = 0)] - [string]$version -) - dotnet clean -c Release $repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY" # Building for packing and publishing. -dotnet pack -c Release --output "$PSScriptRoot/artifacts" /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl +dotnet pack -c Release --output "$PSScriptRoot/artifacts" /p:RepositoryUrl=$repositoryUrl diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 87482af6f1..bdf1ff49cb 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -26,6 +26,19 @@ true + + + true + true + + + + true + + true + snupkg + + diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index d7171aa0f6..1eeedecd2c 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -20,6 +20,17 @@ $(IntermediateOutputPath)$(MSBuildProjectName).InternalsVisibleTo$(DefaultLanguageSourceExtension) + + + + + <_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/> + + + false @@ -51,7 +62,7 @@ - + diff --git a/src/ImageSharp/Image.FromFile.cs b/src/ImageSharp/Image.FromFile.cs index 3237ea7430..a078f2db98 100644 --- a/src/ImageSharp/Image.FromFile.cs +++ b/src/ImageSharp/Image.FromFile.cs @@ -3,6 +3,7 @@ using System; using System.IO; +using System.Threading.Tasks; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.PixelFormats; @@ -89,6 +90,17 @@ namespace SixLabors.ImageSharp public static Image Load(string path) => Load(Configuration.Default, path); + /// + /// Create a new instance of the class from the given file. + /// + /// The file path to the image. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// A representing the asynchronous operation. + public static Task LoadAsync(string path) + => LoadAsync(Configuration.Default, path); + /// /// Create a new instance of the class from the given file. /// @@ -114,6 +126,25 @@ namespace SixLabors.ImageSharp public static Image Load(Configuration configuration, string path) => Load(configuration, path, out _); + /// + /// Create a new instance of the class from the given file. + /// + /// The configuration for the decoder. + /// The file path to the image. + /// The configuration is null. + /// The path is null. + /// Image format not recognised. + /// Image contains invalid content. + /// A representing the asynchronous operation. + public static async Task LoadAsync(Configuration configuration, string path) + { + using (Stream stream = configuration.FileSystem.OpenRead(path)) + { + (Image img, _) = await LoadWithFormatAsync(configuration, stream).ConfigureAwait(false); + return img; + } + } + /// /// Create a new instance of the class from the given file. /// @@ -137,6 +168,29 @@ namespace SixLabors.ImageSharp } } + /// + /// Create a new instance of the class from the given file. + /// + /// The Configuration. + /// The file path to the image. + /// The decoder. + /// The configuration is null. + /// The path is null. + /// The decoder is null. + /// Image format not recognised. + /// Image contains invalid content. + /// A representing the asynchronous operation. + public static Task LoadAsync(Configuration configuration, string path, IImageDecoder decoder) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.NotNull(path, nameof(path)); + + using (Stream stream = configuration.FileSystem.OpenRead(path)) + { + return LoadAsync(configuration, stream, decoder); + } + } + /// /// Create a new instance of the class from the given file. /// diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index baf4a2ce19..64a496141f 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -19,6 +19,11 @@ SixLabors.ImageSharp + + + + + diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 6428ef32ff..b2d2b1c319 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -28,7 +28,7 @@ - + diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs index 5f7137e151..77e5679f64 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using System; - +using System.Threading.Tasks; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.PixelFormats; @@ -40,6 +40,24 @@ namespace SixLabors.ImageSharp.Tests } } + [Fact] + public async Task Path_Agnostic_Async() + { + using (var img = await Image.LoadAsync(this.Path)) + { + VerifyDecodedImage(img); + } + } + + [Fact] + public async Task Path_Agnostic_Configuration_Async() + { + using (var img = await Image.LoadAsync(Configuration.Default, this.Path)) + { + VerifyDecodedImage(img); + } + } + [Fact] public void Path_Decoder_Specific() { @@ -58,6 +76,15 @@ namespace SixLabors.ImageSharp.Tests } } + [Fact] + public async Task Path_Decoder_Agnostic_Async() + { + using (var img = await Image.LoadAsync(Configuration.Default, this.Path, new BmpDecoder())) + { + VerifyDecodedImage(img); + } + } + [Fact] public void Path_OutFormat_Specific() {