8000 #1098 Deploy usage of support for message formatting in exception c'tors · github/libgit2sharp@c667ece · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Commit c667ece

Browse files
committed
libgit2#1098 Deploy usage of support for message formatting in exception c'tors
Reviewed usages of LibGit2SharpException and removed any unnecessary string.format calls.
1 parent 0854671 commit c667ece

7 files changed

+16
-13
lines changed

LibGit2Sharp/Configuration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,9 +693,9 @@ private ConfigurationSafeHandle RetrieveConfigurationHandle(ConfigurationLevel l
693693

694694
if (handle == null && throwIfStoreHasNotBeenFound)
695695
{
696-
throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture,
696+
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
697697
"No {0} configuration file has been found.",
698-
Enum.GetName(typeof(ConfigurationLevel), level)));
698+
Enum.GetName(typeof(ConfigurationLevel), level));
699699
}
700700

701701
return handle;

LibGit2Sharp/Core/Proxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,9 +1432,9 @@ public static IntPtr git_odb_backend_malloc(IntPtr backend, UIntPtr len)
14321432

14331433
if (IntPtr.Zero == toReturn)
14341434
{
1435-
throw new LibGit2SharpException(String.Format(CultureInfo.InvariantCulture,
1435+
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
14361436
"Unable to allocate {0} bytes; out of memory",
1437-
len),
1437+
len,
14381438
GitErrorCode.Error,
14391439
GitErrorCategory.NoMemory);
14401440
}

LibGit2Sharp/Network.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,9 @@ public virtual void Push(
400400
if (string.IsNullOrEmpty(branch.UpstreamBranchCanonicalName))
401401
{
402402
throw new LibGit2SharpException(
403-
string.Format(
404403
CultureInfo.InvariantCulture,
405404
"The branch '{0}' (\"{1}\") that you are trying to push does not track an upstream branch.",
406-
branch.FriendlyName, branch.CanonicalName));
405+
branch.FriendlyName, branch.CanonicalName);
407406
}
408407
}
409408

LibGit2Sharp/Rebase.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using LibGit2Sharp.Core;
33
using LibGit2Sharp.Core.Handles;
4+
using System.Globalization;
45

56
namespace LibGit2Sharp
67
{
@@ -80,8 +81,9 @@ public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, I
8081

8182
if (this.repository.Info.CurrentOperation != CurrentOperation.None)
8283
{
83-
throw new LibGit2SharpException(string.Format(
84-
"A {0} operation is already in progress.", this.repository.Info.CurrentOperation));
84+
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
85+
"A {0} operation is already in progress.",
86+
this.repository.Info.CurrentOperation);
8587
}
8688

8789
Func<Branch, ReferenceSafeHandle> RefHandleFromBranch = (Branch b) =>

LibGit2Sharp/RebaseOperationImpl.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using LibGit2Sharp.Core;
3+
using System.Globalization;
34

45
namespace LibGit2Sharp
56
{
@@ -118,9 +119,9 @@ private static RebaseResult RunRebaseStep(RebaseSafeHandle rebaseOperationHandle
118119
case RebaseStepOperation.Fixup:
119120
case RebaseStepOperation.Reword:
120121
// These operations are not yet supported by lg2.
121-
throw new LibGit2SharpException(string.Format(
122+
throw new LibGit2SharpException(CultureInfo.InvariantCulture,
122123
"Rebase Operation Type ({0}) is not currently supported in LibGit2Sharp.",
123-
stepToApplyInfo.Type));
124+
stepToApplyInfo.Type);
124125
default:
125126
throw new ArgumentException(string.Format(
126127
"Unexpected Rebase Operation Type: {0}", stepToApplyInfo.Type));

LibGit2Sharp/ReferenceCollection.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,9 @@ public virtual Reference Rename(string currentName, string newName,
405405
if (reference == null)
406406
{
407407
throw new LibGit2SharpException(
408-
string.Format(CultureInfo.InvariantCulture,
409-
"Reference '{0}' doesn't exist. One cannot move a non existing reference.", currentName));
408+
CultureInfo.InvariantCulture,
409+
"Reference '{0}' doesn't exist. One cannot move a non existing reference.",
410+
currentName);
410411
}
411412

412413
return Rename(reference, newName, logMessage, allowOverwrite);

LibGit2Sharp/UnbornBranchException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public UnbornBranchException(string message)
3232
/// <param name="format">A composite format string for use in <see cref="String.Format(IFormatProvider, string, object[])"/>.</param>
3333
/// <param name="args">An object array that contains zero or more objects to format.</param>
3434
public UnbornBranchException(CultureInfo cultureInfo, string format, params object[] args)
35-
: base(String.Format(cultureInfo, format, args))
35+
: base(cultureInfo, format, args)
3636
{ }
3737

3838
/// <summary>

0 commit comments

Comments
 (0)
0