Address new warnings from Resharper 2021.2

This commit is contained in:
Alex Barney 2021-08-06 23:03:01 -07:00
parent 373ba8ea20
commit 39f727bc0d
5 changed files with 13 additions and 69 deletions

View File

@ -313,7 +313,7 @@ namespace LibHac.Diag
// Not null span
// ---------------------------------------------------------------------
private static void NotNullImpl<T>(AssertionType assertionType, [NotNull] Span<T> value,
private static void NotNullImpl<T>(AssertionType assertionType, Span<T> value,
string valueText, string functionName, string fileName, int lineNumber)
{
if (AssertImpl.NotNull(value))
@ -323,7 +323,7 @@ namespace LibHac.Diag
}
[Conditional(AssertCondition)]
public static void NotNull<T>([NotNull] Span<T> value,
public static void NotNull<T>(Span<T> value,
[CallerArgumentExpression("value")] string valueText = "",
[CallerMemberName] string functionName = "",
[CallerFilePath] string fileName = "",
@ -333,7 +333,7 @@ namespace LibHac.Diag
}
[Conditional(AssertCondition)]
internal static void SdkNotNull<T>([NotNull] Span<T> value,
internal static void SdkNotNull<T>(Span<T> value,
[CallerArgumentExpression("value")] string valueText = "",
[CallerMemberName] string functionName = "",
[CallerFilePath] string fileName = "",
@ -343,7 +343,7 @@ namespace LibHac.Diag
}
[Conditional(AssertCondition)]
internal static void SdkRequiresNotNull<T>([NotNull] Span<T> value,
internal static void SdkRequiresNotNull<T>(Span<T> value,
[CallerArgumentExpression("value")] string valueText = "",
[CallerMemberName] string functionName = "",
[CallerFilePath] string fileName = "",
@ -356,7 +356,7 @@ namespace LibHac.Diag
// Not null read-only span
// ---------------------------------------------------------------------
private static void NotNullImpl<T>(AssertionType assertionType, [NotNull] ReadOnlySpan<T> value,
private static void NotNullImpl<T>(AssertionType assertionType, ReadOnlySpan<T> value,
string valueText, string functionName, string fileName, int lineNumber)
{
if (AssertImpl.NotNull(value))
@ -366,7 +366,7 @@ namespace LibHac.Diag
}
[Conditional(AssertCondition)]
public static void NotNull<T>([NotNull] ReadOnlySpan<T> value,
public static void NotNull<T>(ReadOnlySpan<T> value,
[CallerArgumentExpression("value")] string valueText = "",
[CallerMemberName] string functionName = "",
[CallerFilePath] string fileName = "",
@ -376,7 +376,7 @@ namespace LibHac.Diag
}
[Conditional(AssertCondition)]
internal static void SdkNotNull<T>([NotNull] ReadOnlySpan<T> value,
internal static void SdkNotNull<T>(ReadOnlySpan<T> value,
[CallerArgumentExpression("value")] string valueText = "",
[CallerMemberName] string functionName = "",
[CallerFilePath] string fileName = "",
@ -386,7 +386,7 @@ namespace LibHac.Diag
}
[Conditional(AssertCondition)]
internal static void SdkRequiresNotNull<T>([NotNull] ReadOnlySpan<T> value,
internal static void SdkRequiresNotNull<T>(ReadOnlySpan<T> value,
[CallerArgumentExpression("value")] string valueText = "",
[CallerMemberName] string functionName = "",
[CallerFilePath] string fileName = "",

View File

@ -1,15 +1,13 @@
using System;
using System.Runtime.Serialization;
namespace LibHac
{
[Serializable]
public class HorizonResultException : LibHacException, ISerializable
public class HorizonResultException : LibHacException
{
/// <summary>
/// The result code of the error.
/// </summary>
public Result ResultValue { get; set; }
public Result ResultValue { get; }
/// <summary>
/// The original, internal result code if it was converted to a more general external result code.
@ -55,27 +53,6 @@ namespace LibHac
InnerMessage = message;
}
/// <summary>
/// Initializes a new instance of the <see cref="MissingKeyException"/> class with serialized data.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
protected HorizonResultException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
InternalResultValue = (Result)(info.GetValue(nameof(InternalResultValue), InternalResultValue.GetType()) ?? default(Result));
ResultValue = (Result)(info.GetValue(nameof(ResultValue), ResultValue.GetType()) ?? default(Result));
InnerMessage = (string)info.GetValue(nameof(InnerMessage), InnerMessage.GetType());
}
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(nameof(InternalResultValue), InternalResultValue);
info.AddValue(nameof(ResultValue), ResultValue);
info.AddValue(nameof(InnerMessage), InnerMessage);
}
public override string Message
{
get

View File

@ -1,12 +1,10 @@
using System;
using System.Runtime.Serialization;
namespace LibHac
{
/// <summary>
/// This is the exception that is thrown when an error occurs
/// </summary>
[Serializable]
public class LibHacException : Exception
{
/// <summary>
@ -35,15 +33,5 @@ namespace LibHac
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="LibHacException"/> class with serialized data.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
protected LibHacException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

View File

@ -1,13 +1,11 @@
using System;
using System.Runtime.Serialization;
namespace LibHac
{
/// <summary>
/// This is the exception that is thrown when an action requires a key that is not found in the provided keyset.
/// </summary>
[Serializable]
public class MissingKeyException : LibHacException, ISerializable
public class MissingKeyException : LibHacException
{
/// <summary>
/// The name of the key that is missing.
@ -60,25 +58,6 @@ namespace LibHac
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MissingKeyException"/> class with serialized data.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
protected MissingKeyException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Name = info.GetString(nameof(Name));
Type = (KeyType)(info.GetValue(nameof(Type), Type.GetType()) ?? default(KeyType));
}
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(nameof(Name), Name);
info.AddValue(nameof(Type), Type);
}
public override string Message
{
get

View File

@ -13,7 +13,7 @@ namespace LibHac
private const string HeaderMagic = "HEAD";
private const int EncryptedHeaderSize = 0x70;
private readonly byte[] _xciHeaderPubk =
private static readonly byte[] XciHeaderPubk =
{
0x98, 0xC7, 0x26, 0xB6, 0x0D, 0x0A, 0x50, 0xA7, 0x39, 0x21, 0x0A, 0xE3, 0x2F, 0xE4, 0x3E, 0x2E,
0x5B, 0xA2, 0x86, 0x75, 0xAA, 0x5C, 0xEE, 0x34, 0xF1, 0xA3, 0x3A, 0x7E, 0xBD, 0x90, 0x4E, 0xF7,
@ -85,7 +85,7 @@ namespace LibHac
byte[] sigData = reader.ReadBytes(SignatureSize);
reader.BaseStream.Position = SignatureSize + 4;
SignatureValidity = CryptoOld.Rsa2048Pkcs1Verify(sigData, Signature, _xciHeaderPubk);
SignatureValidity = CryptoOld.Rsa2048Pkcs1Verify(sigData, Signature, XciHeaderPubk);
RomAreaStartPage = reader.ReadInt32();
BackupAreaStartPage = reader.ReadInt32();