Skip to content

Commit b82b81e

Browse files
committed
Switch to array and collection expressions
1 parent 9b19bc2 commit b82b81e

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/PowerShellEditorServices/Extensions/EditorWorkspace.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
using System.Collections.Generic;
54
using System.Linq;
65

76
namespace Microsoft.PowerShell.EditorServices.Extensions
@@ -85,9 +84,11 @@ public sealed class EditorWorkspace
8584
/// <summary>
8685
/// Get all currently open documents in the workspace.
8786
/// </summary>
88-
public IEnumerable<EditorWorkspaceDocument> Documents => editorOperations
87+
public EditorWorkspaceDocument[] Documents => [..
88+
editorOperations
8989
.GetWorkspaceOpenDocuments()
90-
.Select(doc => new EditorWorkspaceDocument(this, doc.Path, doc.Saved));
90+
.Select(doc => new EditorWorkspaceDocument(this, doc.Path, doc.Saved))
91+
];
9192

9293
#endregion
9394

test/PowerShellEditorServices.Test/Extensions/EditorWorkspaceTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ public void DocumentsReturnsOpenWorkspaceDocuments()
1818
{
1919
TestEditorOperations editorOperations = new()
2020
{
21-
OpenDocuments = new[]
22-
{
21+
OpenDocuments =
22+
[
2323
new WorkspaceOpenDocument(@"C:\test\one.ps1", saved: true),
2424
new WorkspaceOpenDocument(@"C:\test\two.ps1", saved: true)
25-
}
25+
]
2626
};
2727

2828
EditorWorkspace workspace = new(editorOperations);
2929

30-
IEnumerable<EditorWorkspaceDocument> documents = workspace.Documents;
30+
EditorWorkspaceDocument[] documents = workspace.Documents;
3131

3232
Assert.Collection(
3333
documents,
@@ -49,7 +49,7 @@ public void DocumentOpenSaveAndCloseUseWorkspaceOperations()
4949
const string filePath = @"C:\test\file.ps1";
5050
TestEditorOperations editorOperations = new()
5151
{
52-
OpenDocuments = new[] { new WorkspaceOpenDocument(filePath, saved: true) }
52+
OpenDocuments = [new WorkspaceOpenDocument(filePath, saved: true)]
5353
};
5454

5555
EditorWorkspace workspace = new(editorOperations);

0 commit comments

Comments
 (0)