Merge branch 'master' into feature/AnonymousTypeTests

This commit is contained in:
valentinbreiz 2020-12-19 02:09:38 +01:00 committed by GitHub
commit 535e04b269
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 4 deletions

View file

@ -18,6 +18,8 @@ namespace Cosmos.Compiler.Tests.Bcl.System
expectedResult = "18446744073709551615";
Assert.IsTrue((result == expectedResult), "UInt64.ToString doesn't work");
Assert.IsTrue(value.ToString("X") == "FFFFFFFFFFFFFFFF", "UInt64.ToString(X) doesn't work");
Assert.IsTrue(((ulong)0x121411443).ToString("X") == "121411443", "UInt64.ToString(X) doesn't work");
// Now let's try to concat to a String using '+' operator
result = "The Maximum value of an UInt64 is " + value;

View file

@ -112,13 +112,22 @@
}
/// <summary>
/// Convert 64-bit unsigned int to 16 characters long hexadecimal string, padded with '0's.
/// Convert 64-bit unsigned int to 16 characters long hexadecimal string, optionally padded with '0's.
/// </summary>
/// <param name="aValue">A 64-bit unsigned int to be converted to hexadecimal string.</param>
/// <returns>16 characters long string value, padded with '0's.</returns>
public static string ToHex(this ulong aValue)
/// <param name="withPadding">Determines if a left padding should be applied</param>
/// <returns>16 characters long string value, optionally padded with '0's.</returns>
public static string ToHex(this ulong aValue, bool withPadding = true)
{
return ConvertToHex(aValue).PadLeft(16, '0');
var hex = ConvertToHex(aValue);
if (withPadding)
{
return hex.PadLeft(16, '0');
}
else
{
return hex;
}
}
/// <summary>

View file

@ -1,5 +1,6 @@
using System;
using Cosmos.Common;
using Cosmos.Common.Extensions;
using IL2CPU.API;
using IL2CPU.API.Attribs;
@ -12,5 +13,21 @@ namespace Cosmos.System_Plugs.System
{
return StringHelper.GetNumberString(aThis);
}
public static string ToString(ref ulong aThis, string formating)
{
if(formating == "X")
{
return ToHexString.ToHex(aThis, false);
}
else if(formating == "G")
{
return ToString(ref aThis);
}
else
{
throw new NotImplementedException();
}
}
}
}