Skip to content

Commit

Permalink
Fix analyzer warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bording committed Mar 16, 2024
1 parent 4193f6b commit c407371
Show file tree
Hide file tree
Showing 23 changed files with 134 additions and 11 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project>

<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<UseArtifactsOutput>true</UseArtifactsOutput>
<DefineConstants Condition=" '$(ExtraDefine)' != '' ">$(DefineConstants);$(ExtraDefine)</DefineConstants>
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/desktop/SmartSubtransportFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private HttpWebResponse GetResponseWithRedirects()
}

// rethrow if it's not 401
throw ex;
throw;
}

if (response.StatusCode == HttpStatusCode.Moved || response.StatusCode == HttpStatusCode.Redirect)
Expand Down
10 changes: 8 additions & 2 deletions LibGit2Sharp/AmbiguousSpecificationException.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using LibGit2Sharp.Core;
using System;
#if NETFRAMEWORK
using System.Runtime.Serialization;
#endif
using LibGit2Sharp.Core;

namespace LibGit2Sharp
{
/// <summary>
/// The exception that is thrown when the provided specification cannot uniquely identify a reference, an object or a path.
/// </summary>
#if NETFRAMEWORK
[Serializable]
#endif
public class AmbiguousSpecificationException : NativeException
{
/// <summary>
Expand All @@ -30,7 +34,7 @@ public AmbiguousSpecificationException(string message)
/// <param name="format">A composite format string for use in <see cref="String.Format(IFormatProvider, string, object[])"/>.</param>
/// <param name="args">An object array that contains zero or more objects to format.</param>
public AmbiguousSpecificationException(string format, params object[] args)
: base(String.Format(format, args))
: base(string.Format(format, args))
{
}

Expand All @@ -43,6 +47,7 @@ public AmbiguousSpecificationException(string message, Exception innerException)
: base(message, innerException)
{ }

#if NETFRAMEWORK
/// <summary>
/// Initializes a new instance of the <see cref="AmbiguousSpecificationException"/> class with a serialized data.
/// </summary>
Expand All @@ -51,6 +56,7 @@ public AmbiguousSpecificationException(string message, Exception innerException)
protected AmbiguousSpecificationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
#endif

internal override GitErrorCode ErrorCode
{
Expand Down
6 changes: 6 additions & 0 deletions LibGit2Sharp/BareRepositoryException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
#if NETFRAMEWORK
using System.Runtime.Serialization;
#endif
using LibGit2Sharp.Core;

namespace LibGit2Sharp
Expand All @@ -8,7 +10,9 @@ namespace LibGit2Sharp
/// The exception that is thrown when an operation which requires a
/// working directory is performed against a bare repository.
/// </summary>
#if NETFRAMEWORK
[Serializable]
#endif
public class BareRepositoryException : NativeException
{
/// <summary>
Expand Down Expand Up @@ -43,6 +47,7 @@ public BareRepositoryException(string message, Exception innerException)
: base(message, innerException)
{ }

#if NETFRAMEWORK
/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.BareRepositoryException"/> class with a serialized data.
/// </summary>
Expand All @@ -51,6 +56,7 @@ public BareRepositoryException(string message, Exception innerException)
protected BareRepositoryException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
#endif

internal BareRepositoryException(string message, GitErrorCategory category)
: base(message, category)
Expand Down
6 changes: 6 additions & 0 deletions LibGit2Sharp/CheckoutConflictException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
#if NETFRAMEWORK
using System.Runtime.Serialization;
#endif
using LibGit2Sharp.Core;

namespace LibGit2Sharp
Expand All @@ -9,7 +11,9 @@ namespace LibGit2Sharp
/// because of a conflicting change staged in the index, or unstaged
/// in the working directory.
/// </summary>
#if NETFRAMEWORK
[Serializable]
#endif
public class CheckoutConflictException : NativeException
{
/// <summary>
Expand Down Expand Up @@ -44,6 +48,7 @@ public CheckoutConflictException(string message, Exception innerException)
: base(message, innerException)
{ }

#if NETFRAMEWORK
/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.CheckoutConflictException"/> class with a serialized data.
/// </summary>
Expand All @@ -52,6 +57,7 @@ public CheckoutConflictException(string message, Exception innerException)
protected CheckoutConflictException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
#endif

internal CheckoutConflictException(string message, GitErrorCategory category)
: base(message, category)
Expand Down
6 changes: 6 additions & 0 deletions LibGit2Sharp/EmptyCommitException.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System;
#if NETFRAMEWORK
using System.Runtime.Serialization;
#endif

namespace LibGit2Sharp
{
/// <summary>
/// The exception that is thrown when a commit would create an "empty"
/// commit that is treesame to its parent without an explicit override.
/// </summary>
#if NETFRAMEWORK
[Serializable]
#endif
public class EmptyCommitException : LibGit2SharpException
{
/// <summary>
Expand Down Expand Up @@ -42,6 +46,7 @@ public EmptyCommitException(string message, Exception innerException)
: base(message, innerException)
{ }

#if NETFRAMEWORK
/// <summary>
/// Initializes a new instance of the <see cref="EmptyCommitException"/> class with a serialized data.
/// </summary>
Expand All @@ -50,5 +55,6 @@ public EmptyCommitException(string message, Exception innerException)
protected EmptyCommitException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
#endif
}
}
7 changes: 7 additions & 0 deletions LibGit2Sharp/EntryExistsException.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
using System;
#if NETFRAMEWORK
using System.Runtime.Serialization;
#endif

using LibGit2Sharp.Core;

namespace LibGit2Sharp
{
/// <summary>
/// The exception that is thrown attempting to create a resource that already exists.
/// </summary>
#if NETFRAMEWORK
[Serializable]
#endif
public class EntryExistsException : LibGit2SharpException
{
/// <summary>
Expand Down Expand Up @@ -42,6 +47,7 @@ public EntryExistsException(string message, Exception innerException)
: base(message, innerException)
{ }

#if NETFRAMEWORK
/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.EntryExistsException"/> class with a serialized data.
/// </summary>
Expand All @@ -50,6 +56,7 @@ public EntryExistsException(string message, Exception innerException)
protected EntryExistsException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
#endif

internal EntryExistsException(string message, GitErrorCode code, GitErrorCategory category)
: base(message, code, category)
Expand Down
6 changes: 6 additions & 0 deletions LibGit2Sharp/InvalidSpecificationException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
#if NETFRAMEWORK
using System.Runtime.Serialization;
#endif
using LibGit2Sharp.Core;

namespace LibGit2Sharp
Expand All @@ -10,7 +12,9 @@ namespace LibGit2Sharp
/// if the spec refers to an object of an incorrect type (e.g. asking to
/// create a branch from a blob, or peeling a blob to a commit).
/// </summary>
#if NETFRAMEWORK
[Serializable]
#endif
public class InvalidSpecificationException : NativeException
{
/// <summary>
Expand Down Expand Up @@ -45,6 +49,7 @@ public InvalidSpecificationException(string message, Exception innerException)
: base(message, innerException)
{ }

#if NETFRAMEWORK
/// <summary>
/// Initializes a new instance of the <see cref="InvalidSpecificationException"/> class with a serialized data.
/// </summary>
Expand All @@ -53,6 +58,7 @@ public InvalidSpecificationException(string message, Exception innerException)
protected InvalidSpecificationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
#endif

internal InvalidSpecificationException(string message, GitErrorCategory category)
: base(message, category)
Expand Down
9 changes: 7 additions & 2 deletions LibGit2Sharp/LibGit2SharpException.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using System;
using System.Globalization;
#if NETFRAMEWORK
using System.Runtime.Serialization;
using LibGit2Sharp.Core;
#endif

namespace LibGit2Sharp
{
/// <summary>
/// The exception that is thrown when an error occurs during application execution.
/// </summary>
#if NETFRAMEWORK
[Serializable]
#endif
public class LibGit2SharpException : Exception
{
/// <summary>
Expand Down Expand Up @@ -40,10 +43,11 @@ public LibGit2SharpException(string message, Exception innerException)
/// <param name="format">A composite format string for use in <see cref="String.Format(IFormatProvider, string, object[])"/>.</param>
/// <param name="args">An object array that contains zero or more objects to format.</param>
public LibGit2SharpException(string format, params object[] args)
: base(String.Format(CultureInfo.InvariantCulture, format, args))
: base(string.Format(CultureInfo.InvariantCulture, format, args))
{
}

#if NETFRAMEWORK
/// <summary>
/// Initializes a new instance of the <see cref="LibGit2SharpException"/> class with a serialized data.
/// </summary>
Expand All @@ -52,5 +56,6 @@ public LibGit2SharpException(string format, params object[] args)
protected LibGit2SharpException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
#endif
}
}
6 changes: 6 additions & 0 deletions LibGit2Sharp/LockedFileException.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System;
#if NETFRAMEWORK
using System.Runtime.Serialization;
#endif
using LibGit2Sharp.Core;

namespace LibGit2Sharp
{
/// <summary>
/// The exception that is thrown attempting to open a locked file.
/// </summary>
#if NETFRAMEWORK
[Serializable]
#endif
public class LockedFileException : NativeException
{
/// <summary>
Expand Down Expand Up @@ -42,6 +46,7 @@ public LockedFileException(string message, Exception innerException)
: base(message, innerException)
{ }

#if NETFRAMEWORK
/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.LockedFileException"/> class with a serialized data.
/// </summary>
Expand All @@ -50,6 +55,7 @@ public LockedFileException(string message, Exception innerException)
protected LockedFileException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
#endif

internal LockedFileException(string message, GitErrorCategory category)
: base(message, category)
Expand Down
6 changes: 6 additions & 0 deletions LibGit2Sharp/MergeFetchHeadNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using System;
#if NETFRAMEWORK
using System.Runtime.Serialization;
#endif

namespace LibGit2Sharp
{
/// <summary>
/// The exception that is thrown when the ref to merge with was as part of a pull operation not fetched.
/// </summary>
#if NETFRAMEWORK
[Serializable]
#endif
public class MergeFetchHeadNotFoundException : NotFoundException
{
/// <summary>
Expand Down Expand Up @@ -41,6 +45,7 @@ public MergeFetchHeadNotFoundException(string message, Exception innerException)
: base(message, innerException)
{ }

#if NETFRAMEWORK
/// <summary>
/// Initializes a new instance of the <see cref="MergeFetchHeadNotFoundException"/> class with a serialized data.
/// </summary>
Expand All @@ -49,5 +54,6 @@ public MergeFetchHeadNotFoundException(string message, Exception innerException)
protected MergeFetchHeadNotFoundException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
#endif
}
}
6 changes: 6 additions & 0 deletions LibGit2Sharp/NameConflictException.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System;
#if NETFRAMEWORK
using System.Runtime.Serialization;
#endif
using LibGit2Sharp.Core;

namespace LibGit2Sharp
{
/// <summary>
/// The exception that is thrown when a reference, a remote, a submodule... with the same name already exists in the repository
/// </summary>
#if NETFRAMEWORK
[Serializable]
#endif
public class NameConflictException : NativeException
{
/// <summary>
Expand Down Expand Up @@ -42,6 +46,7 @@ public NameConflictException(string message, Exception innerException)
: base(message, innerException)
{ }

#if NETFRAMEWORK
/// <summary>
/// Initializes a new instance of the <see cref="NameConflictException"/> class with a serialized data.
/// </summary>
Expand All @@ -50,6 +55,7 @@ public NameConflictException(string message, Exception innerException)
protected NameConflictException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
#endif

internal NameConflictException(string message, GitErrorCategory category)
: base(message, category)
Expand Down
Loading

0 comments on commit c407371

Please sign in to comment.