diff --git a/LibGit2Sharp/Blob.cs b/LibGit2Sharp/Blob.cs index 29ef8d812..e33dce14b 100644 --- a/LibGit2Sharp/Blob.cs +++ b/LibGit2Sharp/Blob.cs @@ -62,7 +62,7 @@ public virtual Stream GetContentStream() /// Throws if blob is missing public virtual Stream GetContentStream(FilteringOptions filteringOptions) { - Ensure.ArgumentNotNull(filteringOptions, "filteringOptions"); + Ensure.ArgumentNotNull(filteringOptions, nameof(filteringOptions)); return Proxy.git_blob_filtered_content_stream(repo.Handle, Id, filteringOptions.HintPath, false); } @@ -86,7 +86,7 @@ public virtual string GetContentText() /// Throws if blob is missing public virtual string GetContentText(Encoding encoding) { - Ensure.ArgumentNotNull(encoding, "encoding"); + Ensure.ArgumentNotNull(encoding, nameof(encoding)); return ReadToEnd(GetContentStream(), encoding); } @@ -114,7 +114,7 @@ public virtual string GetContentText(FilteringOptions filteringOptions) /// Throws if blob is missing public virtual string GetContentText(FilteringOptions filteringOptions, Encoding encoding) { - Ensure.ArgumentNotNull(filteringOptions, "filteringOptions"); + Ensure.ArgumentNotNull(filteringOptions, nameof(filteringOptions)); return ReadToEnd(GetContentStream(filteringOptions), encoding); } diff --git a/LibGit2Sharp/BranchCollection.cs b/LibGit2Sharp/BranchCollection.cs index d81a48177..41adc263e 100644 --- a/LibGit2Sharp/BranchCollection.cs +++ b/LibGit2Sharp/BranchCollection.cs @@ -39,7 +39,7 @@ public virtual Branch this[string name] { get { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); if (LooksLikeABranchName(name)) { @@ -138,7 +138,7 @@ public virtual Branch Add(string name, Commit commit) /// A new . public virtual Branch Add(string name, Commit commit, bool allowOverwrite) { - Ensure.ArgumentNotNull(commit, "commit"); + Ensure.ArgumentNotNull(commit, nameof(commit)); return Add(name, commit.Sha, allowOverwrite); } @@ -152,8 +152,8 @@ public virtual Branch Add(string name, Commit commit, bool allowOverwrite) /// A new . public virtual Branch Add(string name, string committish, bool allowOverwrite) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNullOrEmptyString(committish, "committish"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(committish, nameof(committish)); using (Proxy.git_branch_create_from_annotated(repo.Handle, name, committish, allowOverwrite)) { } @@ -178,7 +178,7 @@ public virtual void Remove(string name) /// True if the provided is the name of a remote branch, false otherwise. public virtual void Remove(string name, bool isRemote) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); string branchName = isRemote ? Reference.RemoteTrackingBranchPrefix + name : name; @@ -197,7 +197,7 @@ public virtual void Remove(string name, bool isRemote) /// The branch to delete. public virtual void Remove(Branch branch) { - Ensure.ArgumentNotNull(branch, "branch"); + Ensure.ArgumentNotNull(branch, nameof(branch)); using (ReferenceHandle referencePtr = repo.Refs.RetrieveReferencePtr(branch.CanonicalName)) { @@ -225,8 +225,8 @@ public virtual Branch Rename(string currentName, string newName) /// A new . public virtual Branch Rename(string currentName, string newName, bool allowOverwrite) { - Ensure.ArgumentNotNullOrEmptyString(currentName, "currentName"); - Ensure.ArgumentNotNullOrEmptyString(newName, "newName"); + Ensure.ArgumentNotNullOrEmptyString(currentName, nameof(currentName)); + Ensure.ArgumentNotNullOrEmptyString(newName, nameof(newName)); Branch branch = this[currentName]; @@ -258,8 +258,8 @@ public virtual Branch Rename(Branch branch, string newName) /// A new . public virtual Branch Rename(Branch branch, string newName, bool allowOverwrite) { - Ensure.ArgumentNotNull(branch, "branch"); - Ensure.ArgumentNotNullOrEmptyString(newName, "newName"); + Ensure.ArgumentNotNull(branch, nameof(branch)); + Ensure.ArgumentNotNullOrEmptyString(newName, nameof(newName)); if (branch.IsRemote) { diff --git a/LibGit2Sharp/BranchUpdater.cs b/LibGit2Sharp/BranchUpdater.cs index b0908f272..5a76f3310 100644 --- a/LibGit2Sharp/BranchUpdater.cs +++ b/LibGit2Sharp/BranchUpdater.cs @@ -20,8 +20,8 @@ protected BranchUpdater() internal BranchUpdater(Repository repo, Branch branch) { - Ensure.ArgumentNotNull(repo, "repo"); - Ensure.ArgumentNotNull(branch, "branch"); + Ensure.ArgumentNotNull(repo, nameof(repo)); + Ensure.ArgumentNotNull(branch, nameof(branch)); this.repo = repo; this.branch = branch; diff --git a/LibGit2Sharp/CloneOptions.cs b/LibGit2Sharp/CloneOptions.cs index 12d47c9f3..13b725931 100644 --- a/LibGit2Sharp/CloneOptions.cs +++ b/LibGit2Sharp/CloneOptions.cs @@ -14,7 +14,7 @@ public sealed class CloneOptions : IConvertableToGitCheckoutOpts /// The fetch options to use. public CloneOptions(FetchOptions fetchOptions) : this() { - Ensure.ArgumentNotNull(fetchOptions, "fetchOptions"); + Ensure.ArgumentNotNull(fetchOptions, nameof(fetchOptions)); FetchOptions = fetchOptions; } diff --git a/LibGit2Sharp/Commands/Checkout.cs b/LibGit2Sharp/Commands/Checkout.cs index 46d456be1..c1a03dfc0 100644 --- a/LibGit2Sharp/Commands/Checkout.cs +++ b/LibGit2Sharp/Commands/Checkout.cs @@ -34,9 +34,9 @@ public static Branch Checkout(IRepository repository, string committishOrBranchS /// The that was checked out. public static Branch Checkout(IRepository repository, string committishOrBranchSpec, CheckoutOptions options) { - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNullOrEmptyString(committishOrBranchSpec, "committishOrBranchSpec"); - Ensure.ArgumentNotNull(options, "options"); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNullOrEmptyString(committishOrBranchSpec, nameof(committishOrBranchSpec)); + Ensure.ArgumentNotNull(options, nameof(options)); Reference reference = null; GitObject obj = null; @@ -109,9 +109,9 @@ public static Branch Checkout(IRepository repository, Branch branch) /// The that was checked out. public static Branch Checkout(IRepository repository, Branch branch, CheckoutOptions options) { - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNull(branch, "branch"); - Ensure.ArgumentNotNull(options, "options"); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNull(branch, nameof(branch)); + Ensure.ArgumentNotNull(options, nameof(options)); // Make sure this is not an unborn branch. if (branch.Tip == null) @@ -160,9 +160,9 @@ public static Branch Checkout(IRepository repository, Commit commit) /// The that was checked out. public static Branch Checkout(IRepository repository, Commit commit, CheckoutOptions options) { - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNull(commit, "commit"); - Ensure.ArgumentNotNull(options, "options"); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNull(commit, nameof(commit)); + Ensure.ArgumentNotNull(options, nameof(options)); Checkout(repository, commit.Tree, options, commit.Id.Sha); diff --git a/LibGit2Sharp/Commands/Fetch.cs b/LibGit2Sharp/Commands/Fetch.cs index e531aac51..eb648c716 100644 --- a/LibGit2Sharp/Commands/Fetch.cs +++ b/LibGit2Sharp/Commands/Fetch.cs @@ -33,7 +33,7 @@ private static RemoteHandle RemoteFromNameOrUrl(RepositoryHandle repoHandle, str /// List of refspecs to apply as active. public static void Fetch(Repository repository, string remote, IEnumerable refspecs, FetchOptions options, string logMessage) { - Ensure.ArgumentNotNull(remote, "remote"); + Ensure.ArgumentNotNull(remote, nameof(remote)); options = options ?? new FetchOptions(); using (var remoteHandle = RemoteFromNameOrUrl(repository.Handle, remote)) diff --git a/LibGit2Sharp/Commands/Pull.cs b/LibGit2Sharp/Commands/Pull.cs index f0a68fe9b..49d1b59eb 100644 --- a/LibGit2Sharp/Commands/Pull.cs +++ b/LibGit2Sharp/Commands/Pull.cs @@ -16,8 +16,8 @@ public static partial class Commands /// The options for fetch and merging. public static MergeResult Pull(Repository repository, Signature merger, PullOptions options) { - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNull(merger, "merger"); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNull(merger, nameof(merger)); options = options ?? new PullOptions(); diff --git a/LibGit2Sharp/Commands/Remove.cs b/LibGit2Sharp/Commands/Remove.cs index f96339c12..90b77e9b9 100644 --- a/LibGit2Sharp/Commands/Remove.cs +++ b/LibGit2Sharp/Commands/Remove.cs @@ -68,8 +68,8 @@ public static void Remove(IRepository repository, string path, bool removeFromWo /// public static void Remove(IRepository repository, string path, bool removeFromWorkingDirectory, ExplicitPathsOptions explicitPathsOptions) { - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNull(path, "path"); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNull(path, nameof(path)); Remove(repository, new[] { path }, removeFromWorkingDirectory, explicitPathsOptions); } @@ -115,8 +115,8 @@ public static void Remove(IRepository repository, IEnumerable paths) /// public static void Remove(IRepository repository, IEnumerable paths, bool removeFromWorkingDirectory, ExplicitPathsOptions explicitPathsOptions) { - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNullOrEmptyEnumerable(paths, "paths"); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNullOrEmptyEnumerable(paths, nameof(paths)); var pathsToDelete = paths.Where(p => Directory.Exists(Path.Combine(repository.Info.WorkingDirectory, p))).ToList(); var notConflictedPaths = new List(); @@ -124,7 +124,7 @@ public static void Remove(IRepository repository, IEnumerable paths, boo foreach (var path in paths) { - Ensure.ArgumentNotNullOrEmptyString(path, "path"); + Ensure.ArgumentNotNullOrEmptyString(path, nameof(path)); var conflict = index.Conflicts[path]; diff --git a/LibGit2Sharp/Commands/Stage.cs b/LibGit2Sharp/Commands/Stage.cs index d11bf6f76..bf269efc8 100644 --- a/LibGit2Sharp/Commands/Stage.cs +++ b/LibGit2Sharp/Commands/Stage.cs @@ -19,8 +19,8 @@ public static partial class Commands /// The path of the file within the working directory. public static void Stage(IRepository repository, string path) { - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNull(path, "path"); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNull(path, nameof(path)); Stage(repository, new[] { path }, null); } @@ -35,8 +35,8 @@ public static void Stage(IRepository repository, string path) /// Determines how paths will be staged. public static void Stage(IRepository repository, string path, StageOptions stageOptions) { - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNull(path, "path"); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNull(path, nameof(path)); Stage(repository, new[] { path }, stageOptions); } @@ -63,8 +63,8 @@ public static void Stage(IRepository repository, IEnumerable paths) /// Determines how paths will be staged. public static void Stage(IRepository repository, IEnumerable paths, StageOptions stageOptions) { - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNull(paths, "paths"); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNull(paths, nameof(paths)); DiffModifiers diffModifiers = DiffModifiers.IncludeUntracked; ExplicitPathsOptions explicitPathsOptions = stageOptions != null ? stageOptions.ExplicitPathsOptions : null; @@ -160,8 +160,8 @@ public static void Unstage(IRepository repository, string path) /// public static void Unstage(IRepository repository, string path, ExplicitPathsOptions explicitPathsOptions) { - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNull(path, "path"); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNull(path, nameof(path)); Unstage(repository, new[] { path }, explicitPathsOptions); } @@ -187,8 +187,8 @@ public static void Unstage(IRepository repository, IEnumerable paths) /// public static void Unstage(IRepository repository, IEnumerable paths, ExplicitPathsOptions explicitPathsOptions) { - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNull(paths, "paths"); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNull(paths, nameof(paths)); if (repository.Info.IsHeadUnborn) { @@ -222,9 +222,9 @@ public static void Move(IRepository repository, string sourcePath, string destin /// The target paths of the files within the working directory. public static void Move(IRepository repository, IEnumerable sourcePaths, IEnumerable destinationPaths) { - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNull(sourcePaths, "sourcePaths"); - Ensure.ArgumentNotNull(destinationPaths, "destinationPaths"); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNull(sourcePaths, nameof(sourcePaths)); + Ensure.ArgumentNotNull(destinationPaths, nameof(destinationPaths)); //TODO: Move() should support following use cases: // - Moving a file under a directory ('file' and 'dir' -> 'dir/file') diff --git a/LibGit2Sharp/Commit.cs b/LibGit2Sharp/Commit.cs index 357567d8a..645abf491 100644 --- a/LibGit2Sharp/Commit.cs +++ b/LibGit2Sharp/Commit.cs @@ -185,12 +185,12 @@ public static SignatureInfo ExtractSignature(Repository repo, ObjectId id) /// The contents of the commit object. public static string CreateBuffer(Signature author, Signature committer, string message, Tree tree, IEnumerable parents, bool prettifyMessage, char? commentChar) { - Ensure.ArgumentNotNull(message, "message"); - Ensure.ArgumentDoesNotContainZeroByte(message, "message"); - Ensure.ArgumentNotNull(author, "author"); - Ensure.ArgumentNotNull(committer, "committer"); - Ensure.ArgumentNotNull(tree, "tree"); - Ensure.ArgumentNotNull(parents, "parents"); + Ensure.ArgumentNotNull(message, nameof(message)); + Ensure.ArgumentDoesNotContainZeroByte(message, nameof(message)); + Ensure.ArgumentNotNull(author, nameof(author)); + Ensure.ArgumentNotNull(committer, nameof(committer)); + Ensure.ArgumentNotNull(tree, nameof(tree)); + Ensure.ArgumentNotNull(parents, nameof(parents)); if (prettifyMessage) { diff --git a/LibGit2Sharp/CommitLog.cs b/LibGit2Sharp/CommitLog.cs index 4a6ab1de3..452948ef3 100644 --- a/LibGit2Sharp/CommitLog.cs +++ b/LibGit2Sharp/CommitLog.cs @@ -72,9 +72,9 @@ IEnumerator IEnumerable.GetEnumerator() /// A list of commits, ready to be enumerated. public ICommitLog QueryBy(CommitFilter filter) { - Ensure.ArgumentNotNull(filter, "filter"); - Ensure.ArgumentNotNull(filter.IncludeReachableFrom, "filter.IncludeReachableFrom"); - Ensure.ArgumentNotNullOrEmptyString(filter.IncludeReachableFrom.ToString(), "filter.IncludeReachableFrom"); + Ensure.ArgumentNotNull(filter, nameof(filter)); + Ensure.ArgumentNotNull(filter.IncludeReachableFrom, nameof(filter.IncludeReachableFrom)); + Ensure.ArgumentNotNullOrEmptyString(filter.IncludeReachableFrom.ToString(), nameof(filter.IncludeReachableFrom.ToString())); return new CommitLog(repo, filter); } @@ -86,7 +86,7 @@ public ICommitLog QueryBy(CommitFilter filter) /// A list of file history entries, ready to be enumerated. public IEnumerable QueryBy(string path) { - Ensure.ArgumentNotNull(path, "path"); + Ensure.ArgumentNotNull(path, nameof(path)); return new FileHistory(repo, path); } @@ -99,8 +99,8 @@ public IEnumerable QueryBy(string path) /// A list of file history entries, ready to be enumerated. public IEnumerable QueryBy(string path, CommitFilter filter) { - Ensure.ArgumentNotNull(path, "path"); - Ensure.ArgumentNotNull(filter, "filter"); + Ensure.ArgumentNotNull(path, nameof(path)); + Ensure.ArgumentNotNull(filter, nameof(filter)); return new FileHistory(repo, path, filter); } diff --git a/LibGit2Sharp/Configuration.cs b/LibGit2Sharp/Configuration.cs index 84a8a3e53..75d4387ba 100644 --- a/LibGit2Sharp/Configuration.cs +++ b/LibGit2Sharp/Configuration.cs @@ -245,7 +245,7 @@ public virtual bool Unset(string key) /// The configuration file which should be considered as the target of this operation public virtual bool Unset(string key, ConfigurationLevel level) { - Ensure.ArgumentNotNullOrEmptyString(key, "key"); + Ensure.ArgumentNotNullOrEmptyString(key, nameof(key)); using (ConfigurationHandle h = RetrieveConfigurationHandle(level, true, configHandle)) { @@ -269,7 +269,7 @@ public virtual bool UnsetAll(string key) /// The configuration file which should be considered as the target of this operation public virtual bool UnsetAll(string key, ConfigurationLevel level) { - Ensure.ArgumentNotNullOrEmptyString(key, "key"); + Ensure.ArgumentNotNullOrEmptyString(key, nameof(key)); using (ConfigurationHandle h = RetrieveConfigurationHandle(level, true, configHandle)) { @@ -307,7 +307,7 @@ protected virtual void Dispose(bool disposing) /// The , or null if not set public virtual ConfigurationEntry Get(string[] keyParts) { - Ensure.ArgumentNotNull(keyParts, "keyParts"); + Ensure.ArgumentNotNull(keyParts, nameof(keyParts)); return Get(string.Join(".", keyParts)); } @@ -336,9 +336,9 @@ public virtual ConfigurationEntry Get(string[] keyParts) /// The , or null if not set public virtual ConfigurationEntry Get(string firstKeyPart, string secondKeyPart, string thirdKeyPart) { - Ensure.ArgumentNotNullOrEmptyString(firstKeyPart, "firstKeyPart"); - Ensure.ArgumentNotNullOrEmptyString(secondKeyPart, "secondKeyPart"); - Ensure.ArgumentNotNullOrEmptyString(thirdKeyPart, "thirdKeyPart"); + Ensure.ArgumentNotNullOrEmptyString(firstKeyPart, nameof(firstKeyPart)); + Ensure.ArgumentNotNullOrEmptyString(secondKeyPart, nameof(secondKeyPart)); + Ensure.ArgumentNotNullOrEmptyString(thirdKeyPart, nameof(thirdKeyPart)); return Get(new[] { firstKeyPart, secondKeyPart, thirdKeyPart }); } @@ -374,7 +374,7 @@ public virtual ConfigurationEntry Get(string firstKeyPart, string secondKe /// The , or null if not set public virtual ConfigurationEntry Get(string key) { - Ensure.ArgumentNotNullOrEmptyString(key, "key"); + Ensure.ArgumentNotNullOrEmptyString(key, nameof(key)); using (ConfigurationHandle snapshot = Snapshot()) { @@ -405,7 +405,7 @@ public virtual ConfigurationEntry Get(string key) /// The , or null if not set public virtual ConfigurationEntry Get(string key, ConfigurationLevel level) { - Ensure.ArgumentNotNullOrEmptyString(key, "key"); + Ensure.ArgumentNotNullOrEmptyString(key, nameof(key)); using (ConfigurationHandle snapshot = Snapshot()) using (ConfigurationHandle handle = RetrieveConfigurationHandle(level, false, snapshot)) @@ -587,7 +587,7 @@ private static T ValueOrDefault(ConfigurationEntry value, T defaultValue) private static T ValueOrDefault(ConfigurationEntry value, Func defaultValueSelector) { - Ensure.ArgumentNotNull(defaultValueSelector, "defaultValueSelector"); + Ensure.ArgumentNotNull(defaultValueSelector, nameof(defaultValueSelector)); return value == null ? defaultValueSelector() @@ -634,8 +634,8 @@ public virtual void Set(string key, T value) /// The configuration file which should be considered as the target of this operation public virtual void Set(string key, T value, ConfigurationLevel level) { - Ensure.ArgumentNotNull(value, "value"); - Ensure.ArgumentNotNullOrEmptyString(key, "key"); + Ensure.ArgumentNotNull(value, nameof(value)); + Ensure.ArgumentNotNullOrEmptyString(key, nameof(key)); using (ConfigurationHandle h = RetrieveConfigurationHandle(level, true, configHandle)) { @@ -686,8 +686,8 @@ public virtual void Add(string key, string value) /// The configuration file which should be considered as the target of this operation public virtual void Add(string key, string value, ConfigurationLevel level) { - Ensure.ArgumentNotNull(value, "value"); - Ensure.ArgumentNotNullOrEmptyString(key, "key"); + Ensure.ArgumentNotNull(value, nameof(value)); + Ensure.ArgumentNotNullOrEmptyString(key, nameof(key)); using (ConfigurationHandle h = RetrieveConfigurationHandle(level, true, configHandle)) { @@ -713,7 +713,7 @@ public virtual IEnumerable> Find(string regexp) /// Matching entries. public virtual IEnumerable> Find(string regexp, ConfigurationLevel level) { - Ensure.ArgumentNotNullOrEmptyString(regexp, "regexp"); + Ensure.ArgumentNotNullOrEmptyString(regexp, nameof(regexp)); using (ConfigurationHandle snapshot = Snapshot()) using (ConfigurationHandle h = RetrieveConfigurationHandle(level, true, snapshot)) diff --git a/LibGit2Sharp/Core/FileHistory.cs b/LibGit2Sharp/Core/FileHistory.cs index 5775d0ab8..605743c17 100644 --- a/LibGit2Sharp/Core/FileHistory.cs +++ b/LibGit2Sharp/Core/FileHistory.cs @@ -66,9 +66,9 @@ internal FileHistory(Repository repo, string path) /// When an unsupported commit sort strategy is specified. internal FileHistory(Repository repo, string path, CommitFilter queryFilter) { - Ensure.ArgumentNotNull(repo, "repo"); - Ensure.ArgumentNotNull(path, "path"); - Ensure.ArgumentNotNull(queryFilter, "queryFilter"); + Ensure.ArgumentNotNull(repo, nameof(repo)); + Ensure.ArgumentNotNull(path, nameof(path)); + Ensure.ArgumentNotNull(queryFilter, nameof(queryFilter)); // Ensure the commit sort strategy makes sense. if (!AllowedSortStrategies.Contains(queryFilter.SortBy)) diff --git a/LibGit2Sharp/Core/ObjectSafeWrapper.cs b/LibGit2Sharp/Core/ObjectSafeWrapper.cs index f2ab4a9e1..a56b40fc7 100644 --- a/LibGit2Sharp/Core/ObjectSafeWrapper.cs +++ b/LibGit2Sharp/Core/ObjectSafeWrapper.cs @@ -9,7 +9,7 @@ internal class ObjectSafeWrapper : IDisposable public unsafe ObjectSafeWrapper(ObjectId id, RepositoryHandle handle, bool allowNullObjectId = false, bool throwIfMissing = false) { - Ensure.ArgumentNotNull(handle, "handle"); + Ensure.ArgumentNotNull(handle, nameof(handle)); if (allowNullObjectId && id == null) { @@ -17,7 +17,7 @@ public unsafe ObjectSafeWrapper(ObjectId id, RepositoryHandle handle, bool allow } else { - Ensure.ArgumentNotNull(id, "id"); + Ensure.ArgumentNotNull(id, nameof(id)); objectPtr = Proxy.git_object_lookup(handle, id, GitObjectType.Any); } diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs index 83d35e22c..0f60b3321 100644 --- a/LibGit2Sharp/Core/Proxy.cs +++ b/LibGit2Sharp/Core/Proxy.cs @@ -683,7 +683,7 @@ public static unsafe string git_describe_commit( ObjectId committishId, DescribeOptions options) { - Ensure.ArgumentPositiveInt32(options.MinimumCommitIdAbbreviatedSize, "options.MinimumCommitIdAbbreviatedSize"); + Ensure.ArgumentPositiveInt32(options.MinimumCommitIdAbbreviatedSize, nameof(options.MinimumCommitIdAbbreviatedSize)); using (var osw = new ObjectSafeWrapper(committishId, repo)) { @@ -1808,8 +1808,8 @@ public static unsafe GitRebaseCommitResult git_rebase_commit( Identity author, Identity committer) { - Ensure.ArgumentNotNull(rebase, "rebase"); - Ensure.ArgumentNotNull(committer, "committer"); + Ensure.ArgumentNotNull(rebase, nameof(rebase)); + Ensure.ArgumentNotNull(committer, nameof(committer)); using (SignatureHandle committerHandle = committer.BuildNowSignatureHandle()) using (SignatureHandle authorHandle = author.SafeBuildNowSignatureHandle()) @@ -1852,7 +1852,7 @@ public struct GitRebaseCommitResult public static unsafe void git_rebase_abort( RebaseHandle rebase) { - Ensure.ArgumentNotNull(rebase, "rebase"); + Ensure.ArgumentNotNull(rebase, nameof(rebase)); int result = NativeMethods.git_rebase_abort(rebase); Ensure.ZeroResult(result); @@ -1862,8 +1862,8 @@ public static unsafe void git_rebase_finish( RebaseHandle rebase, Identity committer) { - Ensure.ArgumentNotNull(rebase, "rebase"); - Ensure.ArgumentNotNull(committer, "committer"); + Ensure.ArgumentNotNull(rebase, nameof(rebase)); + Ensure.ArgumentNotNull(committer, nameof(committer)); using (var signatureHandle = committer.BuildNowSignatureHandle()) { diff --git a/LibGit2Sharp/Filter.cs b/LibGit2Sharp/Filter.cs index 0ab999f19..696d0d68d 100644 --- a/LibGit2Sharp/Filter.cs +++ b/LibGit2Sharp/Filter.cs @@ -30,8 +30,8 @@ public abstract class Filter : IEquatable /// protected Filter(string name, IEnumerable attributes) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNull(attributes, "attributes"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(attributes, nameof(attributes)); this.name = name; this.attributes = attributes; @@ -249,8 +249,8 @@ int StreamCreateCallback(out IntPtr git_writestream_out, GitFilter self, IntPtr try { - Ensure.ArgumentNotZeroIntPtr(filterSourcePtr, "filterSourcePtr"); - Ensure.ArgumentNotZeroIntPtr(git_writestream_next, "git_writestream_next"); + Ensure.ArgumentNotZeroIntPtr(filterSourcePtr, nameof(filterSourcePtr)); + Ensure.ArgumentNotZeroIntPtr(git_writestream_next, nameof(git_writestream_next)); state.thisStream = new GitWriteStream(); state.thisStream.close = StreamCloseCallback; @@ -302,14 +302,14 @@ int StreamCloseCallback(IntPtr stream) try { - Ensure.ArgumentNotZeroIntPtr(stream, "stream"); + Ensure.ArgumentNotZeroIntPtr(stream, nameof(stream)); if (!activeStreams.TryGetValue(stream, out state)) { throw new ArgumentException("Unknown stream pointer", nameof(stream)); } - Ensure.ArgumentIsExpectedIntPtr(stream, state.thisPtr, "stream"); + Ensure.ArgumentIsExpectedIntPtr(stream, state.thisPtr, nameof(stream)); using (BufferedStream outputBuffer = new BufferedStream(state.output, BufferSize)) { @@ -335,14 +335,14 @@ void StreamFreeCallback(IntPtr stream) try { - Ensure.ArgumentNotZeroIntPtr(stream, "stream"); + Ensure.ArgumentNotZeroIntPtr(stream, nameof(stream)); if (!activeStreams.TryRemove(stream, out state)) { throw new ArgumentException("Double free or invalid stream pointer", nameof(stream)); } - Ensure.ArgumentIsExpectedIntPtr(stream, state.thisPtr, "stream"); + Ensure.ArgumentIsExpectedIntPtr(stream, state.thisPtr, nameof(stream)); Marshal.FreeHGlobal(state.thisPtr); } @@ -360,15 +360,15 @@ unsafe int StreamWriteCallback(IntPtr stream, IntPtr buffer, UIntPtr len) try { - Ensure.ArgumentNotZeroIntPtr(stream, "stream"); - Ensure.ArgumentNotZeroIntPtr(buffer, "buffer"); + Ensure.ArgumentNotZeroIntPtr(stream, nameof(stream)); + Ensure.ArgumentNotZeroIntPtr(buffer, nameof(buffer)); if (!activeStreams.TryGetValue(stream, out state)) { throw new ArgumentException("Invalid or already freed stream pointer", nameof(stream)); } - Ensure.ArgumentIsExpectedIntPtr(stream, state.thisPtr, "stream"); + Ensure.ArgumentIsExpectedIntPtr(stream, state.thisPtr, nameof(stream)); using (UnmanagedMemoryStream input = new UnmanagedMemoryStream((byte*)buffer.ToPointer(), (long)len)) using (BufferedStream outputBuffer = new BufferedStream(state.output, BufferSize)) diff --git a/LibGit2Sharp/FilterAttributeEntry.cs b/LibGit2Sharp/FilterAttributeEntry.cs index 117523d3e..7a099e71a 100644 --- a/LibGit2Sharp/FilterAttributeEntry.cs +++ b/LibGit2Sharp/FilterAttributeEntry.cs @@ -32,7 +32,7 @@ protected FilterAttributeEntry() { } /// public FilterAttributeEntry(string filterName) { - Ensure.ArgumentNotNullOrEmptyString(filterName, "filterName"); + Ensure.ArgumentNotNullOrEmptyString(filterName, nameof(filterName)); if (filterName.StartsWith("filter=", StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException("The filterName parameter should not begin with \"filter=\"", filterName); diff --git a/LibGit2Sharp/FilteringOptions.cs b/LibGit2Sharp/FilteringOptions.cs index 22988e62e..0b39b58c5 100644 --- a/LibGit2Sharp/FilteringOptions.cs +++ b/LibGit2Sharp/FilteringOptions.cs @@ -13,7 +13,7 @@ public sealed class FilteringOptions /// The path that a file would be checked out as public FilteringOptions(string hintPath) { - Ensure.ArgumentNotNull(hintPath, "hintPath"); + Ensure.ArgumentNotNull(hintPath, nameof(hintPath)); this.HintPath = hintPath; } diff --git a/LibGit2Sharp/GlobalSettings.cs b/LibGit2Sharp/GlobalSettings.cs index 9807155e7..7ad888b04 100644 --- a/LibGit2Sharp/GlobalSettings.cs +++ b/LibGit2Sharp/GlobalSettings.cs @@ -89,7 +89,7 @@ private static string GetExecutingAssemblyDirectory() public static SmartSubtransportRegistration RegisterSmartSubtransport(string scheme) where T : SmartSubtransport, new() { - Ensure.ArgumentNotNull(scheme, "scheme"); + Ensure.ArgumentNotNull(scheme, nameof(scheme)); var registration = new SmartSubtransportRegistration(scheme); @@ -117,7 +117,7 @@ public static SmartSubtransportRegistration RegisterSmartSubtransport(stri public static void UnregisterSmartSubtransport(SmartSubtransportRegistration registration) where T : SmartSubtransport, new() { - Ensure.ArgumentNotNull(registration, "registration"); + Ensure.ArgumentNotNull(registration, nameof(registration)); Proxy.git_transport_unregister(registration.Scheme); registration.Free(); @@ -134,7 +134,7 @@ public static LogConfiguration LogConfiguration { set { - Ensure.ArgumentNotNull(value, "value"); + Ensure.ArgumentNotNull(value, nameof(value)); logConfiguration = value; @@ -244,7 +244,7 @@ public static FilterRegistration RegisterFilter(Filter filter) /// A object used to manage the lifetime of the registration. public static FilterRegistration RegisterFilter(Filter filter, int priority) { - Ensure.ArgumentNotNull(filter, "filter"); + Ensure.ArgumentNotNull(filter, nameof(filter)); if (priority < FilterRegistration.FilterPriorityMin || priority > FilterRegistration.FilterPriorityMax) { throw new ArgumentOutOfRangeException(nameof(priority), @@ -280,7 +280,7 @@ public static FilterRegistration RegisterFilter(Filter filter, int priority) /// Registration object with an associated filter. public static void DeregisterFilter(FilterRegistration registration) { - Ensure.ArgumentNotNull(registration, "registration"); + Ensure.ArgumentNotNull(registration, nameof(registration)); lock (registeredFilters) { diff --git a/LibGit2Sharp/Identity.cs b/LibGit2Sharp/Identity.cs index faa4ec884..125131fe1 100644 --- a/LibGit2Sharp/Identity.cs +++ b/LibGit2Sharp/Identity.cs @@ -18,10 +18,10 @@ public sealed class Identity /// The email. public Identity(string name, string email) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNullOrEmptyString(email, "email"); - Ensure.ArgumentDoesNotContainZeroByte(name, "name"); - Ensure.ArgumentDoesNotContainZeroByte(email, "email"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(email, nameof(email)); + Ensure.ArgumentDoesNotContainZeroByte(name, nameof(name)); + Ensure.ArgumentDoesNotContainZeroByte(email, nameof(email)); _name = name; _email = email; diff --git a/LibGit2Sharp/Ignore.cs b/LibGit2Sharp/Ignore.cs index 63ec6b264..9be2f1187 100644 --- a/LibGit2Sharp/Ignore.cs +++ b/LibGit2Sharp/Ignore.cs @@ -31,7 +31,7 @@ internal Ignore(Repository repo) /// The content of a .gitignore file that will be applied. public virtual void AddTemporaryRules(IEnumerable rules) { - Ensure.ArgumentNotNull(rules, "rules"); + Ensure.ArgumentNotNull(rules, nameof(rules)); var allRules = rules.Aggregate(new StringBuilder(), (acc, x) => { @@ -61,7 +61,7 @@ public virtual void ResetAllTemporaryRules() /// true if the path should be ignored. public virtual bool IsPathIgnored(string relativePath) { - Ensure.ArgumentNotNullOrEmptyString(relativePath, "relativePath"); + Ensure.ArgumentNotNullOrEmptyString(relativePath, nameof(relativePath)); return Proxy.git_ignore_path_is_ignored(repo.Handle, relativePath); } diff --git a/LibGit2Sharp/Index.cs b/LibGit2Sharp/Index.cs index 321673606..ffb4642b4 100644 --- a/LibGit2Sharp/Index.cs +++ b/LibGit2Sharp/Index.cs @@ -78,7 +78,7 @@ public virtual unsafe IndexEntry this[string path] { get { - Ensure.ArgumentNotNullOrEmptyString(path, "path"); + Ensure.ArgumentNotNullOrEmptyString(path, nameof(path)); git_index_entry* entry = Proxy.git_index_get_bypath(handle, path, 0); return IndexEntry.BuildFromPtr(entry); @@ -167,7 +167,7 @@ private void RemoveFromIndex(string relativePath) /// The path of the entry to be removed. public virtual void Remove(string indexEntryPath) { - Ensure.ArgumentNotNull(indexEntryPath, "indexEntryPath"); + Ensure.ArgumentNotNull(indexEntryPath, nameof(indexEntryPath)); RemoveFromIndex(indexEntryPath); } @@ -181,7 +181,7 @@ public virtual void Remove(string indexEntryPath) /// The path, in the working directory, of the file to be added. public virtual void Add(string pathInTheWorkdir) { - Ensure.ArgumentNotNull(pathInTheWorkdir, "pathInTheWorkdir"); + Ensure.ArgumentNotNull(pathInTheWorkdir, nameof(pathInTheWorkdir)); Proxy.git_index_add_bypath(handle, pathInTheWorkdir); } @@ -198,9 +198,9 @@ public virtual void Add(string pathInTheWorkdir) /// or . public virtual void Add(Blob blob, string indexEntryPath, Mode indexEntryMode) { - Ensure.ArgumentConformsTo(indexEntryMode, m => m.HasAny(TreeEntryDefinition.BlobModes), "indexEntryMode"); - Ensure.ArgumentNotNull(blob, "blob"); - Ensure.ArgumentNotNull(indexEntryPath, "indexEntryPath"); + Ensure.ArgumentConformsTo(indexEntryMode, m => m.HasAny(TreeEntryDefinition.BlobModes), nameof(indexEntryMode)); + Ensure.ArgumentNotNull(blob, nameof(blob)); + Ensure.ArgumentNotNull(indexEntryPath, nameof(indexEntryPath)); AddEntryToTheIndex(indexEntryPath, blob.Id, indexEntryMode); } @@ -293,7 +293,7 @@ public virtual void Replace(Commit commit, IEnumerable paths) /// public virtual void Replace(Commit commit, IEnumerable paths, ExplicitPathsOptions explicitPathsOptions) { - Ensure.ArgumentNotNull(commit, "commit"); + Ensure.ArgumentNotNull(commit, nameof(commit)); using (var changes = repo.Diff.Compare(commit.Tree, DiffTargets.Index, paths, explicitPathsOptions, new CompareOptions { Similarity = SimilarityOptions.None })) { diff --git a/LibGit2Sharp/IndexReucEntryCollection.cs b/LibGit2Sharp/IndexReucEntryCollection.cs index 818bce70c..255d68566 100644 --- a/LibGit2Sharp/IndexReucEntryCollection.cs +++ b/LibGit2Sharp/IndexReucEntryCollection.cs @@ -33,7 +33,7 @@ public virtual unsafe IndexReucEntry this[string path] { get { - Ensure.ArgumentNotNullOrEmptyString(path, "path"); + Ensure.ArgumentNotNullOrEmptyString(path, nameof(path)); git_index_reuc_entry* entryHandle = Proxy.git_index_reuc_get_bypath(index.Handle, path); return IndexReucEntry.BuildFromPtr(entryHandle); diff --git a/LibGit2Sharp/LogConfiguration.cs b/LibGit2Sharp/LogConfiguration.cs index dd63bf308..5cf492a91 100644 --- a/LibGit2Sharp/LogConfiguration.cs +++ b/LibGit2Sharp/LogConfiguration.cs @@ -22,8 +22,8 @@ public sealed class LogConfiguration /// Handler to call when logging occurs public LogConfiguration(LogLevel level, LogHandler handler) { - Ensure.ArgumentConformsTo(level, (t) => { return (level != LogLevel.None); }, "level"); - Ensure.ArgumentNotNull(handler, "handler"); + Ensure.ArgumentConformsTo(level, (t) => { return (level != LogLevel.None); }, nameof(level)); + Ensure.ArgumentNotNull(handler, nameof(handler)); Level = level; Handler = handler; diff --git a/LibGit2Sharp/Network.cs b/LibGit2Sharp/Network.cs index ba0a33144..cbc728ac7 100644 --- a/LibGit2Sharp/Network.cs +++ b/LibGit2Sharp/Network.cs @@ -50,7 +50,7 @@ public virtual RemoteCollection Remotes /// The references in the repository. public virtual IEnumerable ListReferences(Remote remote) { - Ensure.ArgumentNotNull(remote, "remote"); + Ensure.ArgumentNotNull(remote, nameof(remote)); return ListReferencesInternal(remote.Url, null, new ProxyOptions()); } @@ -69,7 +69,7 @@ public virtual IEnumerable ListReferences(Remote remote) /// The references in the repository. public virtual IEnumerable ListReferences(Remote remote, ProxyOptions proxyOptions) { - Ensure.ArgumentNotNull(remote, "remote"); + Ensure.ArgumentNotNull(remote, nameof(remote)); return ListReferencesInternal(remote.Url, null, proxyOptions); } @@ -88,8 +88,8 @@ public virtual IEnumerable ListReferences(Remote remote, ProxyOptions /// The references in the repository. public virtual IEnumerable ListReferences(Remote remote, CredentialsHandler credentialsProvider) { - Ensure.ArgumentNotNull(remote, "remote"); - Ensure.ArgumentNotNull(credentialsProvider, "credentialsProvider"); + Ensure.ArgumentNotNull(remote, nameof(remote)); + Ensure.ArgumentNotNull(credentialsProvider, nameof(credentialsProvider)); return ListReferencesInternal(remote.Url, credentialsProvider, new ProxyOptions()); } @@ -109,8 +109,8 @@ public virtual IEnumerable ListReferences(Remote remote, CredentialsH /// The references in the repository. public virtual IEnumerable ListReferences(Remote remote, CredentialsHandler credentialsProvider, ProxyOptions proxyOptions) { - Ensure.ArgumentNotNull(remote, "remote"); - Ensure.ArgumentNotNull(credentialsProvider, "credentialsProvider"); + Ensure.ArgumentNotNull(remote, nameof(remote)); + Ensure.ArgumentNotNull(credentialsProvider, nameof(credentialsProvider)); return ListReferencesInternal(remote.Url, credentialsProvider, proxyOptions); } @@ -128,7 +128,7 @@ public virtual IEnumerable ListReferences(Remote remote, CredentialsH /// The references in the remote repository. public virtual IEnumerable ListReferences(string url) { - Ensure.ArgumentNotNull(url, "url"); + Ensure.ArgumentNotNull(url, nameof(url)); return ListReferencesInternal(url, null, new ProxyOptions()); } @@ -147,7 +147,7 @@ public virtual IEnumerable ListReferences(string url) /// The references in the remote repository. public virtual IEnumerable ListReferences(string url, ProxyOptions proxyOptions) { - Ensure.ArgumentNotNull(url, "url"); + Ensure.ArgumentNotNull(url, nameof(url)); return ListReferencesInternal(url, null, proxyOptions); } @@ -166,8 +166,8 @@ public virtual IEnumerable ListReferences(string url, ProxyOptions pr /// The references in the remote repository. public virtual IEnumerable ListReferences(string url, CredentialsHandler credentialsProvider) { - Ensure.ArgumentNotNull(url, "url"); - Ensure.ArgumentNotNull(credentialsProvider, "credentialsProvider"); + Ensure.ArgumentNotNull(url, nameof(url)); + Ensure.ArgumentNotNull(credentialsProvider, nameof(credentialsProvider)); return ListReferencesInternal(url, credentialsProvider, new ProxyOptions()); } @@ -187,8 +187,8 @@ public virtual IEnumerable ListReferences(string url, CredentialsHand /// The references in the remote repository. public virtual IEnumerable ListReferences(string url, CredentialsHandler credentialsProvider, ProxyOptions proxyOptions) { - Ensure.ArgumentNotNull(url, "url"); - Ensure.ArgumentNotNull(credentialsProvider, "credentialsProvider"); + Ensure.ArgumentNotNull(url, nameof(url)); + Ensure.ArgumentNotNull(credentialsProvider, nameof(credentialsProvider)); return ListReferencesInternal(url, credentialsProvider, new ProxyOptions()); } @@ -270,8 +270,8 @@ public virtual void Fetch( FetchOptions options, string logMessage) { - Ensure.ArgumentNotNull(url, "url"); - Ensure.ArgumentNotNull(refspecs, "refspecs"); + Ensure.ArgumentNotNull(url, nameof(url)); + Ensure.ArgumentNotNull(refspecs, nameof(refspecs)); Commands.Fetch(repository, url, refspecs, options, logMessage); } @@ -353,8 +353,8 @@ public virtual void Push( string objectish, string destinationSpec) { - Ensure.ArgumentNotNull(objectish, "objectish"); - Ensure.ArgumentNotNullOrEmptyString(destinationSpec, "destinationSpec"); + Ensure.ArgumentNotNull(objectish, nameof(objectish)); + Ensure.ArgumentNotNullOrEmptyString(destinationSpec, nameof(destinationSpec)); Push(remote, string.Format(CultureInfo.InvariantCulture, @@ -376,8 +376,8 @@ public virtual void Push( string destinationSpec, PushOptions pushOptions) { - Ensure.ArgumentNotNull(objectish, "objectish"); - Ensure.ArgumentNotNullOrEmptyString(destinationSpec, "destinationSpec"); + Ensure.ArgumentNotNull(objectish, nameof(objectish)); + Ensure.ArgumentNotNullOrEmptyString(destinationSpec, nameof(destinationSpec)); Push(remote, string.Format(CultureInfo.InvariantCulture, @@ -394,7 +394,7 @@ public virtual void Push( /// The pushRefSpec to push. public virtual void Push(Remote remote, string pushRefSpec) { - Ensure.ArgumentNotNullOrEmptyString(pushRefSpec, "pushRefSpec"); + Ensure.ArgumentNotNullOrEmptyString(pushRefSpec, nameof(pushRefSpec)); Push(remote, new[] { pushRefSpec }); } @@ -409,7 +409,7 @@ public virtual void Push( string pushRefSpec, PushOptions pushOptions) { - Ensure.ArgumentNotNullOrEmptyString(pushRefSpec, "pushRefSpec"); + Ensure.ArgumentNotNullOrEmptyString(pushRefSpec, nameof(pushRefSpec)); Push(remote, new[] { pushRefSpec }, pushOptions); } @@ -432,8 +432,8 @@ public virtual void Push(Remote remote, IEnumerable pushRefSpecs) /// controlling push behavior public virtual void Push(Remote remote, IEnumerable pushRefSpecs, PushOptions pushOptions) { - Ensure.ArgumentNotNull(remote, "remote"); - Ensure.ArgumentNotNull(pushRefSpecs, "pushRefSpecs"); + Ensure.ArgumentNotNull(remote, nameof(remote)); + Ensure.ArgumentNotNull(pushRefSpecs, nameof(pushRefSpecs)); // Return early if there is nothing to push. if (!pushRefSpecs.Any()) diff --git a/LibGit2Sharp/NoteCollection.cs b/LibGit2Sharp/NoteCollection.cs index 30084881d..32f4bfc39 100644 --- a/LibGit2Sharp/NoteCollection.cs +++ b/LibGit2Sharp/NoteCollection.cs @@ -85,7 +85,7 @@ public virtual IEnumerable this[ObjectId id] { get { - Ensure.ArgumentNotNull(id, "id"); + Ensure.ArgumentNotNull(id, nameof(id)); return NamespaceRefs .Select(ns => this[ns, id]) @@ -101,7 +101,7 @@ public virtual IEnumerable this[string @namespace] { get { - Ensure.ArgumentNotNull(@namespace, "@namespace"); + Ensure.ArgumentNotNull(@namespace, nameof(@namespace)); string canonicalNamespace = NormalizeToCanonicalName(@namespace); @@ -118,8 +118,8 @@ public virtual IEnumerable this[string @namespace] { get { - Ensure.ArgumentNotNull(id, "id"); - Ensure.ArgumentNotNull(@namespace, "@namespace"); + Ensure.ArgumentNotNull(id, nameof(id)); + Ensure.ArgumentNotNull(@namespace, nameof(@namespace)); string canonicalNamespace = NormalizeToCanonicalName(@namespace); @@ -141,7 +141,7 @@ private string RetrieveDefaultNamespace() internal static string NormalizeToCanonicalName(string name) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); if (name.LooksLikeNote()) { @@ -153,7 +153,7 @@ internal static string NormalizeToCanonicalName(string name) internal static string UnCanonicalizeName(string name) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); if (!name.LooksLikeNote()) { @@ -174,11 +174,11 @@ internal static string UnCanonicalizeName(string name) /// The note which was just saved. public virtual Note Add(ObjectId targetId, string message, Signature author, Signature committer, string @namespace) { - Ensure.ArgumentNotNull(targetId, "targetId"); - Ensure.ArgumentNotNullOrEmptyString(message, "message"); - Ensure.ArgumentNotNull(author, "author"); - Ensure.ArgumentNotNull(committer, "committer"); - Ensure.ArgumentNotNullOrEmptyString(@namespace, "@namespace"); + Ensure.ArgumentNotNull(targetId, nameof(targetId)); + Ensure.ArgumentNotNullOrEmptyString(message, nameof(message)); + Ensure.ArgumentNotNull(author, nameof(author)); + Ensure.ArgumentNotNull(committer, nameof(committer)); + Ensure.ArgumentNotNullOrEmptyString(@namespace, nameof(@namespace)); string canonicalNamespace = NormalizeToCanonicalName(@namespace); @@ -198,10 +198,10 @@ public virtual Note Add(ObjectId targetId, string message, Signature author, Sig /// The namespace on which the note will be removed. It can be either a canonical namespace or an abbreviated namespace ('refs/notes/myNamespace' or just 'myNamespace'). public virtual void Remove(ObjectId targetId, Signature author, Signature committer, string @namespace) { - Ensure.ArgumentNotNull(targetId, "targetId"); - Ensure.ArgumentNotNull(author, "author"); - Ensure.ArgumentNotNull(committer, "committer"); - Ensure.ArgumentNotNullOrEmptyString(@namespace, "@namespace"); + Ensure.ArgumentNotNull(targetId, nameof(targetId)); + Ensure.ArgumentNotNull(author, nameof(author)); + Ensure.ArgumentNotNull(committer, nameof(committer)); + Ensure.ArgumentNotNullOrEmptyString(@namespace, nameof(@namespace)); string canonicalNamespace = NormalizeToCanonicalName(@namespace); diff --git a/LibGit2Sharp/ObjectDatabase.cs b/LibGit2Sharp/ObjectDatabase.cs index 1bad9c907..6774d0391 100644 --- a/LibGit2Sharp/ObjectDatabase.cs +++ b/LibGit2Sharp/ObjectDatabase.cs @@ -66,7 +66,7 @@ IEnumerator IEnumerable.GetEnumerator() /// True if the object has been found; false otherwise. public virtual bool Contains(ObjectId objectId) { - Ensure.ArgumentNotNull(objectId, "objectId"); + Ensure.ArgumentNotNull(objectId, nameof(objectId)); return Proxy.git_odb_exists(handle, objectId); } @@ -80,7 +80,7 @@ public virtual bool Contains(ObjectId objectId) /// GitObjectMetadata object instance containg object header information public virtual GitObjectMetadata RetrieveObjectMetadata(ObjectId objectId) { - Ensure.ArgumentNotNull(objectId, "objectId"); + Ensure.ArgumentNotNull(objectId, nameof(objectId)); return Proxy.git_odb_read_header(handle, objectId); } @@ -94,7 +94,7 @@ public virtual GitObjectMetadata RetrieveObjectMetadata(ObjectId objectId) /// The created . public virtual Blob CreateBlob(string path) { - Ensure.ArgumentNotNullOrEmptyString(path, "path"); + Ensure.ArgumentNotNullOrEmptyString(path, nameof(path)); if (repo.Info.IsBare && !Path.IsPathRooted(path)) { @@ -121,8 +121,8 @@ public virtual Blob CreateBlob(string path) /// The priority at which libgit2 should consult this backend (higher values are consulted first) public virtual void AddBackend(OdbBackend backend, int priority) { - Ensure.ArgumentNotNull(backend, "backend"); - Ensure.ArgumentConformsTo(priority, s => s > 0, "priority"); + Ensure.ArgumentNotNull(backend, nameof(backend)); + Ensure.ArgumentConformsTo(priority, s => s > 0, nameof(priority)); Proxy.git_odb_add_backend(handle, backend.GitOdbBackendPointer, priority); } @@ -195,7 +195,7 @@ public virtual ObjectId Write(byte[] data) where T : GitObject /// The type of object to write public virtual ObjectId Write(Stream stream, long numberOfBytesToConsume) where T : GitObject { - Ensure.ArgumentNotNull(stream, "stream"); + Ensure.ArgumentNotNull(stream, nameof(stream)); if (!stream.CanRead) { @@ -264,7 +264,7 @@ public virtual Blob CreateBlob(Stream stream, string hintpath, long numberOfByte private unsafe Blob CreateBlob(Stream stream, string hintpath, long? numberOfBytesToConsume) { - Ensure.ArgumentNotNull(stream, "stream"); + Ensure.ArgumentNotNull(stream, nameof(stream)); // there's no need to buffer the file for filtering, so simply use a stream if (hintpath == null && numberOfBytesToConsume.HasValue) @@ -344,7 +344,7 @@ public virtual Blob CreateBlob(Stream stream, long numberOfBytesToConsume) /// The created . public virtual Tree CreateTree(TreeDefinition treeDefinition) { - Ensure.ArgumentNotNull(treeDefinition, "treeDefinition"); + Ensure.ArgumentNotNull(treeDefinition, nameof(treeDefinition)); return treeDefinition.Build(repo); } @@ -362,7 +362,7 @@ public virtual Tree CreateTree(TreeDefinition treeDefinition) /// The created . This can be used e.g. to create a . public virtual Tree CreateTree(Index index) { - Ensure.ArgumentNotNull(index, "index"); + Ensure.ArgumentNotNull(index, nameof(index)); var treeId = Proxy.git_index_write_tree(index.Handle); return this.repo.Lookup(treeId); @@ -412,12 +412,12 @@ public virtual Commit CreateCommit(Signature author, Signature committer, string /// The created . public virtual Commit CreateCommit(Signature author, Signature committer, string message, Tree tree, IEnumerable parents, bool prettifyMessage, char? commentChar) { - Ensure.ArgumentNotNull(message, "message"); - Ensure.ArgumentDoesNotContainZeroByte(message, "message"); - Ensure.ArgumentNotNull(author, "author"); - Ensure.ArgumentNotNull(committer, "committer"); - Ensure.ArgumentNotNull(tree, "tree"); - Ensure.ArgumentNotNull(parents, "parents"); + Ensure.ArgumentNotNull(message, nameof(message)); + Ensure.ArgumentDoesNotContainZeroByte(message, nameof(message)); + Ensure.ArgumentNotNull(author, nameof(author)); + Ensure.ArgumentNotNull(committer, nameof(committer)); + Ensure.ArgumentNotNull(tree, nameof(tree)); + Ensure.ArgumentNotNull(parents, nameof(parents)); if (prettifyMessage) { @@ -468,12 +468,12 @@ public virtual ObjectId CreateCommitWithSignature(string commitContent, string s /// The created . public virtual TagAnnotation CreateTagAnnotation(string name, GitObject target, Signature tagger, string message) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNull(message, "message"); - Ensure.ArgumentNotNull(target, "target"); - Ensure.ArgumentNotNull(tagger, "tagger"); - Ensure.ArgumentDoesNotContainZeroByte(name, "name"); - Ensure.ArgumentDoesNotContainZeroByte(message, "message"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(message, nameof(message)); + Ensure.ArgumentNotNull(target, nameof(target)); + Ensure.ArgumentNotNull(tagger, nameof(tagger)); + Ensure.ArgumentDoesNotContainZeroByte(name, nameof(name)); + Ensure.ArgumentDoesNotContainZeroByte(message, nameof(message)); string prettifiedMessage = Proxy.git_message_prettify(message, null); @@ -517,8 +517,8 @@ public virtual void Archive(Commit commit, string archivePath) /// The archiver to use. public virtual void Archive(Commit commit, ArchiverBase archiver) { - Ensure.ArgumentNotNull(commit, "commit"); - Ensure.ArgumentNotNull(archiver, "archiver"); + Ensure.ArgumentNotNull(commit, nameof(commit)); + Ensure.ArgumentNotNull(archiver, nameof(archiver)); archiver.OrchestrateArchiving(commit.Tree, commit.Id, commit.Committer.When); } @@ -530,8 +530,8 @@ public virtual void Archive(Commit commit, ArchiverBase archiver) /// The archiver to use. public virtual void Archive(Tree tree, ArchiverBase archiver) { - Ensure.ArgumentNotNull(tree, "tree"); - Ensure.ArgumentNotNull(archiver, "archiver"); + Ensure.ArgumentNotNull(tree, nameof(tree)); + Ensure.ArgumentNotNull(archiver, nameof(archiver)); archiver.OrchestrateArchiving(tree, null, DateTimeOffset.UtcNow); } @@ -545,8 +545,8 @@ public virtual void Archive(Tree tree, ArchiverBase archiver) /// A instance of . public virtual HistoryDivergence CalculateHistoryDivergence(Commit one, Commit another) { - Ensure.ArgumentNotNull(one, "one"); - Ensure.ArgumentNotNull(another, "another"); + Ensure.ArgumentNotNull(one, nameof(one)); + Ensure.ArgumentNotNull(another, nameof(another)); return new HistoryDivergence(repo, one, another); } @@ -561,8 +561,8 @@ public virtual HistoryDivergence CalculateHistoryDivergence(Commit one, Commit a /// A result containing a if the cherry-pick was successful and a list of s if it is not. public virtual MergeTreeResult CherryPickCommit(Commit cherryPickCommit, Commit cherryPickOnto, int mainline, MergeTreeOptions options) { - Ensure.ArgumentNotNull(cherryPickCommit, "cherryPickCommit"); - Ensure.ArgumentNotNull(cherryPickOnto, "cherryPickOnto"); + Ensure.ArgumentNotNull(cherryPickCommit, nameof(cherryPickCommit)); + Ensure.ArgumentNotNull(cherryPickOnto, nameof(cherryPickOnto)); var modifiedOptions = new MergeTreeOptions(); @@ -635,7 +635,7 @@ public virtual string ShortenObjectId(GitObject gitObject) /// A short string representation of the . public virtual string ShortenObjectId(GitObject gitObject, int minLength) { - Ensure.ArgumentNotNull(gitObject, "gitObject"); + Ensure.ArgumentNotNull(gitObject, nameof(gitObject)); if (minLength <= 0 || minLength > ObjectId.HexSize) { @@ -669,8 +669,8 @@ public virtual string ShortenObjectId(GitObject gitObject, int minLength) /// True if the merge does not result in a conflict, false otherwise. public virtual bool CanMergeWithoutConflict(Commit one, Commit another) { - Ensure.ArgumentNotNull(one, "one"); - Ensure.ArgumentNotNull(another, "another"); + Ensure.ArgumentNotNull(one, nameof(one)); + Ensure.ArgumentNotNull(another, nameof(another)); var opts = new MergeTreeOptions() { @@ -690,8 +690,8 @@ public virtual bool CanMergeWithoutConflict(Commit one, Commit another) /// The merge base or null if none found. public virtual Commit FindMergeBase(Commit first, Commit second) { - Ensure.ArgumentNotNull(first, "first"); - Ensure.ArgumentNotNull(second, "second"); + Ensure.ArgumentNotNull(first, nameof(first)); + Ensure.ArgumentNotNull(second, nameof(second)); return FindMergeBase(new[] { first, second }, MergeBaseFindingStrategy.Standard); } @@ -704,7 +704,7 @@ public virtual Commit FindMergeBase(Commit first, Commit second) /// The merge base or null if none found. public virtual Commit FindMergeBase(IEnumerable commits, MergeBaseFindingStrategy strategy) { - Ensure.ArgumentNotNull(commits, "commits"); + Ensure.ArgumentNotNull(commits, nameof(commits)); ObjectId id; List ids = new List(8); @@ -753,8 +753,8 @@ public virtual Commit FindMergeBase(IEnumerable commits, MergeBaseFindin /// The containing the merged trees and any conflicts public virtual MergeTreeResult MergeCommits(Commit ours, Commit theirs, MergeTreeOptions options) { - Ensure.ArgumentNotNull(ours, "ours"); - Ensure.ArgumentNotNull(theirs, "theirs"); + Ensure.ArgumentNotNull(ours, nameof(ours)); + Ensure.ArgumentNotNull(theirs, nameof(theirs)); var modifiedOptions = new MergeTreeOptions(); @@ -849,8 +849,8 @@ public virtual PackBuilderResults Pack(PackBuilderOptions options, Action public virtual TransientIndex MergeCommitsIntoIndex(Commit ours, Commit theirs, MergeTreeOptions options) { - Ensure.ArgumentNotNull(ours, "ours"); - Ensure.ArgumentNotNull(theirs, "theirs"); + Ensure.ArgumentNotNull(ours, nameof(ours)); + Ensure.ArgumentNotNull(theirs, nameof(theirs)); options = options ?? new MergeTreeOptions(); @@ -879,8 +879,8 @@ public virtual TransientIndex MergeCommitsIntoIndex(Commit ours, Commit theirs, /// The index must be disposed by the caller. public virtual TransientIndex CherryPickCommitIntoIndex(Commit cherryPickCommit, Commit cherryPickOnto, int mainline, MergeTreeOptions options) { - Ensure.ArgumentNotNull(cherryPickCommit, "cherryPickCommit"); - Ensure.ArgumentNotNull(cherryPickOnto, "cherryPickOnto"); + Ensure.ArgumentNotNull(cherryPickCommit, nameof(cherryPickCommit)); + Ensure.ArgumentNotNull(cherryPickOnto, nameof(cherryPickOnto)); options = options ?? new MergeTreeOptions(); @@ -992,8 +992,8 @@ private IndexHandle CherryPickCommit(Commit cherryPickCommit, Commit cherryPickO /// Packing results private PackBuilderResults InternalPack(PackBuilderOptions options, Action packDelegate) { - Ensure.ArgumentNotNull(options, "options"); - Ensure.ArgumentNotNull(packDelegate, "packDelegate"); + Ensure.ArgumentNotNull(options, nameof(options)); + Ensure.ArgumentNotNull(packDelegate, nameof(packDelegate)); PackBuilderResults results = new PackBuilderResults(); @@ -1025,8 +1025,8 @@ private PackBuilderResults InternalPack(PackBuilderOptions options, ActionA result containing a if the revert was successful and a list of s if it is not. public virtual MergeTreeResult RevertCommit(Commit revertCommit, Commit revertOnto, int mainline, MergeTreeOptions options) { - Ensure.ArgumentNotNull(revertCommit, "revertCommit"); - Ensure.ArgumentNotNull(revertOnto, "revertOnto"); + Ensure.ArgumentNotNull(revertCommit, nameof(revertCommit)); + Ensure.ArgumentNotNull(revertOnto, nameof(revertOnto)); options = options ?? new MergeTreeOptions(); diff --git a/LibGit2Sharp/ObjectId.cs b/LibGit2Sharp/ObjectId.cs index d87bbcb34..190ca4cf2 100644 --- a/LibGit2Sharp/ObjectId.cs +++ b/LibGit2Sharp/ObjectId.cs @@ -53,8 +53,8 @@ internal ObjectId(GitOid oid) public ObjectId(byte[] rawId) : this(new GitOid { Id = rawId }) { - Ensure.ArgumentNotNull(rawId, "rawId"); - Ensure.ArgumentConformsTo(rawId, b => b.Length == rawSize, "rawId"); + Ensure.ArgumentNotNull(rawId, nameof(rawId)); + Ensure.ArgumentConformsTo(rawId, b => b.Length == rawSize, nameof(rawId)); } internal static unsafe ObjectId BuildFromPtr(IntPtr ptr) @@ -313,7 +313,7 @@ private static bool LooksValid(string objectId, bool throwIfInvalid) return false; } - Ensure.ArgumentNotNullOrEmptyString(objectId, "objectId"); + Ensure.ArgumentNotNullOrEmptyString(objectId, nameof(objectId)); } if ((objectId.Length != HexSize)) @@ -344,7 +344,7 @@ private static bool LooksValid(string objectId, bool throwIfInvalid) /// false otherwise. public bool StartsWith(string shortSha) { - Ensure.ArgumentNotNullOrEmptyString(shortSha, "shortSha"); + Ensure.ArgumentNotNullOrEmptyString(shortSha, nameof(shortSha)); return Sha.StartsWith(shortSha, StringComparison.OrdinalIgnoreCase); } diff --git a/LibGit2Sharp/PackBuilder.cs b/LibGit2Sharp/PackBuilder.cs index 2ede4ab7b..19b07676c 100644 --- a/LibGit2Sharp/PackBuilder.cs +++ b/LibGit2Sharp/PackBuilder.cs @@ -17,7 +17,7 @@ public sealed class PackBuilder : IDisposable /// internal PackBuilder(Repository repository) { - Ensure.ArgumentNotNull(repository, "repository"); + Ensure.ArgumentNotNull(repository, nameof(repository)); packBuilderHandle = Proxy.git_packbuilder_new(repository.Handle); } @@ -30,7 +30,7 @@ internal PackBuilder(Repository repository) /// if the gitObject is null public void Add(T gitObject) where T : GitObject { - Ensure.ArgumentNotNull(gitObject, "gitObject"); + Ensure.ArgumentNotNull(gitObject, nameof(gitObject)); Add(gitObject.Id); } @@ -43,7 +43,7 @@ public void Add(T gitObject) where T : GitObject /// if the gitObject is null public void AddRecursively(T gitObject) where T : GitObject { - Ensure.ArgumentNotNull(gitObject, "gitObject"); + Ensure.ArgumentNotNull(gitObject, nameof(gitObject)); AddRecursively(gitObject.Id); } @@ -56,7 +56,7 @@ public void AddRecursively(T gitObject) where T : GitObject /// if the id is null public void Add(ObjectId id) { - Ensure.ArgumentNotNull(id, "id"); + Ensure.ArgumentNotNull(id, nameof(id)); Proxy.git_packbuilder_insert(packBuilderHandle, id, null); } @@ -69,7 +69,7 @@ public void Add(ObjectId id) /// if the id is null public void AddRecursively(ObjectId id) { - Ensure.ArgumentNotNull(id, "id"); + Ensure.ArgumentNotNull(id, nameof(id)); Proxy.git_packbuilder_insert_recur(packBuilderHandle, id, null); } @@ -164,7 +164,7 @@ public string PackDirectoryPath { set { - Ensure.ArgumentNotNullOrEmptyString(value, "packDirectory"); + Ensure.ArgumentNotNullOrEmptyString(value, nameof(value)); if (!Directory.Exists(value)) { diff --git a/LibGit2Sharp/Rebase.cs b/LibGit2Sharp/Rebase.cs index c573ffa65..ed55c31c1 100644 --- a/LibGit2Sharp/Rebase.cs +++ b/LibGit2Sharp/Rebase.cs @@ -80,7 +80,7 @@ unsafe AnnotatedCommitHandle AnnotatedCommitHandleFromRefHandle(ReferenceHandle /// true if completed successfully, false if conflicts encountered. public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, Identity committer, RebaseOptions options) { - Ensure.ArgumentNotNull(upstream, "upstream"); + Ensure.ArgumentNotNull(upstream, nameof(upstream)); options = options ?? new RebaseOptions(); @@ -135,7 +135,7 @@ public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, I /// The that specify the rebase behavior. public virtual unsafe RebaseResult Continue(Identity committer, RebaseOptions options) { - Ensure.ArgumentNotNull(committer, "committer"); + Ensure.ArgumentNotNull(committer, nameof(committer)); options = options ?? new RebaseOptions(); diff --git a/LibGit2Sharp/RebaseOperationImpl.cs b/LibGit2Sharp/RebaseOperationImpl.cs index c35564573..00e78d8d0 100644 --- a/LibGit2Sharp/RebaseOperationImpl.cs +++ b/LibGit2Sharp/RebaseOperationImpl.cs @@ -20,10 +20,10 @@ public static RebaseResult Run(RebaseHandle rebaseOperationHandle, Identity committer, RebaseOptions options) { - Ensure.ArgumentNotNull(rebaseOperationHandle, "rebaseOperationHandle"); - Ensure.ArgumentNotNull(repository, "repository"); - Ensure.ArgumentNotNull(committer, "committer"); - Ensure.ArgumentNotNull(options, "options"); + Ensure.ArgumentNotNull(rebaseOperationHandle, nameof(rebaseOperationHandle)); + Ensure.ArgumentNotNull(repository, nameof(repository)); + Ensure.ArgumentNotNull(committer, nameof(committer)); + Ensure.ArgumentNotNull(options, nameof(options)); RebaseResult rebaseResult = null; diff --git a/LibGit2Sharp/RefSpecCollection.cs b/LibGit2Sharp/RefSpecCollection.cs index a35710719..904a3131b 100644 --- a/LibGit2Sharp/RefSpecCollection.cs +++ b/LibGit2Sharp/RefSpecCollection.cs @@ -30,7 +30,7 @@ protected RefSpecCollection() internal RefSpecCollection(Remote remote, RemoteHandle handle) { - Ensure.ArgumentNotNull(handle, "handle"); + Ensure.ArgumentNotNull(handle, nameof(handle)); this.remote = remote; this.handle = handle; diff --git a/LibGit2Sharp/ReferenceCollection.cs b/LibGit2Sharp/ReferenceCollection.cs index 92bf85426..6504853bd 100644 --- a/LibGit2Sharp/ReferenceCollection.cs +++ b/LibGit2Sharp/ReferenceCollection.cs @@ -109,8 +109,8 @@ private static RefState TryResolveReference(out Reference reference, ReferenceCo /// A new . public virtual Reference Add(string name, string canonicalRefNameOrObjectish, string logMessage, bool allowOverwrite) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNullOrEmptyString(canonicalRefNameOrObjectish, "canonicalRefNameOrObjectish"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(canonicalRefNameOrObjectish, nameof(canonicalRefNameOrObjectish)); Reference reference; RefState refState = TryResolveReference(out reference, this, canonicalRefNameOrObjectish); @@ -188,8 +188,8 @@ public virtual DirectReference Add(string name, ObjectId targetId, string logMes /// A new . public virtual DirectReference Add(string name, ObjectId targetId, string logMessage, bool allowOverwrite) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNull(targetId, "targetId"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(targetId, nameof(targetId)); using (ReferenceHandle handle = Proxy.git_reference_create(repo.Handle, name, targetId, allowOverwrite, logMessage)) { @@ -242,8 +242,8 @@ public virtual SymbolicReference Add(string name, Reference targetRef, string lo /// A new . public virtual SymbolicReference Add(string name, Reference targetRef, string logMessage, bool allowOverwrite) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNull(targetRef, "targetRef"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(targetRef, nameof(targetRef)); using (ReferenceHandle handle = Proxy.git_reference_symbolic_create(repo.Handle, name, @@ -284,7 +284,7 @@ public virtual SymbolicReference Add(string name, Reference targetRef, bool allo /// The canonical name of the reference to delete. public virtual void Remove(string name) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Reference reference = this[name]; @@ -302,7 +302,7 @@ public virtual void Remove(string name) /// The reference to delete. public virtual void Remove(Reference reference) { - Ensure.ArgumentNotNull(reference, "reference"); + Ensure.ArgumentNotNull(reference, nameof(reference)); Proxy.git_reference_remove(repo.Handle, reference.CanonicalName); } @@ -329,8 +329,8 @@ public virtual Reference Rename(Reference reference, string newName, string logM /// A new . public virtual Reference Rename(Reference reference, string newName, string logMessage, bool allowOverwrite) { - Ensure.ArgumentNotNull(reference, "reference"); - Ensure.ArgumentNotNullOrEmptyString(newName, "newName"); + Ensure.ArgumentNotNull(reference, nameof(reference)); + Ensure.ArgumentNotNullOrEmptyString(newName, nameof(newName)); if (logMessage == null) { @@ -398,7 +398,7 @@ public virtual Reference Rename(string currentName, string newName, public virtual Reference Rename(string currentName, string newName, string logMessage, bool allowOverwrite) { - Ensure.ArgumentNotNullOrEmptyString(currentName, "currentName"); + Ensure.ArgumentNotNullOrEmptyString(currentName, nameof(currentName)); Reference reference = this[currentName]; @@ -436,7 +436,7 @@ public virtual Reference Rename(Reference reference, string newName, bool allowO internal T Resolve(string name) where T : Reference { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); using (ReferenceHandle referencePtr = RetrieveReferencePtr(name, false)) { @@ -455,8 +455,8 @@ internal T Resolve(string name) where T : Reference /// A new . public virtual Reference UpdateTarget(Reference directRef, ObjectId targetId, string logMessage) { - Ensure.ArgumentNotNull(directRef, "directRef"); - Ensure.ArgumentNotNull(targetId, "targetId"); + Ensure.ArgumentNotNull(directRef, nameof(directRef)); + Ensure.ArgumentNotNull(targetId, nameof(targetId)); if (directRef.CanonicalName == "HEAD") { @@ -484,8 +484,8 @@ private Reference UpdateDirectReferenceTarget(Reference directRef, ObjectId targ /// A new . public virtual Reference UpdateTarget(Reference directRef, string objectish, string logMessage) { - Ensure.ArgumentNotNull(directRef, "directRef"); - Ensure.ArgumentNotNull(objectish, "objectish"); + Ensure.ArgumentNotNull(directRef, nameof(directRef)); + Ensure.ArgumentNotNull(objectish, nameof(objectish)); GitObject target = repo.Lookup(objectish); @@ -514,8 +514,8 @@ public virtual Reference UpdateTarget(Reference directRef, string objectish) /// A new . public virtual Reference UpdateTarget(string name, string canonicalRefNameOrObjectish, string logMessage) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNullOrEmptyString(canonicalRefNameOrObjectish, "canonicalRefNameOrObjectish"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(canonicalRefNameOrObjectish, nameof(canonicalRefNameOrObjectish)); if (name == "HEAD") { @@ -581,8 +581,8 @@ public virtual Reference UpdateTarget(Reference directRef, ObjectId targetId) /// A new . public virtual Reference UpdateTarget(Reference symbolicRef, Reference targetRef, string logMessage) { - Ensure.ArgumentNotNull(symbolicRef, "symbolicRef"); - Ensure.ArgumentNotNull(targetRef, "targetRef"); + Ensure.ArgumentNotNull(symbolicRef, nameof(symbolicRef)); + Ensure.ArgumentNotNull(targetRef, nameof(targetRef)); if (symbolicRef.CanonicalName == "HEAD") { @@ -657,7 +657,7 @@ internal Reference UpdateHeadTarget(ObjectId target, string logMessage) internal Reference UpdateHeadTarget(Reference target, string logMessage) { - Ensure.ArgumentConformsTo(target, r => (r is DirectReference || r is SymbolicReference), "target"); + Ensure.ArgumentConformsTo(target, r => (r is DirectReference || r is SymbolicReference), nameof(target)); Add("HEAD", target, logMessage, true); @@ -685,7 +685,7 @@ internal ReferenceHandle RetrieveReferencePtr(string referenceName, bool shouldT /// A list of references, ready to be enumerated. public virtual IEnumerable FromGlob(string pattern) { - Ensure.ArgumentNotNullOrEmptyString(pattern, "pattern"); + Ensure.ArgumentNotNullOrEmptyString(pattern, nameof(pattern)); return Proxy.git_reference_foreach_glob(repo.Handle, pattern, LaxUtf8Marshaler.FromNative) .Select(n => this[n]); @@ -715,8 +715,8 @@ public virtual IEnumerable ReachableFrom( IEnumerable refSubset, IEnumerable targets) { - Ensure.ArgumentNotNull(refSubset, "refSubset"); - Ensure.ArgumentNotNull(targets, "targets"); + Ensure.ArgumentNotNull(refSubset, nameof(refSubset)); + Ensure.ArgumentNotNull(targets, nameof(targets)); var refs = new List(refSubset); if (refs.Count == 0) @@ -790,7 +790,7 @@ private string DebuggerDisplay /// a , enumerable of public virtual ReflogCollection Log(string canonicalName) { - Ensure.ArgumentNotNullOrEmptyString(canonicalName, "canonicalName"); + Ensure.ArgumentNotNullOrEmptyString(canonicalName, nameof(canonicalName)); return new ReflogCollection(repo, canonicalName); } @@ -802,7 +802,7 @@ public virtual ReflogCollection Log(string canonicalName) /// a , enumerable of public virtual ReflogCollection Log(Reference reference) { - Ensure.ArgumentNotNull(reference, "reference"); + Ensure.ArgumentNotNull(reference, nameof(reference)); return new ReflogCollection(repo, reference.CanonicalName); } @@ -814,7 +814,7 @@ public virtual ReflogCollection Log(Reference reference) /// The objects to rewrite. public virtual void RewriteHistory(RewriteHistoryOptions options, params Commit[] commitsToRewrite) { - Ensure.ArgumentNotNull(commitsToRewrite, "commitsToRewrite"); + Ensure.ArgumentNotNull(commitsToRewrite, nameof(commitsToRewrite)); RewriteHistory(options, commitsToRewrite.AsEnumerable()); } @@ -826,9 +826,9 @@ public virtual void RewriteHistory(RewriteHistoryOptions options, params Commit[ /// The objects to rewrite. public virtual void RewriteHistory(RewriteHistoryOptions options, IEnumerable commitsToRewrite) { - Ensure.ArgumentNotNull(commitsToRewrite, "commitsToRewrite"); - Ensure.ArgumentNotNull(options, "options"); - Ensure.ArgumentNotNullOrEmptyString(options.BackupRefsNamespace, "options.BackupRefsNamespace"); + Ensure.ArgumentNotNull(commitsToRewrite, nameof(commitsToRewrite)); + Ensure.ArgumentNotNull(options, nameof(options)); + Ensure.ArgumentNotNullOrEmptyString(options.BackupRefsNamespace, nameof(options.BackupRefsNamespace)); IList originalRefs = this.ToList(); if (originalRefs.Count == 0) diff --git a/LibGit2Sharp/ReferenceWrapper.cs b/LibGit2Sharp/ReferenceWrapper.cs index 7fb8497c6..3731dc2ec 100644 --- a/LibGit2Sharp/ReferenceWrapper.cs +++ b/LibGit2Sharp/ReferenceWrapper.cs @@ -40,9 +40,9 @@ protected ReferenceWrapper() /// A function to construct the reference's canonical name. protected internal ReferenceWrapper(Repository repo, Reference reference, Func canonicalNameSelector) { - Ensure.ArgumentNotNull(repo, "repo"); - Ensure.ArgumentNotNull(reference, "reference"); - Ensure.ArgumentNotNull(canonicalNameSelector, "canonicalNameSelector"); + Ensure.ArgumentNotNull(repo, nameof(repo)); + Ensure.ArgumentNotNull(reference, nameof(reference)); + Ensure.ArgumentNotNull(canonicalNameSelector, nameof(canonicalNameSelector)); this.repo = repo; canonicalName = canonicalNameSelector(reference); diff --git a/LibGit2Sharp/ReflogCollection.cs b/LibGit2Sharp/ReflogCollection.cs index 20b1a8b73..f6322393f 100644 --- a/LibGit2Sharp/ReflogCollection.cs +++ b/LibGit2Sharp/ReflogCollection.cs @@ -32,8 +32,8 @@ protected ReflogCollection() /// the canonical name of the to retrieve reflog entries on. internal ReflogCollection(Repository repo, string canonicalName) { - Ensure.ArgumentNotNullOrEmptyString(canonicalName, "canonicalName"); - Ensure.ArgumentNotNull(repo, "repo"); + Ensure.ArgumentNotNullOrEmptyString(canonicalName, nameof(canonicalName)); + Ensure.ArgumentNotNull(repo, nameof(repo)); if (!Reference.IsValidName(canonicalName)) { diff --git a/LibGit2Sharp/RemoteCollection.cs b/LibGit2Sharp/RemoteCollection.cs index 45e71c8b2..727380850 100644 --- a/LibGit2Sharp/RemoteCollection.cs +++ b/LibGit2Sharp/RemoteCollection.cs @@ -41,7 +41,7 @@ public virtual Remote this[string name] internal Remote RemoteForName(string name, bool shouldThrowIfNotFound = true) { - Ensure.ArgumentNotNull(name, "name"); + Ensure.ArgumentNotNull(name, nameof(name)); RemoteHandle handle = Proxy.git_remote_lookup(repository.Handle, name, shouldThrowIfNotFound); return handle == null ? null : new Remote(handle, this.repository); @@ -99,8 +99,8 @@ IEnumerator IEnumerable.GetEnumerator() /// A new . public virtual Remote Add(string name, string url) { - Ensure.ArgumentNotNull(name, "name"); - Ensure.ArgumentNotNull(url, "url"); + Ensure.ArgumentNotNull(name, nameof(name)); + Ensure.ArgumentNotNull(url, nameof(url)); RemoteHandle handle = Proxy.git_remote_create(repository.Handle, name, url); return new Remote(handle, this.repository); @@ -115,9 +115,9 @@ public virtual Remote Add(string name, string url) /// A new . public virtual Remote Add(string name, string url, string fetchRefSpec) { - Ensure.ArgumentNotNull(name, "name"); - Ensure.ArgumentNotNull(url, "url"); - Ensure.ArgumentNotNull(fetchRefSpec, "fetchRefSpec"); + Ensure.ArgumentNotNull(name, nameof(name)); + Ensure.ArgumentNotNull(url, nameof(url)); + Ensure.ArgumentNotNull(fetchRefSpec, nameof(fetchRefSpec)); RemoteHandle handle = Proxy.git_remote_create_with_fetchspec(repository.Handle, name, url, fetchRefSpec); return new Remote(handle, this.repository); @@ -130,7 +130,7 @@ public virtual Remote Add(string name, string url, string fetchRefSpec) /// A new . public virtual void Remove(string name) { - Ensure.ArgumentNotNull(name, "name"); + Ensure.ArgumentNotNull(name, nameof(name)); Proxy.git_remote_delete(repository.Handle, name); } @@ -155,8 +155,8 @@ public virtual Remote Rename(string name, string newName) /// A new . public virtual Remote Rename(string name, string newName, RemoteRenameFailureHandler callback) { - Ensure.ArgumentNotNull(name, "name"); - Ensure.ArgumentNotNull(newName, "newName"); + Ensure.ArgumentNotNull(name, nameof(name)); + Ensure.ArgumentNotNull(newName, nameof(newName)); Proxy.git_remote_rename(repository.Handle, name, newName, callback); return this[newName]; diff --git a/LibGit2Sharp/RemoteUpdater.cs b/LibGit2Sharp/RemoteUpdater.cs index 53fd33a4b..d902b3ec5 100644 --- a/LibGit2Sharp/RemoteUpdater.cs +++ b/LibGit2Sharp/RemoteUpdater.cs @@ -24,8 +24,8 @@ protected RemoteUpdater() internal RemoteUpdater(Repository repo, Remote remote) { - Ensure.ArgumentNotNull(repo, "repo"); - Ensure.ArgumentNotNull(remote, "remote"); + Ensure.ArgumentNotNull(repo, nameof(repo)); + Ensure.ArgumentNotNull(remote, nameof(remote)); this.repo = repo; this.remoteName = remote.Name; @@ -36,8 +36,8 @@ internal RemoteUpdater(Repository repo, Remote remote) internal RemoteUpdater(Repository repo, string remote) { - Ensure.ArgumentNotNull(repo, "repo"); - Ensure.ArgumentNotNull(remote, "remote"); + Ensure.ArgumentNotNull(repo, nameof(repo)); + Ensure.ArgumentNotNull(remote, nameof(remote)); this.repo = repo; this.remoteName = remote; @@ -193,7 +193,7 @@ IEnumerator IEnumerable.GetEnumerator() public void ReplaceAll(IEnumerable newValues) { - Ensure.ArgumentNotNull(newValues, "newValues"); + Ensure.ArgumentNotNull(newValues, nameof(newValues)); list.Value.Clear(); list.Value.AddRange(newValues); Save(); diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs index 9ac5e2424..6f1aaa150 100644 --- a/LibGit2Sharp/Repository.cs +++ b/LibGit2Sharp/Repository.cs @@ -146,12 +146,12 @@ private Repository(string path, RepositoryOptions options, RepositoryRequiredPar { if ((requiredParameter & RepositoryRequiredParameter.Path) == RepositoryRequiredParameter.Path) { - Ensure.ArgumentNotNullOrEmptyString(path, "path"); + Ensure.ArgumentNotNullOrEmptyString(path, nameof(path)); } if ((requiredParameter & RepositoryRequiredParameter.Options) == RepositoryRequiredParameter.Options) { - Ensure.ArgumentNotNull(options, "options"); + Ensure.ArgumentNotNull(options, nameof(options)); } try @@ -251,7 +251,7 @@ private Repository(string path, RepositoryOptions options, RepositoryRequiredPar /// True if a repository can be resolved through this path; false otherwise static public bool IsValid(string path) { - Ensure.ArgumentNotNull(path, "path"); + Ensure.ArgumentNotNull(path, nameof(path)); if (string.IsNullOrWhiteSpace(path)) { @@ -493,7 +493,7 @@ public static string Init(string path) /// The path to the created repository. public static string Init(string path, bool isBare) { - Ensure.ArgumentNotNullOrEmptyString(path, "path"); + Ensure.ArgumentNotNullOrEmptyString(path, nameof(path)); using (RepositoryHandle repo = Proxy.git_repository_init_ext(null, path, isBare)) { @@ -510,8 +510,8 @@ public static string Init(string path, bool isBare) /// The path to the created repository. public static string Init(string workingDirectoryPath, string gitDirectoryPath) { - Ensure.ArgumentNotNullOrEmptyString(workingDirectoryPath, "workingDirectoryPath"); - Ensure.ArgumentNotNullOrEmptyString(gitDirectoryPath, "gitDirectoryPath"); + Ensure.ArgumentNotNullOrEmptyString(workingDirectoryPath, nameof(workingDirectoryPath)); + Ensure.ArgumentNotNullOrEmptyString(gitDirectoryPath, nameof(gitDirectoryPath)); // When being passed a relative workdir path, libgit2 will evaluate it from the // path to the repository. We pass a fully rooted path in order for the LibGit2Sharp caller @@ -571,7 +571,7 @@ public GitObject Lookup(string objectish, ObjectType type) internal GitObject LookupInternal(ObjectId id, GitObjectType type, string knownPath) { - Ensure.ArgumentNotNull(id, "id"); + Ensure.ArgumentNotNull(id, nameof(id)); using (ObjectHandle obj = Proxy.git_object_lookup(handle, id, type)) { @@ -602,7 +602,7 @@ private static string PathFromRevparseSpec(string spec) internal GitObject Lookup(string objectish, GitObjectType type, LookUpOptions lookUpOptions) { - Ensure.ArgumentNotNullOrEmptyString(objectish, "objectish"); + Ensure.ArgumentNotNullOrEmptyString(objectish, nameof(objectish)); GitObject obj; using (ObjectHandle sh = Proxy.git_revparse_single(handle, objectish)) @@ -700,7 +700,7 @@ public static IEnumerable ListRemoteReferences(string url, Credential /// The references in the remote repository. public static IEnumerable ListRemoteReferences(string url, CredentialsHandler credentialsProvider, ProxyOptions proxyOptions) { - Ensure.ArgumentNotNull(url, "url"); + Ensure.ArgumentNotNull(url, nameof(url)); proxyOptions ??= new(); @@ -774,8 +774,8 @@ public static string Clone(string sourceUrl, string workdirPath) /// The path to the created repository. public static string Clone(string sourceUrl, string workdirPath, CloneOptions options) { - Ensure.ArgumentNotNull(sourceUrl, "sourceUrl"); - Ensure.ArgumentNotNull(workdirPath, "workdirPath"); + Ensure.ArgumentNotNull(sourceUrl, nameof(sourceUrl)); + Ensure.ArgumentNotNull(workdirPath, nameof(workdirPath)); options ??= new CloneOptions(); @@ -1001,8 +1001,8 @@ public void Reset(ResetMode resetMode, Commit commit) /// Collection of parameters controlling checkout behavior. public void Reset(ResetMode resetMode, Commit commit, CheckoutOptions opts) { - Ensure.ArgumentNotNull(commit, "commit"); - Ensure.ArgumentNotNull(opts, "opts"); + Ensure.ArgumentNotNull(commit, nameof(commit)); + Ensure.ArgumentNotNull(opts, nameof(opts)); using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(opts)) { @@ -1022,8 +1022,8 @@ public void Reset(ResetMode resetMode, Commit commit, CheckoutOptions opts) /// Collection of parameters controlling checkout behavior. public void CheckoutPaths(string committishOrBranchSpec, IEnumerable paths, CheckoutOptions checkoutOptions) { - Ensure.ArgumentNotNullOrEmptyString(committishOrBranchSpec, "committishOrBranchSpec"); - Ensure.ArgumentNotNull(paths, "paths"); + Ensure.ArgumentNotNullOrEmptyString(committishOrBranchSpec, nameof(committishOrBranchSpec)); + Ensure.ArgumentNotNull(paths, nameof(paths)); var listOfPaths = paths.ToList(); @@ -1193,8 +1193,8 @@ internal T RegisterForCleanup(T disposable) where T : IDisposable /// The of the merge. public MergeResult Merge(Commit commit, Signature merger, MergeOptions options) { - Ensure.ArgumentNotNull(commit, "commit"); - Ensure.ArgumentNotNull(merger, "merger"); + Ensure.ArgumentNotNull(commit, nameof(commit)); + Ensure.ArgumentNotNull(merger, nameof(merger)); options = options ?? new MergeOptions(); @@ -1213,8 +1213,8 @@ public MergeResult Merge(Commit commit, Signature merger, MergeOptions options) /// The of the merge. public MergeResult Merge(Branch branch, Signature merger, MergeOptions options) { - Ensure.ArgumentNotNull(branch, "branch"); - Ensure.ArgumentNotNull(merger, "merger"); + Ensure.ArgumentNotNull(branch, nameof(branch)); + Ensure.ArgumentNotNull(merger, nameof(merger)); options = options ?? new MergeOptions(); @@ -1234,8 +1234,8 @@ public MergeResult Merge(Branch branch, Signature merger, MergeOptions options) /// The of the merge. public MergeResult Merge(string committish, Signature merger, MergeOptions options) { - Ensure.ArgumentNotNull(committish, "committish"); - Ensure.ArgumentNotNull(merger, "merger"); + Ensure.ArgumentNotNull(committish, nameof(committish)); + Ensure.ArgumentNotNull(merger, nameof(merger)); options = options ?? new MergeOptions(); @@ -1255,7 +1255,7 @@ public MergeResult Merge(string committish, Signature merger, MergeOptions optio /// The of the merge. public MergeResult MergeFetchedRefs(Signature merger, MergeOptions options) { - Ensure.ArgumentNotNull(merger, "merger"); + Ensure.ArgumentNotNull(merger, nameof(merger)); options = options ?? new MergeOptions(); @@ -1304,8 +1304,8 @@ public MergeResult MergeFetchedRefs(Signature merger, MergeOptions options) /// The result of the revert. public RevertResult Revert(Commit commit, Signature reverter, RevertOptions options) { - Ensure.ArgumentNotNull(commit, "commit"); - Ensure.ArgumentNotNull(reverter, "reverter"); + Ensure.ArgumentNotNull(commit, nameof(commit)); + Ensure.ArgumentNotNull(reverter, nameof(reverter)); if (Info.IsHeadUnborn) { @@ -1393,8 +1393,8 @@ public RevertResult Revert(Commit commit, Signature reverter, RevertOptions opti /// The result of the cherry pick. public CherryPickResult CherryPick(Commit commit, Signature committer, CherryPickOptions options) { - Ensure.ArgumentNotNull(commit, "commit"); - Ensure.ArgumentNotNull(committer, "committer"); + Ensure.ArgumentNotNull(commit, nameof(commit)); + Ensure.ArgumentNotNull(committer, nameof(committer)); options = options ?? new CherryPickOptions(); @@ -1691,7 +1691,7 @@ internal FilePath[] ToFilePaths(IEnumerable paths) /// A representing the state of the parameter. public FileStatus RetrieveStatus(string filePath) { - Ensure.ArgumentNotNullOrEmptyString(filePath, "filePath"); + Ensure.ArgumentNotNullOrEmptyString(filePath, nameof(filePath)); string relativePath = this.BuildRelativePathFrom(filePath); @@ -1753,8 +1753,8 @@ internal void UpdatePhysicalIndex() /// A descriptive identifier for the commit based on the nearest annotated tag. public string Describe(Commit commit, DescribeOptions options) { - Ensure.ArgumentNotNull(commit, "commit"); - Ensure.ArgumentNotNull(options, "options"); + Ensure.ArgumentNotNull(commit, nameof(commit)); + Ensure.ArgumentNotNull(options, nameof(options)); return Proxy.git_describe_commit(handle, commit.Id, options); } diff --git a/LibGit2Sharp/RepositoryExtensions.cs b/LibGit2Sharp/RepositoryExtensions.cs index 5d0788c8a..76189d29f 100644 --- a/LibGit2Sharp/RepositoryExtensions.cs +++ b/LibGit2Sharp/RepositoryExtensions.cs @@ -171,7 +171,7 @@ public static void Reset(this IRepository repository, ResetMode resetMode) /// A revparse spec for the target commit object. public static void Reset(this IRepository repository, ResetMode resetMode, string committish) { - Ensure.ArgumentNotNullOrEmptyString(committish, "committish"); + Ensure.ArgumentNotNullOrEmptyString(committish, nameof(committish)); Commit commit = LookUpCommit(repository, committish); diff --git a/LibGit2Sharp/RepositoryStatus.cs b/LibGit2Sharp/RepositoryStatus.cs index cc1c6e7e0..8ed0661e6 100644 --- a/LibGit2Sharp/RepositoryStatus.cs +++ b/LibGit2Sharp/RepositoryStatus.cs @@ -196,7 +196,7 @@ public virtual StatusEntry this[string path] { get { - Ensure.ArgumentNotNullOrEmptyString(path, "path"); + Ensure.ArgumentNotNullOrEmptyString(path, nameof(path)); var entries = statusEntries.Where(e => string.Equals(e.FilePath, path, StringComparison.Ordinal)).ToList(); diff --git a/LibGit2Sharp/Signature.cs b/LibGit2Sharp/Signature.cs index 7ed7a4916..a5be68605 100644 --- a/LibGit2Sharp/Signature.cs +++ b/LibGit2Sharp/Signature.cs @@ -32,10 +32,10 @@ internal unsafe Signature(git_signature* sig) /// The when. public Signature(string name, string email, DateTimeOffset when) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNullOrEmptyString(email, "email"); - Ensure.ArgumentDoesNotContainZeroByte(name, "name"); - Ensure.ArgumentDoesNotContainZeroByte(email, "email"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(email, nameof(email)); + Ensure.ArgumentDoesNotContainZeroByte(name, nameof(name)); + Ensure.ArgumentDoesNotContainZeroByte(email, nameof(email)); this.name = name; this.email = email; @@ -49,7 +49,7 @@ public Signature(string name, string email, DateTimeOffset when) /// The when. public Signature(Identity identity, DateTimeOffset when) { - Ensure.ArgumentNotNull(identity, "identity"); + Ensure.ArgumentNotNull(identity, nameof(identity)); this.name = identity.Name; this.email = identity.Email; diff --git a/LibGit2Sharp/StashCollection.cs b/LibGit2Sharp/StashCollection.cs index 42162ada5..2b5b8e503 100644 --- a/LibGit2Sharp/StashCollection.cs +++ b/LibGit2Sharp/StashCollection.cs @@ -122,7 +122,7 @@ public virtual Stash Add(Signature stasher, string message) /// the newly created public virtual Stash Add(Signature stasher, string message, StashModifiers options) { - Ensure.ArgumentNotNull(stasher, "stasher"); + Ensure.ArgumentNotNull(stasher, nameof(stasher)); string prettifiedMessage = Proxy.git_message_prettify(string.IsNullOrEmpty(message) ? string.Empty : message, null); diff --git a/LibGit2Sharp/SubmoduleCollection.cs b/LibGit2Sharp/SubmoduleCollection.cs index 061196c7d..260372456 100644 --- a/LibGit2Sharp/SubmoduleCollection.cs +++ b/LibGit2Sharp/SubmoduleCollection.cs @@ -39,7 +39,7 @@ public virtual Submodule this[string name] { get { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); return Lookup(name, handle => new Submodule(repo, name, Proxy.git_submodule_path(handle), diff --git a/LibGit2Sharp/TagCollection.cs b/LibGit2Sharp/TagCollection.cs index 98bfd257d..8d74a0e0d 100644 --- a/LibGit2Sharp/TagCollection.cs +++ b/LibGit2Sharp/TagCollection.cs @@ -37,7 +37,7 @@ public virtual Tag this[string name] { get { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); var canonicalName = NormalizeToCanonicalName(name); var reference = repo.Refs.Resolve(canonicalName); return reference == null ? null : new Tag(repo, reference, canonicalName); @@ -91,7 +91,7 @@ public virtual Tag Add(string name, string objectish, Signature tagger, string m /// True to allow silent overwriting a potentially existing tag, false otherwise. public virtual Tag Add(string name, string objectish, Signature tagger, string message, bool allowOverwrite) { - Ensure.ArgumentNotNullOrEmptyString(objectish, "target"); + Ensure.ArgumentNotNullOrEmptyString(objectish, nameof(objectish)); GitObject objectToTag = repo.Lookup(objectish, GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound); @@ -116,7 +116,7 @@ public virtual Tag Add(string name, string objectish) /// True to allow silent overwriting a potentially existing tag, false otherwise. public virtual Tag Add(string name, string objectish, bool allowOverwrite) { - Ensure.ArgumentNotNullOrEmptyString(objectish, "objectish"); + Ensure.ArgumentNotNullOrEmptyString(objectish, nameof(objectish)); GitObject objectToTag = repo.Lookup(objectish, GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound); @@ -147,10 +147,10 @@ public virtual Tag Add(string name, GitObject target, Signature tagger, string m /// The added . public virtual Tag Add(string name, GitObject target, Signature tagger, string message, bool allowOverwrite) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNull(target, "target"); - Ensure.ArgumentNotNull(tagger, "tagger"); - Ensure.ArgumentNotNull(message, "message"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(target, nameof(target)); + Ensure.ArgumentNotNull(tagger, nameof(tagger)); + Ensure.ArgumentNotNull(message, nameof(message)); string prettifiedMessage = Proxy.git_message_prettify(message, null); @@ -179,8 +179,8 @@ public virtual Tag Add(string name, GitObject target) /// The added . public virtual Tag Add(string name, GitObject target, bool allowOverwrite) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNull(target, "target"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(target, nameof(target)); Proxy.git_tag_create_lightweight(repo.Handle, name, target, allowOverwrite); @@ -193,7 +193,7 @@ public virtual Tag Add(string name, GitObject target, bool allowOverwrite) /// The short or canonical name of the tag to delete. public virtual void Remove(string name) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Proxy.git_tag_delete(repo.Handle, UnCanonicalizeName(name)); } @@ -204,14 +204,14 @@ public virtual void Remove(string name) /// The tag to delete. public virtual void Remove(Tag tag) { - Ensure.ArgumentNotNull(tag, "tag"); + Ensure.ArgumentNotNull(tag, nameof(tag)); Remove(tag.CanonicalName); } private static string NormalizeToCanonicalName(string name) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); if (name.LooksLikeTag()) { @@ -223,7 +223,7 @@ private static string NormalizeToCanonicalName(string name) private static string UnCanonicalizeName(string name) { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); if (!name.LooksLikeTag()) { diff --git a/LibGit2Sharp/TreeDefinition.cs b/LibGit2Sharp/TreeDefinition.cs index 91389f6e3..7743d1c91 100644 --- a/LibGit2Sharp/TreeDefinition.cs +++ b/LibGit2Sharp/TreeDefinition.cs @@ -22,7 +22,7 @@ public class TreeDefinition /// A new holding the meta data of the . public static TreeDefinition From(Tree tree) { - Ensure.ArgumentNotNull(tree, "tree"); + Ensure.ArgumentNotNull(tree, nameof(tree)); var td = new TreeDefinition(); @@ -41,7 +41,7 @@ public static TreeDefinition From(Tree tree) /// A new holding the meta data of the 's . public static TreeDefinition From(Commit commit) { - Ensure.ArgumentNotNull(commit, "commit"); + Ensure.ArgumentNotNull(commit, nameof(commit)); return From(commit.Tree); } @@ -65,7 +65,7 @@ private void AddEntry(string targetTreeEntryName, TreeEntryDefinition treeEntryD /// The current . public virtual TreeDefinition Remove(IEnumerable treeEntryPaths) { - Ensure.ArgumentNotNull(treeEntryPaths, "treeEntryPaths"); + Ensure.ArgumentNotNull(treeEntryPaths, nameof(treeEntryPaths)); foreach (var treeEntryPath in treeEntryPaths) { @@ -82,7 +82,7 @@ public virtual TreeDefinition Remove(IEnumerable treeEntryPaths) /// The current . public virtual TreeDefinition Remove(string treeEntryPath) { - Ensure.ArgumentNotNullOrEmptyString(treeEntryPath, "treeEntryPath"); + Ensure.ArgumentNotNullOrEmptyString(treeEntryPath, nameof(treeEntryPath)); if (this[treeEntryPath] == null) { @@ -124,8 +124,8 @@ public virtual TreeDefinition Remove(string treeEntryPath) /// The current . public virtual TreeDefinition Add(string targetTreeEntryPath, TreeEntryDefinition treeEntryDefinition) { - Ensure.ArgumentNotNullOrEmptyString(targetTreeEntryPath, "targetTreeEntryPath"); - Ensure.ArgumentNotNull(treeEntryDefinition, "treeEntryDefinition"); + Ensure.ArgumentNotNullOrEmptyString(targetTreeEntryPath, nameof(targetTreeEntryPath)); + Ensure.ArgumentNotNull(treeEntryDefinition, nameof(treeEntryDefinition)); if (treeEntryDefinition is TransientTreeTreeEntryDefinition) { @@ -161,7 +161,7 @@ public virtual TreeDefinition Add(string targetTreeEntryPath, TreeEntryDefinitio /// The current . public virtual TreeDefinition Add(string targetTreeEntryPath, TreeEntry treeEntry) { - Ensure.ArgumentNotNull(treeEntry, "treeEntry"); + Ensure.ArgumentNotNull(treeEntry, nameof(treeEntry)); TreeEntryDefinition ted = TreeEntryDefinition.From(treeEntry); @@ -177,8 +177,8 @@ public virtual TreeDefinition Add(string targetTreeEntryPath, TreeEntry treeEntr /// The current . public virtual TreeDefinition Add(string targetTreeEntryPath, Blob blob, Mode mode) { - Ensure.ArgumentNotNull(blob, "blob"); - Ensure.ArgumentConformsTo(mode, m => m.HasAny(TreeEntryDefinition.BlobModes), "mode"); + Ensure.ArgumentNotNull(blob, nameof(blob)); + Ensure.ArgumentConformsTo(mode, m => m.HasAny(TreeEntryDefinition.BlobModes), nameof(mode)); TreeEntryDefinition ted = TreeEntryDefinition.From(blob, mode); @@ -195,7 +195,7 @@ public virtual TreeDefinition Add(string targetTreeEntryPath, Blob blob, Mode mo /// The current . public virtual TreeDefinition Add(string targetTreeEntryPath, string filePath, Mode mode) { - Ensure.ArgumentNotNullOrEmptyString(filePath, "filePath"); + Ensure.ArgumentNotNullOrEmptyString(filePath, nameof(filePath)); TreeEntryDefinition ted = TreeEntryDefinition.TransientBlobFrom(filePath, mode); @@ -211,8 +211,8 @@ public virtual TreeDefinition Add(string targetTreeEntryPath, string filePath, M /// The current . public virtual TreeDefinition Add(string targetTreeEntryPath, ObjectId id, Mode mode) { - Ensure.ArgumentNotNull(id, "id"); - Ensure.ArgumentConformsTo(mode, m => m.HasAny(TreeEntryDefinition.BlobModes), "mode"); + Ensure.ArgumentNotNull(id, nameof(id)); + Ensure.ArgumentConformsTo(mode, m => m.HasAny(TreeEntryDefinition.BlobModes), nameof(mode)); TreeEntryDefinition ted = TreeEntryDefinition.From(id, mode); @@ -227,7 +227,7 @@ public virtual TreeDefinition Add(string targetTreeEntryPath, ObjectId id, Mode /// The current . public virtual TreeDefinition Add(string targetTreeEntryPath, Tree tree) { - Ensure.ArgumentNotNull(tree, "tree"); + Ensure.ArgumentNotNull(tree, nameof(tree)); TreeEntryDefinition ted = TreeEntryDefinition.From(tree); @@ -241,7 +241,7 @@ public virtual TreeDefinition Add(string targetTreeEntryPath, Tree tree) /// The current . public virtual TreeDefinition Add(Submodule submodule) { - Ensure.ArgumentNotNull(submodule, "submodule"); + Ensure.ArgumentNotNull(submodule, nameof(submodule)); return AddGitLink(submodule.Path, submodule.HeadCommitId); } @@ -256,7 +256,7 @@ public virtual TreeDefinition Add(Submodule submodule) /// The current . public virtual TreeDefinition AddGitLink(string targetTreeEntryPath, ObjectId objectId) { - Ensure.ArgumentNotNull(objectId, "objectId"); + Ensure.ArgumentNotNull(objectId, nameof(objectId)); var ted = TreeEntryDefinition.From(objectId); @@ -379,7 +379,7 @@ public virtual TreeEntryDefinition this[string treeEntryPath] { get { - Ensure.ArgumentNotNullOrEmptyString(treeEntryPath, "treeEntryPath"); + Ensure.ArgumentNotNullOrEmptyString(treeEntryPath, nameof(treeEntryPath)); Tuple segments = ExtractPosixLeadingSegment(treeEntryPath); diff --git a/LibGit2Sharp/TreeEntryDefinition.cs b/LibGit2Sharp/TreeEntryDefinition.cs index d32cc722c..379336245 100644 --- a/LibGit2Sharp/TreeEntryDefinition.cs +++ b/LibGit2Sharp/TreeEntryDefinition.cs @@ -54,7 +54,7 @@ internal static TreeEntryDefinition From(TreeEntry treeEntry) internal static TreeEntryDefinition From(Blob blob, Mode mode) { - Ensure.ArgumentNotNull(blob, "blob"); + Ensure.ArgumentNotNull(blob, nameof(blob)); return new TreeEntryDefinition { @@ -67,8 +67,8 @@ internal static TreeEntryDefinition From(Blob blob, Mode mode) internal static TreeEntryDefinition From(ObjectId id, Mode mode) { - Ensure.ArgumentNotNull(id, "id"); - Ensure.ArgumentNotNull(mode, "mode"); + Ensure.ArgumentNotNull(id, nameof(id)); + Ensure.ArgumentNotNull(mode, nameof(mode)); return new TreeEntryDefinition { @@ -80,7 +80,7 @@ internal static TreeEntryDefinition From(ObjectId id, Mode mode) internal static TreeEntryDefinition TransientBlobFrom(string filePath, Mode mode) { - Ensure.ArgumentConformsTo(mode, m => m.HasAny(BlobModes), "mode"); + Ensure.ArgumentConformsTo(mode, m => m.HasAny(BlobModes), nameof(mode)); return new TransientBlobTreeEntryDefinition { diff --git a/LibGit2Sharp/WorktreeCollection.cs b/LibGit2Sharp/WorktreeCollection.cs index d99e11d7a..50a6b8ba3 100644 --- a/LibGit2Sharp/WorktreeCollection.cs +++ b/LibGit2Sharp/WorktreeCollection.cs @@ -37,7 +37,7 @@ public virtual Worktree this[string name] { get { - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); return Lookup(name, handle => new Worktree(repo, name, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy