3 Commits
1.1.0 ... 1.2.0

Author SHA1 Message Date
Matt Nadareski
2ec364a0ec Support ancient .NET 2023-11-14 14:33:35 -05:00
Matt Nadareski
9960a9123c Expand supported RIDs 2023-11-08 22:51:21 -05:00
Matt Nadareski
13267b98f2 Enable latest language version 2023-11-07 22:08:18 -05:00
6 changed files with 14 additions and 74 deletions

View File

@@ -1,7 +1,5 @@
namespace SabreTools.ASN1
{
#pragma warning disable IDE0011
/// <summary>
/// Methods related to Object Identifiers (OID) and ASN.1 notation
/// </summary>
@@ -14,16 +12,10 @@ namespace SabreTools.ASN1
/// <param name="index">Current index into the list</param>
/// <returns>ASN.1 formatted string, if possible</returns>
/// <remarks>
#if NET48
public static string ParseOIDToASN1Notation(ulong[] values, ref int index)
#else
public static string? ParseOIDToASN1Notation(ulong[]? values, ref int index)
#endif
{
// TODO: Once the modified OID-IRI formatting is done, make an ASN.1 notation version
return null;
}
}
#pragma warning restore IDE0011
}

View File

@@ -1,10 +1,11 @@
using System.Linq;
using System.Text;
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0164 // This label has not been referenced
namespace SabreTools.ASN1
{
#pragma warning disable IDE0011
/// <summary>
/// Methods related to Object Identifiers (OID) and OID-IRI formatting
/// </summary>
@@ -21,11 +22,7 @@ namespace SabreTools.ASN1
/// not considered to be fully OID-IRI compliant.
/// </remarks>
/// <see href="http://www.oid-info.com/index.htm"/>
#if NET48
public static string ParseOIDToModifiedOIDIRI(ulong[] values)
#else
public static string? ParseOIDToModifiedOIDIRI(ulong[]? values)
#endif
{
// If we have an invalid set of values, we can't do anything
if (values == null || values.Length == 0)
@@ -38,11 +35,7 @@ namespace SabreTools.ASN1
var nameBuilder = new StringBuilder();
// Try to parse the standard value
#if NET48
string standard = ParseOIDToModifiedOIDIRI(values, ref index);
#else
string? standard = ParseOIDToModifiedOIDIRI(values, ref index);
#endif
if (standard == null)
return null;
@@ -72,11 +65,7 @@ namespace SabreTools.ASN1
/// a string from the official description. As such, the output of this is
/// not considered to be fully OID-IRI compliant.
/// </remarks>
#if NET48
private static string ParseOIDToModifiedOIDIRI(ulong[] values, ref int index)
#else
private static string? ParseOIDToModifiedOIDIRI(ulong[]? values, ref int index)
#endif
{
// If we have an invalid set of values, we can't do anything
if (values == null || values.Length == 0)
@@ -17179,6 +17168,4 @@ namespace SabreTools.ASN1
#endregion
}
}
#pragma warning restore IDE0011
}

View File

@@ -3,8 +3,6 @@ using System.Text;
namespace SabreTools.ASN1
{
#pragma warning disable IDE0011
/// <summary>
/// Methods related to Object Identifiers (OID) and OID-IRI formatting
/// </summary>
@@ -17,11 +15,7 @@ namespace SabreTools.ASN1
/// <param name="index">Current index into the list</param>
/// <returns>OID-IRI formatted string, if possible</returns>
/// <see href="http://www.oid-info.com/index.htm"/>
#if NET48
public static string ParseOIDToOIDIRINotation(ulong[] values)
#else
public static string? ParseOIDToOIDIRINotation(ulong[]? values)
#endif
{
// If we have an invalid set of values, we can't do anything
if (values == null || values.Length == 0)
@@ -34,11 +28,7 @@ namespace SabreTools.ASN1
var nameBuilder = new StringBuilder();
// Try to parse the standard value
#if NET48
string standard = ParseOIDToOIDIRINotation(values, ref index);
#else
string? standard = ParseOIDToOIDIRINotation(values, ref index);
#endif
if (standard == null)
return null;
@@ -64,11 +54,7 @@ namespace SabreTools.ASN1
/// <param name="index">Current index into the list</param>
/// <returns>OID-IRI formatted string, if possible</returns>
/// <see href="http://www.oid-info.com/index.htm"/>
#if NET48
private static string ParseOIDToOIDIRINotation(ulong[] values, ref int index)
#else
private static string? ParseOIDToOIDIRINotation(ulong[]? values, ref int index)
#endif
{
// If we have an invalid set of values, we can't do anything
if (values == null || values.Length == 0)
@@ -877,6 +863,4 @@ namespace SabreTools.ASN1
#endregion
}
}
#pragma warning restore IDE0011
}

View File

@@ -1,7 +1,5 @@
namespace SabreTools.ASN1
{
#pragma warning disable IDE0011
/// <summary>
/// Methods related to Object Identifiers (OID) and dot notation
/// </summary>
@@ -12,11 +10,7 @@ namespace SabreTools.ASN1
/// </summary>
/// <param name="values">List of values to check against</param>
/// <returns>List of values representing the dot notation</returns>
#if NET48
public static string ParseOIDToDotNotation(ulong[] values)
#else
public static string? ParseOIDToDotNotation(ulong[]? values)
#endif
{
// If we have an invalid set of values, we can't do anything
if (values == null || values.Length == 0)
@@ -25,6 +19,4 @@ namespace SabreTools.ASN1
return string.Join(".", values);
}
}
#pragma warning restore IDE0011
}

View File

@@ -2,10 +2,12 @@
<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net48;net6.0;net7.0;net8.0</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<Version>1.1.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>1.2.0</Version>
<!-- Package Properties -->
<Authors>Matt Nadareski</Authors>
@@ -19,16 +21,12 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'!='net48'">
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath=""/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="SabreTools.IO" Version="1.1.1" />
<PackageReference Include="SabreTools.IO" Version="1.2.0" />
</ItemGroup>
</Project>

View File

@@ -25,11 +25,7 @@ namespace SabreTools.ASN1
/// <summary>
/// Generic value associated with <see cref="Type"/>
/// </summary>
#if NET48
public object Value { get; private set; }
#else
public object? Value { get; private set; }
#endif
/// <summary>
/// Read from the source data array at an index
@@ -117,11 +113,7 @@ namespace SabreTools.ASN1
}
// Get the value as a byte array
#if NET48
byte[] valueAsByteArray = this.Value as byte[];
#else
byte[]? valueAsByteArray = this.Value as byte[];
#endif
if (valueAsByteArray == null)
{
formatBuilder.Append(", Value: [INVALID DATA TYPE]");
@@ -166,13 +158,8 @@ namespace SabreTools.ASN1
ulong[] objectNodes = ObjectIdentifier.ParseDERIntoArray(valueAsByteArray, this.Length);
// Append the dot and modified OID-IRI notations
#if NET48
string dotNotationString = ObjectIdentifier.ParseOIDToDotNotation(objectNodes);
string oidIriString = ObjectIdentifier.ParseOIDToOIDIRINotation(objectNodes);
#else
string? dotNotationString = ObjectIdentifier.ParseOIDToDotNotation(objectNodes);
string? oidIriString = ObjectIdentifier.ParseOIDToOIDIRINotation(objectNodes);
#endif
formatBuilder.Append($", Value: {dotNotationString} ({oidIriString})");
break;
@@ -210,7 +197,11 @@ namespace SabreTools.ASN1
break;
default:
#if NET40 || NET452
formatBuilder.Append($", Value (Unknown Format): {BitConverter.ToString(this.Value as byte[] ?? new byte[0]).Replace('-', ' ')}");
#else
formatBuilder.Append($", Value (Unknown Format): {BitConverter.ToString(this.Value as byte[] ?? Array.Empty<byte>()).Replace('-', ' ')}");
#endif
break;
}
@@ -239,11 +230,7 @@ namespace SabreTools.ASN1
// Otherwise, use the value as the number of remaining bytes to read
int bytesToRead = length & ~0x80;
#if NET48
byte[] bytesRead = data.ReadBytes(ref index, bytesToRead);
#else
byte[]? bytesRead = data.ReadBytes(ref index, bytesToRead);
#endif
if (bytesRead == null)
throw new InvalidOperationException();