Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Rans4ckeR committed Dec 26, 2023
1 parent 9bd5608 commit b54775b
Show file tree
Hide file tree
Showing 84 changed files with 171 additions and 342 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1380,3 +1380,4 @@ csharp_style_prefer_switch_expression = true:warning
csharp_style_prefer_pattern_matching = true:warning
csharp_style_prefer_not_pattern = true:warning
csharp_style_prefer_extended_property_pattern = true:warning
dotnet_diagnostic.SA1010.severity = warning
16 changes: 5 additions & 11 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@main
with:
dotnet-version: '7.x.x'
dotnet-version: '8.x.x'
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@main
with:
Expand All @@ -32,17 +32,11 @@ jobs:
dotnet publish CipherPunk.UI/CipherPunk.UI.csproj --configuration Release --no-self-contained --framework net7.0-windows --runtime win-arm64 -p:PublishReadyToRun=true -p:PublishReadyToRunComposite=true -p:PublishSingleFile=true -p:DebugType=embedded -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
- name: Zip
run: |
7z a -r ${{ format('CipherPunk-v{0}-net7.0-windows-x86.zip', env.GitVersion_SemVer) }} ./CipherPunk.UI/bin/Release/net7.0-windows/win-x86/publish/*.*
7z a -r ${{ format('CipherPunk-v{0}-net7.0-windows-x64.zip', env.GitVersion_SemVer) }} ./CipherPunk.UI/bin/Release/net7.0-windows/win-x64/publish/*.*
7z a -r ${{ format('CipherPunk-v{0}-net7.0-windows-ARM64.zip', env.GitVersion_SemVer) }} ./CipherPunk.UI/bin/Release/net7.0-windows/win-arm64/publish/*.*
- name: Prerelease
if: ${{ env.GitVersion_PreReleaseTag != '' }}
run: gh release create ${{ format('v{0}', env.GitVersion_SemVer) }} (get-item *.zip) --generate-notes --target ${{ github.sha }} --prerelease
env:
GH_TOKEN: ${{ github.token }}
7z a -r "${{ format('CipherPunk-v{0}-net7.0-windows-x86.zip', env.GitVersion_SemVer) }}" "./CipherPunk.UI/bin/Release/net7.0-windows/win-x86/publish/*.*" "-x!*.xml"
7z a -r "${{ format('CipherPunk-v{0}-net7.0-windows-x64.zip', env.GitVersion_SemVer) }}" "./CipherPunk.UI/bin/Release/net7.0-windows/win-x64/publish" "-x!*.xml"
7z a -r "${{ format('CipherPunk-v{0}-net7.0-windows-ARM64.zip', env.GitVersion_SemVer) }}" "./CipherPunk.UI/bin/Release/net7.0-windows/win-arm64/publish/*.*" "-x!*.xml"
- name: Release
if: ${{ env.GitVersion_PreReleaseTag == '' }}
run: gh release create ${{ format('v{0}', env.GitVersion_SemVer) }} (get-item *.zip) --generate-notes --target ${{ github.sha }}
run: gh release create v${{ env.GitVersion_SemVer }} (get-item *.zip) --generate-notes --target ${{ github.sha }} ${{ env.PreReleaseTag != '' && '--prerelease' || '' }}
env:
GH_TOKEN: ${{ github.token }}
- name: Package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<AnalysisLevel>preview-all</AnalysisLevel>
<LangVersion>preview</LangVersion>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.0.0.1</Version>
Expand All @@ -24,10 +25,10 @@
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
</ItemGroup>
</Project>
4 changes: 1 addition & 3 deletions CipherPunk.UI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ private static void PreventWpfFlashBang(Window window)
}

private static void SetUiCulture()
{
FrameworkElement.LanguageProperty.OverrideMetadata(
=> FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
}

private void AppDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
Expand Down
8 changes: 4 additions & 4 deletions CipherPunk.UI/CipherPunk.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
<AnalysisLevel>preview-all</AnalysisLevel>
<LangVersion>preview</LangVersion>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
<Version>0.0.0.1</Version>
<FileVersion>0.0.0.1</FileVersion>
<InformationalVersion>0.0.0.1</InformationalVersion>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<Platforms>x86;x64;ARM64</Platforms>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -38,15 +38,15 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="55.0.45-preview">
<PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="56.0.13-preview">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.WDK.Win32Metadata" Version="0.9.9-experimental">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
15 changes: 3 additions & 12 deletions CipherPunk.UI/Infrastructure/BaseViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ protected BaseViewModel(ILogger logger)
DefaultCommand = new AsyncRelayCommand<bool?>(ExecuteDefaultCommandAsync, _ => CanExecuteDefaultCommand);
PropertyChanged += BaseViewModelPropertyChanged;

StrongReferenceMessenger.Default.Register<PropertyChangedMessage<bool>>(this, (r, m) =>
{
((BaseViewModel)r).Receive(m);
});
StrongReferenceMessenger.Default.Register<PropertyChangedMessage<bool>>(this, (r, m) => ((BaseViewModel)r).Receive(m));
}

public IAsyncRelayCommand DefaultCommand { get; }
Expand Down Expand Up @@ -67,15 +64,9 @@ protected virtual void BaseViewModelPropertyChanged(object? sender, PropertyChan
}
}

protected virtual bool GetCanExecuteDefaultCommand()
{
return !DefaultCommandActive;
}
protected virtual bool GetCanExecuteDefaultCommand() => !DefaultCommandActive;

protected void UpdateCanExecuteDefaultCommand()
{
CanExecuteDefaultCommand = GetCanExecuteDefaultCommand();
}
protected void UpdateCanExecuteDefaultCommand() => CanExecuteDefaultCommand = GetCanExecuteDefaultCommand();

private async Task ExecuteDefaultCommandAsync(bool? showView, CancellationToken cancellationToken)
{
Expand Down
5 changes: 1 addition & 4 deletions CipherPunk.UI/Infrastructure/ExceptionMessageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

public static class ExceptionMessageBuilder
{
public static string GetDetailedExceptionInfo(this Exception ex)
{
return new StringBuilder().GetExceptionInfo(ex).ToString();
}
public static string GetDetailedExceptionInfo(this Exception ex) => new StringBuilder().GetExceptionInfo(ex).ToString();

private static StringBuilder GetExceptionInfo(this StringBuilder sb, Exception ex)
{
Expand Down
5 changes: 1 addition & 4 deletions CipherPunk.UI/Infrastructure/NoScrollDataGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

internal sealed class NoScrollDataGrid : DataGrid
{
public NoScrollDataGrid()
{
PreviewMouseWheel += OnPreviewMouseWheel;
}
public NoScrollDataGrid() => PreviewMouseWheel += OnPreviewMouseWheel;

private static void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
Expand Down
21 changes: 6 additions & 15 deletions CipherPunk.UI/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,8 @@ public MainWindowViewModel(
CopyMessageCommand = new RelayCommand(ExecuteCopyMessageCommand);
CloseMessageCommand = new RelayCommand(ExecuteCloseMessageCommand);

StrongReferenceMessenger.Default.Register<UserMessageValueChangedMessage>(this, (r, m) =>
{
((MainWindowViewModel)r).UserMessage = m.Value.Message;
});
StrongReferenceMessenger.Default.Register<ActiveViewValueChangedMessage>(this, (r, m) =>
{
((MainWindowViewModel)r).ActiveView = m.Value;
});
StrongReferenceMessenger.Default.Register<UserMessageValueChangedMessage>(this, (r, m) => ((MainWindowViewModel)r).UserMessage = m.Value.Message);
StrongReferenceMessenger.Default.Register<ActiveViewValueChangedMessage>(this, (r, m) => ((MainWindowViewModel)r).ActiveView = m.Value);
UpdateCanExecuteDefaultCommand();
}

Expand Down Expand Up @@ -81,17 +75,17 @@ public MainWindowViewModel(

public double MainContentOpacity
{
get => mainContentOpacity; set { _ = SetProperty(ref mainContentOpacity, value); }
get => mainContentOpacity; set => _ = SetProperty(ref mainContentOpacity, value);
}

public bool MainContentIsHitTestVisible
{
get => mainContentIsHitTestVisible; set { _ = SetProperty(ref mainContentIsHitTestVisible, value); }
get => mainContentIsHitTestVisible; set => _ = SetProperty(ref mainContentIsHitTestVisible, value);
}

public int MessageZIndex
{
get => messageZIndex; set { _ = SetProperty(ref messageZIndex, value); }
get => messageZIndex; set => _ = SetProperty(ref messageZIndex, value);
}

public string? UserMessage
Expand Down Expand Up @@ -138,8 +132,5 @@ private void ExecuteCopyMessageCommand()
Clipboard.Clear();
}

private void ExecuteCloseMessageCommand()
{
UserMessage = null;
}
private void ExecuteCloseMessageCommand() => UserMessage = null;
}
2 changes: 1 addition & 1 deletion CipherPunk.UI/Messaging/ActiveViewValueChangedMessage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace CipherPunk.UI;
namespace CipherPunk.UI;

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging.Messages;
Expand Down
2 changes: 1 addition & 1 deletion CipherPunk.UI/Messaging/UserInterfaceLogService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace CipherPunk.UI;
namespace CipherPunk.UI;

using CommunityToolkit.Mvvm.Messaging;

Expand Down
2 changes: 1 addition & 1 deletion CipherPunk.UI/Messaging/UserMessage.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace CipherPunk.UI;
namespace CipherPunk.UI;

internal readonly record struct UserMessage(string Message);
2 changes: 1 addition & 1 deletion CipherPunk.UI/Messaging/UserMessageValueChangedMessage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace CipherPunk.UI;
namespace CipherPunk.UI;

using CommunityToolkit.Mvvm.Messaging.Messages;

Expand Down
2 changes: 1 addition & 1 deletion CipherPunk.UI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using System.Windows;
using System.Windows;

[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
2 changes: 1 addition & 1 deletion CipherPunk.UI/Properties/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma warning disable IDE0065 // Misplaced using directive
#pragma warning disable IDE0065 // Misplaced using directive
#pragma warning disable SA1200 // Using directives should be placed correctly
global using CipherPunk;
global using Microsoft.Extensions.Logging;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@

internal sealed partial class CipherSuitesGroupPolicySettingsView
{
public CipherSuitesGroupPolicySettingsView()
{
InitializeComponent();
}
public CipherSuitesGroupPolicySettingsView() => InitializeComponent();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ internal sealed class CipherSuitesGroupPolicySettingsViewModel : BaseViewModel
private readonly IUacIconService uacIconService;
private readonly ICipherSuiteInfoApiService cipherSuiteInfoApiService;
private readonly IGroupPolicyService groupPolicyService;
private readonly List<CipherSuite?> onlineCipherSuiteInfos = new();
private readonly List<CipherSuite?> onlineCipherSuiteInfos = [];
private ObservableCollection<UiWindowsDocumentationCipherSuiteConfiguration>? activeGroupPolicyCipherSuiteConfigurations;
private ObservableCollection<UiWindowsDocumentationCipherSuiteConfiguration>? defaultGroupPolicyCipherSuiteConfigurations;
private BitmapSource? uacIcon;
private bool fetchOnlineInfo = true;
private string? adminMessage;

public CipherSuitesGroupPolicySettingsViewModel(ILogger logger, ICipherSuiteService cipherSuiteService, IUacIconService uacIconService, ICipherSuiteInfoApiService cipherSuiteInfoApiService, IGroupPolicyService groupPolicyService)
public CipherSuitesGroupPolicySettingsViewModel(
ILogger logger, ICipherSuiteService cipherSuiteService, IUacIconService uacIconService, ICipherSuiteInfoApiService cipherSuiteInfoApiService, IGroupPolicyService groupPolicyService)
: base(logger)
{
this.cipherSuiteService = cipherSuiteService;
Expand All @@ -35,10 +36,7 @@ public string? AdminMessage
private set => _ = SetProperty(ref adminMessage, value);
}

public BitmapSource UacIcon
{
get => uacIcon ??= uacIconService.GetUacShieldIcon();
}
public BitmapSource UacIcon => uacIcon ??= uacIconService.GetUacShieldIcon();

public bool FetchOnlineInfo
{
Expand All @@ -61,7 +59,7 @@ public ObservableCollection<UiWindowsDocumentationCipherSuiteConfiguration>? Def
protected override async Task DoExecuteDefaultCommandAsync(CancellationToken cancellationToken)
{
string[] windowsDefaultGroupPolicyCipherSuiteConfigurationsStrings = await groupPolicyService.GetSslCipherSuiteOrderPolicyWindowsDefaultsAsync(cancellationToken);
string[] windowsActiveGroupPolicyCipherSuiteConfigurationsStrings = Array.Empty<string>();
string[] windowsActiveGroupPolicyCipherSuiteConfigurationsStrings = [];

AdminMessage = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@

internal sealed partial class CipherSuitesOsSettingsView
{
public CipherSuitesOsSettingsView()
{
InitializeComponent();
}
public CipherSuitesOsSettingsView() => InitializeComponent();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal sealed class CipherSuitesOsSettingsViewModel : BaseViewModel
private readonly ICipherSuiteService cipherSuiteService;
private readonly IUacIconService uacIconService;
private readonly ICipherSuiteInfoApiService cipherSuiteInfoApiService;
private readonly List<CipherSuite?> onlineCipherSuiteInfos = new();
private readonly List<CipherSuite?> onlineCipherSuiteInfos = [];
private ObservableCollection<UiWindowsApiCipherSuiteConfiguration>? activeCipherSuiteConfigurations;
private ObservableCollection<UiWindowsDocumentationCipherSuiteConfiguration>? osDefaultCipherSuiteConfigurations;
private BitmapSource? uacIcon;
Expand All @@ -26,10 +26,7 @@ public CipherSuitesOsSettingsViewModel(ILogger logger, ICipherSuiteService ciphe
UpdateCanExecuteDefaultCommand();
}

public BitmapSource UacIcon
{
get => uacIcon ??= uacIconService.GetUacShieldIcon();
}
public BitmapSource UacIcon => uacIcon ??= uacIconService.GetUacShieldIcon();

public bool FetchOnlineInfo
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@

internal sealed partial class CipherSuitesView
{
public CipherSuitesView()
{
InitializeComponent();
}
public CipherSuitesView() => InitializeComponent();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal sealed class CipherSuitesViewModel : BaseViewModel
{
private readonly ICipherSuiteService cipherSuiteService;
private readonly ICipherSuiteInfoApiService cipherSuiteInfoApiService;
private readonly List<CipherSuite?> onlineCipherSuiteInfos = new();
private readonly List<CipherSuite?> onlineCipherSuiteInfos = [];
private ObservableCollection<UiWindowsApiCipherSuiteConfiguration>? activeCipherSuiteConfigurations;
private bool fetchOnlineInfo = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@

internal sealed partial class EllipticCurvesGroupPolicySettingsView
{
public EllipticCurvesGroupPolicySettingsView()
{
InitializeComponent();
}
public EllipticCurvesGroupPolicySettingsView() => InitializeComponent();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ public string? AdminMessage
private set => _ = SetProperty(ref adminMessage, value);
}

public BitmapSource UacIcon
{
get => uacIcon ??= uacIconService.GetUacShieldIcon();
}
public BitmapSource UacIcon => uacIcon ??= uacIconService.GetUacShieldIcon();

public ObservableCollection<UiWindowsApiEllipticCurveConfiguration>? ActiveEllipticCurveConfigurations
{
Expand All @@ -57,7 +54,7 @@ protected override async Task DoExecuteDefaultCommandAsync(CancellationToken can
{
await Task.CompletedTask;

string[] activeGroupPolicyEllipticCurveConfigurationsStrings = Array.Empty<string>();
string[] activeGroupPolicyEllipticCurveConfigurationsStrings = [];

AdminMessage = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@

internal sealed partial class EllipticCurvesOsSettingsView
{
public EllipticCurvesOsSettingsView()
{
InitializeComponent();
}
public EllipticCurvesOsSettingsView() => InitializeComponent();
}
Loading

0 comments on commit b54775b

Please sign in to comment.