diff --git a/.gitignore b/.gitignore index aee58232..0477214a 100644 --- a/.gitignore +++ b/.gitignore @@ -255,3 +255,7 @@ paket-files/ #SoundCloud *.sonarqube/ + +# VS Code +.vscode/settings.json + diff --git a/CHANGELOG.md b/CHANGELOG.md index 30dc2233..a7130902 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,18 @@ ## [**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.18...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) @@ -14,6 +22,10 @@ - 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) @@ -28,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:** @@ -39,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) @@ -181,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) 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/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/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/NFUnitTestInterface/UnitTestInterfaceTests.cs b/Tests/NFUnitTestInterface/UnitTestInterfaceTests.cs index 451d31d6..b78d3369 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/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/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/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/NFUnitTestSystemLib/UnitTestDateTime.cs b/Tests/NFUnitTestSystemLib/UnitTestDateTime.cs index 38045297..d9646df0 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,99 +116,1346 @@ 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 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}"); + + // UniversalSortableDateTimePattern + var specifier1 = "u"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try { - if (i == 2) + 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 DateTime.ToString (String) returns correct String using a specified format + /// + OutputHelper.WriteLine("Generating random DateTime"); + + DateTime dt = GetRandomDateTime(); + + OutputHelper.WriteLine($"Test DateTime is: {dt}"); + + // YearMonthPattern + var specifier1 = "y"; + var specifier2 = "Y"; + + 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 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}\")"); + } + } + + [TestMethod] + public void DateTime_ToStringTest24() + { + /// + /// 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 = "d MMM yyyy"; + + OutputHelper.WriteLine($"Testing specified format(s): '{specifier1}'"); + + try + { + string dtOutput1 = dt.ToString(specifier1); + + OutputHelper.WriteLine($"Output from ToString(\"{specifier1}\") was '{dtOutput1}'"); + + int minLength = 10; + + // check 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(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(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 'f' + // need to do the math to get the fraction part from ticks + var fraction = dt.Ticks % _TicksPerSecond; + 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 ':'"); + Assert.Equal(":", dtOutput1.Substring(5, 1), "Wrong output1 in for ':'"); + + // check '.' + 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'"); + + // 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}\")"); } - 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", "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_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() @@ -734,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)) { @@ -750,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)) { @@ -1043,10 +2290,15 @@ 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}; + // 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 +2341,42 @@ 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 + 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/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 ad02e6e5..e3cba8bb 100644 --- a/Tests/NFUnitTest_DummyAdapter/NFUnitTest_DummyAdapter.nfproj +++ b/Tests/NFUnitTest_DummyAdapter/NFUnitTest_DummyAdapter.nfproj @@ -40,20 +40,20 @@ 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 - + @@ -63,6 +63,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/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/assets/nf-logo.png b/assets/nf-logo.png index 6f576caa..572c4ff3 100644 Binary files a/assets/nf-logo.png and b/assets/nf-logo.png differ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9bd65839..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 @@ -156,6 +193,7 @@ jobs: inputs: gitHubToken: $(GitHubToken) repositoriesToUpdate: | + nanoFramework.Devices.OneWire nanoFramework.Runtime.Events nanoFramework.Runtime.Native nanoFramework.TestFramework @@ -163,6 +201,7 @@ jobs: nanoFramework.Devices.OneWire nanoFramework.Networking.Sntp nanoFramework.Hardware.Stm32 + nanoFramework.Hardware.TI nanoFramework.TI.EasyLink nanoFramework.ResourceManager nanoFramework.Json @@ -170,13 +209,15 @@ jobs: Windows.Devices.I2c Windows.Devices.Pwm Windows.Devices.Spi + System.Collections + System.Device.Adc System.Device.Dac System.Device.I2c + System.Device.Pwm System.Device.Spi - System.Threading System.Math - System.Collections System.Text + System.Threading displayName: Update dependent class libs ################################## @@ -186,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 5ecb1c73..71406fc5 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\ @@ -179,7 +179,13 @@ + + System\Runtime\CompilerServices\IsExternalInit.cs + + + System\Runtime\CompilerServices\RuntimeFeature.cs + @@ -406,11 +412,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/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.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.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 d25bde3c..14304bc3 100644 --- a/nanoFramework.CoreLibrary/CoreLibrary.nfproj +++ b/nanoFramework.CoreLibrary/CoreLibrary.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ @@ -175,7 +175,9 @@ + + @@ -398,11 +400,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/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); } } 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 b953f01f..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: @@ -247,64 +248,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 +314,97 @@ 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; - - // 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) + if (tokenLen <= MaxSecondsFractionDigits) { - fraction /= 10; - precision--; + // compute requested precision + var precision = MaxSecondsFractionDigits - (MaxSecondsFractionDigits - tokenLen); + + // get fraction value from ticks + var fraction = dateTime.Ticks % DateTime.TicksPerSecond; + + // compute value with effective digits from requested precision + int effectiveDigits = MaxSecondsFractionDigits - precision; + while (effectiveDigits > 0) + { + fraction /= 10; + effectiveDigits--; + } + + tempResult = FormatDigits((int)fraction, precision); } - - tempResult = FormatDigits(fraction, tokenLen); - } - else throw new ArgumentException("Format_InvalidString"); - break; + 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 +422,59 @@ 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 '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; - 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; 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", "" }; } } } 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 + { + } +} 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; + } + } +} 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 diff --git a/version.json b/version.json index 4b4bd5a3..a8c8aadc 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.5", + "version": "1.11.6", "assemblyVersion": { "precision": "revision" }, @@ -14,8 +14,7 @@ "^refs/heads/v\\d+(?:\\.\\d+)?$" ], "cloudBuild": { - "setAllVariables": true, - "buildNumber": null + "setAllVariables": true }, "release": { "branchName": "release-v{version}",