mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
General code refactor.
This commit is contained in:
1056
.editorconfig
1056
.editorconfig
File diff suppressed because it is too large
Load Diff
@@ -54,22 +54,22 @@
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ArrayFill.cs" />
|
||||
<Compile Include="BigEndianBitConverter.cs" />
|
||||
<Compile Include="BitEndian.cs" />
|
||||
<Compile Include="DateHandlers.cs" />
|
||||
<Compile Include="Marshal.cs" />
|
||||
<Compile Include="MarshallingPropertiesAttribute.cs" />
|
||||
<Compile Include="PrintHex.cs" />
|
||||
<Compile Include="StringHandlers.cs" />
|
||||
<Compile Include="Swapping.cs" />
|
||||
<Compile Include="ArrayIsEmpty.cs" />
|
||||
<Compile Include="CompareBytes.cs" />
|
||||
<Compile Include="CountBits.cs" />
|
||||
<Compile Include="CHS.cs" />
|
||||
<Compile Include="ArrayFill.cs"/>
|
||||
<Compile Include="BigEndianBitConverter.cs"/>
|
||||
<Compile Include="BitEndian.cs"/>
|
||||
<Compile Include="DateHandlers.cs"/>
|
||||
<Compile Include="Marshal.cs"/>
|
||||
<Compile Include="MarshallingPropertiesAttribute.cs"/>
|
||||
<Compile Include="PrintHex.cs"/>
|
||||
<Compile Include="StringHandlers.cs"/>
|
||||
<Compile Include="Swapping.cs"/>
|
||||
<Compile Include="ArrayIsEmpty.cs"/>
|
||||
<Compile Include="CompareBytes.cs"/>
|
||||
<Compile Include="CountBits.cs"/>
|
||||
<Compile Include="CHS.cs"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj">
|
||||
@@ -83,16 +83,16 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Memory" Version="4.5.4" />
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.3.0" PrivateAssets="all" />
|
||||
<PackageReference Include="System.Memory" Version="4.5.4"/>
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.3.0" PrivateAssets="all"/>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************
Aaru Data Preservation Suite
----------------------------------------------------------------------------
 
Filename : ${FileName}
Author(s) : ${AuthorName} <${AuthorEmail}>

Component : Component
 
--[ Description ] ----------------------------------------------------------
 
 Description
 
--[ License ] --------------------------------------------------------------
 
 This library is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as
 published by the Free Software Foundation; either version 2.1 of the
 License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, see <http://www.gnu.org/licenses/>.

----------------------------------------------------------------------------
Copyright © 2011-${Year} ${CopyrightHolder}
****************************************************************************/" />
|
||||
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp" />
|
||||
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp" />
|
||||
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************
Aaru Data Preservation Suite
----------------------------------------------------------------------------
 
Filename : ${FileName}
Author(s) : ${AuthorName} <${AuthorEmail}>

Component : Component
 
--[ Description ] ----------------------------------------------------------
 
 Description
 
--[ License ] --------------------------------------------------------------
 
 This library is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as
 published by the Free Software Foundation; either version 2.1 of the
 License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, see <http://www.gnu.org/licenses/>.

----------------------------------------------------------------------------
Copyright © 2011-${Year} ${CopyrightHolder}
****************************************************************************/"/>
|
||||
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp"/>
|
||||
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp"/>
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
|
||||
@@ -34,9 +34,7 @@ using System.Linq;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations to work with arrays
|
||||
/// </summary>
|
||||
/// <summary>Helper operations to work with arrays</summary>
|
||||
public static partial class ArrayHelpers
|
||||
{
|
||||
/// <summary>Checks if an array is null, filled with the NULL byte (0x00) or ASCII whitespace (0x20)</summary>
|
||||
|
||||
@@ -305,9 +305,7 @@ namespace Aaru.Helpers
|
||||
public static ulong ToUInt64(byte[] value, int startIndex) =>
|
||||
BitConverter.ToUInt64(value.Reverse().ToArray(), value.Length - sizeof(ulong) - startIndex);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a big endian byte array representation of a GUID into the .NET Guid structure
|
||||
/// </summary>
|
||||
/// <summary>Converts a big endian byte array representation of a GUID into the .NET Guid structure</summary>
|
||||
/// <param name="value">Byte array containing a GUID in big endian</param>
|
||||
/// <param name="startIndex">Start of the byte array to process</param>
|
||||
/// <returns>Processed Guid</returns>
|
||||
|
||||
4
CHS.cs
4
CHS.cs
@@ -32,9 +32,7 @@
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations to work with CHS values
|
||||
/// </summary>
|
||||
/// <summary>Helper operations to work with CHS values</summary>
|
||||
public static class CHS
|
||||
{
|
||||
/// <summary>Converts a CHS position to a LBA one</summary>
|
||||
|
||||
@@ -32,9 +32,7 @@
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations to count bits
|
||||
/// </summary>
|
||||
/// <summary>Helper operations to count bits</summary>
|
||||
public static class CountBits
|
||||
{
|
||||
/// <summary>Counts the number of bits set to <c>true</c> in a number</summary>
|
||||
|
||||
@@ -36,9 +36,7 @@ using Aaru.Console;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations for timestamp management (date and time)
|
||||
/// </summary>
|
||||
/// <summary>Helper operations for timestamp management (date and time)</summary>
|
||||
public static class DateHandlers
|
||||
{
|
||||
static readonly DateTime _lisaEpoch = new DateTime(1901, 1, 1, 0, 0, 0);
|
||||
|
||||
11
Marshal.cs
11
Marshal.cs
@@ -266,8 +266,7 @@ namespace Aaru.Helpers
|
||||
/// <summary>Swaps all members of a structure</summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining), SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static object SwapStructureMembersEndian(object str)
|
||||
{
|
||||
Type t = str.GetType();
|
||||
@@ -362,9 +361,7 @@ namespace Aaru.Helpers
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps all fields in an structure considering them to follow PDP endian conventions
|
||||
/// </summary>
|
||||
/// <summary>Swaps all fields in an structure considering them to follow PDP endian conventions</summary>
|
||||
/// <param name="str">Source structure</param>
|
||||
/// <returns>Resulting structure</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -435,9 +432,7 @@ namespace Aaru.Helpers
|
||||
public static byte[] StructureToByteArrayBigEndian<T>(T str) where T : struct =>
|
||||
StructureToByteArrayLittleEndian((T)SwapStructureMembersEndian(str));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a hexadecimal string into a byte array
|
||||
/// </summary>
|
||||
/// <summary>Converts a hexadecimal string into a byte array</summary>
|
||||
/// <param name="hex">Hexadecimal string</param>
|
||||
/// <param name="outBuf">Resulting byte array</param>
|
||||
/// <returns>Number of output bytes processed</returns>
|
||||
|
||||
@@ -35,9 +35,7 @@ using Aaru.Console;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations to get hexadecimal representations of byte arrays
|
||||
/// </summary>
|
||||
/// <summary>Helper operations to get hexadecimal representations of byte arrays</summary>
|
||||
public static class PrintHex
|
||||
{
|
||||
/// <summary>Prints a byte array as hexadecimal values to the console</summary>
|
||||
|
||||
@@ -35,9 +35,7 @@ using System.Text;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations to work with strings
|
||||
/// </summary>
|
||||
/// <summary>Helper operations to work with strings</summary>
|
||||
public static class StringHandlers
|
||||
{
|
||||
/// <summary>Converts a null-terminated (aka C string) ASCII byte array to a C# string</summary>
|
||||
|
||||
36
Swapping.cs
36
Swapping.cs
@@ -34,46 +34,34 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations to work with swapping endians
|
||||
/// </summary>
|
||||
/// <summary>Helper operations to work with swapping endians</summary>
|
||||
public static class Swapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the PDP endian equivalent of the given little endian unsigned integer
|
||||
/// </summary>
|
||||
/// <summary>Gets the PDP endian equivalent of the given little endian unsigned integer</summary>
|
||||
/// <param name="x">Little endian unsigned integer</param>
|
||||
/// <returns>PDP unsigned integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static uint PDPFromLittleEndian(uint x) => ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the PDP endian equivalent of the given big endian unsigned integer
|
||||
/// </summary>
|
||||
/// <summary>Gets the PDP endian equivalent of the given big endian unsigned integer</summary>
|
||||
/// <param name="x">Big endian unsigned integer</param>
|
||||
/// <returns>PDP unsigned integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static uint PDPFromBigEndian(uint x) => ((x & 0xff00ff) << 8) | ((x & 0xff00ff00) >> 8);
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the endian of the specified unsigned short integer
|
||||
/// </summary>
|
||||
/// <summary>Swaps the endian of the specified unsigned short integer</summary>
|
||||
/// <param name="x">Unsigned short integer</param>
|
||||
/// <returns>Swapped unsigned short integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort Swap(ushort x) => (ushort)((x << 8) | (x >> 8));
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the endian of the specified signed short integer
|
||||
/// </summary>
|
||||
/// <summary>Swaps the endian of the specified signed short integer</summary>
|
||||
/// <param name="x">Signed short integer</param>
|
||||
/// <returns>Swapped signed short integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short Swap(short x) => (short)((x << 8) | ((x >> 8) & 0xFF));
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the endian of the specified unsigned integer
|
||||
/// </summary>
|
||||
/// <summary>Swaps the endian of the specified unsigned integer</summary>
|
||||
/// <param name="x">Unsigned integer</param>
|
||||
/// <returns>Swapped unsigned integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -84,9 +72,7 @@ namespace Aaru.Helpers
|
||||
return (x << 16) | (x >> 16);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the endian of the specified signed integer
|
||||
/// </summary>
|
||||
/// <summary>Swaps the endian of the specified signed integer</summary>
|
||||
/// <param name="x">Signed integer</param>
|
||||
/// <returns>Swapped signed integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -97,9 +83,7 @@ namespace Aaru.Helpers
|
||||
return (int)(((uint)x << 16) | (((uint)x >> 16) & 0xFFFF));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the endian of the specified unsigned long integer
|
||||
/// </summary>
|
||||
/// <summary>Swaps the endian of the specified unsigned long integer</summary>
|
||||
/// <param name="x">Unsigned long integer</param>
|
||||
/// <returns>Swapped unsigned long integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -112,9 +96,7 @@ namespace Aaru.Helpers
|
||||
return x;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the endian of the specified signed long integer
|
||||
/// </summary>
|
||||
/// <summary>Swaps the endian of the specified signed long integer</summary>
|
||||
/// <param name="x">Signed long integer</param>
|
||||
/// <returns>Swapped signed long integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
Reference in New Issue
Block a user