Skip to content

net6.0 support and fixes #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions src/ByteSizeLib.Tests/ArithmeticMethods.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using Xunit;
using Xunit;

namespace ByteSizeLib.Tests
{
Expand Down Expand Up @@ -42,17 +41,6 @@ public void SubtractMethod()
Assert.Equal(2, size.Bytes);
}

[Fact]
public void IncrementOperator()
{
var size = ByteSize.FromBytes(2);
size++;

Assert.Equal(24, size.Bits);
Assert.Equal(3, size.Bytes);
}


[Fact]
public void MinusOperatorUnary()
{
Expand All @@ -73,16 +61,6 @@ public void MinusOperatorBinary()
Assert.Equal(2, size.Bytes);
}

[Fact]
public void DecrementOperator()
{
var size = ByteSize.FromBytes(2);
size--;

Assert.Equal(8, size.Bits);
Assert.Equal(1, size.Bytes);
}

[Fact]
public void MultiplyOperator()
{
Expand Down
8 changes: 6 additions & 2 deletions src/ByteSizeLib.Tests/ByteSizeLib.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>

<SignAssembly>True</SignAssembly>

<AssemblyOriginatorKeyFile>bytetests.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../ByteSizeLib/ByteSizeLib.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
10 changes: 3 additions & 7 deletions src/ByteSizeLib.Tests/ByteSizeTypeConverterTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using System.Collections.Generic;
using System.ComponentModel;
using Xunit;

namespace ByteSizeLib.Tests
{
Expand All @@ -16,7 +12,7 @@ public void ConvertsToString()
var converter = TypeDescriptor.GetConverter(typeof(ByteSize));
Assert.NotNull(converter);
var bs = ByteSize.FromBytes(1024);
var actual =converter.ConvertToString(bs);
var actual = converter.ConvertToString(bs);
var expected = "1 KiB";
Assert.Equal(expected, actual);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ByteSizeLib.Tests/Decimal/ParsingMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void ParseCultureNumberSeparator()
var result = ByteSize.Parse(val);

Assert.Equal(expected, result);

CultureInfo.CurrentCulture = new CultureInfo("en-US");
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ByteSizeLib.Tests/ToStringMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void StringInterpolationWithFormat()
var result = $"{b:0.0}";

// Assert
Assert.Equal("12.0 B", result);
Assert.Equal($"{12.0:0.0} B", result);
}

[Fact]
Expand All @@ -203,7 +203,7 @@ public void StringInterpolationDefaultFormat()
var result = $"{b}";

// Assert
Assert.Equal("1.12 KB", result);
Assert.Equal($"{1.12} KB", result);
}
}
}
Binary file added src/ByteSizeLib.Tests/bytetests.snk
Binary file not shown.
19 changes: 19 additions & 0 deletions src/ByteSizeLib/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// In SDK-style projects such as this one, several assembly attributes that were historically
// defined in this file are now automatically added during build and populated with
// values defined in project properties. For details of which attributes are included
// and how to customise this process see: https://aka.ms/assembly-info-properties


// Setting ComVisible to false makes the types in this assembly not visible to COM
// components. If you need to access a type in this assembly from COM, set the ComVisible
// attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM.

[assembly: Guid("c5d64482-f2bc-41b0-b6c1-0ed7a24f338d")]
[assembly: InternalsVisibleTo("ByteSizeLib.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001009dc5b9fd3ac54829a66893b2e69fa3bed6a91b4cc788c6a8a87f48e94210eb6728bac2cf673cc29f5e0d422c45970064e571af4b2b4f6c564fded8ab671f3a3c40c9667caa04c659c4d2aeef867eb75528db421ad5741b363cb03bba3bd28785a1a68edd70d86b653917c476b84145c4690da184fb58f2419f82f51e1ac14fcc")]
22 changes: 11 additions & 11 deletions src/ByteSizeLib/BinaryByteSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,43 @@ public partial struct ByteSize

/// <summary>Number of bytes in 1 mebibyte.</summary>
public const long BytesInMebiByte = 1_048_576;

/// <summary>Number of bytes in 1 gibibyte.</summary>
public const long BytesInGibiByte = 1_073_741_824;

/// <summary>Number of bytes in 1 tebibyte.</summary>
public const long BytesInTebiByte = 1_099_511_627_776;

/// <summary>Number of bytes in 1 pebibyte.</summary>
public const long BytesInPebiByte = 1_125_899_906_842_624;

/// <summary>Kibibyte symbol.</summary>
public const string KibiByteSymbol = "KiB";

/// <summary>Mebibyte symbol.</summary>
public const string MebiByteSymbol = "MiB";

/// <summary>Gibibyte symbol.</summary>
public const string GibiByteSymbol = "GiB";

/// <summary>Tebibyte symbol.</summary>
public const string TebiByteSymbol = "TiB";

/// <summary>Pebibyte symbol.</summary>
public const string PebiByteSymbol = "PiB";

/// <summary>Gets the number of kibibytes represented by this object.</summary>
public double KibiBytes => Bytes / BytesInKibiByte;

/// <summary>Gets the number of mebibytes represented by this object.</summary>
public double MebiBytes => Bytes / BytesInMebiByte;

/// <summary>Gets the number of gibibytes represented by this object.</summary>
public double GibiBytes => Bytes / BytesInGibiByte;

/// <summary>Gets the number of tebibytes represented by this object.</summary>
public double TebiBytes => Bytes / BytesInTebiByte;

/// <summary>Gets the number of pebibytes represented by this object.</summary>
public double PebiBytes => Bytes / BytesInPebiByte;

Expand Down
Loading