Skip to content

Commit

Permalink
Use langword in XML comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinungf committed Apr 1, 2024
1 parent 937798d commit 4e4a728
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ dotnet_diagnostic.MA0053.severity = warning
MA0053.public_class_should_be_sealed = true
# MA0076: Do not use implicit culture-sensitive ToString in interpolated strings
dotnet_diagnostic.MA0076.severity = warning
# MA0154: Use langword in XML comment
dotnet_diagnostic.MA0154.severity = warning

# Disable MA0053 (sealing class) for types that have been publicly exposed in a previous version
[{AutoFilterOptions.cs,ColumnOptions.cs,RowOptions.cs,SpreadCheetahOptions.cs,WorksheetOptions.cs,WorksheetRowGenerator.cs}]
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<GlobalPackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />
<GlobalPackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.9.28" />
<GlobalPackageReference Include="Roslynator.Analyzers" Version="4.12.0" />
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="9.21.0.86780" />
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="9.23.0.88079" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.13.12" />
Expand Down
16 changes: 8 additions & 8 deletions SpreadCheetah/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public readonly record struct Cell

/// <summary>
/// Initializes a new instance of the <see cref="Cell"/> struct with a text value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public Cell(string? value, StyleId? styleId = null) : this(new DataCell(value), null, styleId)
{
Expand All @@ -34,7 +34,7 @@ public Cell(int value, StyleId? styleId = null) : this(new DataCell(value), null

/// <summary>
/// Initializes a new instance of the <see cref="Cell"/> struct with an integer value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public Cell(int? value, StyleId? styleId = null) : this(new DataCell(value), null, styleId)
{
Expand All @@ -50,7 +50,7 @@ public Cell(long value, StyleId? styleId = null) : this(new DataCell(value), nul

/// <summary>
/// Initializes a new instance of the <see cref="Cell"/> struct with a long integer value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// Note that Open XML limits the precision to 15 significant digits for numbers. This could potentially lead to a loss of precision.
/// </summary>
public Cell(long? value, StyleId? styleId = null) : this(new DataCell(value), null, styleId)
Expand All @@ -66,7 +66,7 @@ public Cell(float value, StyleId? styleId = null) : this(new DataCell(value), nu

/// <summary>
/// Initializes a new instance of the <see cref="Cell"/> struct with a floating point value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public Cell(float? value, StyleId? styleId = null) : this(new DataCell(value), null, styleId)
{
Expand All @@ -82,7 +82,7 @@ public Cell(double value, StyleId? styleId = null) : this(new DataCell(value), n

/// <summary>
/// Initializes a new instance of the <see cref="Cell"/> struct with a double-precision floating-point value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// Note that Open XML limits the precision to 15 significant digits for numbers. This could potentially lead to a loss of precision.
/// </summary>
public Cell(double? value, StyleId? styleId = null) : this(new DataCell(value), null, styleId)
Expand All @@ -99,7 +99,7 @@ public Cell(decimal value, StyleId? styleId = null) : this(new DataCell(value),

/// <summary>
/// Initializes a new instance of the <see cref="Cell"/> struct with a decimal floating-point value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// Note that Open XML limits the precision to 15 significant digits for numbers. This could potentially lead to a loss of precision.
/// </summary>
public Cell(decimal? value, StyleId? styleId = null) : this(new DataCell(value), null, styleId)
Expand All @@ -119,7 +119,7 @@ public Cell(DateTime value, StyleId? styleId = null) : this(new DataCell(value),
/// Initializes a new instance of the <see cref="StyledCell"/> struct with a <see cref="DateTime"/> value and an optional style.
/// Will be displayed in the number format from <see cref="Style.Format"/> if set,
/// otherwise <see cref="SpreadCheetahOptions.DefaultDateTimeFormat"/> will be used instead.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public Cell(DateTime? value, StyleId? styleId = null) : this(new DataCell(value), null, styleId)
{
Expand All @@ -134,7 +134,7 @@ public Cell(bool value, StyleId? styleId = null) : this(new DataCell(value), nul

/// <summary>
/// Initializes a new instance of the <see cref="Cell"/> struct with a boolean value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public Cell(bool? value, StyleId? styleId = null) : this(new DataCell(value), null, styleId)
{
Expand Down
16 changes: 8 additions & 8 deletions SpreadCheetah/DataCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public readonly record struct DataCell

/// <summary>
/// Initializes a new instance of the <see cref="DataCell"/> struct with a text value.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public DataCell(string? value)
{
Expand All @@ -32,7 +32,7 @@ public DataCell(int value)

/// <summary>
/// Initializes a new instance of the <see cref="DataCell"/> struct with an integer value.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public DataCell(int? value)
{
Expand All @@ -50,7 +50,7 @@ public DataCell(long value) : this((double)value)

/// <summary>
/// Initializes a new instance of the <see cref="DataCell"/> struct with a long integer value.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// Note that Open XML limits the precision to 15 significant digits for numbers. This could potentially lead to a loss of precision.
/// </summary>
public DataCell(long? value) : this((double?)value)
Expand All @@ -68,7 +68,7 @@ public DataCell(float value)

/// <summary>
/// Initializes a new instance of the <see cref="DataCell"/> struct with a floating-point value.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public DataCell(float? value)
{
Expand All @@ -88,7 +88,7 @@ public DataCell(double value)

/// <summary>
/// Initializes a new instance of the <see cref="DataCell"/> struct with a double-precision floating-point value.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// Note that Open XML limits the precision to 15 significant digits for numbers. This could potentially lead to a loss of precision.
/// </summary>
public DataCell(double? value)
Expand All @@ -107,7 +107,7 @@ public DataCell(decimal value) : this(decimal.ToDouble(value))

/// <summary>
/// Initializes a new instance of the <see cref="DataCell"/> struct with a decimal floating-point value.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// Note that Open XML limits the precision to 15 significant digits for numbers. This could potentially lead to a loss of precision.
/// </summary>
public DataCell(decimal? value) : this(value != null ? decimal.ToDouble(value.GetValueOrDefault()) : null)
Expand All @@ -127,7 +127,7 @@ public DataCell(DateTime value)
/// <summary>
/// Initializes a new instance of the <see cref="DataCell"/> struct with a <see cref="DateTime"/> value.
/// Will be displayed in the number format from <see cref="SpreadCheetahOptions.DefaultDateTimeFormat"/>.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public DataCell(DateTime? value)
{
Expand All @@ -145,7 +145,7 @@ public DataCell(bool value)

/// <summary>
/// Initializes a new instance of the <see cref="DataCell"/> struct with a boolean value.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public DataCell(bool? value)
{
Expand Down
8 changes: 4 additions & 4 deletions SpreadCheetah/Images/ImageCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ private static ImageCanvas FillCell(SingleCellRelativeReference upperLeft, ushor
/// The <paramref name="moveWithCells"/> parameter decides whether or not the image should move when
/// cells further up or left change size.
/// The <paramref name="resizeWithCells"/> parameter decides whether or not the image should resize when
/// the cell is being resized. <paramref name="resizeWithCells"/> can only be set to <c>true</c>
/// if <paramref name="moveWithCells"/> is also set to <c>true</c>.
/// the cell is being resized. <paramref name="resizeWithCells"/> can only be set to <see langword="true"/>
/// if <paramref name="moveWithCells"/> is also set to <see langword="true"/>.
/// </summary>
public static ImageCanvas FillCell(ReadOnlySpan<char> cellReference, bool moveWithCells = true, bool resizeWithCells = true)
{
Expand All @@ -119,8 +119,8 @@ public static ImageCanvas FillCell(ReadOnlySpan<char> cellReference, bool moveWi
/// The <paramref name="moveWithCells"/> parameter decides whether or not the image should move when
/// cells further up or left change size.
/// The <paramref name="resizeWithCells"/> parameter decides whether or not the image should resize when
/// the cell range is being resized. <paramref name="resizeWithCells"/> can only be set to <c>true</c>
/// if <paramref name="moveWithCells"/> is also set to <c>true</c>.
/// the cell range is being resized. <paramref name="resizeWithCells"/> can only be set to <see langword="true"/>
/// if <paramref name="moveWithCells"/> is also set to <see langword="true"/>.
/// </summary>
public static ImageCanvas FillCells(ReadOnlySpan<char> upperLeftReference, ReadOnlySpan<char> lowerRightReference, bool moveWithCells = true, bool resizeWithCells = true)
{
Expand Down
2 changes: 1 addition & 1 deletion SpreadCheetah/SpreadCheetahOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public string? DefaultDateTimeNumberFormat
/// <item>Microsoft Spreadsheet Compare tool.</item>
/// </list>
/// Writing the attribute will slightly affect the performance of writing cells, and will also increase the resulting file size.
/// Defaults to <c>false</c>.
/// Defaults to <see langword="false"/>.
/// </summary>
public bool WriteCellReferenceAttributes { get; set; }
}
2 changes: 1 addition & 1 deletion SpreadCheetah/Spreadsheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public void AddDataValidation(string reference, DataValidation validation)
/// <item><term><c>A1:A1048576</c></term><description>References all cells in column A.</description></item>
/// <item><term><c>A5:XFD5</c></term><description>References all cells in row 5.</description></item>
/// </list>
/// Note that there can be max 65534 data validations in a worksheet. This method returns <c>false</c> if attempting to add more than that.
/// Note that there can be max 65534 data validations in a worksheet. This method returns <see langword="false"/> if attempting to add more than that.
/// </summary>
public bool TryAddDataValidation(string reference, DataValidation validation)
{
Expand Down
4 changes: 2 additions & 2 deletions SpreadCheetah/SpreadsheetUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static string GetColumnName(int columnNumber)

/// <summary>
/// Try to write the UTF8 column name from a column number into the specified span. E.g. column number 1 results in column name 'A'.
/// Returns <c>true</c> if the column name was written into the span, and <c>false</c> otherwise.
/// Returns <see langword="true"/> if the column name was written into the span, and <see langword="false"/> otherwise.
/// </summary>
public static bool TryGetColumnNameUtf8(int columnNumber, Span<byte> destination, out int bytesWritten)
{
Expand Down Expand Up @@ -106,7 +106,7 @@ public static bool TryGetColumnNameUtf8(int columnNumber, Span<byte> destination

/// <summary>
/// Try to parse the column number from a column name. E.g. column name 'A' can be parsed to column number 1.
/// Returns <c>true</c> if the column number was parsed successfully, and <c>false</c> otherwise.
/// Returns <see langword="true"/> if the column number was parsed successfully, and <see langword="false"/> otherwise.
/// </summary>
public static bool TryParseColumnName(ReadOnlySpan<char> columnName, out int columnNumber)
{
Expand Down
16 changes: 8 additions & 8 deletions SpreadCheetah/StyledCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public readonly record struct StyledCell

/// <summary>
/// Initializes a new instance of the <see cref="StyledCell"/> struct with a text value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public StyledCell(string? value, StyleId? styleId)
{
Expand All @@ -33,7 +33,7 @@ public StyledCell(int value, StyleId? styleId)

/// <summary>
/// Initializes a new instance of the <see cref="StyledCell"/> struct with an integer value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public StyledCell(int? value, StyleId? styleId)
{
Expand All @@ -53,7 +53,7 @@ public StyledCell(long value, StyleId? styleId)

/// <summary>
/// Initializes a new instance of the <see cref="StyledCell"/> struct with a long integer value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// Note that Open XML limits the precision to 15 significant digits for numbers. This could potentially lead to a loss of precision.
/// </summary>
public StyledCell(long? value, StyleId? styleId)
Expand All @@ -73,7 +73,7 @@ public StyledCell(float value, StyleId? styleId)

/// <summary>
/// Initializes a new instance of the <see cref="StyledCell"/> struct with a floating point value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public StyledCell(float? value, StyleId? styleId)
{
Expand All @@ -93,7 +93,7 @@ public StyledCell(double value, StyleId? styleId)

/// <summary>
/// Initializes a new instance of the <see cref="StyledCell"/> struct with a double-precision floating-point value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// Note that Open XML limits the precision to 15 significant digits for numbers. This could potentially lead to a loss of precision.
/// </summary>
public StyledCell(double? value, StyleId? styleId)
Expand All @@ -114,7 +114,7 @@ public StyledCell(decimal value, StyleId? styleId)

/// <summary>
/// Initializes a new instance of the <see cref="StyledCell"/> struct with a decimal floating-point value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// Note that Open XML limits the precision to 15 significant digits for numbers. This could potentially lead to a loss of precision.
/// </summary>
public StyledCell(decimal? value, StyleId? styleId)
Expand All @@ -138,7 +138,7 @@ public StyledCell(DateTime value, StyleId? styleId)
/// Initializes a new instance of the <see cref="StyledCell"/> struct with a <see cref="DateTime"/> value and an optional style.
/// Will be displayed in the number format from <see cref="Style.Format"/> if set,
/// otherwise <see cref="SpreadCheetahOptions.DefaultDateTimeFormat"/> will be used instead.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public StyledCell(DateTime? value, StyleId? styleId)
{
Expand All @@ -157,7 +157,7 @@ public StyledCell(bool value, StyleId? styleId)

/// <summary>
/// Initializes a new instance of the <see cref="StyledCell"/> struct with a boolean value and an optional style.
/// If <c>value</c> is <c>null</c>, the cell will be empty.
/// If <c>value</c> is <see langword="null"/>, the cell will be empty.
/// </summary>
public StyledCell(bool? value, StyleId? styleId)
{
Expand Down
6 changes: 3 additions & 3 deletions SpreadCheetah/Styling/Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public string? Name
set => _name = XmlUtility.XmlEncode(value.WithEnsuredMaxLength(31));
}

/// <summary>Bold font weight. Defaults to <c>false</c>.</summary>
/// <summary>Bold font weight. Defaults to <see langword="false"/>.</summary>
public bool Bold { get; set; }

/// <summary>Italic font type. Defaults to <c>false</c>.</summary>
/// <summary>Italic font type. Defaults to <see langword="false"/>.</summary>
public bool Italic { get; set; }

/// <summary>Adds a horizontal line through the center of the characters. Defaults to <c>false</c>.</summary>
/// <summary>Adds a horizontal line through the center of the characters. Defaults to <see langword="false"/>.</summary>
public bool Strikethrough { get; set; }

/// <summary>Font size. Defaults to 11.</summary>
Expand Down
8 changes: 4 additions & 4 deletions SpreadCheetah/Validations/DataValidation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ private DataValidation(
Value2 = value2;
}

/// <summary>Ignore cells without values. Defaults to <c>true</c>.</summary>
/// <summary>Ignore cells without values. Defaults to <see langword="true"/>.</summary>
public bool IgnoreBlank { get; set; } = true;
/// <summary>Show an error alert for invalid values. Defaults to <c>true</c>.</summary>
/// <summary>Show an error alert for invalid values. Defaults to <see langword="true"/>.</summary>
public bool ShowErrorAlert { get; set; } = true;
/// <summary>Show the input message box. Defaults to <c>true</c>.</summary>
/// <summary>Show the input message box. Defaults to <see langword="true"/>.</summary>
public bool ShowInputMessage { get; set; } = true;

/// <summary>Title for error alerts. Maximum 32 characters.</summary>
Expand Down Expand Up @@ -219,7 +219,7 @@ public static DataValidation ListValues(IEnumerable<string> values, bool showDro
/// <item><description>The values can't contain commas.</description></item>
/// <item><description>The combined length of the values (including required comma separators) can't exceed 255 characters.</description></item>
/// </list>
/// Returns <c>false</c> if any of these requirements are not met.
/// Returns <see langword="false"/> if any of these requirements are not met.
/// </summary>
public static bool TryCreateListValues(IEnumerable<string> values, bool showDropdown, [NotNullWhen(true)] out DataValidation? dataValidation)
{
Expand Down
2 changes: 1 addition & 1 deletion SpreadCheetah/Worksheets/ColumnOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public double? Width
private double? _width;

/// <summary>
/// Is the column hidden or not. Defaults to false.
/// Is the column hidden or not. Defaults to <see langword="false"/>.
/// </summary>
public bool Hidden { get; set; }
}

0 comments on commit 4e4a728

Please sign in to comment.