/// <summary> /// <para> /// Returns the next version number when a specified change is /// made to a given line of compatibility with the specified /// metadata. /// </para> /// </summary> /// <param name="line"> /// The line of compatibility to which the change is being /// made. /// </param> /// <param name="change"> /// The type of change being made to <paramref name="line"/>. /// </param> /// <param name="metadata"> /// The metadata to be included with the new version. /// </param> /// <returns> /// <para> /// The next version number produced when the specified change /// is made to the specified line of compatibility. /// </para> /// <para> /// If <paramref name="change"/> is equal to /// <see cref="MonotonicChange.Compatible"/>, the release number /// is incremented but the compatibility number remains the same. /// </para> /// <para> /// If <paramref name="change"/> is equal to /// <see cref="MonotonicChange.Breaking"/>, both the release and /// compatibility numbers are incremented. /// </para> /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <para> /// <paramref name="line"/> is negative. /// </para> /// <para> /// <paramref name="change"/> is not a recognised type of change. /// </para> /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="metadata"/> or an item therein is null. /// </exception> /// <exception cref="ArgumentException"> /// <para> /// One or more items within <paramref name="metadata"/> is not a /// valid metadata string. /// </para> /// <para> /// <paramref name="line"/> is not a current line of compatibility. /// </para> /// </exception> public SemanticVersion Next( int line, MonotonicChange change, IEnumerable<string> metadata ) { if (line < 0) { throw new ArgumentOutOfRangeException( message: "The specified line of compatibility cannot " + "be negative.", paramName: nameof(line) ); } if (!Enum.IsDefined(typeof(MonotonicChange), change)) { throw new ArgumentOutOfRangeException( message: "The specified change was unrecognised " + "or invalid.", paramName: nameof(change) ); } _verifyMetadataColl(metadata); if (!_latestVers.Keys.Contains(line)) { throw new ArgumentException( message: "The specified line of compatibility is not " + "recognised for this versioner.", paramName: nameof(line) ); } // If it's a breaking change, we are free to ignore the change // because a breaking change will produce a new line of compatibility. if (change == MonotonicChange.Breaking) { return _add(new SemanticVersion( major: _latestVers.Keys.Max() + 1, minor: _latest.Minor + 1, patch: 0, identifiers: Enumerable.Empty<string>(), metadata: metadata )); } // Otherwise, we use the line of compatibility specified. else if (change == MonotonicChange.Compatible) { return _add(new SemanticVersion( major: line, minor: _latest.Minor + 1, patch: 0, identifiers: Enumerable.Empty<string>(), metadata: metadata )); } throw new Exception("Invalid [MonotonicVersioner.Next] state."); }
/// <summary> /// <para> /// Returns the next version number when a specified change is /// made to a given line of compatibility. /// </para> /// </summary> /// <param name="line"> /// The line of compatibility to which the change is being /// made. /// </param> /// <param name="change"> /// The type of change being made to <paramref name="line"/>. /// </param> /// <returns> /// <para> /// The next version number produced when the specified change /// is made to the specified line of compatibility. /// </para> /// <para> /// If <paramref name="change"/> is equal to /// <see cref="MonotonicChange.Compatible"/>, the release number /// is incremented but the compatibility number remains the same. /// </para> /// <para> /// If <paramref name="change"/> is equal to /// <see cref="MonotonicChange.Breaking"/>, both the release and /// compatibility numbers are incremented. /// </para> /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <para> /// <paramref name="line"/> is negative. /// </para> /// <para> /// <paramref name="change"/> is not a recognised type of change. /// </para> /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="line"/> is not a current line of compatibility. /// </exception> public SemanticVersion Next(int line, MonotonicChange change) { return this.Next(line, change, Enumerable.Empty<string>()); }
/// <summary> /// <para> /// Returns the next version number when a specified change is /// made to the latest version. /// </para> /// </summary> /// <param name="change"> /// The type of change being made to the latest version. /// </param> /// <param name="metadata"> /// The metadata to be included with the new version. /// </param> /// <returns> /// <para> /// The next version number produced when the specified change /// is made to the latest version, with the specified metadata. /// </para> /// <para> /// If <paramref name="change"/> is equal to /// <see cref="MonotonicChange.Compatible"/>, the release number /// is incremented but the compatibility number remains the same. /// </para> /// <para> /// If <paramref name="change"/> is equal to /// <see cref="MonotonicChange.Breaking"/>, both the release and /// compatibility numbers are incremented. /// </para> /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <para> /// <paramref name="change"/> is not a recognised type of change. /// </para> /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="metadata"/> or an item therein is null. /// </exception> /// <exception cref="ArgumentException"> /// One or more items within <paramref name="metadata"/> is not a /// valid metadata string. /// </exception> public SemanticVersion Next( MonotonicChange change, IEnumerable<string> metadata ) { return this.Next(this.Latest.Major, change, metadata); }
/// <summary> /// <para> /// Returns the next version number when a specified change is /// made to a given line of compatibility with the specified /// metadata. /// </para> /// </summary> /// <param name="line"> /// The line of compatibility to which the change is being /// made. /// </param> /// <param name="change"> /// The type of change being made to <paramref name="line"/>. /// </param> /// <param name="metadata"> /// The metadata to be included with the new version. /// </param> /// <returns> /// <para> /// The next version number produced when the specified change /// is made to the specified line of compatibility. /// </para> /// <para> /// If <paramref name="change"/> is equal to /// <see cref="MonotonicChange.Compatible"/>, the release number /// is incremented but the compatibility number remains the same. /// </para> /// <para> /// If <paramref name="change"/> is equal to /// <see cref="MonotonicChange.Breaking"/>, both the release and /// compatibility numbers are incremented. /// </para> /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <para> /// <paramref name="line"/> is negative. /// </para> /// <para> /// <paramref name="change"/> is not a recognised type of change. /// </para> /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="metadata"/> or an item therein is null. /// </exception> /// <exception cref="ArgumentException"> /// <para> /// One or more items within <paramref name="metadata"/> is not a /// valid metadata string. /// </para> /// <para> /// <paramref name="line"/> is not a current line of compatibility. /// </para> /// </exception> public SemanticVersion Next( int line, MonotonicChange change, IEnumerable <string> metadata ) { if (line < 0) { throw new ArgumentOutOfRangeException( message: "The specified line of compatibility cannot " + "be negative.", paramName: nameof(line) ); } if (!Enum.IsDefined(typeof(MonotonicChange), change)) { throw new ArgumentOutOfRangeException( message: "The specified change was unrecognised " + "or invalid.", paramName: nameof(change) ); } _verifyMetadataColl(metadata); if (!_latestVers.Keys.Contains(line)) { throw new ArgumentException( message: "The specified line of compatibility is not " + "recognised for this versioner.", paramName: nameof(line) ); } // If it's a breaking change, we are free to ignore the change // because a breaking change will produce a new line of compatibility. if (change == MonotonicChange.Breaking) { return(_add(new SemanticVersion( major: _latestVers.Keys.Max() + 1, minor: _latest.Minor + 1, patch: 0, identifiers: Enumerable.Empty <string>(), metadata: metadata ))); } // Otherwise, we use the line of compatibility specified. else if (change == MonotonicChange.Compatible) { return(_add(new SemanticVersion( major: line, minor: _latest.Minor + 1, patch: 0, identifiers: Enumerable.Empty <string>(), metadata: metadata ))); } throw new Exception("Invalid [MonotonicVersioner.Next] state."); }
/// <summary> /// <para> /// Returns the next version number when a specified change is /// made to a given line of compatibility. /// </para> /// </summary> /// <param name="line"> /// The line of compatibility to which the change is being /// made. /// </param> /// <param name="change"> /// The type of change being made to <paramref name="line"/>. /// </param> /// <returns> /// <para> /// The next version number produced when the specified change /// is made to the specified line of compatibility. /// </para> /// <para> /// If <paramref name="change"/> is equal to /// <see cref="MonotonicChange.Compatible"/>, the release number /// is incremented but the compatibility number remains the same. /// </para> /// <para> /// If <paramref name="change"/> is equal to /// <see cref="MonotonicChange.Breaking"/>, both the release and /// compatibility numbers are incremented. /// </para> /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <para> /// <paramref name="line"/> is negative. /// </para> /// <para> /// <paramref name="change"/> is not a recognised type of change. /// </para> /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="line"/> is not a current line of compatibility. /// </exception> public SemanticVersion Next(int line, MonotonicChange change) { return(this.Next(line, change, Enumerable.Empty <string>())); }
/// <summary> /// <para> /// Returns the next version number when a specified change is /// made to the latest version. /// </para> /// </summary> /// <param name="change"> /// The type of change being made to the latest version. /// </param> /// <param name="metadata"> /// The metadata to be included with the new version. /// </param> /// <returns> /// <para> /// The next version number produced when the specified change /// is made to the latest version, with the specified metadata. /// </para> /// <para> /// If <paramref name="change"/> is equal to /// <see cref="MonotonicChange.Compatible"/>, the release number /// is incremented but the compatibility number remains the same. /// </para> /// <para> /// If <paramref name="change"/> is equal to /// <see cref="MonotonicChange.Breaking"/>, both the release and /// compatibility numbers are incremented. /// </para> /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <para> /// <paramref name="change"/> is not a recognised type of change. /// </para> /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="metadata"/> or an item therein is null. /// </exception> /// <exception cref="ArgumentException"> /// One or more items within <paramref name="metadata"/> is not a /// valid metadata string. /// </exception> public SemanticVersion Next( MonotonicChange change, IEnumerable <string> metadata ) { return(this.Next(this.Latest.Major, change, metadata)); }