fix: fix some warnings from visual studio (#7031)

This commit is contained in:
MistEO
2023-10-23 17:38:21 +08:00
committed by GitHub
3 changed files with 11 additions and 14 deletions

View File

@@ -372,12 +372,7 @@ namespace MaaWpfGui.Helper
try
{
var obj = (JObject)JsonConvert.DeserializeObject(str);
if (obj is null)
{
throw new Exception("Failed to parse json file");
}
return obj;
return obj ?? throw new Exception("Failed to parse json file");
}
catch (Exception ex)
{

View File

@@ -114,7 +114,7 @@ namespace MaaWpfGui.Main
ptr3 = EncodeNullTerminatedUtf8(config))
{
bool ret = AsstConnect(handle, ptr1, ptr2, ptr3);
_logger.Information($"handle: {((long)handle).ToString()}, adbPath: {adbPath}, address: {address}, config: {config}, return: {ret}");
_logger.Information($"handle: {(long)handle}, adbPath: {adbPath}, address: {address}, config: {config}, return: {ret}");
return ret;
}
}
@@ -302,6 +302,7 @@ namespace MaaWpfGui.Main
AsstSetInstanceOption(InstanceOptionKey.TouchMode, Instances.SettingsViewModel.TouchMode);
AsstSetInstanceOption(InstanceOptionKey.DeploymentWithPause, Instances.SettingsViewModel.DeploymentWithPause ? "1" : "0");
AsstSetInstanceOption(InstanceOptionKey.AdbLiteEnabled, Instances.SettingsViewModel.AdbLiteEnabled ? "1" : "0");
// TODO: 之后把这个 OnUIThread 拆出来
// ReSharper disable once AsyncVoidLambda
Execute.OnUIThread(async () =>
@@ -973,6 +974,7 @@ namespace MaaWpfGui.Main
break;
}
case "CombatRecordRecognitionTask":
{
string what = details["what"]?.ToString();
@@ -1433,17 +1435,17 @@ namespace MaaWpfGui.Main
{
string bsHvAddress = Instances.SettingsViewModel.TryToSetBlueStacksHyperVAddress();
if (String.Equals(Instances.SettingsViewModel.ConnectAddress, bsHvAddress))
if (string.Equals(Instances.SettingsViewModel.ConnectAddress, bsHvAddress))
{
// 防止bsHvAddress和connectAddress重合
bsHvAddress = String.Empty;
bsHvAddress = string.Empty;
}
// tcp连接测试端口是否有效超时时间500ms
// 如果是本地设备,没有冒号
bool adbResult =
!Instances.SettingsViewModel.ConnectAddress.Contains(":") &&
!string.IsNullOrEmpty(Instances.SettingsViewModel.ConnectAddress) ||
(!Instances.SettingsViewModel.ConnectAddress.Contains(":") &&
!string.IsNullOrEmpty(Instances.SettingsViewModel.ConnectAddress)) ||
IfPortEstablished(Instances.SettingsViewModel.ConnectAddress);
bool bsResult = IfPortEstablished(bsHvAddress);
bool adbConfResult = Instances.SettingsViewModel.DetectAdbConfig(ref error);

View File

@@ -258,7 +258,6 @@ namespace MaaWpfGui.ViewModels.UI
}
}
private string _remoteControlDeviceIdentity = ConfigurationHelper.GetValue(ConfigurationKeys.RemoteControlDeviceIdentity, string.Empty);
public string RemoteControlDeviceIdentity
@@ -883,6 +882,7 @@ namespace MaaWpfGui.ViewModels.UI
{
// ReSharper disable once SuspiciousTypeConversion.Global
var link = (IShellLink)new ShellLink();
// ReSharper disable once SuspiciousTypeConversion.Global
var file = (IPersistFile)link;
file.Load(EmulatorPath, 0); // STGM_READ
@@ -1713,7 +1713,7 @@ namespace MaaWpfGui.ViewModels.UI
private string _roguelikeMode = ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeMode, "0");
/// <summary>
/// 策略,往后打 / 刷一层就退 / 烧热水
/// Gets or sets 策略,往后打 / 刷一层就退 / 烧热水
/// </summary>
public string RoguelikeMode
{
@@ -1779,7 +1779,7 @@ namespace MaaWpfGui.ViewModels.UI
private ObservableCollection<string> _roguelikeCoreCharList = new ObservableCollection<string>();
/// <summary>
/// Gets or sets the roguelike core character.
/// Gets the roguelike core character.
/// </summary>
public ObservableCollection<string> RoguelikeCoreCharList
{