Prefer IReadOnlyCollection<> or IReadOnlyList<> over IEnumerable<>
Part of wixtoolset/issues#6422
Rob Mensching committed
Apr 19, 2021 at 16:09 UTC
a4c7643523a3fc79c2a79292d22487196ea388fb
22 files changed
+148
-48
src/WixToolset.Extensibility/BaseBurnBackendBinderExtension.cs
+1
-1
@@ -33,7 +33,7 @@ namespace WixToolset.Extensibility
33
/// <summary>
34
/// Optional symbol definitions.
35
/// </summary>
36
- protected virtual IEnumerable<IntermediateSymbolDefinition> SymbolDefinitions => Enumerable.Empty<IntermediateSymbolDefinition>();
36
+ protected virtual IReadOnlyCollection<IntermediateSymbolDefinition> SymbolDefinitions => Array.Empty<IntermediateSymbolDefinition>();
37
38
/// <summary>
39
/// See <see cref="IBurnBackendBinderExtension.PreBackendBind(IBindContext)"/>
src/WixToolset.Extensibility/BaseExtensionCommandLine.cs
+2
-2
@@ -2,8 +2,8 @@
2
3
namespace WixToolset.Extensibility
4
{
5
+ using System;
6
using System.Collections.Generic;
6
- using System.Linq;
7
using WixToolset.Extensibility.Data;
8
using WixToolset.Extensibility.Services;
9
@@ -15,7 +15,7 @@ namespace WixToolset.Extensibility
15
/// <summary>
16
/// See <see cref="IExtensionCommandLine.CommandLineSwitches" />
17
/// </summary>
18
- public virtual IEnumerable<ExtensionCommandLineSwitch> CommandLineSwitches => Enumerable.Empty<ExtensionCommandLineSwitch>();
18
+ public virtual IReadOnlyCollection<ExtensionCommandLineSwitch> CommandLineSwitches => Array.Empty<ExtensionCommandLineSwitch>();
19
20
/// <summary>
21
/// See <see cref="IExtensionCommandLine.PostParse" />
src/WixToolset.Extensibility/BaseExtensionFactory.cs
+1
-1
@@ -15,7 +15,7 @@ namespace WixToolset.Extensibility
15
/// <summary>
16
/// The extension types of the WiX extension.
17
/// </summary>
18
- protected abstract IEnumerable<Type> ExtensionTypes { get; }
18
+ protected abstract IReadOnlyCollection<Type> ExtensionTypes { get; }
19
20
/// <summary>
21
/// See <see cref="IExtensionFactory.TryCreateExtension(Type, out object)"/>
src/WixToolset.Extensibility/BaseLibrarianExtension.cs
+1
-1
@@ -59,7 +59,7 @@ namespace WixToolset.Extensibility
59
/// <param name="path">Optional resolved path to file.</param>
60
/// <param name="checkedPaths">Optional collection of paths checked for the file.</param>
61
/// <returns>Resolved file result.</returns>
62
- protected IResolveFileResult CreateResolveFileResult(string path = null, IEnumerable<string> checkedPaths = null)
62
+ protected IResolveFileResult CreateResolveFileResult(string path = null, IReadOnlyCollection<string> checkedPaths = null)
63
{
64
var result = this.Context.ServiceProvider.GetService<IResolveFileResult>();
65
result.Path = path;
src/WixToolset.Extensibility/BaseWindowsInstallerBackendBinderExtension.cs
+2
-1
@@ -2,6 +2,7 @@
2
3
namespace WixToolset.Extensibility
4
{
5
+ using System;
6
using System.Collections.Generic;
7
using System.Linq;
8
using WixToolset.Data;
@@ -33,7 +34,7 @@ namespace WixToolset.Extensibility
34
/// <summary>
35
/// Optional table definitions.
36
/// </summary>
36
- public virtual IEnumerable<TableDefinition> TableDefinitions => Enumerable.Empty<TableDefinition>();
37
+ public virtual IReadOnlyCollection<TableDefinition> TableDefinitions => Array.Empty<TableDefinition>();
38
39
/// <summary>
40
/// Creates a resolved cabinet result.
src/WixToolset.Extensibility/Data/IBindContext.cs
+6
-6
@@ -35,27 +35,27 @@ namespace WixToolset.Extensibility.Data
35
/// <summary>
36
/// Delayed fields that need to be resolved again.
37
/// </summary>
38
- IEnumerable<IDelayedField> DelayedFields { get; set; }
38
+ IReadOnlyCollection<IDelayedField> DelayedFields { get; set; }
39
40
/// <summary>
41
/// Embedded files to extract.
42
/// </summary>
43
- IEnumerable<IExpectedExtractFile> ExpectedEmbeddedFiles { get; set; }
43
+ IReadOnlyCollection<IExpectedExtractFile> ExpectedEmbeddedFiles { get; set; }
44
45
/// <summary>
46
/// Binder extensions.
47
/// </summary>
48
- IEnumerable<IBinderExtension> Extensions { get; set; }
48
+ IReadOnlyCollection<IBinderExtension> Extensions { get; set; }
49
50
/// <summary>
51
/// File system extensions.
52
/// </summary>
53
- IEnumerable<IFileSystemExtension> FileSystemExtensions { get; set; }
53
+ IReadOnlyCollection<IFileSystemExtension> FileSystemExtensions { get; set; }
54
55
/// <summary>
56
/// Set of ICEs to execute.
57
/// </summary>
58
- IEnumerable<string> Ices { get; set; }
58
+ IReadOnlyCollection<string> Ices { get; set; }
59
60
/// <summary>
61
/// Intermedaite folder.
@@ -100,7 +100,7 @@ namespace WixToolset.Extensibility.Data
100
/// <summary>
101
/// Set of ICEs to skip.
102
/// </summary>
103
- IEnumerable<string> SuppressIces { get; set; }
103
+ IReadOnlyCollection<string> SuppressIces { get; set; }
104
105
/// <summary>
106
/// Skip all ICEs.
src/WixToolset.Extensibility/Data/IBindResult.cs
+14
-3
@@ -6,13 +6,24 @@ namespace WixToolset.Extensibility.Data
6
using System.Collections.Generic;
7
using WixToolset.Data;
8
9
-#pragma warning disable 1591 // TODO: add documentation
9
+ /// <summary>
10
+ /// Result of bind operation.
11
+ /// </summary>
12
public interface IBindResult : IDisposable
13
{
12
- IEnumerable<IFileTransfer> FileTransfers { get; set; }
14
+ /// <summary>
15
+ /// Collection of file transfers to complete.
16
+ /// </summary>
17
+ IReadOnlyCollection<IFileTransfer> FileTransfers { get; set; }
18
14
- IEnumerable<ITrackedFile> TrackedFiles { get; set; }
19
+ /// <summary>
20
+ /// Collection of files tracked during binding.
21
+ /// </summary>
22
+ IReadOnlyCollection<ITrackedFile> TrackedFiles { get; set; }
23
24
+ /// <summary>
25
+ /// Ouput of binding.
26
+ /// </summary>
27
WixOutput Wixout { get; set; }
28
}
29
}
src/WixToolset.Extensibility/Data/ICompileContext.cs
+1
-1
@@ -26,7 +26,7 @@ namespace WixToolset.Extensibility.Data
26
/// <summary>
27
/// Set of extensions provided to the compiler.
28
/// </summary>
29
- IEnumerable<ICompilerExtension> Extensions { get; set; }
29
+ IReadOnlyCollection<ICompilerExtension> Extensions { get; set; }
30
31
/// <summary>
32
/// Gets or sets the platform which the compiler will use when defaulting 64-bit attributes and elements.
src/WixToolset.Extensibility/Data/IDecompileContext.cs
+1
-1
@@ -16,7 +16,7 @@ namespace WixToolset.Extensibility.Data
16
17
OutputType DecompileType { get; set; }
18
19
- IEnumerable<IDecompilerExtension> Extensions { get; set; }
19
+ IReadOnlyCollection<IDecompilerExtension> Extensions { get; set; }
20
21
string ExtractFolder { get; set; }
22
src/WixToolset.Extensibility/Data/IDecompileResult.cs
+1
-1
@@ -11,7 +11,7 @@ namespace WixToolset.Extensibility.Data
11
{
12
XDocument Document { get; set; }
13
14
- IEnumerable<string> ExtractedFilePaths { get; set; }
14
+ IReadOnlyCollection<string> ExtractedFilePaths { get; set; }
15
16
Platform? Platform { get; set; }
17
}
src/WixToolset.Extensibility/Data/ILayoutContext.cs
+3
-3
@@ -19,17 +19,17 @@ namespace WixToolset.Extensibility.Data
19
/// <summary>
20
/// Extensions for use during layout.
21
/// </summary>
22
- IEnumerable<ILayoutExtension> Extensions { get; set; }
22
+ IReadOnlyCollection<ILayoutExtension> Extensions { get; set; }
23
24
/// <summary>
25
/// Set of tracked of files created during processing to be cleaned up.
26
/// </summary>
27
- IEnumerable<ITrackedFile> TrackedFiles { get; set; }
27
+ IReadOnlyCollection<ITrackedFile> TrackedFiles { get; set; }
28
29
/// <summary>
30
/// Set of files to transfer.
31
/// </summary>
32
- IEnumerable<IFileTransfer> FileTransfers { get; set; }
32
+ IReadOnlyCollection<IFileTransfer> FileTransfers { get; set; }
33
34
/// <summary>
35
/// File to capture list of content files.
src/WixToolset.Extensibility/Data/ILibraryContext.cs
+31
-5
@@ -7,23 +7,49 @@ namespace WixToolset.Extensibility.Data
7
using System.Threading;
8
using WixToolset.Data;
9
10
-#pragma warning disable 1591 // TODO: add documentation
10
+ /// <summary>
11
+ /// Context provided during library creation operations.
12
+ /// </summary>
13
public interface ILibraryContext
14
{
15
+ /// <summary>
16
+ /// Service provider.
17
+ /// </summary>
18
IServiceProvider ServiceProvider { get; }
19
20
+ /// <summary>
21
+ /// Indicates whether files should be bound into the library.
22
+ /// </summary>
23
bool BindFiles { get; set; }
24
17
- IEnumerable<IBindPath> BindPaths { get; set; }
25
+ /// <summary>
26
+ /// Collection of bindpaths used to bind files.
27
+ /// </summary>
28
+ IReadOnlyCollection<IBindPath> BindPaths { get; set; }
29
19
- IEnumerable<ILibrarianExtension> Extensions { get; set; }
30
+ /// <summary>
31
+ /// Collection of extensions used during creation of library.
32
+ /// </summary>
33
+ IReadOnlyCollection<ILibrarianExtension> Extensions { get; set; }
34
35
+ /// <summary>
36
+ /// Identifier of the library.
37
+ /// </summary>
38
string LibraryId { get; set; }
39
23
- IEnumerable<Localization> Localizations { get; set; }
40
+ /// <summary>
41
+ /// Collection of localization files to use in the library.
42
+ /// </summary>
43
+ IReadOnlyCollection<Localization> Localizations { get; set; }
44
25
- IEnumerable<Intermediate> Intermediates { get; set; }
45
+ /// <summary>
46
+ /// Collection of intermediates to include in the library.
47
+ /// </summary>
48
+ IReadOnlyCollection<Intermediate> Intermediates { get; set; }
49
50
+ /// <summary>
51
+ /// Cancellation token.
52
+ /// </summary>
53
CancellationToken CancellationToken { get; set; }
54
}
55
}
src/WixToolset.Extensibility/Data/ILinkContext.cs
+27
-4
@@ -7,21 +7,44 @@ namespace WixToolset.Extensibility.Data
7
using System.Threading;
8
using WixToolset.Data;
9
10
-#pragma warning disable 1591 // TODO: add documentation
10
+ /// <summary>
11
+ /// Context provided during linking.
12
+ /// </summary>
13
public interface ILinkContext
14
{
15
+ /// <summary>
16
+ /// Service provider.
17
+ /// </summary>
18
IServiceProvider ServiceProvider { get; }
19
15
- IEnumerable<ILinkerExtension> Extensions { get; set; }
20
+ /// <summary>
21
+ /// Collection of extensions to use during linking.
22
+ /// </summary>
23
+ IReadOnlyCollection<ILinkerExtension> Extensions { get; set; }
24
17
- IEnumerable<IExtensionData> ExtensionData { get; set; }
25
+ /// <summary>
26
+ /// Collection of extension data to use during linking.
27
+ /// </summary>
28
+ IReadOnlyCollection<IExtensionData> ExtensionData { get; set; }
29
30
+ /// <summary>
31
+ /// Expected output type.
32
+ /// </summary>
33
OutputType ExpectedOutputType { get; set; }
34
21
- IEnumerable<Intermediate> Intermediates { get; set; }
35
+ /// <summary>
36
+ /// Collection of intermediates to link.
37
+ /// </summary>
38
+ IReadOnlyCollection<Intermediate> Intermediates { get; set; }
39
40
+ /// <summary>
41
+ /// Symbol definition creator used to load extension data.
42
+ /// </summary>
43
ISymbolDefinitionCreator SymbolDefinitionCreator { get; set; }
44
45
+ /// <summary>
46
+ /// Cancellation token.
47
+ /// </summary>
48
CancellationToken CancellationToken { get; set; }
49
}
50
}
src/WixToolset.Extensibility/Data/IPreprocessContext.cs
+26
-3
@@ -7,14 +7,25 @@ namespace WixToolset.Extensibility.Data
7
using System.Threading;
8
using WixToolset.Data;
9
10
-#pragma warning disable 1591 // TODO: add documentation
10
+ /// <summary>
11
+ /// Preprocessor context.
12
+ /// </summary>
13
public interface IPreprocessContext
14
{
15
+ /// <summary>
16
+ /// Service provider.
17
+ /// </summary>
18
IServiceProvider ServiceProvider { get; }
19
15
- IEnumerable<IPreprocessorExtension> Extensions { get; set; }
20
+ /// <summary>
21
+ /// Collection of extensions to use during preprocessing.
22
+ /// </summary>
23
+ IReadOnlyCollection<IPreprocessorExtension> Extensions { get; set; }
24
17
- IEnumerable<string> IncludeSearchPaths { get; set; }
25
+ /// <summary>
26
+ /// Collection of search paths to find include files.
27
+ /// </summary>
28
+ IReadOnlyCollection<string> IncludeSearchPaths { get; set; }
29
30
/// <summary>
31
/// Gets the platform which the compiler will use when defaulting 64-bit attributes and elements.
@@ -22,12 +33,24 @@ namespace WixToolset.Extensibility.Data
33
/// <value>The platform which the compiler will use when defaulting 64-bit attributes and elements.</value>
34
Platform Platform { get; set; }
35
36
+ /// <summary>
37
+ /// Path to the source file being preprocessed.
38
+ /// </summary>
39
string SourcePath { get; set; }
40
41
+ /// <summary>
42
+ /// Collection of name/value pairs used as preprocessor variables.
43
+ /// </summary>
44
IDictionary<string, string> Variables { get; set; }
45
46
+ /// <summary>
47
+ /// Current source line number of the preprocessor.
48
+ /// </summary>
49
SourceLineNumber CurrentSourceLineNumber { get; set; }
50
51
+ /// <summary>
52
+ /// Cancellation token.
53
+ /// </summary>
54
CancellationToken CancellationToken { get; set; }
55
}
56
}
src/WixToolset.Extensibility/Data/IPreprocessResult.cs
+10
-2
@@ -5,11 +5,19 @@ namespace WixToolset.Extensibility.Data
5
using System.Collections.Generic;
6
using System.Xml.Linq;
7
8
-#pragma warning disable 1591 // TODO: add documentation
8
+ /// <summary>
9
+ /// Result of preprocessing.
10
+ /// </summary>
11
public interface IPreprocessResult
12
{
13
+ /// <summary>
14
+ /// Document result of preprocessor.
15
+ /// </summary>
16
XDocument Document { get; set; }
17
13
- IEnumerable<IIncludedFile> IncludedFiles { get; set; }
18
+ /// <summary>
19
+ /// Collection of files included during preprocessing.
20
+ /// </summary>
21
+ IReadOnlyCollection<IIncludedFile> IncludedFiles { get; set; }
22
}
23
}
src/WixToolset.Extensibility/Data/IResolveContext.cs
+5
-5
@@ -20,22 +20,22 @@ namespace WixToolset.Extensibility.Data
20
/// <summary>
21
/// Bind paths used during resolution.
22
/// </summary>
23
- IEnumerable<IBindPath> BindPaths { get; set; }
23
+ IReadOnlyCollection<IBindPath> BindPaths { get; set; }
24
25
/// <summary>
26
/// Resolve extensions.
27
/// </summary>
28
- IEnumerable<IResolverExtension> Extensions { get; set; }
28
+ IReadOnlyCollection<IResolverExtension> Extensions { get; set; }
29
30
/// <summary>
31
/// Extension data.
32
/// </summary>
33
- IEnumerable<IExtensionData> ExtensionData { get; set; }
33
+ IReadOnlyCollection<IExtensionData> ExtensionData { get; set; }
34
35
/// <summary>
36
/// List of cultures to filter the localizations.
37
/// </summary>
38
- IEnumerable<string> FilterCultures { get; set; }
38
+ IReadOnlyCollection<string> FilterCultures { get; set; }
39
40
/// <summary>
41
/// Intermediate folder.
@@ -50,7 +50,7 @@ namespace WixToolset.Extensibility.Data
50
/// <summary>
51
/// Localizations used to resolve.
52
/// </summary>
53
- IEnumerable<Localization> Localizations { get; set; }
53
+ IReadOnlyCollection<Localization> Localizations { get; set; }
54
55
/// <summary>
56
/// Indicates whether to allow localization and bind variables to remain unresolved.
src/WixToolset.Extensibility/Data/IResolveFileResult.cs
+10
-2
@@ -4,11 +4,19 @@ namespace WixToolset.Extensibility.Data
4
{
5
using System.Collections.Generic;
6
7
-#pragma warning disable 1591 // TODO: add documentation
7
+ /// <summary>
8
+ /// Result of resolving a file.
9
+ /// </summary>
10
public interface IResolveFileResult
11
{
10
- IEnumerable<string> CheckedPaths { get; set; }
12
+ /// <summary>
13
+ /// Collection of paths checked to find file.
14
+ /// </summary>
15
+ IReadOnlyCollection<string> CheckedPaths { get; set; }
16
17
+ /// <summary>
18
+ /// Path to found file, if found.
19
+ /// </summary>
20
string Path { get; set; }
21
}
22
}
src/WixToolset.Extensibility/Data/IResolveResult.cs
+2
-2
@@ -28,12 +28,12 @@ namespace WixToolset.Extensibility.Data
28
/// <summary>
29
/// Fields still requiring resolution.
30
/// </summary>
31
- IEnumerable<IDelayedField> DelayedFields { get; set; }
31
+ IReadOnlyCollection<IDelayedField> DelayedFields { get; set; }
32
33
/// <summary>
34
/// Files to extract from embedded .wixlibs.
35
/// </summary>
36
- IEnumerable<IExpectedExtractFile> ExpectedEmbeddedFiles { get; set; }
36
+ IReadOnlyCollection<IExpectedExtractFile> ExpectedEmbeddedFiles { get; set; }
37
38
/// <summary>
39
/// Resolved intermediate.
src/WixToolset.Extensibility/IExtensionCommandLine.cs
+1
-1
@@ -15,7 +15,7 @@ namespace WixToolset.Extensibility
15
/// Gets the supported command line types for this extension.
16
/// </summary>
17
/// <value>The supported command line types for this extension.</value>
18
- IEnumerable<ExtensionCommandLineSwitch> CommandLineSwitches { get; }
18
+ IReadOnlyCollection<ExtensionCommandLineSwitch> CommandLineSwitches { get; }
19
20
/// <summary>
21
/// Called before the command-line is parsed.
src/WixToolset.Extensibility/IWindowsInstallerBackendBinderExtension.cs
+1
-1
@@ -16,7 +16,7 @@ namespace WixToolset.Extensibility
16
/// <summary>
17
/// Table definitions provided by the extension.
18
/// </summary>
19
- IEnumerable<TableDefinition> TableDefinitions { get; }
19
+ IReadOnlyCollection<TableDefinition> TableDefinitions { get; }
20
21
/// <summary>
22
/// Called before binding occurs.
src/WixToolset.Extensibility/Services/IBackendHelper.cs
+1
-1
@@ -72,7 +72,7 @@ namespace WixToolset.Extensibility.Services
72
/// </summary>
73
/// <param name="embeddedFiles">Embedded files to extract.</param>
74
/// <returns><c>ITrackedFile</c> for each embedded file extracted.</returns>
75
- IEnumerable<ITrackedFile> ExtractEmbeddedFiles(IEnumerable<IExpectedExtractFile> embeddedFiles);
75
+ IReadOnlyList<ITrackedFile> ExtractEmbeddedFiles(IEnumerable<IExpectedExtractFile> embeddedFiles);
76
77
/// <summary>
78
/// Generate an identifier by hashing data from the row.
src/WixToolset.Extensibility/Services/IExtensionManager.cs
+1
-1
@@ -37,6 +37,6 @@ namespace WixToolset.Extensibility.Services
37
/// </summary>
38
/// <typeparam name="T">Type of extension to get.</typeparam>
39
/// <returns>Extensions of the specified type.</returns>
40
- IEnumerable<T> GetServices<T>() where T : class;
40
+ IReadOnlyCollection<T> GetServices<T>() where T : class;
41
}
42
}