Skip to content

Commit

Permalink
Add missing ConfigureAwait(false) and improve Skin ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
PotatoMaster101 committed Mar 21, 2023
1 parent 2e6a5de commit 41957dc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
8 changes: 5 additions & 3 deletions src/McSkin/McSkin.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyVersion>1.0.0</AssemblyVersion>
<AssemblyVersion>1.0.1</AssemblyVersion>
<Authors>PotatoMaster101</Authors>
<Copyright>Copyright (c) 2023 PotatoMaster101</Copyright>
<Description>Small library for playing with Minecraft Skins</Description>
<FileVersion>1.0.0</FileVersion>
<FileVersion>1.0.1</FileVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReleaseNotes>Initial release</PackageReleaseNotes>
<PackageReleaseNotes>- Added missing `ConfigureAwait`
- Added `isLegacy` to `Skin` constructor</PackageReleaseNotes>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageTags>Minecraft</PackageTags>
<RepositoryUrl>https://github.com/PotatoMaster101/McSkin</RepositoryUrl>
<TargetFramework>net7.0</TargetFramework>
<Title>McSkin</Title>
<Version>1.0.1</Version>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
3 changes: 2 additions & 1 deletion src/McSkin/Skin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class Skin : IDisposable
/// <summary>
/// Constructs a new instance of <see cref="Skin"/>.
/// </summary>
public Skin() : this(new Image<Rgba32>(StandardWidth, StandardHeight))
/// <param name="isLegacy">Whether the skin is a legacy skin.</param>
public Skin(bool isLegacy = false) : this(new Image<Rgba32>(StandardWidth, isLegacy ? LegacyHeight : StandardHeight))
{ }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/McSkin/SkinGrabber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class SkinGrabber
/// <exception cref="ArgumentException">Thrown when the skin image is invalid.</exception>
public static async Task<Skin> FromFile(string path, CancellationToken cancellationToken = default)
{
return new Skin(await Image.LoadAsync(path, cancellationToken));
return new Skin(await Image.LoadAsync(path, cancellationToken).ConfigureAwait(false));
}

/// <summary>
Expand Down
12 changes: 7 additions & 5 deletions test/McSkin.Test/SkinTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ namespace McSkin.Test;
/// </summary>
public class SkinTest
{
[Fact]
public void Ctor1_SetsMembers()
[Theory]
[InlineData(true)]
[InlineData(false)]
public void Ctor1_SetsMembers(bool isLegacy)
{
// act
using var skin = new Skin();
using var skin = new Skin(isLegacy);

// assert
Assert.False(skin.IsLegacy);
Assert.Equal(isLegacy, skin.IsLegacy);
Assert.Equal(Skin.StandardWidth, skin.SkinImage.Width);
Assert.Equal(Skin.StandardHeight, skin.SkinImage.Height);
Assert.Equal(isLegacy ? Skin.LegacyHeight : Skin.StandardHeight, skin.SkinImage.Height);
}

[Theory]
Expand Down

0 comments on commit 41957dc

Please sign in to comment.