Skip to content

Commit

Permalink
More use of collection expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinungf committed Apr 14, 2024
1 parent 9b64632 commit 946c750
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ dotnet_diagnostic.IDE0028.severity = warning
dotnet_diagnostic.IDE0300.severity = warning
# IDE0301: Use collection expression for empty
dotnet_diagnostic.IDE0301.severity = warning
# IDE0305: Use collection expression for fluent
dotnet_diagnostic.IDE0305.severity = warning

[{ColumnHeaderAttribute.cs,ColumnOrderAttribute.cs,WorksheetRowAttribute.cs}]
# CA1019: Define accessors for attribute arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class EnumerableExtensions
public static EquatableArray<T> ToEquatableArray<T>(this IEnumerable<T> elements)
where T : IEquatable<T>
{
var array = elements is T[] arr ? arr : elements.ToArray();
var array = elements is T[] arr ? arr : [.. elements];
return new EquatableArray<T>(array);
}
}
10 changes: 5 additions & 5 deletions SpreadCheetah/MetadataXml/StylesXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static ValueTask WriteAsync(
CancellationToken token)
{
var entry = archive.CreateEntry("xl/styles.xml", compressionLevel);
var writer = new StylesXml(styles.Keys.ToList());
var writer = new StylesXml([.. styles.Keys]);
#pragma warning disable EPS06 // Hidden struct copy operation
return writer.WriteAsync(entry, buffer, token);
#pragma warning restore EPS06 // Hidden struct copy operation
Expand Down Expand Up @@ -51,10 +51,10 @@ private StylesXml(List<ImmutableStyle> styles)
_borders = CreateBorderDictionary(styles);
_fills = CreateFillDictionary(styles);
_fonts = CreateFontDictionary(styles);
_numberFormatsXml = new StyleNumberFormatsXml(_customNumberFormats?.ToList());
_bordersXml = new StyleBordersXml(_borders.Keys.ToList());
_fillsXml = new StyleFillsXml(_fills.Keys.ToList());
_fontsXml = new StyleFontsXml(_fonts.Keys.ToList());
_numberFormatsXml = new StyleNumberFormatsXml(_customNumberFormats is { } formats ? [.. formats] : null);
_bordersXml = new StyleBordersXml([.. _borders.Keys]);
_fillsXml = new StyleFillsXml([.. _fills.Keys]);
_fontsXml = new StyleFontsXml([.. _fonts.Keys]);
_styles = styles;
}

Expand Down
2 changes: 1 addition & 1 deletion SpreadCheetah/MetadataXml/WorksheetStartXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal struct WorksheetStartXml : IXmlWriter
public WorksheetStartXml(WorksheetOptions? options)
{
_options = options;
_columns = options?.ColumnOptions.ToList();
_columns = options is not null ? [.. options.ColumnOptions] : null;
}

public bool TryWrite(Span<byte> bytes, out int bytesWritten)
Expand Down

0 comments on commit 946c750

Please sign in to comment.