From 5dde86c1923976389771586934b90c6ae387dd41 Mon Sep 17 00:00:00 2001 From: nfbot Date: Tue, 13 Jul 2021 17:27:11 +0000 Subject: [PATCH 01/18] Set version to '1.10.6-preview.{height}' --- version.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/version.json b/version.json index 6b7f254c..eede3799 100644 --- a/version.json +++ b/version.json @@ -1,10 +1,9 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.10.5-preview.{height}", + "version": "1.10.6-preview.{height}", "assemblyVersion": { "precision": "revision" }, - "versionHeightOffset": 3, "semVer1NumericIdentifierPadding": 3, "nuGetPackageVersion": { "semVer": 2.0 @@ -20,7 +19,7 @@ }, "release": { "branchName": "release-v{version}", - "firstUnstableTag": "preview", - "versionIncrement": "build" + "versionIncrement": "build", + "firstUnstableTag": "preview" } -} +} \ No newline at end of file From d81e62f0be07d5ce9e2931934794fbedcff57915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Fri, 8 Oct 2021 19:50:22 +0100 Subject: [PATCH 02/18] Fix code style in DateTimeFormat ***NO_CI*** --- .../System/Globalization/DateTimeFormat.cs | 296 +++++++++--------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormat.cs b/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormat.cs index b953f01f..6a771947 100644 --- a/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormat.cs +++ b/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormat.cs @@ -247,64 +247,64 @@ private static String FormatCustomized(DateTime dateTime, String format, DateTim switch (ch) { case ':': - tempResult = dtfi.TimeSeparator; - tokenLen = 1; - break; + tempResult = dtfi.TimeSeparator; + tokenLen = 1; + break; case '/': - tempResult = dtfi.DateSeparator; - tokenLen = 1; - break; + tempResult = dtfi.DateSeparator; + tokenLen = 1; + break; case '\'': case '\"': - tempResult = ParseQuoteString(format, i, out tokenLen); - break; + tempResult = ParseQuoteString(format, i, out tokenLen); + break; case '%': - // Optional format character. - // For example, format string "%d" will print day of month - // without leading zero. Most of the cases, "%" can be ignored. - nextChar = ParseNextChar(format, i); - // nextChar will be -1 if we already reach the end of the format string. - // Besides, we will not allow "%%" appear in the pattern. - if (nextChar >= 0 && nextChar != '%') - { - tempResult = FormatCustomized(dateTime, ((char)nextChar).ToString(), dtfi); - tokenLen = 2; - } - else - { - // - // This means that '%' is at the end of the format string or - // "%%" appears in the format string. - // - throw new ArgumentException("Format_InvalidString"); - } - break; + // Optional format character. + // For example, format string "%d" will print day of month + // without leading zero. Most of the cases, "%" can be ignored. + nextChar = ParseNextChar(format, i); + // nextChar will be -1 if we already reach the end of the format string. + // Besides, we will not allow "%%" appear in the pattern. + if (nextChar >= 0 && nextChar != '%') + { + tempResult = FormatCustomized(dateTime, ((char)nextChar).ToString(), dtfi); + tokenLen = 2; + } + else + { + // + // This means that '%' is at the end of the format string or + // "%%" appears in the format string. + // + throw new ArgumentException("Format_InvalidString"); + } + break; case '\\': - // Escaped character. Can be used to insert character into the format string. - // For exmple, "\d" will insert the character 'd' into the string. - // - // NOTENOTE : we can remove this format character if we enforce the enforced quote - // character rule. - // That is, we ask everyone to use single quote or double quote to insert characters, - // then we can remove this character. - // - nextChar = ParseNextChar(format, i); - if (nextChar >= 0) - { - tempResult = ((char)nextChar).ToString(); - tokenLen = 2; - } - else - { + // Escaped character. Can be used to insert character into the format string. + // For exmple, "\d" will insert the character 'd' into the string. // - // This means that '\' is at the end of the formatting string. + // NOTENOTE : we can remove this format character if we enforce the enforced quote + // character rule. + // That is, we ask everyone to use single quote or double quote to insert characters, + // then we can remove this character. // - throw new ArgumentException("Format_InvalidString"); - } - break; + nextChar = ParseNextChar(format, i); + if (nextChar >= 0) + { + tempResult = ((char)nextChar).ToString(); + tokenLen = 2; + } + else + { + // + // This means that '\' is at the end of the formatting string. + // + throw new ArgumentException("Format_InvalidString"); + } + break; default: - doneParsingCh = false; - break; + doneParsingCh = false; + break; } if (!doneParsingCh) @@ -313,95 +313,95 @@ private static String FormatCustomized(DateTime dateTime, String format, DateTim switch (ch) { case 'h': - var hour12 = dateTime.Hour % 12; - if (hour12 == 0) hour12 = 12; - tempResult = FormatDigits(hour12, tokenLen); - break; + var hour12 = dateTime.Hour % 12; + if (hour12 == 0) hour12 = 12; + tempResult = FormatDigits(hour12, tokenLen); + break; case 'H': - tempResult = FormatDigits(dateTime.Hour, tokenLen); - break; + tempResult = FormatDigits(dateTime.Hour, tokenLen); + break; case 'm': - tempResult = FormatDigits(dateTime.Minute, tokenLen); - break; + tempResult = FormatDigits(dateTime.Minute, tokenLen); + break; case 's': - tempResult = FormatDigits(dateTime.Second, tokenLen); - break; + tempResult = FormatDigits(dateTime.Second, tokenLen); + break; case 'f': - if (tokenLen <= _maxSecondsFractionDigits) - { - var precision = 3; - var fraction = dateTime.Millisecond; + if (tokenLen <= _maxSecondsFractionDigits) + { + var precision = 3; + var fraction = dateTime.Millisecond; - // Note: Need to add special case when tokenLen > precision to begin with - // if we're to change MaxSecondsFractionDigits to be more than 3 + // Note: Need to add special case when tokenLen > precision to begin with + // if we're to change MaxSecondsFractionDigits to be more than 3 - while (tokenLen < precision) - { - fraction /= 10; - precision--; - } + while (tokenLen < precision) + { + fraction /= 10; + precision--; + } - tempResult = FormatDigits(fraction, tokenLen); - } - else throw new ArgumentException("Format_InvalidString"); - break; + tempResult = FormatDigits(fraction, tokenLen); + } + else throw new ArgumentException("Format_InvalidString"); + break; case 't': - if (tokenLen == 1) - { - if (dateTime.Hour < 12) + if (tokenLen == 1) { - if (dtfi.AMDesignator.Length >= 1) tempResult = dtfi.AMDesignator[0].ToString(); + if (dateTime.Hour < 12) + { + if (dtfi.AMDesignator.Length >= 1) tempResult = dtfi.AMDesignator[0].ToString(); + } + else + { + if (dtfi.PMDesignator.Length >= 1) tempResult = dtfi.PMDesignator[0].ToString(); + } + } + else tempResult = dateTime.Hour < 12 ? dtfi.AMDesignator : dtfi.PMDesignator; + break; + case 'd': + // + // tokenLen == 1 : Day of month as digits with no leading zero. + // tokenLen == 2 : Day of month as digits with leading zero for single-digit months. + // tokenLen == 3 : Day of week as a three-leter abbreviation. + // tokenLen >= 4 : Day of week as its full name. + // + if (tokenLen <= 2) tempResult = FormatDigits(dateTime.Day, tokenLen); else { - if (dtfi.PMDesignator.Length >= 1) tempResult = dtfi.PMDesignator[0].ToString(); - } + var dayOfWeek = (int)dateTime.DayOfWeek; - } - else tempResult = dateTime.Hour < 12 ? dtfi.AMDesignator : dtfi.PMDesignator; - break; - case 'd': - // - // tokenLen == 1 : Day of month as digits with no leading zero. - // tokenLen == 2 : Day of month as digits with leading zero for single-digit months. - // tokenLen == 3 : Day of week as a three-leter abbreviation. - // tokenLen >= 4 : Day of week as its full name. - // - if (tokenLen <= 2) tempResult = FormatDigits(dateTime.Day, tokenLen); - else - { - var dayOfWeek = (int)dateTime.DayOfWeek; - - tempResult = tokenLen == 3 ? dtfi.AbbreviatedDayNames[dayOfWeek] : dtfi.DayNames[dayOfWeek]; - } - break; + tempResult = tokenLen == 3 ? dtfi.AbbreviatedDayNames[dayOfWeek] : dtfi.DayNames[dayOfWeek]; + } + break; case 'M': - // - // tokenLen == 1 : Month as digits with no leading zero. - // tokenLen == 2 : Month as digits with leading zero for single-digit months. - // tokenLen == 3 : Month as a three-letter abbreviation. - // tokenLen >= 4 : Month as its full name. - // - var month = dateTime.Month; - if (tokenLen <= 2) tempResult = FormatDigits(month, tokenLen); - else tempResult = tokenLen == 3 ? dtfi.AbbreviatedMonthNames[month - 1] : dtfi.MonthNames[month - 1]; - break; + // + // tokenLen == 1 : Month as digits with no leading zero. + // tokenLen == 2 : Month as digits with leading zero for single-digit months. + // tokenLen == 3 : Month as a three-letter abbreviation. + // tokenLen >= 4 : Month as its full name. + // + var month = dateTime.Month; + if (tokenLen <= 2) tempResult = FormatDigits(month, tokenLen); + else tempResult = tokenLen == 3 ? dtfi.AbbreviatedMonthNames[month - 1] : dtfi.MonthNames[month - 1]; + break; case 'y': - // Notes about OS behavior: - // y: Always print (year % 100). No leading zero. - // yy: Always print (year % 100) with leading zero. - // yyy/yyyy/yyyyy/... : Print year value. With leading zeros. + // Notes about OS behavior: + // y: Always print (year % 100). No leading zero. + // yy: Always print (year % 100) with leading zero. + // yyy/yyyy/yyyyy/... : Print year value. With leading zeros. - var year = dateTime.Year; + var year = dateTime.Year; - tempResult = tokenLen <= 2 ? FormatDigits(year % 100, tokenLen) : year.ToString(); + tempResult = tokenLen <= 2 ? FormatDigits(year % 100, tokenLen) : year.ToString(); - if (tempResult.Length < tokenLen) tempResult = new string('0', tokenLen - tempResult.Length) + tempResult; - break; + if (tempResult.Length < tokenLen) tempResult = new string('0', tokenLen - tempResult.Length) + tempResult; + break; default: - tempResult = tokenLen == 1 ? ch.ToString() : new String(ch, tokenLen); - break; + tempResult = tokenLen == 1 ? ch.ToString() : new String(ch, tokenLen); + break; } } @@ -419,52 +419,52 @@ internal static String GetRealFormat(String format, DateTimeFormatInfo dtfi) switch (format[0]) { case 'd': // Short Date - realFormat = dtfi.ShortDatePattern; - break; + realFormat = dtfi.ShortDatePattern; + break; case 'D': // Long Date - realFormat = dtfi.LongDatePattern; - break; + realFormat = dtfi.LongDatePattern; + break; case 'f': // Full (long date + short time) - realFormat = dtfi.LongDatePattern + " " + dtfi.ShortTimePattern; - break; + realFormat = dtfi.LongDatePattern + " " + dtfi.ShortTimePattern; + break; case 'F': // Full (long date + long time) - realFormat = dtfi.FullDateTimePattern; - break; + realFormat = dtfi.FullDateTimePattern; + break; case 'g': // General (short date + short time) - realFormat = dtfi.GeneralShortTimePattern; - break; + realFormat = dtfi.GeneralShortTimePattern; + break; case 'G': // General (short date + long time) - realFormat = dtfi.GeneralLongTimePattern; - break; + realFormat = dtfi.GeneralLongTimePattern; + break; case 'm': case 'M': // Month/Day Date - realFormat = dtfi.MonthDayPattern; - break; + realFormat = dtfi.MonthDayPattern; + break; case 'r': case 'R': // RFC 1123 Standard - realFormat = dtfi.RFC1123Pattern; - break; + realFormat = dtfi.RFC1123Pattern; + break; case 's': // Sortable without Time Zone Info - realFormat = dtfi.SortableDateTimePattern; - break; + realFormat = dtfi.SortableDateTimePattern; + break; case 't': // Short Time - realFormat = dtfi.ShortTimePattern; - break; + realFormat = dtfi.ShortTimePattern; + break; case 'T': // Long Time - realFormat = dtfi.LongTimePattern; - break; + realFormat = dtfi.LongTimePattern; + break; case 'u': // Universal with Sortable format - realFormat = dtfi.UniversalSortableDateTimePattern; - break; + realFormat = dtfi.UniversalSortableDateTimePattern; + break; case 'U': // Universal with Full (long date + long time) format - realFormat = dtfi.FullDateTimePattern; - break; + realFormat = dtfi.FullDateTimePattern; + break; case 'y': case 'Y': // Year/Month Date - realFormat = dtfi.YearMonthPattern; - break; + realFormat = dtfi.YearMonthPattern; + break; default: - throw new ArgumentException("Format_InvalidString"); + throw new ArgumentException("Format_InvalidString"); } return realFormat; From ebcb832596b4c3ab81a9f2e60837127d5f566877 Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Mon, 11 Oct 2021 11:52:31 +0100 Subject: [PATCH 03/18] ISO8601 compatibility for DateTime ToString (#158) ***NO_CI*** --- Tests/NFUnitTestSystemLib/UnitTestDateTime.cs | 215 +++++++++++++----- nanoFramework.CoreLibrary/System/DateTime.cs | 2 +- .../System/Globalization/DateTimeFormat.cs | 34 ++- 3 files changed, 183 insertions(+), 68 deletions(-) diff --git a/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs b/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs index 38045297..c9007733 100644 --- a/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs +++ b/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs @@ -157,58 +157,146 @@ public void DateTime_ToStringTest6() Assert.Equal(dt.ToString(), str); } - //[TestMethod] - //public void DateTime_ToStringTest7() - //{ - // /// - // /// 1. Creates a DateTime - // /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format - // /// - // OutputHelper.WriteLine("Generating random DateTime"); - // DateTime dt = GetRandomDateTime(); - // OutputHelper.WriteLine("DateTime.ToString(String) using Standard Formats and Verifying"); - // string[] standardFmts = { "d", "D", "f", "F", "g", "G", "m", "M", "o", "R", "r", "s", "t", "T", "u", "U", "Y", "y" }; - // foreach (string standardFmt in standardFmts) - // { - // try - // { - // if (dt.ToString(standardFmt).Length < 1) - // { - // OutputHelper.WriteLine("Expected a String length greater than '0' but got '" + - // dt.ToString(standardFmt).Length + "'"); - // testResult = MFTestResults.Fail; - // } - // } - // catch (Exception ex) - // { - // OutputHelper.WriteLine("This currently fails, DateTime.ToString(String)" + - // " throws ArgumentException for some string formats, see 22837 for details"); - // OutputHelper.WriteLine("Caught " + ex.Message + " when Trying DateTime.ToString(" + standardFmt + ")"); - // testResult = MFTestResults.KnownFailure; - // } - // } - // OutputHelper.WriteLine("DateTime.ToString(String) using Custom Formats and Verifying"); - // string[] customFmts = {"h:mm:ss.ff t", "d MMM yyyy", "HH:mm:ss.f","dd MMM HH:mm:ss", - // @"\Mon\t\h\: M", "MM/dd/yyyy", "dddd, dd MMMM yyyy", "MMMM dd", "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", - // "yyyy'-'MM'-'dd'T'HH':'mm':'ss", "HH:mm", "yyyy'-'MM'-'dd HH':'mm':'ss'Z'", "yyyy MMMM"}; - // foreach (string customFmt in customFmts) - // { - // try - // { - // if (dt.ToString(customFmt).Length < 1) - // { - // OutputHelper.WriteLine("Expected a String length greater than '0' but got '" + - // dt.ToString(customFmt).Length + "'"); - // testResult = MFTestResults.Fail; - // } - // } - // catch (Exception ex) - // { - // OutputHelper.WriteLine("Caught " + ex.Message + " when Trying DateTime.ToString(" + customFmt + ")"); - // testResult = MFTestResults.KnownFailure; - // } - // } - //} + [TestMethod] + public void DateTime_ToStringTest7() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + DateTime dt = GetRandomDateTime(); + OutputHelper.WriteLine("DateTime.ToString(String) using Standard Formats and Verifying"); + string[] standardFmts = { "d", "D", "f", "F", "g", "G", "m", "M", "o", "O", "R", "r", "s", "t", "T", "u", "U", "Y", "y" }; + foreach (string standardFmt in standardFmts) + { + try + { + if (dt.ToString(standardFmt).Length < 1) + { + throw new Exception("Expected a String length greater than '0' but got '" + + dt.ToString(standardFmt).Length + "'"); + } + } + catch (Exception ex) + { + throw new Exception("Caught " + ex.Message + " when Trying DateTime.ToString(" + standardFmt + ")"); + } + OutputHelper.WriteLine("Successfully verified 'DateTime.ToString(" + standardFmt + ")' format as: " + dt.ToString(standardFmt)); + } + OutputHelper.WriteLine("DateTime.ToString(String) using Custom Formats and Verifying"); + string[] customFmts = {"h:mm:ss.ff t", "d MMM yyyy", "HH:mm:ss.f","dd MMM HH:mm:ss", + @"\Mon\t\h\: M", "MM/dd/yyyy", "dddd, dd MMMM yyyy", "MMMM dd", "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss", "HH:mm", "yyyy'-'MM'-'dd HH':'mm':'ss'Z'", "yyyy MMMM"}; + foreach (string customFmt in customFmts) + { + try + { + if (dt.ToString(customFmt).Length < 1) + { + throw new Exception("Expected a String length greater than '0' but got '" + + dt.ToString(customFmt).Length + "'"); + } + } + catch (Exception ex) + { + throw new Exception("Caught " + ex.Message + " when Trying DateTime.ToString(" + customFmt + ")"); + } + OutputHelper.WriteLine("Successfully verified 'DateTime.ToString(" + customFmt + ")' format as: " + dt.ToString(customFmt)); + } + } + + [TestMethod] + public void DateTime_ToStringTest8() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + OutputHelper.WriteLine("DateTime.ToString(String) using specified formats and Verifying"); + + // "o" and "O" + string specifier1 = "o"; + string specifier2 = "O"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}' and '{specifier2}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + string dtOutput2 = dt.ToString(specifier2); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + OutputHelper.WriteLine($"Output from ToString(\"{specifier2}\") was '{dtOutput2}'"); + + // expected format is yyyy-MM-ddTHH:mm:ss.fffffffZ + + int length = 28; + + // check length + Assert.True(length == dtOutput1.Length, $"Wrong output1 length: {dtOutput1.Length}, should have been {length}"); + Assert.True(length == dtOutput2.Length, $"Wrong output1 length: {dtOutput2.Length}, should have been {length}"); + + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(0, 4)), "Wrong output1 for 'yyyy'"); + Assert.Equal(dt.Year, int.Parse(dtOutput2.Substring(0, 4)), "Wrong output2 for 'yyyy'"); + // check 'MM' + Assert.Equal(dt.Month, int.Parse(dtOutput1.Substring(5, 2)), "Wrong output1 in for 'MM'"); + Assert.Equal(dt.Month, int.Parse(dtOutput2.Substring(5, 2)), "Wrong output2 in for 'MM'"); + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(8, 2)), "Wrong output1 in for 'dd'"); + Assert.Equal(dt.Day, int.Parse(dtOutput2.Substring(8, 2)), "Wrong output2 in for 'dd'"); + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(11, 2)), "Wrong output1 in for 'HH'"); + Assert.Equal(dt.Hour, int.Parse(dtOutput2.Substring(11, 2)), "Wrong output2 in for 'HH'"); + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(14, 2)), "Wrong output1 in for 'mm'"); + Assert.Equal(dt.Minute, int.Parse(dtOutput2.Substring(14, 2)), "Wrong output2 in for 'mm'"); + // check 'ss' + Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(17, 2)), "Wrong output1 in for 'ss'"); + Assert.Equal(dt.Second, int.Parse(dtOutput2.Substring(17, 2)), "Wrong output2 in for 'ss'"); + + // check 'fffffff' + // need to do the math to get the fraction part from ticks + var fraction = dt.Ticks % _TicksPerSecond; + Assert.Equal(fraction, int.Parse(dtOutput1.Substring(20, 7)), "Wrong output1 in for 'fffffff'"); + Assert.Equal(fraction, int.Parse(dtOutput2.Substring(20, 7)), "Wrong output2 in for 'fffffff'"); + + // check '-' + Assert.Equal("-", dtOutput1.Substring(4, 1), "Wrong output1 in for '-'"); + Assert.Equal("-", dtOutput2.Substring(4, 1), "Wrong output2 in for '-'"); + Assert.Equal("-", dtOutput1.Substring(7, 1), "Wrong output1 in for '-'"); + Assert.Equal("-", dtOutput2.Substring(7, 1), "Wrong output2 in for '-'"); + // check 'T' + Assert.Equal("T", dtOutput1.Substring(10, 1), "Wrong output1 in for 'T'"); + Assert.Equal("T", dtOutput2.Substring(10, 1), "Wrong output2 in for 'T'"); + // check ':' + Assert.Equal(":", dtOutput1.Substring(13, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput2.Substring(13, 1), "Wrong output2 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(16, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput2.Substring(16, 1), "Wrong output2 in for ':'"); + // check '.' + Assert.Equal(".", dtOutput1.Substring(19, 1), "Wrong output1 in for '.'"); + Assert.Equal(".", dtOutput2.Substring(19, 1), "Wrong output2 in for '.'"); + // check 'Z' + Assert.Equal("Z", dtOutput1.Substring(27, 1), "Wrong output1 in for 'Z'"); + Assert.Equal("Z", dtOutput2.Substring(27, 1), "Wrong output2 in for 'Z'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + + OutputHelper.WriteLine(""); + + } + [TestMethod] public void DateTime_AddTest8() @@ -1047,6 +1135,10 @@ public void DateTime_AboveMaxDatTime_ArgumentOutOfRangeExceptionTest59() static int[] leapYear = new int[] {2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, 2044, 2048, 2052, 2056, 2060, 2064, 2068, 2072, 2076, 2080, 2084, 2088, 2092, 2096}; + // computing our constants here, as these are not accessible + // equivalent to DateTime.TicksPerSecond + const int _TicksPerSecond = 10000 * 1000; + private DateTime[] Get_ArrayOfRandomDateTimes() { OutputHelper.WriteLine(DateTime_btwn_1801_And_2801().ToString()); @@ -1089,21 +1181,34 @@ private DateTime GetRandomDateTime() Random random = new Random(); year = random.Next(1399) + 1601; month = random.Next(12) + 1; + if (month == 2 && IsLeapYear(year)) + { day = random.Next(29) + 1; + } else if (month == 2 && (!IsLeapYear(year))) + { day = random.Next(28) + 1; - else if (((month <= 7) && ((month + 1) % 2 == 0)) || - ((month > 7) && ((month % 2) == 0))) + } + else if (((month <= 7) && ((month + 1) % 2 == 0)) + || ((month > 7) && ((month % 2) == 0))) + { day = random.Next(31) + 1; + } else + { day = random.Next(30) + 1; + } + hour = random.Next(24); minute = random.Next(60); second = random.Next(60); millisec = random.Next(1000); - return new DateTime(year, month, day, hour, minute, second, millisec); + DateTime dt = new(year, month, day, hour, minute, second, millisec); + + // fill in random ticks value so we can have a fully filled ticks value + return new DateTime(dt.Ticks + random.Next(1000_000)); } private DateTime GetLeapYearDateTime() diff --git a/nanoFramework.CoreLibrary/System/DateTime.cs b/nanoFramework.CoreLibrary/System/DateTime.cs index 6ed470b8..65dd4c74 100644 --- a/nanoFramework.CoreLibrary/System/DateTime.cs +++ b/nanoFramework.CoreLibrary/System/DateTime.cs @@ -90,7 +90,7 @@ public struct DateTime // Number of 100ns ticks per time unit private const long TicksPerMillisecond = 10000; - private const long TicksPerSecond = TicksPerMillisecond * 1000; + internal const long TicksPerSecond = TicksPerMillisecond * 1000; private const long TicksPerMinute = TicksPerSecond * 60; private const long TicksPerHour = TicksPerMinute * 60; private const long TicksPerDay = TicksPerHour * 24; diff --git a/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormat.cs b/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormat.cs index 6a771947..97cbed87 100644 --- a/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormat.cs +++ b/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormat.cs @@ -101,7 +101,7 @@ namespace System.Globalization // "g" general date (short date + short time) culture-specific 10/31/1999 2:00 AM // "G" general date (short date + long time) culture-specific 10/31/1999 2:00:00 AM // "m"/"M" Month/Day date culture-specific October 31 - //(G) "o"/"O" Round Trip XML "yyyy-MM-ddTHH:mm:ss.fffffffK" 1999-10-31 02:00:00.0000000Z + //(G) "o"/"O" Round Trip ISO 8601 compatible "yyyy-MM-ddTHH:mm:ss.fffffffK" 1999-10-31T02:00:00.0000000Z //(G) "r"/"R" RFC 1123 date, "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'" Sun, 31 Oct 1999 10:00:00 GMT //(G) "s" Sortable format, based on ISO 8601. "yyyy-MM-dd'T'HH:mm:ss" 1999-10-31T02:00:00 // ('T' for local time) @@ -119,10 +119,11 @@ namespace System.Globalization internal static class DateTimeFormat { - internal const int _maxSecondsFractionDigits = 3; + internal const int MaxSecondsFractionDigits = 7; + //////////////////////////////////////////////////////////////////////////// // - // Format the positive integer value to a string and perfix with assigned + // Format the positive integer value to a string and prefix with assigned // length of leading zero. // // Parameters: @@ -327,21 +328,23 @@ private static String FormatCustomized(DateTime dateTime, String format, DateTim tempResult = FormatDigits(dateTime.Second, tokenLen); break; case 'f': - if (tokenLen <= _maxSecondsFractionDigits) + if (tokenLen <= MaxSecondsFractionDigits) { - var precision = 3; - var fraction = dateTime.Millisecond; + // compute requested precision + var precision = MaxSecondsFractionDigits - (MaxSecondsFractionDigits - tokenLen); - // Note: Need to add special case when tokenLen > precision to begin with - // if we're to change MaxSecondsFractionDigits to be more than 3 + // get fraction value from ticks + var fraction = dateTime.Ticks % DateTime.TicksPerSecond; - while (tokenLen < precision) + // compute value with effective digits from requested precision + int effectiveDigits = MaxSecondsFractionDigits - precision; + while (effectiveDigits > 0) { fraction /= 10; - precision--; + effectiveDigits--; } - - tempResult = FormatDigits(fraction, tokenLen); + + tempResult = FormatDigits((int)fraction, precision); } else throw new ArgumentException("Format_InvalidString"); break; @@ -440,6 +443,13 @@ internal static String GetRealFormat(String format, DateTimeFormatInfo dtfi) case 'M': // Month/Day Date realFormat = dtfi.MonthDayPattern; break; + + case 'o': + case 'O': // Round-trip ISO8601 compatible + // Note: .NET nanoFramework has support for UTC (Z) time, so we're not processing the kind token (K). + realFormat = dtfi.SortableDateTimePattern + ".fffffffZ"; + break; + case 'r': case 'R': // RFC 1123 Standard realFormat = dtfi.RFC1123Pattern; From b08f4ff21663307eaa039c37711e8ee1660f7525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Wed, 13 Oct 2021 12:45:38 +0100 Subject: [PATCH 04/18] Improvements and fixes in DateTimeFormatInfo (#159) ***NO_CI*** --- Tests/NFUnitTestSystemLib/UnitTestDateTime.cs | 1414 +++++++++++++++-- .../Globalization/DateTimeFormatInfo.cs | 70 +- 2 files changed, 1323 insertions(+), 161 deletions(-) diff --git a/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs b/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs index c9007733..18e63fee 100644 --- a/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs +++ b/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs @@ -6,7 +6,7 @@ using nanoFramework.TestFramework; using System; -using System.Diagnostics; +using System.Globalization; namespace NFUnitTestSystemLib { @@ -116,98 +116,1148 @@ public void DateTime_EqualsTest5() /// OutputHelper.WriteLine("Generating random DateTime"); DateTime dt1 = GetRandomDateTime(); - DateTime dt2 = new DateTime(year, month, day, hour, minute, second, millisec); + DateTime dt2 = new DateTime(ticks); Assert.True(dt1.Equals(dt2)); } [TestMethod] - public void DateTime_ToStringTest6() + public void DateTime_ToStringTest06() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies that it correctly returns a string from ToString + /// + /// + OutputHelper.WriteLine("Generating random DateTime"); + DateTime dt = GetRandomDateTime(); + int[] intArr = new int[] { dt.Month, dt.Day, dt.Year, dt.Hour, dt.Minute, dt.Second }; + string[] strArr = new string[] { "", "", "", "", "", "" }; + for (int i = 0; i < intArr.Length; i++) + { + if (i == 2) + { + if (intArr[2] < 100) + strArr[2] += "00" + intArr[2]; + else if (intArr[2] < 1000) + strArr[2] += "0" + intArr[2]; + else + strArr[2] += intArr[2]; + } + else + { + if (intArr[i] < 10) + { + strArr[i] += "0" + intArr[i]; + } + else + strArr[i] += intArr[i]; + } + } + string str = strArr[0] + "/" + strArr[1] + "/" + strArr[2] + " " + strArr[3] + ":" + strArr[4] + ":" + strArr[5]; + Assert.Equal(dt.ToString(), str); + } + + [TestMethod] + public void DateTime_ToStringTest08() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + OutputHelper.WriteLine("DateTime.ToString(String) using specified formats and Verifying"); + + // ShortDatePattern + string specifier1 = "d"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + // expected format is MM/dd/yyyy + + int length = 10; + + // check length + Assert.True(length == dtOutput1.Length, $"Wrong output1 length: {dtOutput1.Length}, should have been {length}"); + + // check 'MM' + Assert.Equal(dt.Month, int.Parse(dtOutput1.Substring(0, 2)), "Wrong output1 in for 'MM'"); + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(3, 2)), "Wrong output1 in for 'dd'"); + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(6, 4)), "Wrong output1 for 'yyyy'"); + + // check '/' + Assert.Equal("/", dtOutput1.Substring(2, 1), "Wrong output1 in for '-'"); + Assert.Equal("/", dtOutput1.Substring(5, 1), "Wrong output1 in for '-'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest09() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // LongDatePattern + var specifier1 = "D"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + // expected format is dddd, dd MMMM yyyy + + int minLength = 19; + + // check length + Assert.True(dtOutput1.Length >= minLength, $"Wrong output1 length: {dtOutput1.Length}, should have been at least {minLength}"); + + // check 'dddd' + int endIndex = dtOutput1.IndexOf(','); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.DayNames[(int)dt.DayOfWeek], + dtOutput1.Substring(0, endIndex), + "Wrong output1 for 'dddd'"); + + // check ',' + Assert.Equal(",", dtOutput1.Substring(endIndex, 1), "Wrong output1 in for ','"); + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex + 1, 1), "Wrong output1 in for ' '"); + + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(endIndex + 2, 2)), "Wrong output1 in for 'dd'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex + 4, 1), "Wrong output1 in for ' '"); + + // check 'MMMM' + var startIndex = dtOutput1.IndexOf(' ', endIndex + 2); + endIndex = dtOutput1.IndexOf(' ', startIndex + 1); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.MonthNames[dt.Month - 1], + dtOutput1.Substring(startIndex + 1, endIndex - 1 - startIndex), + "Wrong output1 in for 'MMMM'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex, 1), "Wrong output1 in for ' '"); + + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(endIndex + 1, 4)), "Wrong output1 for 'yyyy'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + + } + + [TestMethod] + public void DateTime_ToStringTest10() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // full date / short time + var specifier1 = "f"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + // expected format is dddd, dd MMMM yyyy HH:mm + + int minLength = 26; + int actualLength = dtOutput1.Length; + + // check length + Assert.True(dtOutput1.Length >= minLength, $"Wrong output1 length: {dtOutput1.Length}, should have been at least {minLength}"); + + + // check 'dddd' + int endIndex = dtOutput1.IndexOf(','); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.DayNames[(int)dt.DayOfWeek], + dtOutput1.Substring(0, endIndex), + "Wrong output1 for 'dddd'"); + + // check ',' + Assert.Equal(",", dtOutput1.Substring(endIndex, 1), "Wrong output1 in for ','"); + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex + 1, 1), "Wrong output1 in for ' '"); + + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(endIndex + 2, 2)), "Wrong output1 in for 'dd'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex + 4, 1), "Wrong output1 in for ' '"); + + // check 'MMMM' + var startIndex = dtOutput1.IndexOf(' ', endIndex + 2); + endIndex = dtOutput1.IndexOf(' ', startIndex + 1); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.MonthNames[dt.Month - 1], + dtOutput1.Substring(startIndex + 1, endIndex - 1 - startIndex), + "Wrong output1 in for 'MMMM'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex, 1), "Wrong output1 in for ' '"); + + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(endIndex + 1, 4)), "Wrong output1 for 'yyyy'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex + 5, 1), "Wrong output1 in for ' '"); + + startIndex = endIndex + 6; + + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(startIndex, 2)), "Wrong output1 in for 'HH'"); + + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(startIndex + 3, 2)), "Wrong output1 in for 'mm'"); + + // check ':' + Assert.Equal(":", dtOutput1.Substring(startIndex + 2, 1), "Wrong output1 in for ':'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest11() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // full date / long time + var specifier1 = "F"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + // expected format is dddd, dd MMMM yyyy HH:mm:ss + + int minLength = 26; + int actualLength = dtOutput1.Length; + + // check length + Assert.True(dtOutput1.Length >= minLength, $"Wrong output1 length: {dtOutput1.Length}, should have been at least {minLength}"); + + // check 'dddd' + int endIndex = dtOutput1.IndexOf(','); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.DayNames[(int)dt.DayOfWeek], + dtOutput1.Substring(0, endIndex), + "Wrong output1 for 'dddd'"); + + // check ',' + Assert.Equal(",", dtOutput1.Substring(endIndex, 1), "Wrong output1 in for ','"); + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex + 1, 1), "Wrong output1 in for ' '"); + + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(endIndex + 2, 2)), "Wrong output1 in for 'dd'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex + 4, 1), "Wrong output1 in for ' '"); + + // check 'MMMM' + var startIndex = dtOutput1.IndexOf(' ', endIndex + 2); + endIndex = dtOutput1.IndexOf(' ', startIndex + 1); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.MonthNames[dt.Month - 1], + dtOutput1.Substring(startIndex + 1, endIndex - 1 - startIndex), + "Wrong output1 in for 'MMMM'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex, 1), "Wrong output1 in for ' '"); + + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(endIndex + 1, 4)), "Wrong output1 for 'yyyy'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex + 5, 1), "Wrong output1 in for ' '"); + + startIndex = endIndex + 6; + + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(startIndex, 2)), "Wrong output1 in for 'HH'"); + + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(startIndex + 3, 2)), "Wrong output1 in for 'mm'"); + + // check 'ss' + Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(startIndex + 6, 2)), "Wrong output1 in for 'ss'"); + + // check ':' + Assert.Equal(":", dtOutput1.Substring(startIndex + 2, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(startIndex + 5, 1), "Wrong output1 in for ':'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest12() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // short date / short time + var specifier1 = "g"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + // expected format is MM/dd/yyyy HH:mm + + int length = 16; + + // check length + Assert.True(length == dtOutput1.Length, $"Wrong output1 length: {dtOutput1.Length}, should have been {length}"); + + // check 'MM' + Assert.Equal(dt.Month, int.Parse(dtOutput1.Substring(0, 2)), "Wrong output1 in for 'MM'"); + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(3, 2)), "Wrong output1 in for 'dd'"); + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(6, 4)), "Wrong output1 for 'yyyy'"); + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(11, 2)), "Wrong output1 in for 'HH'"); + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(14, 2)), "Wrong output1 in for 'mm'"); + + // check '/' + Assert.Equal("/", dtOutput1.Substring(2, 1), "Wrong output1 in for '/'"); + Assert.Equal("/", dtOutput1.Substring(5, 1), "Wrong output1 in for '/'"); + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(10, 1), "Wrong output1 in for ' '"); + // check ':' + Assert.Equal(":", dtOutput1.Substring(13, 1), "Wrong output1 in for ':'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + + } + + [TestMethod] + public void DateTime_ToStringTest13() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // short date / long time + var specifier1 = "G"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + // expected format is MM/dd/yyyy HH:mm:ss + + int length = 19; + + // check length + Assert.True(length == dtOutput1.Length, $"Wrong output1 length: {dtOutput1.Length}, should have been {length}"); + + // check 'MM' + Assert.Equal(dt.Month, int.Parse(dtOutput1.Substring(0, 2)), "Wrong output1 in for 'MM'"); + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(3, 2)), "Wrong output1 in for 'dd'"); + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(6, 4)), "Wrong output1 for 'yyyy'"); + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(11, 2)), "Wrong output1 in for 'HH'"); + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(14, 2)), "Wrong output1 in for 'mm'"); + // check 'ss' + Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(17, 2)), "Wrong output1 in for 'ss'"); + + // check '/' + Assert.Equal("/", dtOutput1.Substring(2, 1), "Wrong output1 in for '/'"); + Assert.Equal("/", dtOutput1.Substring(5, 1), "Wrong output1 in for '/'"); + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(10, 1), "Wrong output1 in for ' '"); + // check ':' + Assert.Equal(":", dtOutput1.Substring(13, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(16, 1), "Wrong output1 in for ':'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest14() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // MonthDayPattern + var specifier1 = "M"; + var specifier2 = "m"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}' and '{specifier2}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + string dtOutput2 = dt.ToString(specifier2); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + // expected format is MMMM dd + + int minLength = 6; + + // check length + Assert.True(dtOutput1.Length >= minLength, $"Wrong output1 length: {dtOutput1.Length}, should have been at least {minLength}"); + Assert.True(dtOutput2.Length >= minLength, $"Wrong output1 length: {dtOutput2.Length}, should have been at least {minLength}"); + + // check 'MMMM' + var endIndex = dtOutput1.IndexOf(' '); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.MonthNames[dt.Month - 1], + dtOutput1.Substring(0, endIndex), + "Wrong output1 in for 'MMMM'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex, 1), "Wrong output1 in for ' '"); + + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(endIndex + 1, 2)), "Wrong output1 in for 'dd'"); + + // check 'MMMM' + endIndex = dtOutput2.IndexOf(' '); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.MonthNames[dt.Month - 1], + dtOutput2.Substring(0, endIndex), + "Wrong output1 in for 'MMMM'"); + + // check ' ' + Assert.Equal(" ", dtOutput2.Substring(endIndex, 1), "Wrong output1 in for ' '"); + + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput2.Substring(endIndex + 1, 2)), "Wrong output1 in for 'dd'"); + + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest15() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // Round-trip ISO8601 compatible + var specifier1 = "o"; + var specifier2 = "O"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}' and '{specifier2}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + string dtOutput2 = dt.ToString(specifier2); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + OutputHelper.WriteLine($"Output from ToString(\"{specifier2}\") was '{dtOutput2}'"); + + // expected format is yyyy-MM-ddTHH:mm:ss.fffffffZ + + int length = 28; + + // check length + Assert.True(length == dtOutput1.Length, $"Wrong output1 length: {dtOutput1.Length}, should have been {length}"); + Assert.True(length == dtOutput2.Length, $"Wrong output1 length: {dtOutput2.Length}, should have been {length}"); + + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(0, 4)), "Wrong output1 for 'yyyy'"); + Assert.Equal(dt.Year, int.Parse(dtOutput2.Substring(0, 4)), "Wrong output2 for 'yyyy'"); + // check 'MM' + Assert.Equal(dt.Month, int.Parse(dtOutput1.Substring(5, 2)), "Wrong output1 in for 'MM'"); + Assert.Equal(dt.Month, int.Parse(dtOutput2.Substring(5, 2)), "Wrong output2 in for 'MM'"); + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(8, 2)), "Wrong output1 in for 'dd'"); + Assert.Equal(dt.Day, int.Parse(dtOutput2.Substring(8, 2)), "Wrong output2 in for 'dd'"); + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(11, 2)), "Wrong output1 in for 'HH'"); + Assert.Equal(dt.Hour, int.Parse(dtOutput2.Substring(11, 2)), "Wrong output2 in for 'HH'"); + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(14, 2)), "Wrong output1 in for 'mm'"); + Assert.Equal(dt.Minute, int.Parse(dtOutput2.Substring(14, 2)), "Wrong output2 in for 'mm'"); + // check 'ss' + Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(17, 2)), "Wrong output1 in for 'ss'"); + Assert.Equal(dt.Second, int.Parse(dtOutput2.Substring(17, 2)), "Wrong output2 in for 'ss'"); + + // check 'fffffff' + // need to do the math to get the fraction part from ticks + var fraction = dt.Ticks % _TicksPerSecond; + Assert.Equal(fraction, int.Parse(dtOutput1.Substring(20, 7)), "Wrong output1 in for 'fffffff'"); + Assert.Equal(fraction, int.Parse(dtOutput2.Substring(20, 7)), "Wrong output2 in for 'fffffff'"); + + // check '-' + Assert.Equal("-", dtOutput1.Substring(4, 1), "Wrong output1 in for '-'"); + Assert.Equal("-", dtOutput2.Substring(4, 1), "Wrong output2 in for '-'"); + Assert.Equal("-", dtOutput1.Substring(7, 1), "Wrong output1 in for '-'"); + Assert.Equal("-", dtOutput2.Substring(7, 1), "Wrong output2 in for '-'"); + // check 'T' + Assert.Equal("T", dtOutput1.Substring(10, 1), "Wrong output1 in for 'T'"); + Assert.Equal("T", dtOutput2.Substring(10, 1), "Wrong output2 in for 'T'"); + // check ':' + Assert.Equal(":", dtOutput1.Substring(13, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput2.Substring(13, 1), "Wrong output2 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(16, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput2.Substring(16, 1), "Wrong output2 in for ':'"); + // check '.' + Assert.Equal(".", dtOutput1.Substring(19, 1), "Wrong output1 in for '.'"); + Assert.Equal(".", dtOutput2.Substring(19, 1), "Wrong output2 in for '.'"); + // check 'Z' + Assert.Equal("Z", dtOutput1.Substring(27, 1), "Wrong output1 in for 'Z'"); + Assert.Equal("Z", dtOutput2.Substring(27, 1), "Wrong output2 in for 'Z'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest16() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // RFC1123Pattern + var specifier1 = "r"; + var specifier2 = "R"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}' and '{specifier2}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + string dtOutput2 = dt.ToString(specifier2); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + OutputHelper.WriteLine($"Output from ToString(\"{specifier2}\") was '{dtOutput2}'"); + + // expected format is ddd, dd MMM yyyy HH:mm:ss GMT + + int length = 29; + + // check length + Assert.True(length == dtOutput1.Length, $"Wrong output1 length: {dtOutput1.Length}, should have been {length}"); + Assert.True(length == dtOutput2.Length, $"Wrong output1 length: {dtOutput2.Length}, should have been {length}"); + + // check 'ddd' + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.AbbreviatedDayNames[(int)dt.DayOfWeek], + dtOutput1.Substring(0, 3), "Wrong output1 in for 'ddd'"); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.AbbreviatedDayNames[(int)dt.DayOfWeek], + dtOutput2.Substring(0, 3), "Wrong output1 in for 'ddd'"); + + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(5, 2)), "Wrong output1 in for 'dd'"); + Assert.Equal(dt.Day, int.Parse(dtOutput2.Substring(5, 2)), "Wrong output2 in for 'dd'"); + + // check 'MMM' + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.AbbreviatedMonthNames[dt.Month -1], + dtOutput1.Substring(8, 3), "Wrong output1 in for 'MMM'"); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.AbbreviatedMonthNames[dt.Month - 1], + dtOutput2.Substring(8, 3), "Wrong output1 in for 'MMM'"); + + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(12, 4)), "Wrong output1 for 'yyyy'"); + Assert.Equal(dt.Year, int.Parse(dtOutput2.Substring(12, 4)), "Wrong output2 for 'yyyy'"); + + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(17, 2)), "Wrong output1 in for 'HH'"); + Assert.Equal(dt.Hour, int.Parse(dtOutput2.Substring(17, 2)), "Wrong output2 in for 'HH'"); + + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(20, 2)), "Wrong output1 in for 'mm'"); + Assert.Equal(dt.Minute, int.Parse(dtOutput2.Substring(20, 2)), "Wrong output2 in for 'mm'"); + + // check 'ss' + Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(23, 2)), "Wrong output1 in for 'ss'"); + Assert.Equal(dt.Second, int.Parse(dtOutput2.Substring(23, 2)), "Wrong output2 in for 'ss'"); + + // check ',' + Assert.Equal(",", dtOutput1.Substring(3, 1), "Wrong output1 in for ','"); + Assert.Equal(",", dtOutput2.Substring(3, 1), "Wrong output1 in for ','"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(4, 1), "Wrong output1 in for ' '"); + Assert.Equal(" ", dtOutput2.Substring(4, 1), "Wrong output2 in for ' '"); + Assert.Equal(" ", dtOutput1.Substring(7, 1), "Wrong output1 in for ' '"); + Assert.Equal(" ", dtOutput2.Substring(7, 1), "Wrong output2 in for ' '"); + Assert.Equal(" ", dtOutput1.Substring(11, 1), "Wrong output1 in for ' '"); + Assert.Equal(" ", dtOutput2.Substring(11, 1), "Wrong output2 in for ' '"); + Assert.Equal(" ", dtOutput1.Substring(16, 1), "Wrong output1 in for ' '"); + Assert.Equal(" ", dtOutput2.Substring(16, 1), "Wrong output2 in for ' '"); + Assert.Equal(" ", dtOutput1.Substring(25, 1), "Wrong output1 in for ' '"); + Assert.Equal(" ", dtOutput2.Substring(25, 1), "Wrong output2 in for ' '"); + + // check ':' + Assert.Equal(":", dtOutput1.Substring(19, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput2.Substring(19, 1), "Wrong output2 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(22, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput2.Substring(22, 1), "Wrong output2 in for ':'"); + + // check 'GMT' + Assert.Equal("GMT", dtOutput1.Substring(26, 3), "Wrong output1 in for 'GMT'"); + Assert.Equal("GMT", dtOutput2.Substring(26, 3), "Wrong output2 in for 'GMT'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest17() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // SortableDateTimePattern + var specifier1 = "s"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + // expected format is yyyy-MM-ddTHH:mm:ss + + int length = 19; + + // check length + Assert.True(length == dtOutput1.Length, $"Wrong output1 length: {dtOutput1.Length}, should have been {length}"); + + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(0, 4)), "Wrong output1 for 'yyyy'"); + // check 'MM' + Assert.Equal(dt.Month, int.Parse(dtOutput1.Substring(5, 2)), "Wrong output1 in for 'MM'"); + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(8, 2)), "Wrong output1 in for 'dd'"); + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(11, 2)), "Wrong output1 in for 'HH'"); + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(14, 2)), "Wrong output1 in for 'mm'"); + // check 'ss' + Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(17, 2)), "Wrong output1 in for 'ss'"); + + // check '-' + Assert.Equal("-", dtOutput1.Substring(4, 1), "Wrong output1 in for '-'"); + Assert.Equal("-", dtOutput1.Substring(7, 1), "Wrong output1 in for '-'"); + + // check 'T' + Assert.Equal("T", dtOutput1.Substring(10, 1), "Wrong output1 in for 'T'"); + + // check ':' + Assert.Equal(":", dtOutput1.Substring(13, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(16, 1), "Wrong output1 in for ':'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest18() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // long time + var specifier1 = "T"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + // expected format is HH:mm:ss + + int length = 8; + + // check length + Assert.True(dtOutput1.Length >= length, $"Wrong output1 length: {dtOutput1.Length}, should have been at least {length}"); + + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(0, 2)), "Wrong output1 in for 'HH'"); + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(3, 2)), "Wrong output1 in for 'mm'"); + // check 'ss' + Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(6, 2)), "Wrong output1 in for 'ss'"); + + // check ':' + Assert.Equal(":", dtOutput1.Substring(2, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(5, 1), "Wrong output1 in for ':'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest19() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // short time + var specifier1 = "t"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + // expected format is HH:mm + + int length = 5; + + // check length + Assert.True(dtOutput1.Length >= length, $"Wrong output1 length: {dtOutput1.Length}, should have been at least {length}"); + + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(0, 2)), "Wrong output1 in for 'HH'"); + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(3, 2)), "Wrong output1 in for 'mm'"); + + // check ':' + Assert.Equal(":", dtOutput1.Substring(2, 1), "Wrong output1 in for ':'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest20() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // UniversalSortableDateTimePattern + var specifier1 = "u"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + // expected format is yyyy-MM-dd HH:mm:ssZ + + int length = 20; + + // check length + Assert.True(length == dtOutput1.Length, $"Wrong output1 length: {dtOutput1.Length}, should have been {length}"); + + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(0, 4)), "Wrong output1 for 'yyyy'"); + // check 'MM' + Assert.Equal(dt.Month, int.Parse(dtOutput1.Substring(5, 2)), "Wrong output1 in for 'MM'"); + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(8, 2)), "Wrong output1 in for 'dd'"); + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(11, 2)), "Wrong output1 in for 'HH'"); + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(14, 2)), "Wrong output1 in for 'mm'"); + // check 'ss' + Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(17, 2)), "Wrong output1 in for 'ss'"); + + // check '-' + Assert.Equal("-", dtOutput1.Substring(4, 1), "Wrong output1 in for '-'"); + Assert.Equal("-", dtOutput1.Substring(7, 1), "Wrong output1 in for '-'"); + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(10, 1), "Wrong output1 in for ' '"); + // check ':' + Assert.Equal(":", dtOutput1.Substring(13, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(16, 1), "Wrong output1 in for ':'"); + // check 'Z' + Assert.Equal("Z", dtOutput1.Substring(19, 1), "Wrong output1 in for 'Z'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest21() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // FullDateTimePattern + var specifier1 = "U"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + // expected format is dddd, dd MMMM yyyy HH:mm:ss + + int minLength = 19; + + // check length + Assert.True(dtOutput1.Length > minLength, $"Wrong output1 length: {dtOutput1.Length}, should have been at least {minLength}"); + + // check 'dddd' + int endIndex = dtOutput1.IndexOf(','); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.DayNames[(int)dt.DayOfWeek], + dtOutput1.Substring(0, endIndex), + "Wrong output1 for 'dddd'"); + + // check ',' + Assert.Equal(",", dtOutput1.Substring(endIndex, 1), "Wrong output1 in for ','"); + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex + 1, 1), "Wrong output1 in for ' '"); + + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(endIndex + 2, 2)), "Wrong output1 in for 'dd'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex + 4, 1), "Wrong output1 in for ' '"); + + // check 'MMMM' + var startIndex = dtOutput1.IndexOf(' ', endIndex + 2); + endIndex = dtOutput1.IndexOf(' ', startIndex + 1); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.MonthNames[dt.Month - 1], + dtOutput1.Substring(startIndex + 1, endIndex - 1 - startIndex), + "Wrong output1 in for 'MMMM'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex, 1), "Wrong output1 in for ' '"); + + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(endIndex + 1, 4)), "Wrong output1 for 'yyyy'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(endIndex + 5, 1), "Wrong output1 in for ' '"); + + startIndex = endIndex + 6; + + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(startIndex, 2)), "Wrong output1 in for 'HH'"); + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(startIndex + 3, 2)), "Wrong output1 in for 'mm'"); + // check 'ss' + Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(startIndex + 6, 2)), "Wrong output1 in for 'ss'"); + + // check ':' + Assert.Equal(":", dtOutput1.Substring(startIndex + 2, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(startIndex + 5, 1), "Wrong output1 in for ':'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest22() { /// /// 1. Creates a DateTime - /// 2. Verifies that it correctly returns a string from ToString + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format /// - /// OutputHelper.WriteLine("Generating random DateTime"); + DateTime dt = GetRandomDateTime(); - int[] intArr = new int[] { dt.Month, dt.Day, dt.Year, dt.Hour, dt.Minute, dt.Second }; - string[] strArr = new string[] { "", "", "", "", "", "" }; - for (int i = 0; i < intArr.Length; i++) + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // YearMonthPattern + var specifier1 = "y"; + var specifier2 = "Y"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}' and '{specifier2}'"); + + try { - if (i == 2) + string dtOutput1 = dt.ToString(specifier1); + string dtOutput2 = dt.ToString(specifier2); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + OutputHelper.WriteLine($"Output from ToString(\"{specifier2}\") was '{dtOutput2}'"); + + // expected format is yyyy MMMM + + int minLength = 6; + + // check length + Assert.True(dtOutput1.Length > minLength, $"Wrong output1 length: {dtOutput1.Length}, should have been at least {minLength}"); + Assert.True(dtOutput2.Length > minLength, $"Wrong output1 length: {dtOutput2.Length}, should have been at least {minLength}"); + + // check 'yyyy' + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(0, 4)), "Wrong output1 for 'yyyy'"); + Assert.Equal(dt.Year, int.Parse(dtOutput2.Substring(0, 4)), "Wrong output2 for 'yyyy'"); + + // check 'MMMM' + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.MonthNames[dt.Month - 1], + dtOutput1.Substring(5, dtOutput1.Length - 5), + "Wrong output1 in for 'MMMM'"); + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.MonthNames[dt.Month - 1], + dtOutput1.Substring(5, dtOutput2.Length - 5), + "Wrong output1 in for 'MMMM'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(4, 1), "Wrong output1 in for ' '"); + Assert.Equal(" ", dtOutput2.Substring(4, 1), "Wrong output2 in for ' '"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest23() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + var specifier1 = "h:mm:ss.ff t"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + int minLength = 12; + + // check length + Assert.True(dtOutput1.Length >= minLength, $"Wrong output1 length: {dtOutput1.Length}, should have been at least {minLength}"); + + // check 'h' + var endIndex = dtOutput1.IndexOf(':'); + + var hour12 = dt.Hour % 12; + if (hour12 == 0) { - if (intArr[2] < 100) - strArr[2] += "00" + intArr[2]; - else if (intArr[2] < 1000) - strArr[2] += "0" + intArr[2]; - else - strArr[2] += intArr[2]; + hour12 = 12; } - else + Assert.Equal(hour12, int.Parse(dtOutput1.Substring(0, endIndex)), "Wrong output1 for 'h'"); + + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(endIndex + 1, 2)), "Wrong output1 in for 'mm'"); + + // check 'ss' + Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(endIndex + 4, 2)), "Wrong output1 in for 'ss'"); + + // check 'ff' + // need to do the math to get the fraction part from ticks + var fraction = dt.Ticks % _TicksPerSecond; + Assert.Equal(fraction.ToString("D7").Substring(0, 2), dtOutput1.Substring(endIndex + 7, 2), "Wrong output1 in for 'ff'"); + + // check 't' + if (dt.Hour < 12) { - if (intArr[i] < 10) + if (CultureInfo.CurrentUICulture.DateTimeFormat.AMDesignator.Length >= 1) { - strArr[i] += "0" + intArr[i]; + Assert.Equal(CultureInfo.CurrentUICulture.DateTimeFormat.AMDesignator[0].ToString(), dtOutput1.Substring(dtOutput1.Length - 1, 1), "Wrong output1 in for 't'"); } - else - strArr[i] += intArr[i]; } + else + { + Assert.Equal(CultureInfo.CurrentUICulture.DateTimeFormat.PMDesignator[0].ToString(), dtOutput1.Substring(dtOutput1.Length - 1, 1), "Wrong output1 in for 't'"); + } + + // check ':' + Assert.Equal(":", dtOutput1.Substring(endIndex, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(endIndex + 3, 1), "Wrong output1 in for ':'"); + + // check '.' + Assert.Equal(".", dtOutput1.Substring(endIndex + 6, 1), "Wrong output1 in for '.'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); } - string str = strArr[0] + "/" + strArr[1] + "/" + strArr[2] + " " + strArr[3] + ":" + strArr[4] + ":" + strArr[5]; - Assert.Equal(dt.ToString(), str); } [TestMethod] - public void DateTime_ToStringTest7() - { - /// - /// 1. Creates a DateTime - /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format - /// - OutputHelper.WriteLine("Generating random DateTime"); - DateTime dt = GetRandomDateTime(); - OutputHelper.WriteLine("DateTime.ToString(String) using Standard Formats and Verifying"); - string[] standardFmts = { "d", "D", "f", "F", "g", "G", "m", "M", "o", "O", "R", "r", "s", "t", "T", "u", "U", "Y", "y" }; - foreach (string standardFmt in standardFmts) - { - try - { - if (dt.ToString(standardFmt).Length < 1) - { - throw new Exception("Expected a String length greater than '0' but got '" + - dt.ToString(standardFmt).Length + "'"); - } - } - catch (Exception ex) - { - throw new Exception("Caught " + ex.Message + " when Trying DateTime.ToString(" + standardFmt + ")"); - } - OutputHelper.WriteLine("Successfully verified 'DateTime.ToString(" + standardFmt + ")' format as: " + dt.ToString(standardFmt)); - } - OutputHelper.WriteLine("DateTime.ToString(String) using Custom Formats and Verifying"); - string[] customFmts = {"h:mm:ss.ff t", "d MMM yyyy", "HH:mm:ss.f","dd MMM HH:mm:ss", - @"\Mon\t\h\: M", "MM/dd/yyyy", "dddd, dd MMMM yyyy", "MMMM dd", "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", - "yyyy'-'MM'-'dd'T'HH':'mm':'ss", "HH:mm", "yyyy'-'MM'-'dd HH':'mm':'ss'Z'", "yyyy MMMM"}; - foreach (string customFmt in customFmts) - { - try - { - if (dt.ToString(customFmt).Length < 1) - { - throw new Exception("Expected a String length greater than '0' but got '" + - dt.ToString(customFmt).Length + "'"); - } - } - catch (Exception ex) - { - throw new Exception("Caught " + ex.Message + " when Trying DateTime.ToString(" + customFmt + ")"); - } - OutputHelper.WriteLine("Successfully verified 'DateTime.ToString(" + customFmt + ")' format as: " + dt.ToString(customFmt)); - } - } - - [TestMethod] - public void DateTime_ToStringTest8() + public void DateTime_ToStringTest24() { /// /// 1. Creates a DateTime @@ -219,84 +1269,193 @@ public void DateTime_ToStringTest8() OutputHelper.WriteLine($"Test DateTime is: {dt}"); - OutputHelper.WriteLine("DateTime.ToString(String) using specified formats and Verifying"); - - // "o" and "O" - string specifier1 = "o"; - string specifier2 = "O"; + var specifier1 = "d MMM yyyy"; - OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}' and '{specifier2}'"); + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); try { string dtOutput1 = dt.ToString(specifier1); - string dtOutput2 = dt.ToString(specifier2); OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); - OutputHelper.WriteLine($"Output from ToString(\"{specifier2}\") was '{dtOutput2}'"); - // expected format is yyyy-MM-ddTHH:mm:ss.fffffffZ - - int length = 28; + int minLength = 10; // check length - Assert.True(length == dtOutput1.Length, $"Wrong output1 length: {dtOutput1.Length}, should have been {length}"); - Assert.True(length == dtOutput2.Length, $"Wrong output1 length: {dtOutput2.Length}, should have been {length}"); + Assert.True(dtOutput1.Length >= minLength, $"Wrong output1 length: {dtOutput1.Length}, should have been at least {minLength}"); + + // check 'd' + var endIndex = dtOutput1.IndexOf(' '); + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(0, endIndex)), "Wrong output1 in for 'd'"); + + // check 'MMM' + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.AbbreviatedMonthNames[dt.Month - 1], + dtOutput1.Substring(endIndex + 1, 3), "Wrong output1 in for 'MMM'"); // check 'yyyy' - Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(0, 4)), "Wrong output1 for 'yyyy'"); - Assert.Equal(dt.Year, int.Parse(dtOutput2.Substring(0, 4)), "Wrong output2 for 'yyyy'"); - // check 'MM' - Assert.Equal(dt.Month, int.Parse(dtOutput1.Substring(5, 2)), "Wrong output1 in for 'MM'"); - Assert.Equal(dt.Month, int.Parse(dtOutput2.Substring(5, 2)), "Wrong output2 in for 'MM'"); - // check 'dd' - Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(8, 2)), "Wrong output1 in for 'dd'"); - Assert.Equal(dt.Day, int.Parse(dtOutput2.Substring(8, 2)), "Wrong output2 in for 'dd'"); + Assert.Equal(dt.Year, int.Parse(dtOutput1.Substring(endIndex + 5, 4)), "Wrong output1 for 'yyyy'"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest25() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + var specifier1 = "HH:mm:ss.f"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + int length = 10; + + // check length + Assert.True(dtOutput1.Length == length, $"Wrong output1 length: {dtOutput1.Length}, should have been {length}"); + // check 'HH' - Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(11, 2)), "Wrong output1 in for 'HH'"); - Assert.Equal(dt.Hour, int.Parse(dtOutput2.Substring(11, 2)), "Wrong output2 in for 'HH'"); + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(0, 2)), "Wrong output1 in for 'HH'"); + // check 'mm' - Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(14, 2)), "Wrong output1 in for 'mm'"); - Assert.Equal(dt.Minute, int.Parse(dtOutput2.Substring(14, 2)), "Wrong output2 in for 'mm'"); + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(3, 2)), "Wrong output1 in for 'mm'"); + // check 'ss' - Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(17, 2)), "Wrong output1 in for 'ss'"); - Assert.Equal(dt.Second, int.Parse(dtOutput2.Substring(17, 2)), "Wrong output2 in for 'ss'"); + Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(6, 2)), "Wrong output1 in for 'ss'"); - // check 'fffffff' + // check 'f' // need to do the math to get the fraction part from ticks var fraction = dt.Ticks % _TicksPerSecond; - Assert.Equal(fraction, int.Parse(dtOutput1.Substring(20, 7)), "Wrong output1 in for 'fffffff'"); - Assert.Equal(fraction, int.Parse(dtOutput2.Substring(20, 7)), "Wrong output2 in for 'fffffff'"); + Assert.Equal(fraction.ToString().Substring(0, 1), dtOutput1.Substring(9, 1), "Wrong output1 in for 'f'"); - // check '-' - Assert.Equal("-", dtOutput1.Substring(4, 1), "Wrong output1 in for '-'"); - Assert.Equal("-", dtOutput2.Substring(4, 1), "Wrong output2 in for '-'"); - Assert.Equal("-", dtOutput1.Substring(7, 1), "Wrong output1 in for '-'"); - Assert.Equal("-", dtOutput2.Substring(7, 1), "Wrong output2 in for '-'"); - // check 'T' - Assert.Equal("T", dtOutput1.Substring(10, 1), "Wrong output1 in for 'T'"); - Assert.Equal("T", dtOutput2.Substring(10, 1), "Wrong output2 in for 'T'"); // check ':' - Assert.Equal(":", dtOutput1.Substring(13, 1), "Wrong output1 in for ':'"); - Assert.Equal(":", dtOutput2.Substring(13, 1), "Wrong output2 in for ':'"); - Assert.Equal(":", dtOutput1.Substring(16, 1), "Wrong output1 in for ':'"); - Assert.Equal(":", dtOutput2.Substring(16, 1), "Wrong output2 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(2, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(5, 1), "Wrong output1 in for ':'"); + // check '.' - Assert.Equal(".", dtOutput1.Substring(19, 1), "Wrong output1 in for '.'"); - Assert.Equal(".", dtOutput2.Substring(19, 1), "Wrong output2 in for '.'"); - // check 'Z' - Assert.Equal("Z", dtOutput1.Substring(27, 1), "Wrong output1 in for 'Z'"); - Assert.Equal("Z", dtOutput2.Substring(27, 1), "Wrong output2 in for 'Z'"); + Assert.Equal(".", dtOutput1.Substring(8, 1), "Wrong output1 in for '.'"); } catch (Exception ex) { throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); } + } + + [TestMethod] + public void DateTime_ToStringTest26() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + var specifier1 = "dd MMM HH:mm:ss"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + int length = 15; + + // check length + Assert.True(dtOutput1.Length == length, $"Wrong output1 length: {dtOutput1.Length}, should have been {length}"); + + // check 'dd' + Assert.Equal(dt.Day, int.Parse(dtOutput1.Substring(0, 2)), "Wrong output1 in for 'dd'"); - OutputHelper.WriteLine(""); + // check 'MMM' + Assert.Equal( + DateTimeFormatInfo.CurrentInfo.AbbreviatedMonthNames[dt.Month - 1], + dtOutput1.Substring(3, 3), + "Wrong output1 in for 'MMM'"); + // check 'HH' + Assert.Equal(dt.Hour, int.Parse(dtOutput1.Substring(7, 2)), "Wrong output1 in for 'HH'"); + + // check 'mm' + Assert.Equal(dt.Minute, int.Parse(dtOutput1.Substring(7+3, 2)), "Wrong output1 in for 'mm'"); + + // check 'ss' + Assert.Equal(dt.Second, int.Parse(dtOutput1.Substring(7+6, 2)), "Wrong output1 in for 'ss'"); + + // check ':' + Assert.Equal(":", dtOutput1.Substring(7+2, 1), "Wrong output1 in for ':'"); + Assert.Equal(":", dtOutput1.Substring(7+5, 1), "Wrong output1 in for ':'"); + + // check ' ' + Assert.Equal(" ", dtOutput1.Substring(2, 1), "Wrong output1 in for ' '"); + Assert.Equal(" ", dtOutput1.Substring(6, 1), "Wrong output1 in for ' '"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } } + [TestMethod] + public void DateTime_ToStringTest27() + { + /// + /// 1. Creates a DateTime + /// 2. Verifies DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + var specifier1 = @"\Mon\t\h\: M"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + int minLength = 8; + + // check length + Assert.True(dtOutput1.Length >= minLength, $"Wrong output1 length: {dtOutput1.Length}, should have been at least {minLength}"); + + // check 'M' + Assert.Equal(dt.Month, int.Parse(dtOutput1.Substring(7)), "Wrong output1 in for 'M'"); + + // check 'Month: ' + Assert.Equal("Month: ", dtOutput1.Substring(0, 7), "Wrong output1 in for 'Month: '"); + } + catch (Exception ex) + { + throw new Exception($"Caught {ex.Message} when Trying DateTime.ToString(\"{specifier1}\")"); + } + } [TestMethod] public void DateTime_AddTest8() @@ -822,7 +1981,7 @@ public void DateTime_op_EqualityTest33() OutputHelper.WriteLine("Creating another DateTime equal to previous one"); OutputHelper.WriteLine("Verifying the two DateTimes are equal using '=='"); DateTime dt1 = GetRandomDateTime(); - DateTime dt2 = new DateTime(year, month, day, hour, minute, second, millisec); + DateTime dt2 = new DateTime(dt1.Ticks); if (!(dt1 == dt2)) { @@ -838,7 +1997,7 @@ public void DateTime_op_InequalityTest34() OutputHelper.WriteLine("Creating another Different DateTime"); OutputHelper.WriteLine("Verifying the two DateTimes are not equal using '!='"); DateTime dt1 = GetRandomDateTime(); - DateTime dt2 = new DateTime(year + 1, month, day, hour, minute, second, millisec); + DateTime dt2 = new DateTime(dt1.Ticks + 100); if (!(dt1 != dt2)) { @@ -1131,6 +2290,7 @@ public void DateTime_AboveMaxDatTime_ArgumentOutOfRangeExceptionTest59() static double[] rdmFraction = new double[] { 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 }; static int year, month, day, hour, minute, second, millisec; + static long ticks; static int[] leapYear = new int[] {2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, 2044, 2048, 2052, 2056, 2060, 2064, 2068, 2072, 2076, 2080, 2084, 2088, 2092, 2096}; @@ -1208,7 +2368,15 @@ private DateTime GetRandomDateTime() DateTime dt = new(year, month, day, hour, minute, second, millisec); // fill in random ticks value so we can have a fully filled ticks value - return new DateTime(dt.Ticks + random.Next(1000_000)); + ticks = dt.Ticks + random.Next(1000_000); + + dt = new(ticks); + + // need to update millisec and second because it could have changed with new ticks value + millisec = dt.Millisecond; + second = dt.Second; + + return dt; } private DateTime GetLeapYearDateTime() diff --git a/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormatInfo.cs b/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormatInfo.cs index f524b839..428ed367 100644 --- a/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormatInfo.cs +++ b/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormatInfo.cs @@ -8,19 +8,13 @@ #define ENABLE_CROSS_APPDOMAIN namespace System.Globalization { - using System; - /// /// Provides culture-specific information about the format of date and time values. /// public sealed class DateTimeFormatInfo /*: ICloneable, IFormatProvider*/ { - internal String _generalShortTimePattern = "MM/dd/yyyy HH:mm"; - internal String _generalLongTimePattern = "MM/dd/yyyy HH:mm:ss"; - internal const String _rfc1123Pattern = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"; - internal const String _sortableDateTimePattern = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"; - internal const String _universalSortableDateTimePattern = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"; - internal String _fullDateTimePattern = "dddd, dd MMMM yyyy HH:mm:ss"; + internal const string _sortableDatePattern = "yyyy'-'MM'-'dd"; + internal const string _sortableTimePattern = "HH':'mm':'ss"; internal DateTimeFormatInfo(CultureInfo cultureInfo) { @@ -42,7 +36,7 @@ public static DateTimeFormatInfo CurrentInfo /// Gets the string designator for hours that are "ante meridiem" (before noon). /// /// The string designator for hours that are ante meridiem. The default for InvariantInfo is "AM". - public String AMDesignator + public string AMDesignator { get { @@ -54,7 +48,7 @@ public String AMDesignator /// Gets the string that separates the components of a date, that is, the year, month, and day. /// /// The string that separates the components of a date, that is, the year, month, and day. The default for InvariantInfo is "/". - public String DateSeparator + public string DateSeparator { get { @@ -66,11 +60,11 @@ public String DateSeparator /// Gets the custom format string for a long date and long time value. /// /// The custom format string for a long date and long time value. - public String FullDateTimePattern + public string FullDateTimePattern { get { - return _fullDateTimePattern; + return LongDatePattern + " " + LongTimePattern; } } @@ -78,7 +72,7 @@ public String FullDateTimePattern /// Gets the custom format string for a long date value. /// /// The custom format string for a long date value. - public String LongDatePattern + public string LongDatePattern { get { @@ -90,7 +84,7 @@ public String LongDatePattern /// Gets the custom format string for a long time value. /// /// The format pattern for a long time value. - public String LongTimePattern + public string LongTimePattern { get { @@ -102,7 +96,7 @@ public String LongTimePattern /// Gets the custom format string for a month and day value. /// /// The custom format string for a month and day value. - public String MonthDayPattern + public string MonthDayPattern { get { @@ -114,7 +108,7 @@ public String MonthDayPattern /// Gets the string designator for hours that are "post meridiem" (after noon). /// /// The string designator for hours that are "post meridiem" (after noon). The default for InvariantInfo is "PM". - public String PMDesignator + public string PMDesignator { get { @@ -126,11 +120,11 @@ public String PMDesignator /// Gets the custom format string for a time value that is based on the Internet Engineering Task Force (IETF) Request for Comments (RFC) 1123 specification. /// /// The custom format string for a time value that is based on the IETF RFC 1123 specification. - public String RFC1123Pattern + public string RFC1123Pattern { get { - return _rfc1123Pattern; + return "ddd, dd MMM yyyy " + _sortableTimePattern + " 'GMT'"; } } @@ -138,7 +132,7 @@ public String RFC1123Pattern /// Gets the custom format string for a short date value. /// /// The custom format string for a short date value. - public String ShortDatePattern + public string ShortDatePattern { get { @@ -150,7 +144,7 @@ public String ShortDatePattern /// Gets the custom format string for a short time value. /// /// The custom format string for a short time value. - public String ShortTimePattern + public string ShortTimePattern { get { @@ -162,27 +156,27 @@ public String ShortTimePattern /// Gets the custom format string for a sortable date and time value. /// /// The custom format string for a sortable date and time value. - public String SortableDateTimePattern + public string SortableDateTimePattern { get { - return _sortableDateTimePattern; + return _sortableDatePattern + "'T'" + _sortableTimePattern; } } - internal String GeneralShortTimePattern + internal string GeneralShortTimePattern { get { - return _generalShortTimePattern; + return ShortDatePattern + " " + ShortTimePattern; } } - internal String GeneralLongTimePattern + internal string GeneralLongTimePattern { get { - return _generalLongTimePattern; + return ShortDatePattern + " " + LongTimePattern; } } @@ -190,7 +184,7 @@ internal String GeneralLongTimePattern /// Gets the string that separates the components of time, that is, the hour, minutes, and seconds. /// /// The string that separates the components of time. The default for InvariantInfo is ":". - public String TimeSeparator + public string TimeSeparator { get { @@ -202,11 +196,11 @@ public String TimeSeparator /// Gets the custom format string for a universal, sortable date and time string. /// /// The custom format string for a universal, sortable date and time string. - public String UniversalSortableDateTimePattern + public string UniversalSortableDateTimePattern { get { - return _universalSortableDateTimePattern; + return _sortableDatePattern + " " + _sortableTimePattern + "'Z'"; } } @@ -214,7 +208,7 @@ public String UniversalSortableDateTimePattern /// Gets the custom format string for a year and month value. /// /// The custom format string for a year and month value. - public String YearMonthPattern + public string YearMonthPattern { get { @@ -226,11 +220,11 @@ public String YearMonthPattern /// Gets a one-dimensional array of type String containing the culture-specific abbreviated names of the days of the week. /// /// A one-dimensional array of type String containing the culture-specific abbreviated names of the days of the week. The array for InvariantInfo contains "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", and "Sat". - public String[] AbbreviatedDayNames + public string[] AbbreviatedDayNames { get { - return new String[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + return new string[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; } } @@ -238,11 +232,11 @@ public String[] AbbreviatedDayNames /// Gets a one-dimensional string array that contains the culture-specific full names of the days of the week. /// /// A one-dimensional string array that contains the culture-specific full names of the days of the week. The array for InvariantInfo contains "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", and "Saturday". - public String[] DayNames + public string[] DayNames { get { - return new String[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; + return new string[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; } } @@ -251,11 +245,11 @@ public String[] DayNames /// /// A one-dimensional string array with 13 elements that contains the culture-specific abbreviated names of the months. For 12-month calendars, the 13th element of the array is an empty string. /// The array for InvariantInfo contains "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", and "". - public String[] AbbreviatedMonthNames + public string[] AbbreviatedMonthNames { get { - return new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "" }; + return new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "" }; } } @@ -264,11 +258,11 @@ public String[] AbbreviatedMonthNames /// /// A one-dimensional array of type String containing the culture-specific full names of the months. In a 12-month calendar, the 13th element of the array is an empty string. /// The array for InvariantInfo contains "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", and "". - public String[] MonthNames + public string[] MonthNames { get { - return new String[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "" }; + return new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "" }; } } } From d7bb7cf68e8667061acea009cf2c4d7c8d016b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Wed, 13 Oct 2021 13:06:21 +0100 Subject: [PATCH 05/18] Fix DateTime_ToString Test25 (#160) ***NO_CI*** --- Tests/NFUnitTestSystemLib/UnitTestDateTime.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs b/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs index 18e63fee..d9646df0 100644 --- a/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs +++ b/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs @@ -1342,7 +1342,7 @@ public void DateTime_ToStringTest25() // check 'f' // need to do the math to get the fraction part from ticks var fraction = dt.Ticks % _TicksPerSecond; - Assert.Equal(fraction.ToString().Substring(0, 1), dtOutput1.Substring(9, 1), "Wrong output1 in for 'f'"); + Assert.Equal(fraction.ToString("D7").Substring(0, 1), dtOutput1.Substring(9, 1), "Wrong output1 in for 'f'"); // check ':' Assert.Equal(":", dtOutput1.Substring(2, 1), "Wrong output1 in for ':'"); From 39010d41b27bdaba7cca6141c6bee8e8f9292b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Mon, 18 Oct 2021 23:10:41 +0100 Subject: [PATCH 06/18] Work CI-CD - Add new repos to update task. ***NO_CI*** --- azure-pipelines.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9bd65839..3449cf56 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -156,6 +156,7 @@ jobs: inputs: gitHubToken: $(GitHubToken) repositoriesToUpdate: | + nanoFramework.Devices.OneWire nanoFramework.Runtime.Events nanoFramework.Runtime.Native nanoFramework.TestFramework @@ -163,6 +164,7 @@ jobs: nanoFramework.Devices.OneWire nanoFramework.Networking.Sntp nanoFramework.Hardware.Stm32 + nanoFramework.Hardware.TI nanoFramework.TI.EasyLink nanoFramework.ResourceManager nanoFramework.Json @@ -173,6 +175,7 @@ jobs: System.Device.Dac System.Device.I2c System.Device.Spi + System.Device.Pwm System.Threading System.Math System.Collections From 4525a27ef6856877f50ee251edbcfff170899089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Wed, 27 Oct 2021 16:01:47 +0100 Subject: [PATCH 07/18] Work CI-CD - Add System.Device.Adc to dependents to update list. - Reorder list. - Update gitignore. ***NO_CI*** --- .gitignore | 3 +++ azure-pipelines.yml | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index aee58232..8e103c8d 100644 --- a/.gitignore +++ b/.gitignore @@ -255,3 +255,6 @@ paket-files/ #SoundCloud *.sonarqube/ + +# VS Code +.vscode/settings.json diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3449cf56..4abea2c0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -172,14 +172,15 @@ jobs: Windows.Devices.I2c Windows.Devices.Pwm Windows.Devices.Spi + System.Collections + System.Device.Adc System.Device.Dac System.Device.I2c - System.Device.Spi System.Device.Pwm - System.Threading + System.Device.Spi System.Math - System.Collections System.Text + System.Threading displayName: Update dependent class libs ################################## From f439af108ca04c9c263879d2ba7c84cda8c00a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Thu, 11 Nov 2021 12:50:50 +0000 Subject: [PATCH 08/18] Work CI-CD - Migrate projects to use VS2022. - Update logo for nuget packages. - Reorder nuget sources. ***NO_CI*** --- NuGet.Config | 2 +- assets/nf-logo.png | Bin 4129 -> 9200 bytes .../CoreLibrary.NoReflection.nfproj | 2 +- nanoFramework.CoreLibrary/CoreLibrary.nfproj | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index 0521fe64..ef0bacfd 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + diff --git a/assets/nf-logo.png b/assets/nf-logo.png index 6f576caa11431ae1f032fde71fd1ec0bd049ed39..572c4ff374c386db1a9c1e670f4c880ed4ccec63 100644 GIT binary patch literal 9200 zcmVpF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H1AOJ~3 zK~#90?R|NC6-B!CQ+=`rvJ(n>Sa+-aAA{01;UO%2!u6cAqm+|lGFE(bGo~_yS6?#8Rz?M-ro;$`aM-|y;aY< zR8?1>2HL2N+Nh1%sEyjFjoPS<+US25k(LVR)8pzhe42i-uIr<8P0It&5d_hObR8tv ziqR4w(CL=xG8A7Y9GE>+hP z2!b}9@>QaR0ib74t#Qyr^7(C^(slisvJapC0*d5QE!a1A<~<1p3s{_y4vK z5|SD~-=0?w&^4?D(9ZNy8StiJPF^JQJWF0==MhZc5zge0@?>rqhb(TJ6z~om9Bo#E z=p)MCeQpN?6eao+0CXQ-0?^KA+zEox3P9w|wz}cwd6qo3XZ@ym-niy?bA;y+?R7%t z0vH1U2_ryW?$wi^VIdpT@Rwa`M$<~mI?13%a=(Bj-wrC%bL|Gg;_>9Oj7<+rsQCMH zOTZy<1n}X}*3R>+x{=&3aDyrU#v$J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`Hm42c( zH&_Z(havY$!-q%u$4k-^Jy}x-EYtMb!TxyUMXs5VF zXvXo@gy4|PUg+LvFTeAKf}zf@RF%i-UkS|`Y+V&9^5n+(>s5kz=!t$$AS7vB9@Kq# z!hXRqcqVKbl8jZ$B@xk}N+koZUtB4;T{!6lOaf(C^Da4KP9FUi#KndcN(sBhl)IR1 zjTJ*azL(#EEDkeTT;!uL${VFseCza_n*tze5v5q33&BvqjaN@#JyZS()xCqmms@Z7hlQdp~%Mj(y?yU_VQLEXjUmbXQ2;n*zHv)L?!CU2noM zaj8YrgA==5d`73qa%0orSyE7EQVomATEUr)q-O9s(Nmj$bmPWg@gt@GlD2haMuBf? zSshPsqG8B~fWo}w+1GQ?jzr|*~+$lvC2X-&?{ zvC+`h!nC@M1;1CtzXf>=G=_HntF@%Bs7~v#<78-IpTGR^j}j6Xt;(wfQx)Fi2T|6z z=&-lUOBg$2WtbejO)!LWieK(FRr-Rp9-;kDkIkv%VbY>u#}Lc)V2!}QoHI08nS9r& zjLTnrnC$4ZFDHrI0!v5YqHE-b$fIO{e|2D={A3I}9W6_5bT&wH0lP`i=9txRjoWg; z>+h5}O8lvMF6tY@zP$G`&omXY$|scj9rKJyP}n^$^4HAMq{#lgR%ld~)I&G`VS5o3 zFUJg}>2l_F#g(vEHl?MXwdh-^0pXlrU#da;p>BhmZM@pa{+ZEf>gU<`xo_qdj+H`4 zHs$~Z>$kPJk0T87YRaHl+(0T-t4yZRpkY$`qz!g6($oPgSvM|r|Ikv98KKPax~o;- zSPC){=Lw=@q)#m-pj1$2_0Q0|&9Y7j?v)4voHhS1l8)gC81tmXyP8B_+`RRGs-mVs JDbnoI{{Xpk+?xOZ diff --git a/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj b/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj index 5ecb1c73..e39eba35 100644 --- a/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj +++ b/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/nanoFramework.CoreLibrary/CoreLibrary.nfproj b/nanoFramework.CoreLibrary/CoreLibrary.nfproj index d25bde3c..4612b463 100644 --- a/nanoFramework.CoreLibrary/CoreLibrary.nfproj +++ b/nanoFramework.CoreLibrary/CoreLibrary.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ From e03eb3f8b4c7565a7e5a42cc5613ad6aa71c1145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Sat, 20 Nov 2021 11:32:17 +0000 Subject: [PATCH 09/18] Work CI-CD (#161) ***NO_CI*** --- README.md | 10 ++-- .../NFUnitTest_DummyAdapter.nfproj | 6 +- Tests/NFUnitTest_DummyAdapter/packages.config | 2 +- azure-pipelines.yml | 58 ++++++++++++++++--- nanoFramework.CoreLibrary.NoReflection.nuspec | 4 +- .../CoreLibrary.NoReflection.nfproj | 4 +- .../packages.config | 2 +- nanoFramework.CoreLibrary.nuspec | 4 +- nanoFramework.CoreLibrary/CoreLibrary.nfproj | 4 +- nanoFramework.CoreLibrary/packages.config | 2 +- nanoFramework.TestFramework | 2 +- 11 files changed, 72 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index d8bcc31f..1484e18f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=nanoframework_lib-CoreLibrary&metric=alert_status)](https://sonarcloud.io/dashboard?id=nanoframework_lib-CoreLibrary) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=nanoframework_lib-CoreLibrary&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=nanoframework_lib-CoreLibrary) [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) [![NuGet](https://img.shields.io/nuget/dt/nanoFramework.CoreLibrary.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.CoreLibrary/) [![#yourfirstpr](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](https://github.com/nanoframework/Home/blob/main/CONTRIBUTING.md) [![Discord](https://img.shields.io/discord/478725473862549535.svg?logo=discord&logoColor=white&label=Discord&color=7289DA)](https://discord.gg/gCyBu8T) -![nanoFramework logo](https://github.com/nanoframework/Home/blob/main/resources/logo/nanoFramework-repo-logo.png) +![nanoFramework logo](https://raw.githubusercontent.com/nanoframework/Home/main/resources/logo/nanoFramework-repo-logo.png) ----- -# Welcome to the **nanoFramework** Base Class Library repository! +# Welcome to the .NET **nanoFramework** Base Class Library repository ## Build status @@ -26,7 +26,7 @@ nanoFramework has a dedicated [Unit Test framework](https://github.com/nanoframe CoreLibrary has specific needs that differ from what you'll find in the documentation: -- You need to have the nanoFramework.TestFramework as a nuget package as it will bring the nanoCLR Win32 emulator +- You need to have the nanoFramework.TestFramework as a NuGet package as it will bring the nanoCLR Win32 emulator - You need to remove the reference to mscorlib, nanoFramework.TestFramework and nanoFramework.UnitTestLauncher - Use project reference instead for all those 3 elements @@ -51,7 +51,7 @@ vstest.console.exe .\Tests\NFUnitTestBitConverter\bin\Release\NFUnitTest.dll /S *Notes*: -- You have to build the TestAdapter from the source in this case. You can use the path to the nuget as well, this will have the same effect. +- You have to build the TestAdapter from the source in this case. You can use the path to the NuGet as well, this will have the same effect. - you have full diagnostic enabled in this case. ## Feedback and documentation @@ -70,7 +70,7 @@ The **nanoFramework** Class Libraries are licensed under the [MIT license](LICEN ## Code of Conduct -This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. +This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct). ### .NET Foundation diff --git a/Tests/NFUnitTest_DummyAdapter/NFUnitTest_DummyAdapter.nfproj b/Tests/NFUnitTest_DummyAdapter/NFUnitTest_DummyAdapter.nfproj index ad02e6e5..dd40ea29 100644 --- a/Tests/NFUnitTest_DummyAdapter/NFUnitTest_DummyAdapter.nfproj +++ b/Tests/NFUnitTest_DummyAdapter/NFUnitTest_DummyAdapter.nfproj @@ -40,13 +40,13 @@ True True - - ..\..\packages\nanoFramework.TestFramework.1.0.132\lib\nanoFramework.TestFramework.dll + + ..\..\packages\nanoFramework.TestFramework.1.0.157\lib\nanoFramework.TestFramework.dll True True - ..\..\packages\nanoFramework.TestFramework.1.0.132\lib\nanoFramework.UnitTestLauncher.exe + ..\..\packages\nanoFramework.TestFramework.1.0.157\lib\nanoFramework.UnitTestLauncher.exe True True diff --git a/Tests/NFUnitTest_DummyAdapter/packages.config b/Tests/NFUnitTest_DummyAdapter/packages.config index af86a8a0..4616b1db 100644 --- a/Tests/NFUnitTest_DummyAdapter/packages.config +++ b/Tests/NFUnitTest_DummyAdapter/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4abea2c0..fef7ecf3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,11 +2,13 @@ trigger: branches: include: [main, develop, "release-*" ] paths: - exclude: [README.md, LICENSE.md, NuGet.Config, .github_changelog_generator, .gitignore] + exclude: [README.md, LICENSE.md, CHANGELOG.md, CODE_OF_CONDUCT.md, NuGet.Config, .github_changelog_generator, .gitignore] tags: include: ["v*"] # PR always trigger build +pr: + autoCancel: true # add nf-tools repo to resources (for Azure Pipelines templates) resources: @@ -26,7 +28,7 @@ jobs: variables: DOTNET_NOLOGO: true - solution: '**/*.sln' + solution: 'nanoFramework.CoreLibrary.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' nugetPackageName: 'nanoFramework.CoreLibrary' @@ -76,7 +78,12 @@ jobs: # need to push the other package to NuGet because the template above can only push one package (happens on all builds except PRs) - task: NuGetCommand@2 - condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], ''), eq( variables['StartReleaseCandidate'], false ) ) + condition: >- + and( + succeeded(), + eq(variables['System.PullRequest.PullRequestId'], ''), + eq(variables['StartReleaseCandidate'], false) + ) displayName: Push "NoReflection" variant NuGet package to Azure Artifacts inputs: command: push @@ -88,7 +95,12 @@ jobs: continueOnError: true - task: NuGetCommand@2 - condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], ''), eq( variables['StartReleaseCandidate'], false ) ) + condition: >- + and( + succeeded(), + eq(variables['System.PullRequest.PullRequestId'], ''), + eq(variables['StartReleaseCandidate'], false) + ) displayName: Push "NoReflection" variant NuGet package to Azure Artifacts inputs: command: push @@ -101,7 +113,13 @@ jobs: # create or update GitHub release - task: GithubRelease@1 - condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], ''), not( startsWith(variables['Build.SourceBranch'], 'refs/tags/v') ), ne( variables['StartReleaseCandidate'], true ) ) + condition: >- + and( + succeeded(), + eq(variables['System.PullRequest.PullRequestId'], ''), + not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')), + ne(variables['StartReleaseCandidate'], true) + ) displayName: Create/Update GitHub PREVIEW release inputs: gitHubConnection: 'github.com_nano-$(System.TeamProject)' @@ -117,7 +135,13 @@ jobs: # create or update GitHub release ON tags from release or master branches - task: GithubRelease@1 - condition: and( succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), not(contains(variables['Build.SourceBranch'], 'preview') ), ne( variables['StartReleaseCandidate'], true ) ) + condition: >- + and( + succeeded(), + startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), + not(contains(variables['Build.SourceBranch'], 'preview')), + ne(variables['StartReleaseCandidate'], true) + ) displayName: Create/Update GitHub stable release inputs: gitHubConnection: 'github.com_nano-$(System.TeamProject)' @@ -133,7 +157,20 @@ jobs: ############################## - job: Update_Dependents - condition: or( and( succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['StartReleaseCandidate'], 'false') ), and( succeeded(), contains(variables['getCommitMessage.COMMIT_MESSAGE'], '***UPDATE_DEPENDENTS***'), eq(variables['StartReleaseCandidate'], 'false') ), eq(variables['UPDATE_DEPENDENTS'], 'true') ) + condition: >- + or( + and( + succeeded(), + startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), + eq(variables['StartReleaseCandidate'], 'false') + ), + and( + succeeded(), + contains(variables['getCommitMessage.COMMIT_MESSAGE'], '***UPDATE_DEPENDENTS***'), + eq(variables['StartReleaseCandidate'], 'false') + ), + eq(variables['UPDATE_DEPENDENTS'], 'true') + ) dependsOn: - Build_mscorlib @@ -190,7 +227,12 @@ jobs: dependsOn: - Build_mscorlib - Update_Dependents - condition: or( failed('Build_mscorlib'), failed('Build_mscorlib_no_reflection'), failed('Update_Dependents')) + condition: >- + or( + failed('Build_mscorlib'), + failed('Build_mscorlib_no_reflection'), + failed('Update_Dependents') + ) pool: vmImage: 'windows-2019' diff --git a/nanoFramework.CoreLibrary.NoReflection.nuspec b/nanoFramework.CoreLibrary.NoReflection.nuspec index d1691522..f67d4db9 100644 --- a/nanoFramework.CoreLibrary.NoReflection.nuspec +++ b/nanoFramework.CoreLibrary.NoReflection.nuspec @@ -5,10 +5,11 @@ $version$ nanoFramework.CoreLibrary.NoReflection nanoFramework project contributors - nanoFramework project contributors,dotnetfoundation + nanoFramework,dotnetfoundation false LICENSE.md + docs\README.md false https://github.com/nanoframework/CoreLibrary images\nf-logo.png @@ -25,6 +26,7 @@ + diff --git a/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj b/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj index e39eba35..60d28af6 100644 --- a/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj +++ b/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj @@ -406,11 +406,11 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. - + \ No newline at end of file diff --git a/nanoFramework.CoreLibrary.NoReflection/packages.config b/nanoFramework.CoreLibrary.NoReflection/packages.config index 4812d292..6f7c3459 100644 --- a/nanoFramework.CoreLibrary.NoReflection/packages.config +++ b/nanoFramework.CoreLibrary.NoReflection/packages.config @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/nanoFramework.CoreLibrary.nuspec b/nanoFramework.CoreLibrary.nuspec index ca1325f1..9143d7ae 100644 --- a/nanoFramework.CoreLibrary.nuspec +++ b/nanoFramework.CoreLibrary.nuspec @@ -5,10 +5,11 @@ $version$ nanoFramework.CoreLibrary nanoFramework project contributors - nanoFramework project contributors,dotnetfoundation + nanoFramework,dotnetfoundation false LICENSE.md + docs\README.md false https://github.com/nanoframework/CoreLibrary images\nf-logo.png @@ -25,6 +26,7 @@ + diff --git a/nanoFramework.CoreLibrary/CoreLibrary.nfproj b/nanoFramework.CoreLibrary/CoreLibrary.nfproj index 4612b463..1b2d240e 100644 --- a/nanoFramework.CoreLibrary/CoreLibrary.nfproj +++ b/nanoFramework.CoreLibrary/CoreLibrary.nfproj @@ -398,11 +398,11 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. - + \ No newline at end of file diff --git a/nanoFramework.CoreLibrary/packages.config b/nanoFramework.CoreLibrary/packages.config index 4812d292..6f7c3459 100644 --- a/nanoFramework.CoreLibrary/packages.config +++ b/nanoFramework.CoreLibrary/packages.config @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/nanoFramework.TestFramework b/nanoFramework.TestFramework index 10d54715..9c1674d1 160000 --- a/nanoFramework.TestFramework +++ b/nanoFramework.TestFramework @@ -1 +1 @@ -Subproject commit 10d5471522f26da929b82eba1be2a31fc2e1c469 +Subproject commit 9c1674d1a3f1a067641b4ffdebb37a4aea029f3e From 9c5f2e3f7681fa52c1d9e17e9a956058d5331397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Sat, 20 Nov 2021 11:54:22 +0000 Subject: [PATCH 10/18] Add Console.Write and Console.WriteLine (#162) ***NO_CI*** --- .../System/AssemblyInfo.cs | 2 +- nanoFramework.CoreLibrary/System/Console.cs | 35 +++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/nanoFramework.CoreLibrary/System/AssemblyInfo.cs b/nanoFramework.CoreLibrary/System/AssemblyInfo.cs index 3488e1e1..af4d82ff 100644 --- a/nanoFramework.CoreLibrary/System/AssemblyInfo.cs +++ b/nanoFramework.CoreLibrary/System/AssemblyInfo.cs @@ -13,4 +13,4 @@ [assembly: AssemblyProduct(".NET nanoFramework mscorlib")] [assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors")] -[assembly: AssemblyNativeVersion("100.5.0.12")] +[assembly: AssemblyNativeVersion("100.5.0.14")] diff --git a/nanoFramework.CoreLibrary/System/Console.cs b/nanoFramework.CoreLibrary/System/Console.cs index 169ec5ab..0e09c32c 100644 --- a/nanoFramework.CoreLibrary/System/Console.cs +++ b/nanoFramework.CoreLibrary/System/Console.cs @@ -5,10 +5,39 @@ namespace System { - internal static class Console + /// + /// Writes the specified data, followed by the current line terminator, to the standard output stream. + /// + /// + /// The default line terminator is a string whose value is a carriage return followed by a line feed ("\r\n" in C#, or vbCrLf in Visual Basic). + /// In .NET nanoFramework this will write to Visual Studio Output window. + /// + public static class Console { - internal static void Write(string value) => Diagnostics.Debug.WriteLineNative(value, false); + /// + /// Writes the specified string value, followed by the current line terminator, to the standard output stream. + /// + /// The value to write. + /// + /// In .NET nanoFramework this will write to Visual Studio Output window. + /// + public static void Write(string value) => Diagnostics.Debug.WriteLineNative(value, false); - internal static void WriteLine(string value) => Diagnostics.Debug.WriteLineNative(value, true); + /// + /// Writes the current line terminator to the standard output stream. + /// + /// + /// In .NET nanoFramework this will write to Visual Studio Output window. + /// + public static void WriteLine() => Diagnostics.Debug.WriteLineNative(string.Empty, true); + + /// + /// Writes the specified string value, followed by the current line terminator, to the standard output stream. + /// + /// The value to write. + /// + /// In .NET nanoFramework this will write to Visual Studio Output window. + /// + public static void WriteLine(string value) => Diagnostics.Debug.WriteLineNative(value, true); } } From 6781a2893dba76725e5c887287ffabf5b30a5fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Tue, 23 Nov 2021 11:28:13 +0000 Subject: [PATCH 11/18] Update references to test framework - Missed #161. ***NO_CI*** --- Tests/NFUnitTestArithmetic/NFUnitTestArithmetic.nfproj | 4 ++-- Tests/NFUnitTestArray/NFUnitTestArray.nfproj | 4 ++-- Tests/NFUnitTestAttributes/NFUnitTestAttributes.nfproj | 4 ++-- Tests/NFUnitTestBasicConcepts/NFUnitTestBasicConcepts.nfproj | 4 ++-- Tests/NFUnitTestBitConverter/NFUnitTestBitConverter.nfproj | 4 ++-- Tests/NFUnitTestClasses/NFUnitTestClasses.nfproj | 4 ++-- Tests/NFUnitTestConversions/NFUnitTestConversions.nfproj | 4 ++-- Tests/NFUnitTestDelegates/NFUnitTestDelegates.nfproj | 4 ++-- Tests/NFUnitTestEnum/NFUnitTestEnum.nfproj | 4 ++-- Tests/NFUnitTestException/NFUnitTestException.nfproj | 4 ++-- Tests/NFUnitTestInterface/NFUnitTestInterface.nfproj | 4 ++-- Tests/NFUnitTestLexical/NFUnitTestLexical.nfproj | 4 ++-- Tests/NFUnitTestNamespace/NFUnitTestNamespace.nfproj | 4 ++-- Tests/NFUnitTestStatementsTests/NFUnitTestStatements.nfproj | 4 ++-- Tests/NFUnitTestStruct/NFUnitTestStruct.nfproj | 4 ++-- Tests/NFUnitTestSystemLib/NFUnitTestSystemLib.nfproj | 4 ++-- Tests/NFUnitTestThread/NFUnitTestThread.nfproj | 4 ++-- Tests/NFUnitTestTypes/NFUnitTestTypes.nfproj | 4 ++-- Tests/NFUnitTestVariables/NFUnitTestVariables.nfproj | 4 ++-- Tests/NFUnitTest_DummyAdapter/NFUnitTest_DummyAdapter.nfproj | 4 ++-- 20 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Tests/NFUnitTestArithmetic/NFUnitTestArithmetic.nfproj b/Tests/NFUnitTestArithmetic/NFUnitTestArithmetic.nfproj index 1c54f4a9..a7b3fdb1 100644 --- a/Tests/NFUnitTestArithmetic/NFUnitTestArithmetic.nfproj +++ b/Tests/NFUnitTestArithmetic/NFUnitTestArithmetic.nfproj @@ -44,7 +44,7 @@ - + @@ -54,6 +54,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestArray/NFUnitTestArray.nfproj b/Tests/NFUnitTestArray/NFUnitTestArray.nfproj index 2f1cc2be..76b4117f 100644 --- a/Tests/NFUnitTestArray/NFUnitTestArray.nfproj +++ b/Tests/NFUnitTestArray/NFUnitTestArray.nfproj @@ -41,7 +41,7 @@ - + @@ -51,6 +51,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestAttributes/NFUnitTestAttributes.nfproj b/Tests/NFUnitTestAttributes/NFUnitTestAttributes.nfproj index 34345d7f..61912ebb 100644 --- a/Tests/NFUnitTestAttributes/NFUnitTestAttributes.nfproj +++ b/Tests/NFUnitTestAttributes/NFUnitTestAttributes.nfproj @@ -40,7 +40,7 @@ - + @@ -50,6 +50,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestBasicConcepts/NFUnitTestBasicConcepts.nfproj b/Tests/NFUnitTestBasicConcepts/NFUnitTestBasicConcepts.nfproj index 9d8ef09f..fcf1717f 100644 --- a/Tests/NFUnitTestBasicConcepts/NFUnitTestBasicConcepts.nfproj +++ b/Tests/NFUnitTestBasicConcepts/NFUnitTestBasicConcepts.nfproj @@ -40,7 +40,7 @@ - + @@ -50,6 +50,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestBitConverter/NFUnitTestBitConverter.nfproj b/Tests/NFUnitTestBitConverter/NFUnitTestBitConverter.nfproj index 78dfa437..a255558f 100644 --- a/Tests/NFUnitTestBitConverter/NFUnitTestBitConverter.nfproj +++ b/Tests/NFUnitTestBitConverter/NFUnitTestBitConverter.nfproj @@ -41,7 +41,7 @@ - + @@ -51,6 +51,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestClasses/NFUnitTestClasses.nfproj b/Tests/NFUnitTestClasses/NFUnitTestClasses.nfproj index 6b0e2503..8624185d 100644 --- a/Tests/NFUnitTestClasses/NFUnitTestClasses.nfproj +++ b/Tests/NFUnitTestClasses/NFUnitTestClasses.nfproj @@ -51,7 +51,7 @@ - + @@ -61,6 +61,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestConversions/NFUnitTestConversions.nfproj b/Tests/NFUnitTestConversions/NFUnitTestConversions.nfproj index 71075e67..4a1de0d1 100644 --- a/Tests/NFUnitTestConversions/NFUnitTestConversions.nfproj +++ b/Tests/NFUnitTestConversions/NFUnitTestConversions.nfproj @@ -39,7 +39,7 @@ - + @@ -49,6 +49,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestDelegates/NFUnitTestDelegates.nfproj b/Tests/NFUnitTestDelegates/NFUnitTestDelegates.nfproj index 904d0f0b..30d8a15e 100644 --- a/Tests/NFUnitTestDelegates/NFUnitTestDelegates.nfproj +++ b/Tests/NFUnitTestDelegates/NFUnitTestDelegates.nfproj @@ -37,7 +37,7 @@ - + @@ -47,6 +47,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestEnum/NFUnitTestEnum.nfproj b/Tests/NFUnitTestEnum/NFUnitTestEnum.nfproj index 045b660f..bd4cc87a 100644 --- a/Tests/NFUnitTestEnum/NFUnitTestEnum.nfproj +++ b/Tests/NFUnitTestEnum/NFUnitTestEnum.nfproj @@ -37,7 +37,7 @@ - + @@ -47,6 +47,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestException/NFUnitTestException.nfproj b/Tests/NFUnitTestException/NFUnitTestException.nfproj index f1463d2d..170390e9 100644 --- a/Tests/NFUnitTestException/NFUnitTestException.nfproj +++ b/Tests/NFUnitTestException/NFUnitTestException.nfproj @@ -40,7 +40,7 @@ - + @@ -50,6 +50,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestInterface/NFUnitTestInterface.nfproj b/Tests/NFUnitTestInterface/NFUnitTestInterface.nfproj index 01fa2a41..f13c2359 100644 --- a/Tests/NFUnitTestInterface/NFUnitTestInterface.nfproj +++ b/Tests/NFUnitTestInterface/NFUnitTestInterface.nfproj @@ -37,7 +37,7 @@ - + @@ -47,6 +47,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestLexical/NFUnitTestLexical.nfproj b/Tests/NFUnitTestLexical/NFUnitTestLexical.nfproj index f7e008d7..146a3e3a 100644 --- a/Tests/NFUnitTestLexical/NFUnitTestLexical.nfproj +++ b/Tests/NFUnitTestLexical/NFUnitTestLexical.nfproj @@ -38,7 +38,7 @@ - + @@ -48,6 +48,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestNamespace/NFUnitTestNamespace.nfproj b/Tests/NFUnitTestNamespace/NFUnitTestNamespace.nfproj index 0dcab34f..6365b83d 100644 --- a/Tests/NFUnitTestNamespace/NFUnitTestNamespace.nfproj +++ b/Tests/NFUnitTestNamespace/NFUnitTestNamespace.nfproj @@ -47,7 +47,7 @@ - + @@ -57,6 +57,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestStatementsTests/NFUnitTestStatements.nfproj b/Tests/NFUnitTestStatementsTests/NFUnitTestStatements.nfproj index 2d24943d..f19a5fcc 100644 --- a/Tests/NFUnitTestStatementsTests/NFUnitTestStatements.nfproj +++ b/Tests/NFUnitTestStatementsTests/NFUnitTestStatements.nfproj @@ -37,7 +37,7 @@ - + @@ -47,6 +47,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestStruct/NFUnitTestStruct.nfproj b/Tests/NFUnitTestStruct/NFUnitTestStruct.nfproj index 466f60a4..8ea4efd8 100644 --- a/Tests/NFUnitTestStruct/NFUnitTestStruct.nfproj +++ b/Tests/NFUnitTestStruct/NFUnitTestStruct.nfproj @@ -37,7 +37,7 @@ - + @@ -47,6 +47,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestSystemLib/NFUnitTestSystemLib.nfproj b/Tests/NFUnitTestSystemLib/NFUnitTestSystemLib.nfproj index 08529f1e..9c7e4d8d 100644 --- a/Tests/NFUnitTestSystemLib/NFUnitTestSystemLib.nfproj +++ b/Tests/NFUnitTestSystemLib/NFUnitTestSystemLib.nfproj @@ -48,7 +48,7 @@ - + @@ -58,6 +58,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestThread/NFUnitTestThread.nfproj b/Tests/NFUnitTestThread/NFUnitTestThread.nfproj index ed4932de..d5dd28bd 100644 --- a/Tests/NFUnitTestThread/NFUnitTestThread.nfproj +++ b/Tests/NFUnitTestThread/NFUnitTestThread.nfproj @@ -46,7 +46,7 @@ - + @@ -56,6 +56,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestTypes/NFUnitTestTypes.nfproj b/Tests/NFUnitTestTypes/NFUnitTestTypes.nfproj index 22f87d25..627e3d77 100644 --- a/Tests/NFUnitTestTypes/NFUnitTestTypes.nfproj +++ b/Tests/NFUnitTestTypes/NFUnitTestTypes.nfproj @@ -43,7 +43,7 @@ - + @@ -53,6 +53,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTestVariables/NFUnitTestVariables.nfproj b/Tests/NFUnitTestVariables/NFUnitTestVariables.nfproj index 261bf435..f8506af6 100644 --- a/Tests/NFUnitTestVariables/NFUnitTestVariables.nfproj +++ b/Tests/NFUnitTestVariables/NFUnitTestVariables.nfproj @@ -38,7 +38,7 @@ - + @@ -48,6 +48,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file diff --git a/Tests/NFUnitTest_DummyAdapter/NFUnitTest_DummyAdapter.nfproj b/Tests/NFUnitTest_DummyAdapter/NFUnitTest_DummyAdapter.nfproj index dd40ea29..e3cba8bb 100644 --- a/Tests/NFUnitTest_DummyAdapter/NFUnitTest_DummyAdapter.nfproj +++ b/Tests/NFUnitTest_DummyAdapter/NFUnitTest_DummyAdapter.nfproj @@ -53,7 +53,7 @@ - + @@ -63,6 +63,6 @@ Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. - + \ No newline at end of file From a7632de2af38739b7982727fc0293cbb68f21516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Tue, 23 Nov 2021 11:49:11 +0000 Subject: [PATCH 12/18] Add RuntimeFeature.IsSupported (#164) ***NO_CI*** --- .../UnitTestInterfaceTests.cs | 126 ++++++++++++++++++ .../CoreLibrary.NoReflection.nfproj | 3 + .../System/Runtime/.gitkeep | 0 .../System/Runtime/CompilerServices/.gitkeep | 0 nanoFramework.CoreLibrary/CoreLibrary.nfproj | 1 + .../CompilerServices/RuntimeFeature.cs | 29 ++++ 6 files changed, 159 insertions(+) create mode 100644 nanoFramework.CoreLibrary.NoReflection/System/Runtime/.gitkeep create mode 100644 nanoFramework.CoreLibrary.NoReflection/System/Runtime/CompilerServices/.gitkeep create mode 100644 nanoFramework.CoreLibrary/System/Runtime/CompilerServices/RuntimeFeature.cs diff --git a/Tests/NFUnitTestInterface/UnitTestInterfaceTests.cs b/Tests/NFUnitTestInterface/UnitTestInterfaceTests.cs index 451d31d6..45badb8c 100644 --- a/Tests/NFUnitTestInterface/UnitTestInterfaceTests.cs +++ b/Tests/NFUnitTestInterface/UnitTestInterfaceTests.cs @@ -6,6 +6,7 @@ using nanoFramework.TestFramework; using System; +using System.Collections; using System.Diagnostics; namespace NFUnitTestInterface @@ -3325,10 +3326,135 @@ public static bool testMethod() } } + // Interfaces and classes for "default interface members" + interface ICustomer + { + ArrayList PreviousOrders { get; } + + DateTime DateJoined { get; } + DateTime LastOrder { get; } + string Name { get; } + + public ArrayList Reminders { get; } + } + + interface IOrder + { + DateTime Purchased { get; } + double Cost { get; } + } + + class SampleCustomer : ICustomer + { + public SampleCustomer(string name, DateTime dateJoined) + { + Name = name; + DateJoined = dateJoined; + } + + private ArrayList allOrders = new ArrayList(); + + public ArrayList PreviousOrders => allOrders; + + public DateTime DateJoined { get; } + + public DateTime LastOrder { get; private set; } + + public string Name { get; } + + private ArrayList reminders = new ArrayList(); + public ArrayList Reminders => reminders; + + public void AddOrder(IOrder order) + { + if (order.Purchased > DateTime.MinValue) + { + LastOrder = order.Purchased; + } + + allOrders.Add(order); + } + } + + class Reminder + { + public DateTime Date { get; set; } + public string Subject { get; set; } + + public Reminder(DateTime date, string subject) + { + Date = date; + Subject = subject; + } + } + + class SampleOrder : IOrder + { + public SampleOrder(DateTime purchase, double cost) + { + Purchased = purchase; + Cost = cost; + } + + public DateTime Purchased { get; } + + public double Cost { get; } + } + + [TestMethod] + public void DefaultInterfaceMembers_01_Test() + { + var reminder00Date = new DateTime(2010, 08, 12); + var reminder00Subject = "childs's birthday"; + + var reminder01Date = new DateTime(1012, 11, 15); + var reminder01Subject = "anniversary"; + + SampleCustomer c = new SampleCustomer("customer one", new DateTime(2010, 5, 31)) + { + Reminders = + { + new Reminder(reminder00Date, reminder00Subject), + new Reminder(reminder01Date, reminder01Subject) + } + }; + + var newOrder00Date = new DateTime(2012, 6, 1); + var newOrder00Cost = 5_000; + SampleOrder o = new SampleOrder(newOrder00Date, newOrder00Cost); + c.AddOrder(o); + + var newOrder01Date = new DateTime(2103, 7, 4); + var newOrder01Cost = 25_000; + o = new SampleOrder(newOrder01Date, newOrder01Cost); + c.AddOrder(o); + + OutputHelper.WriteLine($"Data about {c.Name}"); + OutputHelper.WriteLine($"Joined on {c.DateJoined}. Made {c.PreviousOrders.Count} orders, the last on {c.LastOrder}"); + OutputHelper.WriteLine("Reminders:"); + + foreach (var item in c.Reminders) + { + OutputHelper.WriteLine($"\t{(item as Reminder).Subject} on {(item as Reminder).Date}"); + } + foreach (IOrder order in c.PreviousOrders) + { + OutputHelper.WriteLine($"Order on {order.Purchased} for {order.Cost}"); + } + Assert.Equal(c.Reminders.Count, 2, "Reminders count is wrong"); + Assert.Equal((c.Reminders[0] as Reminder).Date, reminder00Date, "Reminder 1 date is wrong"); + Assert.Equal((c.Reminders[1] as Reminder).Subject, reminder01Subject, "Reminder 2 subject is wrong"); + + Assert.Equal(c.PreviousOrders.Count, 2, "Previous Orders count is wrong"); + Assert.Equal(c.LastOrder.Ticks, newOrder01Date.Ticks, "Last order Previous Orders count is wrong"); + Assert.Equal((c.PreviousOrders[0] as IOrder).Cost, newOrder00Cost, "Last order cost is wrong"); + Assert.Equal((c.PreviousOrders[1] as IOrder).Purchased, newOrder01Date, "Last order cost is wrong"); + } } + } namespace Interface_TestClass_struct_decl_02_NS { diff --git a/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj b/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj index 60d28af6..63513c66 100644 --- a/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj +++ b/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj @@ -180,6 +180,9 @@ + + System\Runtime\CompilerServices\RuntimeFeature.cs + diff --git a/nanoFramework.CoreLibrary.NoReflection/System/Runtime/.gitkeep b/nanoFramework.CoreLibrary.NoReflection/System/Runtime/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/nanoFramework.CoreLibrary.NoReflection/System/Runtime/CompilerServices/.gitkeep b/nanoFramework.CoreLibrary.NoReflection/System/Runtime/CompilerServices/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/nanoFramework.CoreLibrary/CoreLibrary.nfproj b/nanoFramework.CoreLibrary/CoreLibrary.nfproj index 1b2d240e..e7841326 100644 --- a/nanoFramework.CoreLibrary/CoreLibrary.nfproj +++ b/nanoFramework.CoreLibrary/CoreLibrary.nfproj @@ -176,6 +176,7 @@ + diff --git a/nanoFramework.CoreLibrary/System/Runtime/CompilerServices/RuntimeFeature.cs b/nanoFramework.CoreLibrary/System/Runtime/CompilerServices/RuntimeFeature.cs new file mode 100644 index 00000000..3726dfee --- /dev/null +++ b/nanoFramework.CoreLibrary/System/Runtime/CompilerServices/RuntimeFeature.cs @@ -0,0 +1,29 @@ +// +// Copyright (c) .NET Foundation and Contributors +// Portions Copyright (c) Microsoft Corporation. All rights reserved. +// See LICENSE file in the project root for full license information. +// + +namespace System.Runtime.CompilerServices +{ + public static partial class RuntimeFeature + { + /// + /// Indicates that this version of runtime supports default interface method implementations. + /// + public const string DefaultImplementationsOfInterfaces = nameof(DefaultImplementationsOfInterfaces); + + /// + /// Checks whether a certain feature is supported by the Runtime. + /// + public static bool IsSupported(string feature) + { + if (feature == DefaultImplementationsOfInterfaces) + { + return true; + } + + return false; + } + } +} From eee9db8624a19d2d115632d66b2397c14e2e72d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Tue, 23 Nov 2021 12:08:18 +0000 Subject: [PATCH 13/18] Add IsExternalInit (#163) ***NO_CI*** --- .../NFUnitTestRecords.nfproj | 55 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 31 +++++++++++ Tests/NFUnitTestRecords/UnitTestRecords.cs | 45 +++++++++++++++ Tests/NFUnitTestRecords/nano.runsettings | 14 +++++ .../CoreLibrary.NoReflection.nfproj | 3 + nanoFramework.CoreLibrary.sln | 9 +++ nanoFramework.CoreLibrary/CoreLibrary.nfproj | 1 + .../CompilerServices/IsExternalInit.cs | 19 +++++++ 8 files changed, 177 insertions(+) create mode 100644 Tests/NFUnitTestRecords/NFUnitTestRecords.nfproj create mode 100644 Tests/NFUnitTestRecords/Properties/AssemblyInfo.cs create mode 100644 Tests/NFUnitTestRecords/UnitTestRecords.cs create mode 100644 Tests/NFUnitTestRecords/nano.runsettings create mode 100644 nanoFramework.CoreLibrary/System/Runtime/CompilerServices/IsExternalInit.cs diff --git a/Tests/NFUnitTestRecords/NFUnitTestRecords.nfproj b/Tests/NFUnitTestRecords/NFUnitTestRecords.nfproj new file mode 100644 index 00000000..382e00fc --- /dev/null +++ b/Tests/NFUnitTestRecords/NFUnitTestRecords.nfproj @@ -0,0 +1,55 @@ + + + + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ + + + + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 0be498d1-cb3e-4d1e-ba4c-2c49ae30432d + Library + Properties + 512 + NFUnitTestRecords + NFUnitTest + False + true + UnitTest + v1.0 + + + + $(MSBuildProjectDirectory)\nano.runsettings + + + + + + + + + + + + + + + + + + + + + + + + Update the Import path in nfproj to the correct nanoFramework.TestFramework NuGet package folder. + + + + \ No newline at end of file diff --git a/Tests/NFUnitTestRecords/Properties/AssemblyInfo.cs b/Tests/NFUnitTestRecords/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a3735af6 --- /dev/null +++ b/Tests/NFUnitTestRecords/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyCopyright("Copyright (c) 2021 nanoFramework contributors")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/NFUnitTestRecords/UnitTestRecords.cs b/Tests/NFUnitTestRecords/UnitTestRecords.cs new file mode 100644 index 00000000..a66a5422 --- /dev/null +++ b/Tests/NFUnitTestRecords/UnitTestRecords.cs @@ -0,0 +1,45 @@ +using nanoFramework.TestFramework; +using System; + +namespace NFUnitTestRecords +{ + //[TestClass] + //public class UnitTestRecords + //{ + // [TestMethod] + // public void Records_Test00() + // { + // var firstName = "Test"; + // var lastName = "Person"; + // var dob = new DateTime(1998, 1, 31); + // var id = Guid.NewGuid(); + // var emptyGuid = Guid.Empty; + + // var newPerson = new Person(firstName, lastName, dob) + // { + // Id = emptyGuid, + // }; + + // var expectedPerson = new Person(firstName, lastName, dob) + // { + // Id = id, + // }; + // } + //} + + //public record Person + //{ + // public Person(string firstName, string lastName, DateTime + // dateOfBirth) + // { + // FirstName = firstName; + // LastName = lastName; + // DateOfBirth = dateOfBirth; + // } + + // public Guid Id { get; set; } + // public string FirstName { get; } + // public string LastName { get; } + // public DateTime DateOfBirth { get; } + //} +} diff --git a/Tests/NFUnitTestRecords/nano.runsettings b/Tests/NFUnitTestRecords/nano.runsettings new file mode 100644 index 00000000..fa881e3a --- /dev/null +++ b/Tests/NFUnitTestRecords/nano.runsettings @@ -0,0 +1,14 @@ + + + + + 1 + .\TestResults + 120000 + Framework40 + + + None + False + + \ No newline at end of file diff --git a/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj b/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj index 63513c66..71406fc5 100644 --- a/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj +++ b/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj @@ -179,6 +179,9 @@ + + System\Runtime\CompilerServices\IsExternalInit.cs + System\Runtime\CompilerServices\RuntimeFeature.cs diff --git a/nanoFramework.CoreLibrary.sln b/nanoFramework.CoreLibrary.sln index 93515151..509b3a36 100644 --- a/nanoFramework.CoreLibrary.sln +++ b/nanoFramework.CoreLibrary.sln @@ -64,6 +64,8 @@ Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "TestFrameworkShared", "nano EndProject Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "NFUnitTest_DummyAdapter", "Tests\NFUnitTest_DummyAdapter\NFUnitTest_DummyAdapter.nfproj", "{396A2B21-8A5F-4274-9FDD-3B35DC8EAE47}" EndProject +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "NFUnitTestRecords", "Tests\NFUnitTestRecords\NFUnitTestRecords.nfproj", "{0BE498D1-CB3E-4D1E-BA4C-2C49AE30432D}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution nanoFramework.TestFramework\source\TestFrameworkShared\TestFrameworkShared.projitems*{55f048b5-6739-43c5-a93d-db61db8e912f}*SharedItemsImports = 13 @@ -217,6 +219,12 @@ Global {396A2B21-8A5F-4274-9FDD-3B35DC8EAE47}.Release|Any CPU.ActiveCfg = Release|Any CPU {396A2B21-8A5F-4274-9FDD-3B35DC8EAE47}.Release|Any CPU.Build.0 = Release|Any CPU {396A2B21-8A5F-4274-9FDD-3B35DC8EAE47}.Release|Any CPU.Deploy.0 = Release|Any CPU + {0BE498D1-CB3E-4D1E-BA4C-2C49AE30432D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0BE498D1-CB3E-4D1E-BA4C-2C49AE30432D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0BE498D1-CB3E-4D1E-BA4C-2C49AE30432D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {0BE498D1-CB3E-4D1E-BA4C-2C49AE30432D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0BE498D1-CB3E-4D1E-BA4C-2C49AE30432D}.Release|Any CPU.Build.0 = Release|Any CPU + {0BE498D1-CB3E-4D1E-BA4C-2C49AE30432D}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -245,6 +253,7 @@ Global {44A0C6A8-4F31-405B-95CA-6F0D65BC11B8} = {0BAE286A-5434-4F56-A9F1-41B72056170E} {55F048B5-6739-43C5-A93D-DB61DB8E912F} = {0BAE286A-5434-4F56-A9F1-41B72056170E} {396A2B21-8A5F-4274-9FDD-3B35DC8EAE47} = {0BAE286A-5434-4F56-A9F1-41B72056170E} + {0BE498D1-CB3E-4D1E-BA4C-2C49AE30432D} = {0BAE286A-5434-4F56-A9F1-41B72056170E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8DE44407-9B41-4459-97D2-FCE54B1F4300} diff --git a/nanoFramework.CoreLibrary/CoreLibrary.nfproj b/nanoFramework.CoreLibrary/CoreLibrary.nfproj index e7841326..14304bc3 100644 --- a/nanoFramework.CoreLibrary/CoreLibrary.nfproj +++ b/nanoFramework.CoreLibrary/CoreLibrary.nfproj @@ -175,6 +175,7 @@ + diff --git a/nanoFramework.CoreLibrary/System/Runtime/CompilerServices/IsExternalInit.cs b/nanoFramework.CoreLibrary/System/Runtime/CompilerServices/IsExternalInit.cs new file mode 100644 index 00000000..f44255df --- /dev/null +++ b/nanoFramework.CoreLibrary/System/Runtime/CompilerServices/IsExternalInit.cs @@ -0,0 +1,19 @@ +// +// Copyright (c) .NET Foundation and Contributors +// Portions Copyright (c) Microsoft Corporation. All rights reserved. +// See LICENSE file in the project root for full license information. +// + +using System.ComponentModel; + +namespace System.Runtime.CompilerServices +{ + /// + /// Reserved to be used by the compiler for tracking metadata. + /// This class should not be used by developers in source code. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static class IsExternalInit + { + } +} From 9563dd3eabc75197666c2b0d2ad769cab7a3748b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Tue, 30 Nov 2021 22:16:50 +0000 Subject: [PATCH 14/18] Work CI-CD - Bump version. --- version.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.json b/version.json index eede3799..bd89db74 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.10.6-preview.{height}", + "version": "1.11.6-preview.{height}", "assemblyVersion": { "precision": "revision" }, @@ -22,4 +22,4 @@ "versionIncrement": "build", "firstUnstableTag": "preview" } -} \ No newline at end of file +} From cefffebe74d7f93021af585bb7a91772b27c6bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Tue, 30 Nov 2021 22:32:38 +0000 Subject: [PATCH 15/18] Remove Unit Test DefaultInterfaceMembers_01_Test --- .../UnitTestInterfaceTests.cs | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/Tests/NFUnitTestInterface/UnitTestInterfaceTests.cs b/Tests/NFUnitTestInterface/UnitTestInterfaceTests.cs index 45badb8c..b78d3369 100644 --- a/Tests/NFUnitTestInterface/UnitTestInterfaceTests.cs +++ b/Tests/NFUnitTestInterface/UnitTestInterfaceTests.cs @@ -3402,57 +3402,57 @@ public SampleOrder(DateTime purchase, double cost) public double Cost { get; } } - [TestMethod] - public void DefaultInterfaceMembers_01_Test() - { - var reminder00Date = new DateTime(2010, 08, 12); - var reminder00Subject = "childs's birthday"; - - var reminder01Date = new DateTime(1012, 11, 15); - var reminder01Subject = "anniversary"; - - SampleCustomer c = new SampleCustomer("customer one", new DateTime(2010, 5, 31)) - { - Reminders = - { - new Reminder(reminder00Date, reminder00Subject), - new Reminder(reminder01Date, reminder01Subject) - } - }; - - var newOrder00Date = new DateTime(2012, 6, 1); - var newOrder00Cost = 5_000; - SampleOrder o = new SampleOrder(newOrder00Date, newOrder00Cost); - c.AddOrder(o); - - var newOrder01Date = new DateTime(2103, 7, 4); - var newOrder01Cost = 25_000; - o = new SampleOrder(newOrder01Date, newOrder01Cost); - c.AddOrder(o); - - OutputHelper.WriteLine($"Data about {c.Name}"); - OutputHelper.WriteLine($"Joined on {c.DateJoined}. Made {c.PreviousOrders.Count} orders, the last on {c.LastOrder}"); - OutputHelper.WriteLine("Reminders:"); + // [TestMethod] + // public void DefaultInterfaceMembers_01_Test() + // { + // var reminder00Date = new DateTime(2010, 08, 12); + // var reminder00Subject = "childs's birthday"; + + // var reminder01Date = new DateTime(1012, 11, 15); + // var reminder01Subject = "anniversary"; + + // SampleCustomer c = new SampleCustomer("customer one", new DateTime(2010, 5, 31)) + // { + // Reminders = + // { + // new Reminder(reminder00Date, reminder00Subject), + // new Reminder(reminder01Date, reminder01Subject) + // } + // }; + + // var newOrder00Date = new DateTime(2012, 6, 1); + // var newOrder00Cost = 5_000; + // SampleOrder o = new SampleOrder(newOrder00Date, newOrder00Cost); + // c.AddOrder(o); + + // var newOrder01Date = new DateTime(2103, 7, 4); + // var newOrder01Cost = 25_000; + // o = new SampleOrder(newOrder01Date, newOrder01Cost); + // c.AddOrder(o); + + // OutputHelper.WriteLine($"Data about {c.Name}"); + // OutputHelper.WriteLine($"Joined on {c.DateJoined}. Made {c.PreviousOrders.Count} orders, the last on {c.LastOrder}"); + // OutputHelper.WriteLine("Reminders:"); - foreach (var item in c.Reminders) - { - OutputHelper.WriteLine($"\t{(item as Reminder).Subject} on {(item as Reminder).Date}"); - } - - foreach (IOrder order in c.PreviousOrders) - { - OutputHelper.WriteLine($"Order on {order.Purchased} for {order.Cost}"); - } - - Assert.Equal(c.Reminders.Count, 2, "Reminders count is wrong"); - Assert.Equal((c.Reminders[0] as Reminder).Date, reminder00Date, "Reminder 1 date is wrong"); - Assert.Equal((c.Reminders[1] as Reminder).Subject, reminder01Subject, "Reminder 2 subject is wrong"); - - Assert.Equal(c.PreviousOrders.Count, 2, "Previous Orders count is wrong"); - Assert.Equal(c.LastOrder.Ticks, newOrder01Date.Ticks, "Last order Previous Orders count is wrong"); - Assert.Equal((c.PreviousOrders[0] as IOrder).Cost, newOrder00Cost, "Last order cost is wrong"); - Assert.Equal((c.PreviousOrders[1] as IOrder).Purchased, newOrder01Date, "Last order cost is wrong"); - } + // foreach (var item in c.Reminders) + // { + // OutputHelper.WriteLine($"\t{(item as Reminder).Subject} on {(item as Reminder).Date}"); + // } + + // foreach (IOrder order in c.PreviousOrders) + // { + // OutputHelper.WriteLine($"Order on {order.Purchased} for {order.Cost}"); + // } + + // Assert.Equal(c.Reminders.Count, 2, "Reminders count is wrong"); + // Assert.Equal((c.Reminders[0] as Reminder).Date, reminder00Date, "Reminder 1 date is wrong"); + // Assert.Equal((c.Reminders[1] as Reminder).Subject, reminder01Subject, "Reminder 2 subject is wrong"); + + // Assert.Equal(c.PreviousOrders.Count, 2, "Previous Orders count is wrong"); + // Assert.Equal(c.LastOrder.Ticks, newOrder01Date.Ticks, "Last order Previous Orders count is wrong"); + // Assert.Equal((c.PreviousOrders[0] as IOrder).Cost, newOrder00Cost, "Last order cost is wrong"); + // Assert.Equal((c.PreviousOrders[1] as IOrder).Purchased, newOrder01Date, "Last order cost is wrong"); + // } } } From 80c32a881f2d0c5c7fca6bd50cf5606665ce5efe Mon Sep 17 00:00:00 2001 From: nfbot Date: Tue, 30 Nov 2021 22:44:16 +0000 Subject: [PATCH 16/18] Update CHANGELOG for v1.11.6 ***NO_CI*** --- CHANGELOG.md | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3988f42..a7130902 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,33 @@ ## [**Changes available only in 'Preview' NuGet packages:**](https://github.com/nanoframework/CoreLibrary/tree/HEAD) -[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.10.5-preview.13...HEAD) +[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.10.5...HEAD) + +**Implemented enhancements:** + +- Add IsExternalInit [\#163](https://github.com/nanoframework/CoreLibrary/pull/163) +- Add Console.Write and Console.WriteLine [\#162](https://github.com/nanoframework/CoreLibrary/pull/162) +- Improvements and fixes in DateTimeFormatInfo [\#159](https://github.com/nanoframework/CoreLibrary/pull/159) +- ISO8601 compatibility for DateTime ToString [\#158](https://github.com/nanoframework/CoreLibrary/pull/158) + +**Documentation and other chores:** + +- Fix DateTime\_ToString Test25 [\#160](https://github.com/nanoframework/CoreLibrary/pull/160) +- Update test framework @10d5471 [\#156](https://github.com/nanoframework/CoreLibrary/pull/156) +- Update test framewok @965a065 [\#155](https://github.com/nanoframework/CoreLibrary/pull/155) +- Add exception to System.Reflection.Load documentation [\#154](https://github.com/nanoframework/CoreLibrary/pull/154) +- Add new Unit Test [\#152](https://github.com/nanoframework/CoreLibrary/pull/152) +- Fix NFUnitTestArray Unit Test project [\#151](https://github.com/nanoframework/CoreLibrary/pull/151) +- Fix Unit Test for GUID box/unbox [\#150](https://github.com/nanoframework/CoreLibrary/pull/150) +- Update Unit Tests [\#149](https://github.com/nanoframework/CoreLibrary/pull/149) + +## [v1.10.5](https://github.com/nanoframework/CoreLibrary/tree/v1.10.5) (2021-07-13) + +[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.10.5-preview.18...v1.10.5) + +## [v1.10.5-preview.18](https://github.com/nanoframework/CoreLibrary/tree/v1.10.5-preview.18) (2021-06-19) + +[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.10.5-preview.13...v1.10.5-preview.18) **Implemented enhancements:** @@ -14,7 +40,7 @@ ## [v1.10.5-preview.13](https://github.com/nanoframework/CoreLibrary/tree/v1.10.5-preview.13) (2021-06-07) -[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.10.5-alpha.150.10...v1.10.5-preview.13) +[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.10.5-preview.10...v1.10.5-preview.13) **Fixed bugs:** @@ -25,13 +51,13 @@ - Clean up unit tests for CoreLibrary and complete tests for Type.GetType [\#143](https://github.com/nanoframework/CoreLibrary/pull/143) -## [v1.10.5-alpha.150.10](https://github.com/nanoframework/CoreLibrary/tree/v1.10.5-alpha.150.10) (2021-06-02) +## [v1.10.5-preview.10](https://github.com/nanoframework/CoreLibrary/tree/v1.10.5-preview.10) (2021-06-02) -[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.10.5-preview.10...v1.10.5-alpha.150.10) +[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.10.5-alpha.150.10...v1.10.5-preview.10) -## [v1.10.5-preview.10](https://github.com/nanoframework/CoreLibrary/tree/v1.10.5-preview.10) (2021-06-02) +## [v1.10.5-alpha.150.10](https://github.com/nanoframework/CoreLibrary/tree/v1.10.5-alpha.150.10) (2021-06-02) -[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.10.5-preview.4...v1.10.5-preview.10) +[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.10.5-preview.4...v1.10.5-alpha.150.10) ## [v1.10.5-preview.4](https://github.com/nanoframework/CoreLibrary/tree/v1.10.5-preview.4) (2021-05-31) @@ -167,20 +193,20 @@ ## [v1.9.1-preview.4](https://github.com/nanoframework/CoreLibrary/tree/v1.9.1-preview.4) (2020-10-20) -[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.9.0-alpha.11...v1.9.1-preview.4) +[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.9.0-preview.11...v1.9.1-preview.4) **Implemented enhancements:** - Add Enum.HasFlag [\#112](https://github.com/nanoframework/CoreLibrary/pull/112) - Add Convert.ToBoolean\(byte\) [\#111](https://github.com/nanoframework/CoreLibrary/pull/111) -## [v1.9.0-alpha.11](https://github.com/nanoframework/CoreLibrary/tree/v1.9.0-alpha.11) (2020-10-20) +## [v1.9.0-preview.11](https://github.com/nanoframework/CoreLibrary/tree/v1.9.0-preview.11) (2020-10-20) -[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.9.0-preview.11...v1.9.0-alpha.11) +[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.9.0-alpha.11...v1.9.0-preview.11) -## [v1.9.0-preview.11](https://github.com/nanoframework/CoreLibrary/tree/v1.9.0-preview.11) (2020-10-20) +## [v1.9.0-alpha.11](https://github.com/nanoframework/CoreLibrary/tree/v1.9.0-alpha.11) (2020-10-20) -[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.9.0-preview.5...v1.9.0-preview.11) +[Full Changelog](https://github.com/nanoframework/CoreLibrary/compare/v1.9.0-preview.5...v1.9.0-alpha.11) ## [v1.9.0-preview.5](https://github.com/nanoframework/CoreLibrary/tree/v1.9.0-preview.5) (2020-09-30) From d1b8834c3f12b5d2ba02e9c6c8f69e8dc6d1433e Mon Sep 17 00:00:00 2001 From: nfbot Date: Thu, 2 Dec 2021 13:16:01 +0000 Subject: [PATCH 17/18] Set version to '1.11.6' --- version.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/version.json b/version.json index bd89db74..2ad13fa5 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.11.6-preview.{height}", + "version": "1.11.6", "assemblyVersion": { "precision": "revision" }, @@ -14,12 +14,11 @@ "^refs/heads/v\\d+(?:\\.\\d+)?$" ], "cloudBuild": { - "setAllVariables": true, - "buildNumber": null + "setAllVariables": true }, "release": { "branchName": "release-v{version}", "versionIncrement": "build", "firstUnstableTag": "preview" } -} +} \ No newline at end of file From 358d1c71d38d90ae4a2532f10f30afa87f67c237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Thu, 2 Dec 2021 13:33:14 +0000 Subject: [PATCH 18/18] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8e103c8d..0477214a 100644 --- a/.gitignore +++ b/.gitignore @@ -258,3 +258,4 @@ paket-files/ # VS Code .vscode/settings.json +