// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Linq;
///
/// Represent release notes.
///
///
/// Original from Cake build tool source:
/// https://github.com/cake-build/cake/blob/9828d7b246d332054896e52ba56983822feb3f05/src/Cake.Common/ReleaseNotes.cs
///
public sealed class ReleaseNotes
{
private readonly List _notes;
///
/// Gets the version.
///
/// The version.
public SemVersion SemVersion { get; }
///
/// Gets the version.
///
/// The version.
public Version Version { get; }
///
/// Gets the release notes.
///
/// The release notes.
public IReadOnlyList Notes => _notes;
///
/// Gets the raw text of the line that was extracted from.
///
/// The raw text of the Version line.
public string RawVersionLine { get; }
///
/// Initializes a new instance of the class.
///
/// The semantic version.
/// The notes.
/// The raw text of the version line.
public ReleaseNotes(SemVersion semVersion, IEnumerable notes, string rawVersionLine)
: this(
semVersion?.AssemblyVersion ?? throw new ArgumentNullException(nameof(semVersion)),
semVersion,
notes,
rawVersionLine)
{
}
///
/// Initializes a new instance of the class.
///
/// The version.
/// The notes.
/// The raw text of the version line.
public ReleaseNotes(Version version, IEnumerable notes, string rawVersionLine)
: this(
version ?? throw new ArgumentNullException(nameof(version)),
new SemVersion(version.Major, version.Minor, version.Build),
notes,
rawVersionLine)
{
}
private ReleaseNotes(Version version, SemVersion semVersion, IEnumerable notes, string rawVersionLine)
{
Version = version ?? throw new ArgumentNullException(nameof(version));
SemVersion = semVersion ?? throw new ArgumentNullException(nameof(semVersion));
RawVersionLine = rawVersionLine;
_notes = new List(notes ?? Enumerable.Empty());
}
}