Class CopyrightNotice
A copyright notice with all its parsed information, when possible.
public class CopyrightNotice
- Inheritance
-
CopyrightNotice
- Inherited Members
Properties
ContactAddress
The contact address of the copyright holder (e.g. jane@example.com or
https://project.example.com), if present in between angle brackets in the original text. Stored without
the angle brackets.
public string? ContactAddress { get; }
Property Value
FullText
Full text of the copyright notice, as presented in the original document.
public string FullText { get; }
Property Value
HolderName
Name of the copyright holder.
public string HolderName { get; }
Property Value
Years
Years of publication, if present in the original text.
public IReadOnlyList<CopyrightNotice.YearItem> Years { get; }
Property Value
Methods
ContainsCopyrightNotice(string)
According to the REUSE Specification – Version 3.3, a copyright notice MUST start with "SPDX-FileCopyrightText:", "SPDX-SnippetCopyrightText:", "Copyright", or "©".
Here we also impose a requirement that the word "Copyright" should be followed by a whitespace character.
public static bool ContainsCopyrightNotice(string line)
Parameters
linestring
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Parse(string)
Parses the copyright notice. Note that it will parse even an invalid string (for support of erroneous texts). Test with ContainsCopyrightNotice(string) if you want to check the input for correctness.
public static CopyrightNotice Parse(string fullText)
Parameters
fullTextstring
Returns
Remarks
This does the best effort to parse and store the copyright notice according to the REUSE Specification – Version 3.3.
Note that most of the specification regarding the copyright notice format is a recommendation and not a strict requirement. So, not every aspect of the copyright notice MUST be parseable.
The specification does not document how year ranges are supposed to be parsed, so we follow the proposal that doesn't contradict anything said in the spec.
Following the order recommended by the specification (year, name, contact address), the contact address of
the copyright holder is parsed from in between angle brackets at the very end of the notice (e.g.
<jane@example.com>). If the angle brackets are not correctly paired, or if there is any text
after the closing bracket, then no contact address is parsed, and the whole remaining text is considered to
be a part of the HolderName.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.