From c726d052f6f5b73c75ffaf251aa4fb96126cbb81 Mon Sep 17 00:00:00 2001 From: XCVGVCX Date: Tue, 19 May 2020 17:18:38 -0700 Subject: [PATCH 1/9] updated license --- LICENSE.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/LICENSE.txt b/LICENSE.txt index 5d7c15d..b306838 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,5 @@ Copyright (C) Microsoft Corporation +Copyright (c) 2019 Chris Leclair All rights reserved. MIT License From b2b7b58d240779ebd8da39a7b55311e02524038e Mon Sep 17 00:00:00 2001 From: XCVGVCX Date: Tue, 19 May 2020 17:25:20 -0700 Subject: [PATCH 2/9] updated project templates (library: .net standard 2.0, test: .net framework 4.8) --- BitConverter.sln | 27 +++--- .../EndianBitConverter.Tests.csproj | 84 +++++++++++++++---- .../Properties/AssemblyInfo.cs | 20 +++++ EndianBitConverter.Tests/packages.config | 5 ++ EndianBitConverter/EndianBitConverter.csproj | 22 +---- .../LICENSE.EndianBitConverter.txt | 10 --- 6 files changed, 112 insertions(+), 56 deletions(-) create mode 100644 EndianBitConverter.Tests/Properties/AssemblyInfo.cs create mode 100644 EndianBitConverter.Tests/packages.config delete mode 100644 EndianBitConverter/LICENSE.EndianBitConverter.txt diff --git a/BitConverter.sln b/BitConverter.sln index ac7865a..3a1051a 100644 --- a/BitConverter.sln +++ b/BitConverter.sln @@ -1,11 +1,11 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30104.148 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndianBitConverter", "EndianBitConverter\EndianBitConverter.csproj", "{848519BA-2143-4B62-92B4-A93425CE8A19}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndianBitConverter", "EndianBitConverter\EndianBitConverter.csproj", "{307C7700-BA3F-4B56-A44A-D369D2021B77}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndianBitConverter.Tests", "EndianBitConverter.Tests\EndianBitConverter.Tests.csproj", "{8D662449-7772-4CD2-9444-C073B6FE1F90}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndianBitConverter.Tests", "EndianBitConverter.Tests\EndianBitConverter.Tests.csproj", "{12C7685A-9CBA-4FD2-9679-6360FA7DAED5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,16 +13,19 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {848519BA-2143-4B62-92B4-A93425CE8A19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {848519BA-2143-4B62-92B4-A93425CE8A19}.Debug|Any CPU.Build.0 = Debug|Any CPU - {848519BA-2143-4B62-92B4-A93425CE8A19}.Release|Any CPU.ActiveCfg = Release|Any CPU - {848519BA-2143-4B62-92B4-A93425CE8A19}.Release|Any CPU.Build.0 = Release|Any CPU - {8D662449-7772-4CD2-9444-C073B6FE1F90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8D662449-7772-4CD2-9444-C073B6FE1F90}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8D662449-7772-4CD2-9444-C073B6FE1F90}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8D662449-7772-4CD2-9444-C073B6FE1F90}.Release|Any CPU.Build.0 = Release|Any CPU + {307C7700-BA3F-4B56-A44A-D369D2021B77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {307C7700-BA3F-4B56-A44A-D369D2021B77}.Debug|Any CPU.Build.0 = Debug|Any CPU + {307C7700-BA3F-4B56-A44A-D369D2021B77}.Release|Any CPU.ActiveCfg = Release|Any CPU + {307C7700-BA3F-4B56-A44A-D369D2021B77}.Release|Any CPU.Build.0 = Release|Any CPU + {12C7685A-9CBA-4FD2-9679-6360FA7DAED5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {12C7685A-9CBA-4FD2-9679-6360FA7DAED5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {12C7685A-9CBA-4FD2-9679-6360FA7DAED5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {12C7685A-9CBA-4FD2-9679-6360FA7DAED5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5ECCA5D4-B184-46AC-A898-61EAE3F91B47} + EndGlobalSection EndGlobal diff --git a/EndianBitConverter.Tests/EndianBitConverter.Tests.csproj b/EndianBitConverter.Tests/EndianBitConverter.Tests.csproj index 5e37fcf..06da965 100644 --- a/EndianBitConverter.Tests/EndianBitConverter.Tests.csproj +++ b/EndianBitConverter.Tests/EndianBitConverter.Tests.csproj @@ -1,22 +1,76 @@ - - - - net45;netcoreapp1.0 - False + + + + + + Debug + AnyCPU + {12C7685A-9CBA-4FD2-9679-6360FA7DAED5} + Library + Properties + EndianBitConverter.Tests + EndianBitConverter.Tests + v4.8 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + - + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.2.1.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.2.1.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + - - - + + + + - - + - - + + {307c7700-ba3f-4b56-a44a-d369d2021b77} + EndianBitConverter + - - + + + + + This project references NuGet package(s) that are missing on this computer. Use 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/EndianBitConverter.Tests/Properties/AssemblyInfo.cs b/EndianBitConverter.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e2dfbf5 --- /dev/null +++ b/EndianBitConverter.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("EndianBitConverter.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EndianBitConverter.Tests")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("12c7685a-9cba-4fd2-9679-6360fa7daed5")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/EndianBitConverter.Tests/packages.config b/EndianBitConverter.Tests/packages.config new file mode 100644 index 0000000..6a20910 --- /dev/null +++ b/EndianBitConverter.Tests/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/EndianBitConverter/EndianBitConverter.csproj b/EndianBitConverter/EndianBitConverter.csproj index 4ba8749..9f5c4f4 100644 --- a/EndianBitConverter/EndianBitConverter.csproj +++ b/EndianBitConverter/EndianBitConverter.csproj @@ -1,23 +1,7 @@ - + - net45;net40;netcoreapp1.0;netstandard1.0 - True - 1.1.0.0 - bin\$(Configuration)\$(TargetFramework)\$(MSBuildProjectName).xml - Microsoft Corporation - © Microsoft Corporation. All rights reserved. - David Reaburn - Endian BigEndian LittleEndian BitConverter - True - Provides a big-endian and little-endian BitConverter that convert base data types to an array of bytes, and an array of bytes to base data types, regardless of machine architecture. - https://raw.githubusercontent.com/davidrea-MS/BitConverter/master/LICENSE.txt - https://github.com/davidrea-MS/BitConverter - https://raw.githubusercontent.com/davidrea-MS/BitConverter/master/EndianBitConverter.png + netstandard2.0 - - - - - \ No newline at end of file + diff --git a/EndianBitConverter/LICENSE.EndianBitConverter.txt b/EndianBitConverter/LICENSE.EndianBitConverter.txt deleted file mode 100644 index 5d7c15d..0000000 --- a/EndianBitConverter/LICENSE.EndianBitConverter.txt +++ /dev/null @@ -1,10 +0,0 @@ -Copyright (C) Microsoft Corporation -All rights reserved. - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 413f56fb2847e154f2d4ed0e5f845e5c1b30bd7f Mon Sep 17 00:00:00 2001 From: XCVGVCX Date: Tue, 19 May 2020 17:33:08 -0700 Subject: [PATCH 3/9] configuration/metadata for build and package --- EndianBitConverter/EndianBitConverter.csproj | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/EndianBitConverter/EndianBitConverter.csproj b/EndianBitConverter/EndianBitConverter.csproj index 9f5c4f4..9945480 100644 --- a/EndianBitConverter/EndianBitConverter.csproj +++ b/EndianBitConverter/EndianBitConverter.csproj @@ -2,6 +2,30 @@ netstandard2.0 + 2.0.0.0 + 2.0.0.0 + 2.0.0 + true + David Reaburn, Chris Leclair + LICENSE.txt + https://github.com/XCVG/BitConverter + EndianBitConverter.png + https://github.com/XCVG/BitConverter + © Microsoft Corporation, Chris Leclair. All rights reserved. + Microsoft Corporation, XCVG Systems + Provides a big-endian and little-endian BitConverter that convert base data types to an array of bytes, and an array of bytes to base data types, regardless of machine architecture. + Endian BigEndian LittleEndian BitConverter + + + True + + + + True + + + + From 38c2ff5046031f3d183112a4ae281dfb958b10a0 Mon Sep 17 00:00:00 2001 From: XCVGVCX Date: Tue, 19 May 2020 17:37:10 -0700 Subject: [PATCH 4/9] renamed package --- EndianBitConverter/EndianBitConverter.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EndianBitConverter/EndianBitConverter.csproj b/EndianBitConverter/EndianBitConverter.csproj index 9945480..d93f3d1 100644 --- a/EndianBitConverter/EndianBitConverter.csproj +++ b/EndianBitConverter/EndianBitConverter.csproj @@ -13,8 +13,9 @@ https://github.com/XCVG/BitConverter © Microsoft Corporation, Chris Leclair. All rights reserved. Microsoft Corporation, XCVG Systems - Provides a big-endian and little-endian BitConverter that convert base data types to an array of bytes, and an array of bytes to base data types, regardless of machine architecture. + Provides a big-endian and little-endian BitConverter that convert base data types to an array of bytes, and an array of bytes to base data types, regardless of machine architecture. This is a third-party fork of the original project with the project cleaned up slightly and updated to .NET Standard 2.0. Endian BigEndian LittleEndian BitConverter + XCVGSystems.EndianBitConverter From e3465d189625bdda47239891f492497927617d4d Mon Sep 17 00:00:00 2001 From: XCVGVCX Date: Wed, 20 May 2020 11:36:58 -0700 Subject: [PATCH 5/9] changed namespace from BitConverter to EndianBitConverter --- EndianBitConverter.Tests/GetBytesTests.cs | 2 +- EndianBitConverter.Tests/GetValueTests.cs | 2 +- EndianBitConverter.Tests/InterfaceTests.cs | 2 +- EndianBitConverter/BigEndianBitConverter.cs | 2 +- EndianBitConverter/EndianBitConverter.cs | 2 +- EndianBitConverter/LittleEndianBitConverter.cs | 2 +- EndianBitConverter/SingleConverter.cs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/EndianBitConverter.Tests/GetBytesTests.cs b/EndianBitConverter.Tests/GetBytesTests.cs index a7abd9e..b954d43 100644 --- a/EndianBitConverter.Tests/GetBytesTests.cs +++ b/EndianBitConverter.Tests/GetBytesTests.cs @@ -1,6 +1,6 @@ // Copyright (C) Microsoft Corporation. All rights reserved. -namespace BitConverter.Tests +namespace EndianBitConverter.Tests { using System; using System.Linq; diff --git a/EndianBitConverter.Tests/GetValueTests.cs b/EndianBitConverter.Tests/GetValueTests.cs index 4584d26..817c5f0 100644 --- a/EndianBitConverter.Tests/GetValueTests.cs +++ b/EndianBitConverter.Tests/GetValueTests.cs @@ -1,6 +1,6 @@ // Copyright (C) Microsoft Corporation. All rights reserved. -namespace BitConverter.Tests +namespace EndianBitConverter.Tests { using System; using System.Linq; diff --git a/EndianBitConverter.Tests/InterfaceTests.cs b/EndianBitConverter.Tests/InterfaceTests.cs index 0aa9735..6e494fb 100644 --- a/EndianBitConverter.Tests/InterfaceTests.cs +++ b/EndianBitConverter.Tests/InterfaceTests.cs @@ -1,6 +1,6 @@ // Copyright (C) Microsoft Corporation. All rights reserved. -namespace BitConverter.Tests +namespace EndianBitConverter.Tests { using System.Reflection; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/EndianBitConverter/BigEndianBitConverter.cs b/EndianBitConverter/BigEndianBitConverter.cs index 4215d26..db87d37 100644 --- a/EndianBitConverter/BigEndianBitConverter.cs +++ b/EndianBitConverter/BigEndianBitConverter.cs @@ -1,6 +1,6 @@ // Copyright (C) Microsoft Corporation. All rights reserved. -namespace BitConverter +namespace EndianBitConverter { /// /// A big-endian BitConverter that converts base data types to an array of bytes, and an array of bytes to base data types. All conversions are in diff --git a/EndianBitConverter/EndianBitConverter.cs b/EndianBitConverter/EndianBitConverter.cs index 62777fc..b4b0faa 100644 --- a/EndianBitConverter/EndianBitConverter.cs +++ b/EndianBitConverter/EndianBitConverter.cs @@ -1,6 +1,6 @@ // Copyright (C) Microsoft Corporation. All rights reserved. -namespace BitConverter +namespace EndianBitConverter { using System; using System.Runtime.CompilerServices; diff --git a/EndianBitConverter/LittleEndianBitConverter.cs b/EndianBitConverter/LittleEndianBitConverter.cs index 91d2037..2770646 100644 --- a/EndianBitConverter/LittleEndianBitConverter.cs +++ b/EndianBitConverter/LittleEndianBitConverter.cs @@ -1,6 +1,6 @@ // Copyright (C) Microsoft Corporation. All rights reserved. -namespace BitConverter +namespace EndianBitConverter { /// /// A little-endian BitConverter that converts base data types to an array of bytes, and an array of bytes to base data types. All conversions are in diff --git a/EndianBitConverter/SingleConverter.cs b/EndianBitConverter/SingleConverter.cs index 45f7e84..8c91ace 100644 --- a/EndianBitConverter/SingleConverter.cs +++ b/EndianBitConverter/SingleConverter.cs @@ -1,6 +1,6 @@ // Copyright (C) Microsoft Corporation. All rights reserved. -namespace BitConverter +namespace EndianBitConverter { using System.Runtime.InteropServices; From 9c7f826a3ef2dce2d59cba99df6de71f58bfb80e Mon Sep 17 00:00:00 2001 From: XCVGVCX Date: Wed, 20 May 2020 11:50:36 -0700 Subject: [PATCH 6/9] added README --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f5fa000 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# EndianBitConverter + +Provides a big-endian and little-endian BitConverter that convert base data types to an array of bytes, and an array of bytes to base data types, regardless of machine architecture. + +This fork cleans up and updates a few things. It was really intended for one or two specific projects rather than a direct replacement for the original. + +## Changes in this fork + +* Updated project and solution files. They're created and maintained with Visual Studio 2019. +* Updated to .NET Standard 2.0 and test project to .NET Framework 4.8. This removes a bunch of unused dependencies when used with .NET Standard 2.0 compatible frameworks but obviously means it **no longer works with older frameworks.** +* Changed the namespace from "BitConverter" to "EndianBitConverter" as the former clashes with the built-in BitConverter type. **This is a breaking change.** + +## License + +This project is licensed under the MIT License. See the included LICENSE.txt for details. \ No newline at end of file From e5769bf98c18c33ded826dca97bcd6ecb6f2944e Mon Sep 17 00:00:00 2001 From: XCVGVCX Date: Wed, 20 May 2020 12:08:41 -0700 Subject: [PATCH 7/9] upgraded the version again (I uploaded the wrong nuget and breaking changes have been made) --- EndianBitConverter/EndianBitConverter.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EndianBitConverter/EndianBitConverter.csproj b/EndianBitConverter/EndianBitConverter.csproj index d93f3d1..70e04cf 100644 --- a/EndianBitConverter/EndianBitConverter.csproj +++ b/EndianBitConverter/EndianBitConverter.csproj @@ -2,9 +2,9 @@ netstandard2.0 - 2.0.0.0 - 2.0.0.0 - 2.0.0 + 3.0.0.0 + 3.0.0.0 + 3.0.0 true David Reaburn, Chris Leclair LICENSE.txt From 99d3679bf6e5cd2d6b78336025c25f5446a9393a Mon Sep 17 00:00:00 2001 From: Ovidiu-Daniel Diaconescu Date: Tue, 15 Dec 2020 18:14:54 +0200 Subject: [PATCH 8/9] Updated testes to netcore3.1 --- BitConverter.sln | 20 ++-- .../EndianBitConverter.Tests.csproj | 96 ++++--------------- EndianBitConverter/EndianBitConverter.csproj | 31 ++---- 3 files changed, 39 insertions(+), 108 deletions(-) diff --git a/BitConverter.sln b/BitConverter.sln index 3a1051a..0df48d0 100644 --- a/BitConverter.sln +++ b/BitConverter.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30104.148 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndianBitConverter", "EndianBitConverter\EndianBitConverter.csproj", "{307C7700-BA3F-4B56-A44A-D369D2021B77}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndianBitConverter", "EndianBitConverter\EndianBitConverter.csproj", "{ABC12A77-84A8-4079-995A-E72FE047CC96}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndianBitConverter.Tests", "EndianBitConverter.Tests\EndianBitConverter.Tests.csproj", "{12C7685A-9CBA-4FD2-9679-6360FA7DAED5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndianBitConverter.Tests", "EndianBitConverter.Tests\EndianBitConverter.Tests.csproj", "{C56FC316-F02D-4C0D-B588-CAA4132CF360}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,14 +13,14 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {307C7700-BA3F-4B56-A44A-D369D2021B77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {307C7700-BA3F-4B56-A44A-D369D2021B77}.Debug|Any CPU.Build.0 = Debug|Any CPU - {307C7700-BA3F-4B56-A44A-D369D2021B77}.Release|Any CPU.ActiveCfg = Release|Any CPU - {307C7700-BA3F-4B56-A44A-D369D2021B77}.Release|Any CPU.Build.0 = Release|Any CPU - {12C7685A-9CBA-4FD2-9679-6360FA7DAED5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {12C7685A-9CBA-4FD2-9679-6360FA7DAED5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {12C7685A-9CBA-4FD2-9679-6360FA7DAED5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {12C7685A-9CBA-4FD2-9679-6360FA7DAED5}.Release|Any CPU.Build.0 = Release|Any CPU + {ABC12A77-84A8-4079-995A-E72FE047CC96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ABC12A77-84A8-4079-995A-E72FE047CC96}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ABC12A77-84A8-4079-995A-E72FE047CC96}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ABC12A77-84A8-4079-995A-E72FE047CC96}.Release|Any CPU.Build.0 = Release|Any CPU + {C56FC316-F02D-4C0D-B588-CAA4132CF360}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C56FC316-F02D-4C0D-B588-CAA4132CF360}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C56FC316-F02D-4C0D-B588-CAA4132CF360}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C56FC316-F02D-4C0D-B588-CAA4132CF360}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/EndianBitConverter.Tests/EndianBitConverter.Tests.csproj b/EndianBitConverter.Tests/EndianBitConverter.Tests.csproj index 06da965..f8a3506 100644 --- a/EndianBitConverter.Tests/EndianBitConverter.Tests.csproj +++ b/EndianBitConverter.Tests/EndianBitConverter.Tests.csproj @@ -1,76 +1,20 @@ - - - - - - Debug - AnyCPU - {12C7685A-9CBA-4FD2-9679-6360FA7DAED5} - Library - Properties - EndianBitConverter.Tests - EndianBitConverter.Tests - v4.8 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\MSTest.TestFramework.2.1.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.2.1.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - - - - - - - - - - - - - - {307c7700-ba3f-4b56-a44a-d369d2021b77} - EndianBitConverter - - - - - - - This project references NuGet package(s) that are missing on this computer. Use 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 + + + + netcoreapp3.1 + + false + + + + + + + + + + + + + + diff --git a/EndianBitConverter/EndianBitConverter.csproj b/EndianBitConverter/EndianBitConverter.csproj index 70e04cf..965e319 100644 --- a/EndianBitConverter/EndianBitConverter.csproj +++ b/EndianBitConverter/EndianBitConverter.csproj @@ -2,31 +2,18 @@ netstandard2.0 - 3.0.0.0 - 3.0.0.0 - 3.0.0 + 3.1.0.0 + 3.1.0.0 + 3.1.0 true David Reaburn, Chris Leclair LICENSE.txt https://github.com/XCVG/BitConverter EndianBitConverter.png - https://github.com/XCVG/BitConverter - © Microsoft Corporation, Chris Leclair. All rights reserved. - Microsoft Corporation, XCVG Systems - Provides a big-endian and little-endian BitConverter that convert base data types to an array of bytes, and an array of bytes to base data types, regardless of machine architecture. This is a third-party fork of the original project with the project cleaned up slightly and updated to .NET Standard 2.0. - Endian BigEndian LittleEndian BitConverter - XCVGSystems.EndianBitConverter + https://github.com/ovidiaconescu/BitConverter + © Microsoft Corporation, Chris Leclair, Ovidiu Diaconescu. All rights reserved. + Microsoft Corporation, XCVG Systems, Ovidiu Diaconescu + Provides a big-endian, little-endian mid big-endian, mid little-endian BitConverter that convert base data types to an array of bytes, and an array of bytes to base data types, regardless of machine architecture. This is a third-party fork of the original project with the project cleaned up slightly and updated to .NET Standard 2.0. + Endian BigEndian LittleEndian MidBigEndian MidLittleEndian BitConverter - - - - True - - - - True - - - - - + From dc1b59de88fb5b7446bbe506e49d9ff233c2c51c Mon Sep 17 00:00:00 2001 From: Ovidiu-Daniel Diaconescu Date: Tue, 15 Dec 2020 18:24:19 +0200 Subject: [PATCH 9/9] Mid Big-Endian and Mid Little-Endian converters --- BitConverter.sln | 9 +++ .../EndianBitConverter.Tests.csproj | 3 +- EndianBitConverter.Tests/InterfaceTests.cs | 13 ++++ EndianBitConverter.Tests/packages.config | 5 -- EndianBitConverter/BigEndianBitConverter.cs | 2 +- EndianBitConverter/EndianBitConverter.cs | 18 ++++++ .../LittleEndianBitConverter.cs | 2 +- .../MidBigEndianBitConverter.cs | 59 +++++++++++++++++++ .../MidLittleEndianBitConverter.cs | 57 ++++++++++++++++++ 9 files changed, 159 insertions(+), 9 deletions(-) delete mode 100644 EndianBitConverter.Tests/packages.config create mode 100644 EndianBitConverter/MidBigEndianBitConverter.cs create mode 100644 EndianBitConverter/MidLittleEndianBitConverter.cs diff --git a/BitConverter.sln b/BitConverter.sln index 0df48d0..aab2dc5 100644 --- a/BitConverter.sln +++ b/BitConverter.sln @@ -7,6 +7,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndianBitConverter", "Endia EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndianBitConverter.Tests", "EndianBitConverter.Tests\EndianBitConverter.Tests.csproj", "{C56FC316-F02D-4C0D-B588-CAA4132CF360}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_solution files", "_solution files", "{C7D9E938-1285-4249-B43F-7D1F4DEA9FA1}" + ProjectSection(SolutionItems) = preProject + .gitattributes = .gitattributes + .gitignore = .gitignore + EndianBitConverter.png = EndianBitConverter.png + LICENSE.txt = LICENSE.txt + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/EndianBitConverter.Tests/EndianBitConverter.Tests.csproj b/EndianBitConverter.Tests/EndianBitConverter.Tests.csproj index f8a3506..a345ee8 100644 --- a/EndianBitConverter.Tests/EndianBitConverter.Tests.csproj +++ b/EndianBitConverter.Tests/EndianBitConverter.Tests.csproj @@ -2,8 +2,7 @@ netcoreapp3.1 - - false + false diff --git a/EndianBitConverter.Tests/InterfaceTests.cs b/EndianBitConverter.Tests/InterfaceTests.cs index 6e494fb..92cff3e 100644 --- a/EndianBitConverter.Tests/InterfaceTests.cs +++ b/EndianBitConverter.Tests/InterfaceTests.cs @@ -11,8 +11,21 @@ public class InterfaceTests [TestMethod] public void IsLittleEndian() { + //big-endian Assert.IsFalse(EndianBitConverter.BigEndian.IsLittleEndian); + Assert.IsFalse(EndianBitConverter.BigEndian.IsMid); + + //mid big-endian + Assert.IsFalse(EndianBitConverter.MidBigEndian.IsLittleEndian); + Assert.IsTrue(EndianBitConverter.MidBigEndian.IsMid); + + //little-endian Assert.IsTrue(EndianBitConverter.LittleEndian.IsLittleEndian); + Assert.IsFalse(EndianBitConverter.LittleEndian.IsMid); + + //mid little-endian + Assert.IsTrue(EndianBitConverter.MidLittleEndian.IsLittleEndian); + Assert.IsTrue(EndianBitConverter.MidLittleEndian.IsMid); } } } diff --git a/EndianBitConverter.Tests/packages.config b/EndianBitConverter.Tests/packages.config deleted file mode 100644 index 6a20910..0000000 --- a/EndianBitConverter.Tests/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/EndianBitConverter/BigEndianBitConverter.cs b/EndianBitConverter/BigEndianBitConverter.cs index db87d37..498fcd2 100644 --- a/EndianBitConverter/BigEndianBitConverter.cs +++ b/EndianBitConverter/BigEndianBitConverter.cs @@ -12,7 +12,7 @@ internal class BigEndianBitConverter : EndianBitConverter internal BigEndianBitConverter() { } public override bool IsLittleEndian { get; } = false; - + public override bool IsMid { get; } = false; public override byte[] GetBytes(short value) { return new byte[] { (byte)(value >> 8), (byte)value }; diff --git a/EndianBitConverter/EndianBitConverter.cs b/EndianBitConverter/EndianBitConverter.cs index b4b0faa..efbc5ff 100644 --- a/EndianBitConverter/EndianBitConverter.cs +++ b/EndianBitConverter/EndianBitConverter.cs @@ -22,17 +22,35 @@ public abstract class EndianBitConverter /// public static EndianBitConverter LittleEndian { get; } = new LittleEndianBitConverter(); + /// + /// Get an instance of a , a BitConverter which performs all conversions in mid little-endian format regardless of + /// machine architecture. + /// + public static EndianBitConverter MidLittleEndian { get; } = new MidLittleEndianBitConverter(); + /// /// Get an instance of a , a BitConverter which performs all conversions in big-endian format regardless of /// machine architecture. /// public static EndianBitConverter BigEndian { get; } = new BigEndianBitConverter(); + /// + /// Get an instance of a , a BitConverter which performs all conversions in mid big-endian format regardless of + /// machine architecture. + /// + public static EndianBitConverter MidBigEndian { get; } = new MidBigEndianBitConverter(); + /// /// Indicates the byte order ("endianness") in which data should be converted. /// public abstract bool IsLittleEndian { get; } + /// + /// Indicates if the bytes should be converted from mid. + /// + public abstract bool IsMid { get; } + + /// /// Returns the specified Boolean value as a byte array. /// diff --git a/EndianBitConverter/LittleEndianBitConverter.cs b/EndianBitConverter/LittleEndianBitConverter.cs index 2770646..b0c9f86 100644 --- a/EndianBitConverter/LittleEndianBitConverter.cs +++ b/EndianBitConverter/LittleEndianBitConverter.cs @@ -12,7 +12,7 @@ internal class LittleEndianBitConverter : EndianBitConverter internal LittleEndianBitConverter() { } public override bool IsLittleEndian { get; } = true; - + public override bool IsMid { get; } = false; public override byte[] GetBytes(short value) { return new byte[] { (byte)value, (byte)(value >> 8) }; diff --git a/EndianBitConverter/MidBigEndianBitConverter.cs b/EndianBitConverter/MidBigEndianBitConverter.cs new file mode 100644 index 0000000..718b5ca --- /dev/null +++ b/EndianBitConverter/MidBigEndianBitConverter.cs @@ -0,0 +1,59 @@ +// Copyright (C) Microsoft Corporation. All rights reserved. + +namespace EndianBitConverter +{ + /// + /// A mid big-endian BitConverter that converts base data types to an array of bytes, and an array of bytes to base data types. + /// All conversions are in mid big-endian format regardless of machine architecture. + /// + internal class MidBigEndianBitConverter : EndianBitConverter + { + // Instance available from EndianBitConverter.BigEndian + internal MidBigEndianBitConverter() { } + + public override bool IsLittleEndian { get; } = false; + public override bool IsMid { get; } = true; + + + public override byte[] GetBytes(short value) + { + return new byte[] { (byte)(value >> 8), (byte)value }; + } + + public override byte[] GetBytes(int value) + { + return new byte[] { (byte)(value >> 16), (byte)(value >> 24), (byte)value, (byte)(value >> 8) }; + } + + public override byte[] GetBytes(long value) + { + return new byte[] { + (byte)(value >> 48), (byte)(value >> 56), (byte)(value >> 32), (byte)(value >> 40), + (byte)(value >> 16), (byte)(value >> 24), (byte)value, (byte)(value >> 8) + }; + } + + public override short ToInt16(byte[] value, int startIndex) + { + this.CheckArguments(value, startIndex, sizeof(short)); + + return (short)((value[startIndex] << 8) | (value[startIndex + 1])); + } + + public override int ToInt32(byte[] value, int startIndex) + { + this.CheckArguments(value, startIndex, sizeof(int)); + + return (value[startIndex] << 16) | (value[startIndex + 1] << 24) | (value[startIndex + 2]) | (value[startIndex + 3] << 8); + } + + public override long ToInt64(byte[] value, int startIndex) + { + this.CheckArguments(value, startIndex, sizeof(long)); + + int highBytes = (value[startIndex] << 16) | (value[startIndex + 1] << 24) | (value[startIndex + 2]) | (value[startIndex + 3] << 8); + int lowBytes = (value[startIndex + 4] << 16) | (value[startIndex + 5] << 24) | (value[startIndex + 6]) | (value[startIndex + 7] << 8); + return ((uint)lowBytes | ((long)highBytes << 32)); + } + } +} diff --git a/EndianBitConverter/MidLittleEndianBitConverter.cs b/EndianBitConverter/MidLittleEndianBitConverter.cs new file mode 100644 index 0000000..6b73003 --- /dev/null +++ b/EndianBitConverter/MidLittleEndianBitConverter.cs @@ -0,0 +1,57 @@ +namespace EndianBitConverter +{ + /// + /// A mid little-endian BitConverter that converts base data types to an array of bytes, and an array of bytes to base data types. + /// All conversions are in mid little-endian format regardless of machine architecture. + /// + internal class MidLittleEndianBitConverter : EndianBitConverter + { + // Instance available from EndianBitConverter.MidLittleEndian + internal MidLittleEndianBitConverter() { } + + public override bool IsLittleEndian { get; } = true; + public override bool IsMid { get; } = true; + + + public override byte[] GetBytes(short value) + { + return new byte[] { (byte)value, (byte)(value >> 8) }; + } + + public override byte[] GetBytes(int value) + { + return new byte[] { (byte)(value >> 8), (byte)value, (byte)(value >> 24), (byte)(value >> 16) }; + } + + public override byte[] GetBytes(long value) + { + return new byte[] { + (byte)(value >> 8), (byte)value, (byte)(value >> 24), (byte)(value >> 16), + (byte)(value >> 40), (byte)(value >> 32), (byte)(value >> 56), (byte)(value >> 48) + }; + } + + public override short ToInt16(byte[] value, int startIndex) + { + this.CheckArguments(value, startIndex, sizeof(short)); + + return (short)((value[startIndex]) | (value[startIndex + 1] << 8)); + } + + public override int ToInt32(byte[] value, int startIndex) + { + this.CheckArguments(value, startIndex, sizeof(int)); + + return (value[startIndex] << 8) | (value[startIndex + 1]) | (value[startIndex + 2] << 24) | (value[startIndex + 3] << 16 ); + } + + public override long ToInt64(byte[] value, int startIndex) + { + this.CheckArguments(value, startIndex, sizeof(long)); + + int lowBytes = (value[startIndex] << 8) | (value[startIndex + 1]) | (value[startIndex + 2] << 24) | (value[startIndex + 3] << 16); + int highBytes = (value[startIndex + 4] << 8) | (value[startIndex + 5]) | (value[startIndex + 6] << 24) | (value[startIndex + 7] << 16); + return ((uint)lowBytes | ((long)highBytes << 32)); + } + } +}