diff --git a/LibGit2Sharp/AmbiguousSpecificationException.cs b/LibGit2Sharp/AmbiguousSpecificationException.cs index 577b84f1a..bad7af141 100644 --- a/LibGit2Sharp/AmbiguousSpecificationException.cs +++ b/LibGit2Sharp/AmbiguousSpecificationException.cs @@ -27,11 +27,10 @@ public AmbiguousSpecificationException(string message) /// /// Initializes a new instance of the class with a specified error message. /// - /// An object that supplies culture-specific formatting information. /// A composite format string for use in . /// An object array that contains zero or more objects to format. - public AmbiguousSpecificationException(CultureInfo cultureInfo, string format, params object[] args) - : base(String.Format(cultureInfo, format, args)) + public AmbiguousSpecificationException(string format, params object[] args) + : base(String.Format(format, args)) { } diff --git a/LibGit2Sharp/BareRepositoryException.cs b/LibGit2Sharp/BareRepositoryException.cs index 33c25f129..75ad9695c 100644 --- a/LibGit2Sharp/BareRepositoryException.cs +++ b/LibGit2Sharp/BareRepositoryException.cs @@ -25,6 +25,15 @@ public BareRepositoryException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public BareRepositoryException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/BranchCollection.cs b/LibGit2Sharp/BranchCollection.cs index 5bb21c9a9..803e28d00 100644 --- a/LibGit2Sharp/BranchCollection.cs +++ b/LibGit2Sharp/BranchCollection.cs @@ -263,8 +263,7 @@ public virtual Branch Rename(Branch branch, string newName, bool allowOverwrite) if (branch.IsRemote) { - throw new LibGit2SharpException(CultureInfo.InvariantCulture, - "Cannot rename branch '{0}'. It's a remote tracking branch.", + throw new LibGit2SharpException("Cannot rename branch '{0}'. It's a remote tracking branch.", branch.FriendlyName); } diff --git a/LibGit2Sharp/CheckoutConflictException.cs b/LibGit2Sharp/CheckoutConflictException.cs index 16a5654b2..a06360afb 100644 --- a/LibGit2Sharp/CheckoutConflictException.cs +++ b/LibGit2Sharp/CheckoutConflictException.cs @@ -26,6 +26,15 @@ public CheckoutConflictException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public CheckoutConflictException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/Configuration.cs b/LibGit2Sharp/Configuration.cs index db6aad033..4dbab2412 100644 --- a/LibGit2Sharp/Configuration.cs +++ b/LibGit2Sharp/Configuration.cs @@ -693,8 +693,7 @@ private ConfigurationSafeHandle RetrieveConfigurationHandle(ConfigurationLevel l if (handle == null && throwIfStoreHasNotBeenFound) { - throw new LibGit2SharpException(CultureInfo.InvariantCulture, - "No {0} configuration file has been found.", + throw new LibGit2SharpException("No {0} configuration file has been found.", Enum.GetName(typeof(ConfigurationLevel), level)); } diff --git a/LibGit2Sharp/Core/Ensure.cs b/LibGit2Sharp/Core/Ensure.cs index e0da6413b..b85cf712c 100644 --- a/LibGit2Sharp/Core/Ensure.cs +++ b/LibGit2Sharp/Core/Ensure.cs @@ -261,16 +261,14 @@ public static void GitObjectIsNotNull(GitObject gitObject, string identifier) return; } - var message = string.Format(CultureInfo.InvariantCulture, - "No valid git object identified by '{0}' exists in the repository.", - identifier); - + var messageFormat = "No valid git object identified by '{0}' exists in the repository."; + if (string.Equals("HEAD", identifier, StringComparison.Ordinal)) { - throw new UnbornBranchException(message); + throw new UnbornBranchException(messageFormat, identifier); } - throw new NotFoundException(message); + throw new NotFoundException(messageFormat, identifier); } } } diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs index bb729ed76..2c9cf12bf 100644 --- a/LibGit2Sharp/Core/Proxy.cs +++ b/LibGit2Sharp/Core/Proxy.cs @@ -823,8 +823,7 @@ public static void git_filter_register(string name, IntPtr filterPtr, int priori int res = NativeMethods.git_filter_register(name, filterPtr, priority); if (res == (int)GitErrorCode.Exists) { - var message = String.Format("A filter with the name '{0}' is already registered", name); - throw new EntryExistsException(message); + throw new EntryExistsException("A filter with the name '{0}' is already registered", name); } Ensure.ZeroResult(res); } @@ -1432,9 +1431,8 @@ public static IntPtr git_odb_backend_malloc(IntPtr backend, UIntPtr len) if (IntPtr.Zero == toReturn) { - throw new LibGit2SharpException(CultureInfo.InvariantCulture, - "Unable to allocate {0} bytes; out of memory", - len, + throw new LibGit2SharpException("Unable to allocate {0} bytes; out of memory", + len, GitErrorCode.Error, GitErrorCategory.NoMemory); } @@ -2257,7 +2255,7 @@ public static void git_remote_rename(RepositorySafeHandle repo, string name, str if (res == (int)GitErrorCode.NotFound) { - throw new NotFoundException(string.Format("Remote '{0}' does not exist and cannot be renamed.", name)); + throw new NotFoundException("Remote '{0}' does not exist and cannot be renamed.", name); } Ensure.ZeroResult(res); @@ -2405,9 +2403,8 @@ public static RepositorySafeHandle git_repository_open(string path) if (res == (int)GitErrorCode.NotFound) { - throw new RepositoryNotFoundException(String.Format(CultureInfo.InvariantCulture, - "Path '{0}' doesn't point at a valid Git repository or workdir.", - path)); + throw new RepositoryNotFoundException("Path '{0}' doesn't point at a valid Git repository or workdir.", + path); } Ensure.ZeroResult(res); @@ -2436,9 +2433,8 @@ public static void git_repository_open_ext(string path, RepositoryOpenFlags flag if (res == (int)GitErrorCode.NotFound) { - throw new RepositoryNotFoundException(String.Format(CultureInfo.InvariantCulture, - "Path '{0}' doesn't point at a valid Git repository or workdir.", - path)); + throw new RepositoryNotFoundException("Path '{0}' doesn't point at a valid Git repository or workdir.", + path); } Ensure.ZeroResult(res); @@ -2556,8 +2552,7 @@ public static Tuple git_revparse_ext(R return null; case (int)GitErrorCode.Ambiguous: - throw new AmbiguousSpecificationException(CultureInfo.InvariantCulture, - "Provided abbreviated ObjectId '{0}' is too short.", + throw new AmbiguousSpecificationException("Provided abbreviated ObjectId '{0}' is too short.", objectish); default: @@ -2778,8 +2773,7 @@ public static FileStatus git_status_file(RepositorySafeHandle repo, FilePath pat return FileStatus.Nonexistent; case (int)GitErrorCode.Ambiguous: - throw new AmbiguousSpecificationException(CultureInfo.InvariantCulture, - "More than one file matches the pathspec '{0}'. " + + throw new AmbiguousSpecificationException("More than one file matches the pathspec '{0}'. " + "You can either force a literal path evaluation " + "(GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH), or use git_status_foreach().", path); @@ -3079,8 +3073,8 @@ public static void git_transport_register(String prefix, IntPtr transport_cb, In if (res == (int)GitErrorCode.Exists) { - throw new EntryExistsException(String.Format("A custom transport for '{0}' is already registered", - prefix)); + throw new EntryExistsException("A custom transport for '{0}' is already registered", + prefix); } Ensure.ZeroResult(res); diff --git a/LibGit2Sharp/Diff.cs b/LibGit2Sharp/Diff.cs index 1e8d283c6..d18b6b0f8 100644 --- a/LibGit2Sharp/Diff.cs +++ b/LibGit2Sharp/Diff.cs @@ -109,8 +109,7 @@ private static T BuildDiffResult(DiffSafeHandle diff) where T : class, IDiffR if (!ChangesBuilders.TryGetValue(typeof(T), out builder)) { - throw new LibGit2SharpException(CultureInfo.InvariantCulture, - "User-defined types passed to Compare are not supported. Supported values are: {0}", + throw new LibGit2SharpException("User-defined types passed to Compare are not supported. Supported values are: {0}", string.Join(", ", ChangesBuilders.Keys.Select(x => x.Name))); } diff --git a/LibGit2Sharp/EmptyCommitException.cs b/LibGit2Sharp/EmptyCommitException.cs index 88d43ed87..8cd48e49f 100644 --- a/LibGit2Sharp/EmptyCommitException.cs +++ b/LibGit2Sharp/EmptyCommitException.cs @@ -24,6 +24,15 @@ public EmptyCommitException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public EmptyCommitException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/EntryExistsException.cs b/LibGit2Sharp/EntryExistsException.cs index 117cf4d8f..2c46e4acd 100644 --- a/LibGit2Sharp/EntryExistsException.cs +++ b/LibGit2Sharp/EntryExistsException.cs @@ -24,6 +24,15 @@ public EntryExistsException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public EntryExistsException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/GitObject.cs b/LibGit2Sharp/GitObject.cs index fcad84da2..e2653ca0f 100644 --- a/LibGit2Sharp/GitObject.cs +++ b/LibGit2Sharp/GitObject.cs @@ -77,8 +77,7 @@ internal static GitObject BuildFrom(Repository repo, ObjectId id, GitObjectType return new Blob(repo, id); default: - throw new LibGit2SharpException(CultureInfo.InvariantCulture, - "Unexpected type '{0}' for object '{1}'.", + throw new LibGit2SharpException("Unexpected type '{0}' for object '{1}'.", type, id); } diff --git a/LibGit2Sharp/InvalidSpecificationException.cs b/LibGit2Sharp/InvalidSpecificationException.cs index 0b71be897..64654852c 100644 --- a/LibGit2Sharp/InvalidSpecificationException.cs +++ b/LibGit2Sharp/InvalidSpecificationException.cs @@ -27,6 +27,15 @@ public InvalidSpecificationException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public InvalidSpecificationException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/LibGit2SharpException.cs b/LibGit2Sharp/LibGit2SharpException.cs index 3621b8ccd..e85dd638f 100644 --- a/LibGit2Sharp/LibGit2SharpException.cs +++ b/LibGit2Sharp/LibGit2SharpException.cs @@ -37,11 +37,10 @@ public LibGit2SharpException(string message, Exception innerException) /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// - /// An object that supplies culture-specific formatting information. /// A composite format string for use in . /// An object array that contains zero or more objects to format. - public LibGit2SharpException(CultureInfo cultureInfo, string format, params object[] args) - : base(String.Format(cultureInfo, format, args)) + public LibGit2SharpException(string format, params object[] args) + : base(String.Format(CultureInfo.InvariantCulture, format, args)) { } diff --git a/LibGit2Sharp/LockedFileException.cs b/LibGit2Sharp/LockedFileException.cs index 67abe025b..05859503a 100644 --- a/LibGit2Sharp/LockedFileException.cs +++ b/LibGit2Sharp/LockedFileException.cs @@ -24,6 +24,15 @@ public LockedFileException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public LockedFileException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/MergeFetchHeadNotFoundException.cs b/LibGit2Sharp/MergeFetchHeadNotFoundException.cs index 913b79ea2..a86bf5caf 100644 --- a/LibGit2Sharp/MergeFetchHeadNotFoundException.cs +++ b/LibGit2Sharp/MergeFetchHeadNotFoundException.cs @@ -23,6 +23,15 @@ public MergeFetchHeadNotFoundException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public MergeFetchHeadNotFoundException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/NameConflictException.cs b/LibGit2Sharp/NameConflictException.cs index ddd56156b..815415729 100644 --- a/LibGit2Sharp/NameConflictException.cs +++ b/LibGit2Sharp/NameConflictException.cs @@ -24,6 +24,15 @@ public NameConflictException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public NameConflictException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/Network.cs b/LibGit2Sharp/Network.cs index 2ec15deda..851edb535 100644 --- a/LibGit2Sharp/Network.cs +++ b/LibGit2Sharp/Network.cs @@ -399,9 +399,7 @@ public virtual void Push( { if (string.IsNullOrEmpty(branch.UpstreamBranchCanonicalName)) { - throw new LibGit2SharpException( - CultureInfo.InvariantCulture, - "The branch '{0}' (\"{1}\") that you are trying to push does not track an upstream branch.", + throw new LibGit2SharpException("The branch '{0}' (\"{1}\") that you are trying to push does not track an upstream branch.", branch.FriendlyName, branch.CanonicalName); } } diff --git a/LibGit2Sharp/NonFastForwardException.cs b/LibGit2Sharp/NonFastForwardException.cs index 7431058c8..487e8fd03 100644 --- a/LibGit2Sharp/NonFastForwardException.cs +++ b/LibGit2Sharp/NonFastForwardException.cs @@ -25,6 +25,15 @@ public NonFastForwardException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public NonFastForwardException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/NotFoundException.cs b/LibGit2Sharp/NotFoundException.cs index 4b8c10033..0e9b45bf3 100644 --- a/LibGit2Sharp/NotFoundException.cs +++ b/LibGit2Sharp/NotFoundException.cs @@ -24,6 +24,15 @@ public NotFoundException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public NotFoundException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/PeelException.cs b/LibGit2Sharp/PeelException.cs index 629b67334..09d6bdcc8 100644 --- a/LibGit2Sharp/PeelException.cs +++ b/LibGit2Sharp/PeelException.cs @@ -25,6 +25,15 @@ public PeelException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public PeelException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/Rebase.cs b/LibGit2Sharp/Rebase.cs index d9995ba92..c479f12ca 100644 --- a/LibGit2Sharp/Rebase.cs +++ b/LibGit2Sharp/Rebase.cs @@ -81,8 +81,7 @@ public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, I if (this.repository.Info.CurrentOperation != CurrentOperation.None) { - throw new LibGit2SharpException(CultureInfo.InvariantCulture, - "A {0} operation is already in progress.", + throw new LibGit2SharpException("A {0} operation is already in progress.", this.repository.Info.CurrentOperation); } diff --git a/LibGit2Sharp/RebaseOperationImpl.cs b/LibGit2Sharp/RebaseOperationImpl.cs index b85fd9528..9fb3cf228 100644 --- a/LibGit2Sharp/RebaseOperationImpl.cs +++ b/LibGit2Sharp/RebaseOperationImpl.cs @@ -119,8 +119,7 @@ private static RebaseResult RunRebaseStep(RebaseSafeHandle rebaseOperationHandle case RebaseStepOperation.Fixup: case RebaseStepOperation.Reword: // These operations are not yet supported by lg2. - throw new LibGit2SharpException(CultureInfo.InvariantCulture, - "Rebase Operation Type ({0}) is not currently supported in LibGit2Sharp.", + throw new LibGit2SharpException("Rebase Operation Type ({0}) is not currently supported in LibGit2Sharp.", stepToApplyInfo.Type); default: throw new ArgumentException(string.Format( diff --git a/LibGit2Sharp/Reference.cs b/LibGit2Sharp/Reference.cs index d1a286e26..fa6d9be9e 100644 --- a/LibGit2Sharp/Reference.cs +++ b/LibGit2Sharp/Reference.cs @@ -59,7 +59,7 @@ internal static T BuildFromPtr(ReferenceSafeHandle handle, Repository repo) w break; default: - throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Unable to build a new reference from a type '{0}'.", type); + throw new LibGit2SharpException("Unable to build a new reference from a type '{0}'.", type); } return reference as T; diff --git a/LibGit2Sharp/ReferenceCollection.cs b/LibGit2Sharp/ReferenceCollection.cs index 718e24432..e91115445 100644 --- a/LibGit2Sharp/ReferenceCollection.cs +++ b/LibGit2Sharp/ReferenceCollection.cs @@ -404,9 +404,7 @@ public virtual Reference Rename(string currentName, string newName, if (reference == null) { - throw new LibGit2SharpException( - CultureInfo.InvariantCulture, - "Reference '{0}' doesn't exist. One cannot move a non existing reference.", + throw new LibGit2SharpException("Reference '{0}' doesn't exist. One cannot move a non existing reference.", currentName); } @@ -547,8 +545,7 @@ public virtual Reference UpdateTarget(string name, string canonicalRefNameOrObje return UpdateTarget(symbolicReference, targetRef, logMessage); } - throw new LibGit2SharpException(CultureInfo.InvariantCulture, - "Reference '{0}' has an unexpected type ('{1}').", + throw new LibGit2SharpException("Reference '{0}' has an unexpected type ('{1}').", name, reference.GetType()); } diff --git a/LibGit2Sharp/ReflogCollection.cs b/LibGit2Sharp/ReflogCollection.cs index 0b2e6e113..a15339c57 100644 --- a/LibGit2Sharp/ReflogCollection.cs +++ b/LibGit2Sharp/ReflogCollection.cs @@ -37,8 +37,7 @@ internal ReflogCollection(Repository repo, string canonicalName) if (!Reference.IsValidName(canonicalName)) { - throw new InvalidSpecificationException( - string.Format(CultureInfo.InvariantCulture, "The given reference name '{0}' is not valid", canonicalName)); + throw new InvalidSpecificationException("The given reference name '{0}' is not valid", canonicalName); } this.repo = repo; diff --git a/LibGit2Sharp/RemoveFromIndexException.cs b/LibGit2Sharp/RemoveFromIndexException.cs index a1cea4bb0..6d9718c18 100644 --- a/LibGit2Sharp/RemoveFromIndexException.cs +++ b/LibGit2Sharp/RemoveFromIndexException.cs @@ -25,13 +25,12 @@ public RemoveFromIndexException(string message) { } /// - /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. + /// Initializes a new instance of the class with a specified error message. /// - /// An object that supplies culture-specific formatting information. /// A composite format string for use in . /// An object array that contains zero or more objects to format. - public RemoveFromIndexException(CultureInfo cultureInfo, string format, params object[] args) - : base(cultureInfo, format, args) + public RemoveFromIndexException(string format, params object[] args) + : base(format, args) { } diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs index 730da7eab..e37c9100c 100644 --- a/LibGit2Sharp/Repository.cs +++ b/LibGit2Sharp/Repository.cs @@ -900,8 +900,7 @@ public Branch Checkout(Branch branch, CheckoutOptions options) // Make sure this is not an unborn branch. if (branch.Tip == null) { - throw new UnbornBranchException(CultureInfo.InvariantCulture, - "The tip of branch '{0}' is null. There's nothing to checkout.", + throw new UnbornBranchException("The tip of branch '{0}' is null. There's nothing to checkout.", branch.FriendlyName); } @@ -1081,11 +1080,9 @@ public Commit Commit(string message, Signature author, Signature committer, Comm if (treesame && !amendMergeCommit) { - throw new EmptyCommitException( - options.AmendPreviousCommit ? - String.Format(CultureInfo.InvariantCulture, - "Amending this commit would produce a commit that is identical to its parent (id = {0})", parents[0].Id) : - "No changes; nothing to commit."); + throw (options.AmendPreviousCommit ? + new EmptyCommitException("Amending this commit would produce a commit that is identical to its parent (id = {0})", parents[0].Id) : + new EmptyCommitException("No changes; nothing to commit.")); } } @@ -1274,8 +1271,8 @@ public MergeResult MergeFetchedRefs(Signature merger, MergeOptions options) if (fetchHeads.Length == 0) { var expectedRef = this.Head.UpstreamBranchCanonicalName; - throw new MergeFetchHeadNotFoundException(string.Format(CultureInfo.InvariantCulture, - "The current branch is configured to merge with the reference '{0}' from the remote, but this reference was not fetched.", expectedRef)); + throw new MergeFetchHeadNotFoundException("The current branch is configured to merge with the reference '{0}' from the remote, but this reference was not fetched.", + expectedRef); } GitAnnotatedCommitHandle[] annotatedCommitHandles = fetchHeads.Select(fetchHead => @@ -1858,8 +1855,7 @@ public void Move(IEnumerable sourcePaths, IEnumerable destinatio FileStatus sourceStatus = keyValuePair.Key.Item2; if (sourceStatus.HasAny(new Enum[] { FileStatus.Nonexistent, FileStatus.DeletedFromIndex, FileStatus.NewInWorkdir, FileStatus.DeletedFromWorkdir })) { - throw new LibGit2SharpException(CultureInfo.InvariantCulture, - "Unable to move file '{0}'. Its current status is '{1}'.", + throw new LibGit2SharpException("Unable to move file '{0}'. Its current status is '{1}'.", sourcePath, sourceStatus); } @@ -1870,8 +1866,7 @@ public void Move(IEnumerable sourcePaths, IEnumerable destinatio continue; } - throw new LibGit2SharpException(CultureInfo.InvariantCulture, - "Unable to overwrite file '{0}'. Its current status is '{1}'.", + throw new LibGit2SharpException("Unable to overwrite file '{0}'. Its current status is '{1}'.", destPath, desStatus); } @@ -2106,8 +2101,7 @@ private IEnumerable RemoveStagedItems(IEnumerable paths, bool re status.HasFlag(FileStatus.ModifiedInIndex) || status.HasFlag(FileStatus.NewInIndex))) { - throw new RemoveFromIndexException(CultureInfo.InvariantCulture, - "Unable to remove file '{0}', as it has changes staged in the index. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.", + throw new RemoveFromIndexException("Unable to remove file '{0}', as it has changes staged in the index. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.", treeEntryChanges.Path); } removed.Add(RemoveFromIndex(treeEntryChanges.Path)); @@ -2116,22 +2110,19 @@ private IEnumerable RemoveStagedItems(IEnumerable paths, bool re case ChangeKind.Modified: if (status.HasFlag(FileStatus.ModifiedInWorkdir) && status.HasFlag(FileStatus.ModifiedInIndex)) { - throw new RemoveFromIndexException(CultureInfo.InvariantCulture, - "Unable to remove file '{0}', as it has staged content different from both the working directory and the HEAD.", + throw new RemoveFromIndexException("Unable to remove file '{0}', as it has staged content different from both the working directory and the HEAD.", treeEntryChanges.Path); } if (removeFromWorkingDirectory) { - throw new RemoveFromIndexException(CultureInfo.InvariantCulture, - "Unable to remove file '{0}', as it has local modifications. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.", + throw new RemoveFromIndexException("Unable to remove file '{0}', as it has local modifications. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.", treeEntryChanges.Path); } removed.Add(RemoveFromIndex(treeEntryChanges.Path)); continue; default: - throw new RemoveFromIndexException(CultureInfo.InvariantCulture, - "Unable to remove file '{0}'. Its current status is '{1}'.", + throw new RemoveFromIndexException("Unable to remove file '{0}'. Its current status is '{1}'.", treeEntryChanges.Path, treeEntryChanges.Status); } diff --git a/LibGit2Sharp/RepositoryExtensions.cs b/LibGit2Sharp/RepositoryExtensions.cs index 5aa1fc067..d3754caa3 100644 --- a/LibGit2Sharp/RepositoryExtensions.cs +++ b/LibGit2Sharp/RepositoryExtensions.cs @@ -485,7 +485,7 @@ internal static IEnumerable Committishes(this Repository repo, object if (throwIfNotFound) { - throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Unexpected kind of identifier '{0}'.", identifier); + throw new LibGit2SharpException("Unexpected kind of identifier '{0}'.", identifier); } yield return null; diff --git a/LibGit2Sharp/RepositoryNotFoundException.cs b/LibGit2Sharp/RepositoryNotFoundException.cs index 10333212a..2255c0891 100644 --- a/LibGit2Sharp/RepositoryNotFoundException.cs +++ b/LibGit2Sharp/RepositoryNotFoundException.cs @@ -24,6 +24,15 @@ public RepositoryNotFoundException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public RepositoryNotFoundException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/SubmoduleCollection.cs b/LibGit2Sharp/SubmoduleCollection.cs index bc7aa4707..2ad23f6df 100644 --- a/LibGit2Sharp/SubmoduleCollection.cs +++ b/LibGit2Sharp/SubmoduleCollection.cs @@ -62,9 +62,8 @@ public virtual void Init(string name, bool overwrite) { if (handle == null) { - throw new NotFoundException(string.Format(CultureInfo.InvariantCulture, - "Submodule lookup failed for '{0}'.", - name)); + throw new NotFoundException("Submodule lookup failed for '{0}'.", + name); } Proxy.git_submodule_init(handle, overwrite); @@ -90,9 +89,8 @@ public virtual void Update(string name, SubmoduleUpdateOptions options) { if (handle == null) { - throw new NotFoundException(string.Format(CultureInfo.InvariantCulture, - "Submodule lookup failed for '{0}'.", - name)); + throw new NotFoundException("Submodule lookup failed for '{0}'.", + name); } using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(options)) @@ -160,7 +158,7 @@ internal T Lookup(string name, Func selector, bool th if (throwIfNotFound) { - throw new LibGit2SharpException(CultureInfo.InvariantCulture, "Submodule lookup failed for '{0}'.", name); + throw new LibGit2SharpException("Submodule lookup failed for '{0}'.", name); } return default(T); diff --git a/LibGit2Sharp/UnbornBranchException.cs b/LibGit2Sharp/UnbornBranchException.cs index 5efa88435..099704e8d 100644 --- a/LibGit2Sharp/UnbornBranchException.cs +++ b/LibGit2Sharp/UnbornBranchException.cs @@ -28,11 +28,10 @@ public UnbornBranchException(string message) /// /// Initializes a new instance of the class with a specified error message. /// - /// An object that supplies culture-specific formatting information. /// A composite format string for use in . /// An object array that contains zero or more objects to format. - public UnbornBranchException(CultureInfo cultureInfo, string format, params object[] args) - : base(cultureInfo, format, args) + public UnbornBranchException(string format, params object[] args) + : base(format, args) { } /// diff --git a/LibGit2Sharp/UnmatchedPathException.cs b/LibGit2Sharp/UnmatchedPathException.cs index ae5f3386c..7d118346d 100644 --- a/LibGit2Sharp/UnmatchedPathException.cs +++ b/LibGit2Sharp/UnmatchedPathException.cs @@ -23,6 +23,15 @@ public UnmatchedPathException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public UnmatchedPathException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/UnmergedIndexEntriesException.cs b/LibGit2Sharp/UnmergedIndexEntriesException.cs index 6cfa020c1..729882678 100644 --- a/LibGit2Sharp/UnmergedIndexEntriesException.cs +++ b/LibGit2Sharp/UnmergedIndexEntriesException.cs @@ -25,6 +25,15 @@ public UnmergedIndexEntriesException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public UnmergedIndexEntriesException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. /// diff --git a/LibGit2Sharp/UserCanceledException.cs b/LibGit2Sharp/UserCanceledException.cs index 45ab75f34..41eebb29a 100644 --- a/LibGit2Sharp/UserCanceledException.cs +++ b/LibGit2Sharp/UserCanceledException.cs @@ -24,6 +24,15 @@ public UserCancelledException(string message) : base(message) { } + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// A composite format string for use in . + /// An object array that contains zero or more objects to format. + public UserCancelledException(string format, params object[] args) + : base(format, args) + { } + /// /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. ///