Skip to content

Commit

Permalink
Use new C# syntax for arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Fs00 committed Mar 1, 2024
1 parent 7c24aac commit 2922371
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 33 deletions.
16 changes: 8 additions & 8 deletions src/AppConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ private void WriteToFile()
}

public static readonly AppConfiguration Default = new() {
ServicesToRemove = new[] {
ServicesToRemove = [
"dmwappushservice",
"RetailDemo",
"TroubleshootingSvc"
},
UWPAppsToRemove = new[] {
],
UWPAppsToRemove = [
UwpAppGroup.Bing,
UwpAppGroup.Cortana,
UwpAppGroup.CommunicationsApps,
Expand All @@ -77,16 +77,16 @@ private void WriteToFile()
UwpAppGroup.SolitaireCollection,
UwpAppGroup.Skype,
UwpAppGroup.Zune
},
WindowsFeaturesToRemove = new[] {
],
WindowsFeaturesToRemove = [
"App.StepsRecorder",
"App.Support.QuickAssist",
"App.WirelessDisplay.Connect",
"Browser.InternetExplorer",
"Hello.Face",
"MathRecognizer"
},
ScheduledTasksToDisable = new[] {
],
ScheduledTasksToDisable = [
@"\Microsoft\Windows\ApplicationData\DsSvcCleanup",
@"\Microsoft\Windows\CloudExperienceHost\CreateObjectTask",
@"\Microsoft\Windows\DiskFootprint\Diagnostics",
Expand All @@ -102,7 +102,7 @@ private void WriteToFile()
@"\Microsoft\Windows\Subscription\LicenseAcquisition",
@"\Microsoft\Windows\Diagnosis\Scheduled",
@"\Microsoft\Windows\Diagnosis\RecommendedTroubleshootingScanner"
},
],
UWPAppsRemovalMode = UwpAppRemovalMode.AllUsers
};
}
Expand Down
8 changes: 4 additions & 4 deletions src/Operations/DefenderDisabler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ namespace Win10BloatRemover.Operations;

public class DefenderDisabler : IOperation
{
private static readonly string[] defenderServices = {
private static readonly string[] defenderServices = [
"wscsvc",
"Sense",
"SgrmBroker",
"SgrmAgent"
};
];

private static readonly string[] defenderScheduledTasks = {
private static readonly string[] defenderScheduledTasks = [
@"\Microsoft\Windows\Windows Defender\Windows Defender Cache Maintenance",
@"\Microsoft\Windows\Windows Defender\Windows Defender Cleanup",
@"\Microsoft\Windows\Windows Defender\Windows Defender Scheduled Scan",
@"\Microsoft\Windows\Windows Defender\Windows Defender Verification"
};
];

private readonly IUserInterface ui;
private readonly ServiceRemover serviceRemover;
Expand Down
6 changes: 3 additions & 3 deletions src/Operations/ErrorReportingDisabler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace Win10BloatRemover.Operations;

public class ErrorReportingDisabler : IOperation
{
private static readonly string[] errorReportingServices = { "WerSvc", "wercplsupport" };
private static readonly string[] errorReportingScheduledTasks = {
private static readonly string[] errorReportingServices = ["WerSvc", "wercplsupport"];
private static readonly string[] errorReportingScheduledTasks = [
@"\Microsoft\Windows\Windows Error Reporting\QueueReporting"
};
];

private readonly IUserInterface ui;
private readonly ServiceRemover serviceRemover;
Expand Down
2 changes: 1 addition & 1 deletion src/Operations/FeaturesRemover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void TryRemoveCapability(DismCapability capability, DismClient dismClien
dismClient.RemoveCapability(capability.Name);

if (capability.Name.StartsWith("Hello.Face"))
new ScheduledTasksDisabler(new[] { @"\Microsoft\Windows\HelloFace\FODCleanupTask" }, ui).Run();
new ScheduledTasksDisabler([@"\Microsoft\Windows\HelloFace\FODCleanupTask"], ui).Run();
}
catch (Exception exc)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Operations/PrivacySettingsTweaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace Win10BloatRemover.Operations;

public class PrivacySettingsTweaker : IOperation
{
private static readonly string[] appPermissionsToDeny = {
private static readonly string[] appPermissionsToDeny = [
"location",
"documentsLibrary",
"userDataTasks",
"appDiagnostics",
"userAccountInformation"
};
];

private readonly IUserInterface ui;
public PrivacySettingsTweaker(IUserInterface ui) => this.ui = ui;
Expand Down
4 changes: 2 additions & 2 deletions src/Operations/SuggestionsDisabler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ private void DisableFeedbackRequests()
"DoNotShowFeedbackNotifications", 1);
RegistryUtils.SetForCurrentAndDefaultUser(@"SOFTWARE\Microsoft\Siuf\Rules", "NumberOfSIUFInPeriod", 0);

new ScheduledTasksDisabler(new[] {
new ScheduledTasksDisabler([
@"\Microsoft\Windows\Feedback\Siuf\DmClient",
@"\Microsoft\Windows\Feedback\Siuf\DmClientOnScenarioDownload"
}, ui).Run();
], ui).Run();
}
}
12 changes: 6 additions & 6 deletions src/Operations/TelemetryDisabler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ namespace Win10BloatRemover.Operations;

public class TelemetryDisabler : IOperation
{
private static readonly string[] telemetryServices = {
private static readonly string[] telemetryServices = [
"DiagTrack",
"diagsvc",
"diagnosticshub.standardcollector.service",
"PcaSvc"
};
];

private static readonly string[] protectedTelemetryServices = {
private static readonly string[] protectedTelemetryServices = [
"DPS",
"WdiSystemHost",
"WdiServiceHost"
};
];

private static readonly string[] telemetryScheduledTasks = {
private static readonly string[] telemetryScheduledTasks = [
@"\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser",
@"\Microsoft\Windows\Application Experience\PcaPatchDbTask",
@"\Microsoft\Windows\Application Experience\ProgramDataUpdater",
Expand All @@ -32,7 +32,7 @@ public class TelemetryDisabler : IOperation
@"\Microsoft\Windows\Device Information\Device User",
@"\Microsoft\Windows\NetTrace\GatherNetworkInfo",
@"\Microsoft\Windows\PI\Sqm-Tasks"
};
];

private readonly IUserInterface ui;
private readonly ServiceRemover serviceRemover;
Expand Down
4 changes: 2 additions & 2 deletions src/Operations/UwpAppGroupRemover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private void RestoreWindowsPhotoViewer()
);
Registry.SetValue(@"HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\DropTarget", "Clsid", PHOTO_VIEWER_CLSID);

string[] imageTypes = { "Paint.Picture", "giffile", "jpegfile", "pngfile" };
string[] imageTypes = ["Paint.Picture", "giffile", "jpegfile", "pngfile"];
foreach (string type in imageTypes)
{
Registry.SetValue(
Expand All @@ -262,7 +262,7 @@ private void RestoreWindowsPhotoViewer()

private void RemoveOneSyncServiceFeature()
{
var featuresRemover = new FeaturesRemover(new[] { "OneCoreUAP.OneSync" }, ui);
var featuresRemover = new FeaturesRemover(["OneCoreUAP.OneSync"], ui);
featuresRemover.Run();
rebootFlag.UpdateIfNeeded(featuresRemover.IsRebootRecommended);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private static void Main(string[] args)

private static MenuEntry[] CreateMenuEntries(AppConfiguration configuration, RebootRecommendedFlag rebootFlag)
{
return new MenuEntry[] {
return [
new UWPAppRemovalEntry(configuration),
new EdgeRemovalEntry(),
new OneDriveRemovalEntry(),
Expand All @@ -48,7 +48,7 @@ private static MenuEntry[] CreateMenuEntries(AppConfiguration configuration, Reb
new NewGitHubIssueEntry(),
new AboutEntry(),
new QuitEntry(rebootFlag)
};
];
}

private static bool HasAdministratorRights()
Expand Down
4 changes: 1 addition & 3 deletions src/Utils/TokenPrivilege.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ private struct TokenPrivileges
public TokenPrivileges(Luid luid, uint attributes)
{
Count = 1;
Privileges = new[] {
new LuidAndAttributes(luid, attributes)
};
Privileges = [new LuidAndAttributes(luid, attributes)];
}

private uint Count;
Expand Down

0 comments on commit 2922371

Please sign in to comment.