Skip to content

Commit 0cceb23

Browse files
authored
chore: Apply code formatting rules (IDE0028, and IDE0300-IDE0304) (#10458)
chore: apply code formatter for IDE0028, and IDE0300-IDE0304
1 parent 16e2a3f commit 0cceb23

157 files changed

Lines changed: 516 additions & 516 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ csharp_prefer_static_local_function = true:suggestion
7878
dotnet_diagnostic.IDE0010.severity = suggestion # IDE0010: Add missing cases to switch statement
7979
dotnet_style_object_initializer = true:suggestion # IDE0017: Use object initializers
8080
csharp_style_inlined_variable_declaration = true:suggestion # IDE0018: Inline variable declaration
81-
dotnet_style_collection_initializer = true:suggestion # IDE0028: Use collection initializers
81+
dotnet_style_collection_initializer = true:suggestion # IDE0028: Use collection initializers or expressions
82+
dotnet_style_prefer_collection_expression = true:suggestion # IDE0028: Use collection initializers or expressions
8283
dotnet_style_prefer_auto_properties = true:suggestion # IDE0032: Use auto-implemented property
8384
dotnet_style_explicit_tuple_names = true:suggestion # IDE0033: Use explicitly provided tuple name
8485
csharp_prefer_simple_default_expression = true:suggestion # IDE0034: Simplify default expression

src/Docfx.App/Config/BuildJsonConfig.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ internal class BuildJsonConfig
7272
/// </summary>
7373
[JsonProperty("globalMetadataFiles")]
7474
[JsonPropertyName("globalMetadataFiles")]
75-
public ListWithStringFallback GlobalMetadataFiles { get; set; } = new();
75+
public ListWithStringFallback GlobalMetadataFiles { get; set; } = [];
7676

7777
/// <summary>
7878
/// Metadata that applies to some specific files.
@@ -99,7 +99,7 @@ internal class BuildJsonConfig
9999
/// </summary>
100100
[JsonProperty("template")]
101101
[JsonPropertyName("template")]
102-
public ListWithStringFallback Template { get; set; } = new();
102+
public ListWithStringFallback Template { get; set; } = [];
103103

104104
/// <summary>
105105
/// The themes applied to the documentation.
@@ -123,7 +123,7 @@ internal class BuildJsonConfig
123123
/// </example>
124124
[JsonProperty("postProcessors")]
125125
[JsonPropertyName("postProcessors")]
126-
public ListWithStringFallback PostProcessors { get; set; } = new();
126+
public ListWithStringFallback PostProcessors { get; set; } = [];
127127

128128
/// <summary>
129129
/// Run in debug mode. With debug mode, raw model and view model will be exported

src/Docfx.App/Config/FileMetadataPairs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public FileMetadataPairs(IEnumerable<FileMetadataPairsItem> items)
3939
/// </summary>
4040
public FileMetadataPairs(FileMetadataPairsItem item)
4141
{
42-
_items = new List<FileMetadataPairsItem> { item };
42+
_items = [item];
4343
}
4444

4545
/// <summary>

src/Docfx.App/Config/GroupConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ internal class GroupConfig
2323
/// </summary>
2424
[Newtonsoft.Json.JsonExtensionData]
2525
[System.Text.Json.Serialization.JsonExtensionData]
26-
public Dictionary<string, object> Metadata { get; set; } = new();
26+
public Dictionary<string, object> Metadata { get; set; } = [];
2727
}

src/Docfx.App/Helpers/DocumentBuilderWrapper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private static FileMetadata GetFileMetadata(string baseDirectory, BuildJsonConfi
263263
{
264264
foreach (var (key, value) in config.FileMetadata)
265265
{
266-
var list = result.TryGetValue(key, out var items) ? items : result[key] = new();
266+
var list = result.TryGetValue(key, out var items) ? items : result[key] = [];
267267
foreach (var pair in value.Items)
268268
{
269269
list.Add(new FileMetadataItem(pair.Glob, key, pair.Value));
@@ -277,7 +277,7 @@ private static FileMetadata GetFileMetadata(string baseDirectory, BuildJsonConfi
277277
{
278278
foreach (var (key, value) in JsonUtility.Deserialize<Dictionary<string, FileMetadataPairs>>(path))
279279
{
280-
var list = result.TryGetValue(key, out var items) ? items : result[key] = new();
280+
var list = result.TryGetValue(key, out var items) ? items : result[key] = [];
281281
foreach (var pair in value.Items)
282282
{
283283
list.Add(new FileMetadataItem(pair.Glob, key, pair.Value));

src/Docfx.App/Helpers/MetadataMerger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ namespace Docfx;
1414

1515
internal class MetadataMerger
1616
{
17-
private readonly Dictionary<string, Dictionary<string, object>> _metaTable = new();
18-
private readonly Dictionary<string, Dictionary<string, object>> _propTable = new();
17+
private readonly Dictionary<string, Dictionary<string, object>> _metaTable = [];
18+
private readonly Dictionary<string, Dictionary<string, object>> _propTable = [];
1919

2020
public void Merge(MetadataMergeParameters parameters)
2121
{

src/Docfx.App/PdfBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ await Parallel.ForEachAsync(pages, async (item, _) =>
311311

312312
var key = CleanUrl(url);
313313
if (!pagesByUrl.TryGetValue(key, out var dests))
314-
pagesByUrl[key] = dests = new();
314+
pagesByUrl[key] = dests = [];
315315
dests.Add((node, document.Structure.Catalog.GetNamedDestinations()));
316316

317317
pageBytes[node] = bytes;

src/Docfx.App/RunBuild.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static string Exec(BuildJsonConfig config, BuildOptions options, string c
2121
var stopwatch = Stopwatch.StartNew();
2222
if (config.Template == null || config.Template.Count == 0)
2323
{
24-
config.Template = new ListWithStringFallback { "default" };
24+
config.Template = ["default"];
2525
}
2626

2727
var baseDirectory = Path.GetFullPath(string.IsNullOrEmpty(configDirectory) ? Directory.GetCurrentDirectory() : configDirectory);

src/Docfx.App/RunMerge.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private static MetadataMergeParameters ConfigToParameter(MergeJsonItemConfig con
5656
OutputBaseDir = outputDirectory,
5757
Metadata = config.GlobalMetadata?.ToImmutableDictionary() ?? ImmutableDictionary<string, object>.Empty,
5858
FileMetadata = ConvertToFileMetadataItem(baseDirectory, config.FileMetadata),
59-
TocMetadata = config.TocMetadata?.ToImmutableList() ?? ImmutableList<string>.Empty,
59+
TocMetadata = config.TocMetadata?.ToImmutableList() ?? [],
6060
Files = GetFileCollectionFromFileMapping(
6161
baseDirectory,
6262
DocumentType.Article,

src/Docfx.Build.Common/MarkdownReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Docfx.Build.Common;
1313

1414
public class MarkdownReader
1515
{
16-
private static readonly ImmutableList<string> RequiredProperties = ImmutableList.Create(Constants.PropertyName.Uid);
16+
private static readonly ImmutableList<string> RequiredProperties = [Constants.PropertyName.Uid];
1717

1818
public static IEnumerable<OverwriteDocumentModel> ReadMarkdownAsOverwrite(IHostService host, FileAndType ft)
1919
{

0 commit comments

Comments
 (0)