No more compiler warnings

This commit is contained in:
Halgari 2022-10-07 22:06:17 -06:00
parent 7176ebb531
commit 7a6f843a06
21 changed files with 9 additions and 417 deletions

View File

@ -14,7 +14,6 @@ using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Wabbajack.Common;
using Wabbajack.Downloaders.IPS4OAuth2Downloader;
using Wabbajack.DTOs.Interventions;
using Wabbajack.DTOs.Logins;
using Wabbajack.Messages;
using Wabbajack.Networking.Http.Interfaces;
@ -26,7 +25,6 @@ public class LoversLabLoginManager : ViewModel, ILoginFor<LoversLabDownloader>
{
private readonly ILogger<LoversLabLoginManager> _logger;
private readonly ITokenProvider<LoversLabLoginState> _token;
private readonly IUserInterventionHandler _handler;
private readonly IServiceProvider _serviceProvider;
public string SiteName { get; } = "Lovers Lab";

View File

@ -9,7 +9,6 @@ using Microsoft.Extensions.Logging;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Wabbajack.Downloaders;
using Wabbajack.DTOs.Interventions;
using Wabbajack.DTOs.Logins;
using Wabbajack.Messages;
using Wabbajack.Networking.Http.Interfaces;
@ -21,7 +20,6 @@ public class NexusLoginManager : ViewModel, ILoginFor<NexusDownloader>
{
private readonly ILogger<NexusLoginManager> _logger;
private readonly ITokenProvider<NexusApiState> _token;
private readonly IUserInterventionHandler _handler;
private readonly IServiceProvider _serviceProvider;
public string SiteName { get; } = "Nexus Mods";

View File

@ -13,7 +13,6 @@ using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Wabbajack.Common;
using Wabbajack.Downloaders.IPS4OAuth2Downloader;
using Wabbajack.DTOs.Interventions;
using Wabbajack.DTOs.Logins;
using Wabbajack.Messages;
using Wabbajack.Networking.Http.Interfaces;
@ -25,7 +24,6 @@ public class VectorPlexusLoginManager : ViewModel, ILoginFor<LoversLabDownloader
{
private readonly ILogger<VectorPlexusLoginManager> _logger;
private readonly ITokenProvider<VectorPlexusLoginState> _token;
private readonly IUserInterventionHandler _handler;
private readonly IServiceProvider _serviceProvider;
public string SiteName { get; } = "Vector Plexus";

View File

@ -5,16 +5,11 @@ using System.Threading;
using System.Threading.Tasks;
using System.Web;
using HtmlAgilityPack;
using Microsoft.Extensions.Logging;
using Microsoft.Web.WebView2.Core;
using Microsoft.Web.WebView2.Wpf;
using ReactiveUI.Fody.Helpers;
using Wabbajack.DTOs.Interventions;
using Wabbajack.DTOs.Logins;
using Wabbajack.Interventions;
using Wabbajack.Models;
using Wabbajack.Views;
using Wabbajack.WebAutomation;
namespace Wabbajack.UserIntervention;

View File

@ -119,7 +119,7 @@ public abstract class BrowserWindowViewModel : ViewModel
source.SetResult(new Uri(args.DownloadOperation.Uri));
}
catch (Exception ex)
catch (Exception)
{
source.SetCanceled();
}
@ -170,7 +170,7 @@ public abstract class BrowserWindowViewModel : ViewModel
source.TrySetResult();
};
}
catch (Exception ex)
catch (Exception)
{
source.SetCanceled();
}

View File

@ -1,5 +1,4 @@
using Microsoft.WindowsAPICodePack.Dialogs;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System;
using System.Reactive.Disposables;
@ -12,7 +11,6 @@ using Wabbajack.DTOs;
using Wabbajack.DTOs.GitHub;
using Wabbajack;
using Wabbajack.Extensions;
using Wabbajack.Paths;
using Wabbajack.Paths.IO;
using Consts = Wabbajack.Consts;
@ -22,14 +20,6 @@ namespace Wabbajack
{
public CompilerVM Parent { get; }
private readonly MO2CompilationSettings _settings;
private readonly ObservableAsPropertyHelper<AbsolutePath> _mo2Folder;
public AbsolutePath Mo2Folder => _mo2Folder.Value;
private readonly ObservableAsPropertyHelper<string> _moProfile;
public string MOProfile => _moProfile.Value;
public FilePickerVM DownloadLocation { get; }
public FilePickerVM ModListLocation { get; }

View File

@ -46,7 +46,6 @@ namespace Wabbajack
public List<string> GameTypeEntries => GetGameTypeEntries();
private ObservableAsPropertyHelper<bool> _Loaded;
private readonly Client _wjClient;
private readonly ILogger<ModListGalleryVM> _logger;
private readonly GameLocator _locator;

View File

@ -108,14 +108,12 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM
public string SlideShowDescription { get; set; }
private readonly ObservableAsPropertyHelper<bool> _installing;
private readonly DTOSerializer _dtos;
private readonly ILogger<InstallerVM> _logger;
private readonly SettingsManager _settingsManager;
private readonly IServiceProvider _serviceProvider;
private readonly SystemParametersConstructor _parametersConstructor;
private readonly IGameLocator _gameLocator;
private readonly LogStream _loggerProvider;
private readonly ResourceMonitor _resourceMonitor;
private readonly Services.OSIntegrated.Configuration _configuration;
private readonly HttpClient _client;

View File

@ -15,7 +15,6 @@ namespace Wabbajack
{
public class ModeSelectionVM : ViewModel
{
private MainWindowVM _mainVM;
public ICommand BrowseCommand { get; }
public ICommand InstallCommand { get; }
public ICommand CompileCommand { get; }

View File

@ -15,8 +15,6 @@ namespace Wabbajack.View_Models.Settings
{
public class AuthorFilesVM : BackNavigatingVM
{
private readonly ObservableAsPropertyHelper<Visibility> _isVisible;
[Reactive]
public Visibility IsVisible { get; set; }

View File

@ -1,103 +0,0 @@
using System;
using System.Net.Mail;
using System.Reactive.Linq;
using System.Security;
using System.Threading.Tasks;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Wabbajack.Downloaders.Interfaces;
using Wabbajack;
namespace Wabbajack
{
public class CredentialsLoginVM : ViewModel
{
[Reactive]
public string Username { get; set; }
[Reactive]
public string MFAKey { get; set; }
[Reactive]
public object ReturnMessage { get; set; }
[Reactive]
public bool LoggingIn { get; private set; }
private readonly ObservableAsPropertyHelper<bool> _loginEnabled;
public bool LoginEnabled => _loginEnabled.Value;
private readonly ObservableAsPropertyHelper<bool> _mfaVisible;
public bool MFAVisible => _mfaVisible.Value;
private readonly object _downloader;
public CredentialsLoginVM(INeedsLoginCredentials downloader)
{
_downloader = downloader;
_loginEnabled = this.WhenAny(x => x.Username)
.Select(IsValidAddress)
.CombineLatest(
this.WhenAny(x => x.LoggingIn),
(valid, loggingIn) =>
{
return valid && !loggingIn;
})
.ToGuiProperty(this,
nameof(LoginEnabled));
/*
_mfaVisible = this.WhenAny(x => x.ReturnMessage)
.Select(x => x.ReturnCode == LoginReturnCode.NeedsMFA)
.ToGuiProperty(this, nameof(MFAVisible));
*/
}
public async Task Login(SecureString password)
{
/*
try
{
LoggingIn = true;
if (password == null || password.Length == 0)
{
ReturnMessage = new LoginReturnMessage("You need to input a password!", LoginReturnCode.BadInput);
return;
}
ReturnMessage = await _downloader.LoginWithCredentials(Username, password, string.IsNullOrWhiteSpace(MFAKey) ? null : MFAKey);
password.Clear();
}
catch (Exception e)
{
Utils.Error(e, "Exception while trying to login");
ReturnMessage = new LoginReturnMessage($"Unhandled exception: {e.Message}", LoginReturnCode.InternalError);
}
finally
{
LoggingIn = false;
}
*/
}
private static bool IsValidAddress(string s)
{
if (string.IsNullOrWhiteSpace(s))
return false;
try
{
var _ = new MailAddress(s);
}
catch (Exception)
{
return false;
}
return true;
}
}
}

View File

@ -97,6 +97,6 @@
</mahapps:WindowCommands>
</mahapps:MetroWindow.RightWindowCommands>
<Window.TaskbarItemInfo>
<TaskbarItemInfo x:Name="TaskbarItemInfo"></TaskbarItemInfo>
<TaskbarItemInfo x:Name="TaskbarItemInfoControl"></TaskbarItemInfo>
</Window.TaskbarItemInfo>
</mahapps:MetroWindow>

View File

@ -66,9 +66,9 @@ namespace Wabbajack
.ObserveOnGuiThread()
.Subscribe(u =>
{
TaskbarItemInfo.Description = u.Description;
TaskbarItemInfo.ProgressValue = u.ProgressValue;
TaskbarItemInfo.ProgressState = u.State;
TaskbarItemInfoControl.Description = u.Description;
TaskbarItemInfoControl.ProgressValue = u.ProgressValue;
TaskbarItemInfoControl.ProgressState = u.State;
});
@ -84,7 +84,7 @@ namespace Wabbajack
p.SystemMemorySize.ToFileSizeString(), p.SystemPageSize.ToFileSizeString(), p.ScreenWidth, p.ScreenHeight, p.VideoMemorySize.ToFileSizeString(), p.EnbLEVRAMSize);
if (p.SystemPageSize == 0)
_logger.LogInformation("Pagefile is disabled! Consider increasing to 20000MB. A disabled pagefile can cause crashes and poor in-game performance");
_logger.LogInformation( "Pagefile is disabled! Consider increasing to 20000MB. A disabled pagefile can cause crashes and poor in-game performance");
else if (p.SystemPageSize < 2e+10)
_logger.LogInformation("Pagefile below recommended! Consider increasing to 20000MB. A suboptimal pagefile can cause crashes and poor in-game performance");

View File

@ -1,70 +0,0 @@
<rxui:ReactiveUserControl
x:Class="Wabbajack.CredentialsLoginView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wabbajack"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:rxui="http://reactiveui.net"
d:DesignHeight="450"
d:DesignWidth="800"
x:TypeArguments="local:CredentialsLoginVM"
mc:Ignorable="d">
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="60" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="120" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0"
Margin="0,16,8,0"
FontSize="20">
Email:
</TextBlock>
<TextBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2"
x:Name="Username"
FontSize="20" />
<TextBlock Grid.Row="1" Grid.Column="0"
Margin="0,16,8,0"
FontSize="20">
Password:
</TextBlock>
<PasswordBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"
x:Name="Password"
Margin="0,16,0,8"
FontSize="20" />
<TextBlock Grid.Row="2" Grid.Column="0"
x:Name="MFAText"
Margin="0,16,8,0"
FontSize="20">
MFA Key:
</TextBlock>
<TextBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2"
x:Name="MFA"
FontSize="20" />
<Button Grid.Row="3" Grid.Column="3"
x:Name="LoginButton"
Margin="8,8,0,0"
Click="LoginButton_OnClick">
<TextBlock FontSize="14">Login</TextBlock>
</Button>
<TextBlock Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="3"
x:Name="Message"
Margin="0,16,0,0"
FontSize="20"
TextWrapping="Wrap" />
</Grid>
</rxui:ReactiveUserControl>

View File

@ -1,44 +0,0 @@
using System.Reactive.Disposables;
using System.Windows;
using ReactiveUI;
namespace Wabbajack
{
public partial class CredentialsLoginView
{
public INeedsLoginCredentials Downloader { get; set; }
public CredentialsLoginView(INeedsLoginCredentials downloader)
{
Downloader = downloader;
if (ViewModel == null)
ViewModel = new CredentialsLoginVM(downloader);
InitializeComponent();
this.WhenActivated(disposable =>
{
this.Bind(ViewModel, x => x.Username, x => x.Username.Text)
.DisposeWith(disposable);
this.Bind(ViewModel, x => x.LoginEnabled, x => x.LoginButton.IsEnabled)
.DisposeWith(disposable);
this.Bind(ViewModel, x => x.MFAKey, x => x.MFA.Text)
.DisposeWith(disposable);
this.OneWayBind(ViewModel, x => x.MFAVisible, x => x.MFA.Visibility)
.DisposeWith(disposable);
this.OneWayBind(ViewModel, x => x.MFAVisible, x => x.MFAText.Visibility)
.DisposeWith(disposable);
/* TODO
this.OneWayBind(ViewModel, x => x.ReturnMessage.Message, x => x.Message.Text)
.DisposeWith(disposable);
*/
});
}
private async void LoginButton_OnClick(object sender, RoutedEventArgs e)
{
//ViewModel.Login(Password.SecurePassword).FireAndForget();
}
}
}

View File

@ -1,22 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Reactive.Disposables;
using ReactiveUI;
using Wabbajack.Common;
using Wabbajack.WebAutomation;
namespace Wabbajack
{
@ -39,8 +22,6 @@ namespace Wabbajack
this.WhenAnyValue(x => x.ViewModel.OpenTerminalCommand)
.BindToStrict(this, x => x.OpenTerminal.Command)
.DisposeWith(disposable);
this.ClearCefCache.Click += (sender, args) => {Driver.ClearCache();};
});
}
}

View File

@ -1,22 +0,0 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Wabbajack.DTOs.Logins;
namespace Wabbajack.WebAutomation
{
public interface IWebDriver
{
Task NavigateTo(Uri uri, CancellationToken? token = null);
Task<string> EvaluateJavaScript(string text);
Task<Cookie[]> GetCookies(string domainPrefix);
public Action<Uri>? DownloadHandler { get; set; }
public Task WaitForInitialized();
ISchemeHandler WithSchemeHandler(Predicate<Uri> wabbajack);
}
public interface ISchemeHandler : IDisposable
{
public Task<Uri> Task { get; }
}
}

View File

@ -1,118 +0,0 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using HtmlAgilityPack;
using Microsoft.Extensions.Logging;
using Wabbajack.Models;
using Wabbajack.Paths;
using Wabbajack.Paths.IO;
namespace Wabbajack.WebAutomation
{
public class Driver : IDisposable
{
//private readonly IWebBrowser _browser;
private readonly dynamic _driver;
public Driver(ILogger logger, CefService service)
{
//_browser = new ChromiumWebBrowser();
//_driver = new CefSharpWrapper(logger, _browser, service);
}
public async Task<Uri?> NavigateTo(Uri uri, CancellationToken? token = null)
{
try
{
//await _driver.NavigateTo(uri, token);
return await GetLocation();
}
catch (TaskCanceledException ex)
{
await DumpState(uri, ex);
throw;
}
}
private async Task DumpState(Uri uri, Exception ex)
{
var file = KnownFolders.EntryPoint.Combine("CEFStates", DateTime.UtcNow.ToFileTimeUtc().ToString())
.WithExtension(new Extension(".html"));
file.Parent.CreateDirectory();
var source = await GetSourceAsync();
//var cookies = await Helpers.GetCookies();
//var cookiesString = string.Join('\n', cookies.Select(c => c.Name + " - " + c.Value));
//await file.WriteAllTextAsync(uri + "\n " + source + "\n" + ex + "\n" + cookiesString);
}
public async Task<long> NavigateToAndDownload(Uri uri, AbsolutePath absolutePath, bool quickMode = false, CancellationToken? token = null)
{
try
{
//return await _driver.NavigateToAndDownload(uri, absolutePath, quickMode: quickMode, token: token);
return 0;
}
catch (TaskCanceledException ex) {
await DumpState(uri, ex);
throw;
}
}
public async ValueTask<Uri?> GetLocation()
{
/*
try
{
return new Uri(_browser.Address);
}
catch (UriFormatException)
{
return null;
}*/
return null;
}
public async ValueTask<string> GetSourceAsync()
{
//return await _browser.GetSourceAsync();
return "";
}
public async ValueTask<HtmlDocument> GetHtmlAsync()
{
var body = await GetSourceAsync();
var doc = new HtmlDocument();
doc.LoadHtml(body);
return doc;
}
public Action<Uri?> DownloadHandler {
set => _driver.DownloadHandler = value;
}
public Task<string> GetAttr(string selector, string attr)
{
return _driver.EvaluateJavaScript($"document.querySelector(\"{selector}\").{attr}");
}
public Task<string> EvalJavascript(string js)
{
return _driver.EvaluateJavaScript(js);
}
public void Dispose()
{
//_browser.Dispose();
}
public static void ClearCache()
{
//Helpers.ClearCookies();
}
public async Task DeleteCookiesWhere(Func<DTOs.Logins.Cookie, bool> filter)
{
//await Helpers.DeleteCookiesWhere(filter);
}
}
}

View File

@ -10,7 +10,6 @@ using Wabbajack.DTOs.DownloadStates;
using Wabbajack.Hashing.xxHash64;
using Wabbajack.Installer;
using Wabbajack.Paths.IO;
using Wabbajack.Services.OSIntegrated;
using Xunit;
namespace Wabbajack.Downloaders.Dispatcher.Test;

View File

@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Wabbajack.RateLimiter;
using Wabbajack.Services.OSIntegrated;
namespace Wabbajack.App.Models;
namespace Wabbajack.Services.OSIntegrated;
public class ResourceSettingsManager
{

View File

@ -7,7 +7,6 @@ using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Wabbajack.App.Models;
using Wabbajack.Compiler;
using Wabbajack.Downloaders;
using Wabbajack.Downloaders.GameFile;