Skip to content

Commit

Permalink
Aligned folder structure with namespaces (#523)
Browse files Browse the repository at this point in the history
This PR aligns namespaces with folder structures.
Removes 2 unused methods.
Applies minor code modernizations.
  • Loading branch information
HotCakeX authored Jan 13, 2025
1 parent d2d773a commit 5ef16ae
Show file tree
Hide file tree
Showing 138 changed files with 218 additions and 292 deletions.
6 changes: 6 additions & 0 deletions AppControl Manager/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1096,3 +1096,9 @@ dotnet_diagnostic.CA1002.severity = error

# CA1034: Nested types should not be visible
dotnet_diagnostic.CA1034.severity = error

# IDE0130: Namespace does not match folder structure
dotnet_diagnostic.IDE0130.severity = error

# IDE0320: Make anonymous function static
dotnet_diagnostic.IDE0320.severity = error
5 changes: 3 additions & 2 deletions AppControl Manager/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using AppControlManager.Logging;
using AppControlManager.AppSettings;
using AppControlManager.Others;
using CommunityToolkit.WinUI;
using Microsoft.UI;
using Microsoft.UI.Xaml;
Expand Down Expand Up @@ -57,7 +58,7 @@ public App()
#region

// Check for the SoundSetting in the local settings
bool soundSetting = AppSettings.GetSetting<bool>(AppSettings.SettingKeys.SoundSetting);
bool soundSetting = AppSettingsCls.GetSetting<bool>(AppSettingsCls.SettingKeys.SoundSetting);

if (soundSetting)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Windows.Storage;

namespace AppControlManager;
namespace AppControlManager.AppSettings;

// https://learn.microsoft.com/en-us/uwp/api/windows.storage.applicationdata.localsettings

internal static class AppSettings
internal static class AppSettingsCls
{
/// <summary>
/// Save setting to local storage with a specific key and value
Expand Down
2 changes: 1 addition & 1 deletion AppControl Manager/AppSettings/AppThemeManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace AppControlManager;
namespace AppControlManager.AppSettings;

// Custom EventArgs class for app theme changes
internal sealed class AppThemeChangedEventArgs(string? newTheme) : EventArgs
Expand Down
2 changes: 1 addition & 1 deletion AppControl Manager/AppSettings/IconsStyleManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace AppControlManager;
namespace AppControlManager.AppSettings;

// Custom EventArgs class for Icons Style changes
internal sealed class IconsStyleChangedEventArgs(string? newIconsStyle) : EventArgs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace AppControlManager;
namespace AppControlManager.AppSettings;

// Custom EventArgs class for navigation background changes
internal sealed class NavigationBackgroundChangedEventArgs(bool isBackgroundOn) : EventArgs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace AppControlManager;
namespace AppControlManager.AppSettings;

// Custom EventArgs class for navigation view location changes
internal sealed class NavigationViewLocationChangedEventArgs(string newLocation) : EventArgs
Expand Down
2 changes: 1 addition & 1 deletion AppControl Manager/AppSettings/SoundManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace AppControlManager;
namespace AppControlManager.AppSettings;

// Custom EventArgs class for sound setting changes
internal sealed class SoundSettingChangedEventArgs(bool isSoundOn) : EventArgs
Expand Down
2 changes: 1 addition & 1 deletion AppControl Manager/AppSettings/ThemeManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace AppControlManager;
namespace AppControlManager.AppSettings;

// Custom EventArgs class for the event
internal sealed class BackgroundChangedEventArgs(string? newBackground) : EventArgs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using AppControlManager.Logic.IntelGathering;
using AppControlManager.IntelGathering;
using AppControlManager.Main;
using AppControlManager.Others;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using AppControlManager.Logic.IntelGathering;
using AppControlManager.IntelGathering;
using AppControlManager.Main;
using AppControlManager.Others;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using AppControlManager.Others;

namespace AppControlManager;
namespace AppControlManager.IntelGathering;

internal static class CertCNFetcher
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using AppControlManager.Logging;
using AppControlManager.Others;

namespace AppControlManager.IntelGathering;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using AppControlManager.Logging;
using AppControlManager.Others;

namespace AppControlManager.IntelGathering;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using AppControlManager.Logging;
using AppControlManager.Others;

namespace AppControlManager.IntelGathering;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Linq;
using System.Threading.Tasks;
using System.Xml;
using AppControlManager.Logging;
using AppControlManager.Others;

namespace AppControlManager.IntelGathering;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using AppControlManager.Logging;
using AppControlManager.Others;
using AppControlManager.SiPolicy;

namespace AppControlManager.Logic.IntelGathering;
namespace AppControlManager.IntelGathering;

internal static class CertificatePresence
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using AppControlManager.Logging;
using AppControlManager.Others;

#pragma warning disable CS0649

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
using AppControlManager.Logging;
using AppControlManager.Main;
using AppControlManager.Others;
using AppControlManager.SimulationMethods;
using Microsoft.UI.Xaml.Controls;

namespace AppControlManager.IntelGathering;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.IO;
using AppControlManager.Logging;
using AppControlManager.Others;
using AppControlManager.XMLOps;

namespace AppControlManager.IntelGathering;
Expand Down

This file was deleted.

19 changes: 0 additions & 19 deletions AppControl Manager/Logic/Types And Definitions/FileAttribX.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using AppControlManager.Logging;
using AppControlManager.Others;
using AppControlManager.SimulationMethods;
using AppControlManager.XMLOps;
using Microsoft.UI.Xaml.Controls;

namespace AppControlManager;
namespace AppControlManager.Main;

internal static class AppControlSimulation
{
Expand All @@ -29,7 +30,7 @@ internal static class AppControlSimulation
internal static bool Invoke(List<string>? filePaths, string xmlFilePath, bool noCatalogScanning)
{
// Call the main method to get the verdicts
ConcurrentDictionary<string, SimulationOutput> Results = (Invoke(filePaths, null, xmlFilePath, noCatalogScanning, false, null, 2));
ConcurrentDictionary<string, SimulationOutput> Results = Invoke(filePaths, null, xmlFilePath, noCatalogScanning, false, null, 2);

// See if there are any unauthorized files
IEnumerable<SimulationOutput> ResultsAfterFilter = Results.Values.Where(R => !R.IsAuthorized);
Expand Down Expand Up @@ -249,7 +250,7 @@ internal static ConcurrentDictionary<string, SimulationOutput> Invoke(
double AllFilesCount = CollectedFiles.Count;

// split the file paths by ThreadsCount which by default is 2 and minimum 1
IEnumerable<FileInfo[]> SplitArrays = Enumerable.Chunk(CollectedFiles, (int)Math.Ceiling(AllFilesCount / threadsCount));
IEnumerable<FileInfo[]> SplitArrays = CollectedFiles.Chunk((int)Math.Ceiling(AllFilesCount / threadsCount));

// List of tasks to run in parallel
List<Task> tasks = [];
Expand All @@ -273,7 +274,7 @@ internal static ConcurrentDictionary<string, SimulationOutput> Invoke(
// Update progress bar safely on the UI thread
_ = UIProgressBar.DispatcherQueue.TryEnqueue(() =>
{
double progressPercentage = (processedFilesCount / AllFilesCount) * 100;
double progressPercentage = processedFilesCount / AllFilesCount * 100;

UIProgressBar.Value = Math.Min(progressPercentage, 100);
});
Expand Down Expand Up @@ -310,8 +311,8 @@ internal static ConcurrentDictionary<string, SimulationOutput> Invoke(
continue;
}

String CurrentFilePathHashSHA256;
String CurrentFilePathHashSHA1;
string CurrentFilePathHashSHA256;
string CurrentFilePathHashSHA1;

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Xml;
using AppControlManager.Logging;
using AppControlManager.Logic;
using AppControlManager.Others;
using AppControlManager.XMLOps;

namespace AppControlManager;
namespace AppControlManager.Main;

internal static partial class BasePolicyCreator
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Runtime.InteropServices;
using AppControlManager.Others;

namespace AppControlManager;
namespace AppControlManager.Main;

internal sealed class SecurePolicySetting(object? Value, WLDP_SECURE_SETTING_VALUE_TYPE ValueType, uint ValueSize, bool Status, int StatusCode)
{
Expand Down
Loading

0 comments on commit 5ef16ae

Please sign in to comment.