Skip to content

Commit f09cf22

Browse files
committed
Drop all params method parameters from public methods.
This doesn't allow for stricter setups, such as defaulting such parameters to null, then ensuring a non-null parameter is not empty either.
1 parent 8a06635 commit f09cf22

22 files changed

Lines changed: 11 additions & 11 deletions

src/PSADT/PSADT/ProcessManagement/RunningProcessInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public sealed record RunningProcessInfo
2424
/// <remarks>This method identifies running processes by comparing their names and command-line arguments against the provided process definitions. If a process definition includes a filter, only processes that satisfy the filter are included in the result. Processes that cannot be accessed due to insufficient privileges are skipped.</remarks>
2525
/// <param name="processDefinitions">An array of <see cref="ProcessDefinition"/> objects that define the processes to search for. Each definition specifies the name, optional description, and an optional filter to match processes.</param>
2626
/// <returns>A read-only list of <see cref="RunningProcessInfo"/> objects representing the processes that match the given definitions. The list is ordered by the description of the running processes.</returns>
27-
public static IReadOnlyList<RunningProcessInfo> Get(params IReadOnlyList<ProcessDefinition> processDefinitions)
27+
public static IReadOnlyList<RunningProcessInfo> Get(IReadOnlyList<ProcessDefinition> processDefinitions)
2828
{
2929
// Set up some caches for performance.
3030
if (!(processDefinitions?.Count > 0))

src/PSADT/PSADT/Utilities/ShellUtilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal static void RefreshDesktop()
3232
_ = NativeMethods.SendNotifyMessage(HWND.HWND_BROADCAST, WINDOW_MESSAGE.WM_SETTINGCHANGE, null, "TraySettings");
3333

3434
// Terminate the StartMenuExperienceHost to refresh the start menu. Windows restarts this process instantly.
35-
foreach (RunningProcessInfo runningProcessInfo in RunningProcessInfo.Get(new ProcessDefinition("StartMenuExperienceHost")))
35+
foreach (RunningProcessInfo runningProcessInfo in RunningProcessInfo.Get([new("StartMenuExperienceHost")]))
3636
{
3737
using Process process = runningProcessInfo.Process;
3838
process.Kill();

src/PSADT/PSADT/WindowsInstaller/MsiSummaryInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public sealed record MsiSummaryInfo
2424
/// information. If null, no transforms are applied.</param>
2525
/// <returns>An instance of MsiSummaryInfo containing the summary information extracted from the specified database, with
2626
/// any transforms applied.</returns>
27-
public static MsiSummaryInfo Get(string szDatabasePath, params IReadOnlyList<string>? szTransformFiles)
27+
public static MsiSummaryInfo Get(string szDatabasePath, IReadOnlyList<string>? szTransformFiles = null)
2828
{
2929
// Get the summary information from the given database, with any specified transform files applied.
3030
using MsiCloseHandleSafeHandle hSummaryInfo = MsiUtilities.GetSummaryInformation(szDatabasePath, szTransformFiles);

src/PSADT/PSADT/WindowsInstaller/MsiUtilities.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static class MsiUtilities
6161
/// <returns>A read-only dictionary containing the key-value pairs from the specified table and columns, or null if no
6262
/// properties are found.</returns>
6363
/// <exception cref="InvalidDataException">Thrown if the specified table or column indices are not found in the database.</exception>
64-
public static IReadOnlyDictionary<string, string>? GetMsiTableDictionary(string szDatabasePath, string table, int keyColumn, int valueColumn, params IReadOnlyList<string>? szTransformFiles)
64+
public static IReadOnlyDictionary<string, string>? GetMsiTableDictionary(string szDatabasePath, string table, int keyColumn, int valueColumn, IReadOnlyList<string>? szTransformFiles = null)
6565
{
6666
// Open the database, factoring in any transforms provided, then confirm the caller input is valid.
6767
using MsiCloseHandleSafeHandle hDatabase = OpenDatabase(szDatabasePath, szTransformFiles);
@@ -112,7 +112,7 @@ public static class MsiUtilities
112112
/// <returns>A read-only list of strings containing the values from the specified column in the specified table. The list
113113
/// will be empty if the table contains no rows.</returns>
114114
/// <exception cref="InvalidDataException">Thrown if the specified table or column does not exist in the database.</exception>
115-
public static IReadOnlyList<string> GetMsiTableColumnValues(string szDatabasePath, string table, int column, params IReadOnlyList<string>? szTransformFiles)
115+
public static IReadOnlyList<string> GetMsiTableColumnValues(string szDatabasePath, string table, int column, IReadOnlyList<string>? szTransformFiles = null)
116116
{
117117
// Open the database, factoring in any transforms provided, then confirm the caller input is valid.
118118
using MsiCloseHandleSafeHandle hDatabase = OpenDatabase(szDatabasePath, szTransformFiles);
@@ -220,7 +220,7 @@ public static void CreatePropertyTransformFile(string msiPath, string newTransfo
220220
using MsiCloseHandleSafeHandle hDatabaseOrig = OpenDatabase(msiPath, MSI_PERSISTENCE_MODE.MSIDBOPEN_READONLY);
221221

222222
// Open temp in transact mode so we can modify + commit.
223-
using (MsiCloseHandleSafeHandle hDatabaseTemp = !string.IsNullOrWhiteSpace(applyTransformPath) ? OpenDatabase(tempMsiPath, MSI_PERSISTENCE_MODE.MSIDBOPEN_TRANSACT, applyTransformPath!) : OpenDatabase(tempMsiPath, MSI_PERSISTENCE_MODE.MSIDBOPEN_TRANSACT))
223+
using (MsiCloseHandleSafeHandle hDatabaseTemp = !string.IsNullOrWhiteSpace(applyTransformPath) ? OpenDatabase(tempMsiPath, MSI_PERSISTENCE_MODE.MSIDBOPEN_TRANSACT, [applyTransformPath!]) : OpenDatabase(tempMsiPath, MSI_PERSISTENCE_MODE.MSIDBOPEN_TRANSACT))
224224
{
225225
// One view, executed once, then assign repeatedly. No string interpolation of keys/values; we use records.
226226
_ = NativeMethods.MsiDatabaseOpenView(hDatabaseTemp, "SELECT `Property`,`Value` FROM `Property`", out MsiCloseHandleSafeHandle hView);
@@ -472,7 +472,7 @@ static byte ReadByteFromSwappedPair(ReadOnlySpan<char> s32, int p)
472472
/// <param name="szTransformFiles">An optional collection of transformation file paths to apply to the database. Transforms cannot be applied
473473
/// to patch files.</param>
474474
/// <returns>A handle to the opened database. This handle must be disposed of when no longer needed.</returns>
475-
internal static MsiCloseHandleSafeHandle OpenDatabase(string szDatabasePath, MSI_PERSISTENCE_MODE? szPersist = null, params IReadOnlyList<string>? szTransformFiles)
475+
internal static MsiCloseHandleSafeHandle OpenDatabase(string szDatabasePath, MSI_PERSISTENCE_MODE? szPersist = null, IReadOnlyList<string>? szTransformFiles = null)
476476
{
477477
// Open the msi/msp as a database.
478478
bool isPatchFile = Path.GetExtension(szDatabasePath).Equals(".msp", StringComparison.OrdinalIgnoreCase);
@@ -520,7 +520,7 @@ internal static MsiCloseHandleSafeHandle OpenDatabase(string szDatabasePath, MSI
520520
/// valid and accessible. May be null.</param>
521521
/// <returns>A safe handle representing the opened database. The caller is responsible for closing the handle to release
522522
/// resources.</returns>
523-
internal static MsiCloseHandleSafeHandle OpenDatabase(string szDatabasePath, params IReadOnlyList<string>? szTransformFiles)
523+
internal static MsiCloseHandleSafeHandle OpenDatabase(string szDatabasePath, IReadOnlyList<string>? szTransformFiles = null)
524524
{
525525
return OpenDatabase(szDatabasePath, null, szTransformFiles);
526526
}
@@ -537,7 +537,7 @@ internal static MsiCloseHandleSafeHandle OpenDatabase(string szDatabasePath, par
537537
/// information. If null, no transforms are applied.</param>
538538
/// <returns>A safe handle to the summary information stream of the specified database. The caller is responsible for
539539
/// disposing of the handle when it is no longer needed.</returns>
540-
internal static MsiCloseHandleSafeHandle GetSummaryInformation(string szDatabasePath, params IReadOnlyList<string>? szTransformFiles)
540+
internal static MsiCloseHandleSafeHandle GetSummaryInformation(string szDatabasePath, IReadOnlyList<string>? szTransformFiles = null)
541541
{
542542
using MsiCloseHandleSafeHandle hDatabase = OpenDatabase(szDatabasePath, szTransformFiles);
543543
_ = NativeMethods.MsiGetSummaryInformation(hDatabase, 0, out MsiCloseHandleSafeHandle hSummaryInfo);

src/PSADT/PSAppDeployToolkit/Foundation/DeploymentSession.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public DeploymentSession(IReadOnlyDictionary<string, object>? parameters = null,
389389
// Generate list of MSI executables for use with Show-ADTInstallationWelcome.
390390
if (!Settings.HasFlag(DeploymentSettings.DisableDefaultMsiProcessList))
391391
{
392-
ProcessDefinition[] msiExecList = [.. (!string.IsNullOrWhiteSpace(DefaultMstFile) ? MsiUtilities.GetMsiTableColumnValues(DefaultMsiFile!, "File", 3, DefaultMstFile!) : MsiUtilities.GetMsiTableColumnValues(DefaultMsiFile!, "File", 3)).Where(static p => p.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)).Select(static p => new ProcessDefinition(Path.GetFileNameWithoutExtension(p.Split(['|'], StringSplitOptions.RemoveEmptyEntries).Last())))];
392+
ProcessDefinition[] msiExecList = [.. (!string.IsNullOrWhiteSpace(DefaultMstFile) ? MsiUtilities.GetMsiTableColumnValues(DefaultMsiFile!, "File", 3, [DefaultMstFile!]) : MsiUtilities.GetMsiTableColumnValues(DefaultMsiFile!, "File", 3)).Where(static p => p.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)).Select(static p => new ProcessDefinition(Path.GetFileNameWithoutExtension(p.Split(['|'], StringSplitOptions.RemoveEmptyEntries).Last())))];
393393
if (msiExecList.Length > 0)
394394
{
395395
AppProcessesToClose = new ReadOnlyCollection<ProcessDefinition>([.. AppProcessesToClose.Concat(msiExecList).GroupBy(static p => p.Name, StringComparer.OrdinalIgnoreCase).Select(static g => g.First())]);
@@ -398,7 +398,7 @@ public DeploymentSession(IReadOnlyDictionary<string, object>? parameters = null,
398398
}
399399

400400
// Update our app variables with new values.
401-
IReadOnlyDictionary<string, string> msiProps = (!string.IsNullOrWhiteSpace(DefaultMstFile) ? MsiUtilities.GetMsiTableDictionary(DefaultMsiFile!, "Property", 1, 2, DefaultMstFile!) : MsiUtilities.GetMsiTableDictionary(DefaultMsiFile!, "Property", 1, 2))!;
401+
IReadOnlyDictionary<string, string> msiProps = (!string.IsNullOrWhiteSpace(DefaultMstFile) ? MsiUtilities.GetMsiTableDictionary(DefaultMsiFile!, "Property", 1, 2, [DefaultMstFile!]) : MsiUtilities.GetMsiTableDictionary(DefaultMsiFile!, "Property", 1, 2))!;
402402
if (string.IsNullOrWhiteSpace(AppVendor))
403403
{
404404
AppVendor = msiProps["Manufacturer"];
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)