code formatting

This commit is contained in:
BlueBlock
2023-03-24 01:34:51 -04:00
parent 7454b15ec9
commit 05154af606
8 changed files with 167 additions and 190 deletions

View File

@@ -20,7 +20,7 @@ namespace mRemoteNG.App.Info
public const string UrlDocumentation = "https://mremoteng.readthedocs.io/en/latest/";
public static string ApplicationVersion = Application.ProductVersion;
public static readonly string ProductName = Application.ProductName;
public static readonly string Copyright = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute), false)).Copyright;
public static readonly string Copyright = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute), false))?.Copyright;
public static readonly string HomePath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
//public static string ReportingFilePath = "";

View File

@@ -15,10 +15,7 @@ namespace mRemoteNG.App.Initialization
public StartupDataLogger(MessageCollector messageCollector)
{
if (messageCollector == null)
throw new ArgumentNullException(nameof(messageCollector));
_messageCollector = messageCollector;
_messageCollector = messageCollector ?? throw new ArgumentNullException(nameof(messageCollector));
}
public void LogStartupData()
@@ -50,7 +47,7 @@ namespace mRemoteNG.App.Initialization
.Get())
{
var managementObject = (ManagementObject)o;
osVersion = Convert.ToString(managementObject.GetPropertyValue("Caption")).Trim();
osVersion = Convert.ToString(managementObject.GetPropertyValue("Caption"))?.Trim();
servicePack = GetOSServicePack(servicePack, managementObject);
}
}
@@ -79,8 +76,7 @@ namespace mRemoteNG.App.Initialization
var architecture = string.Empty;
try
{
foreach (var o in new ManagementObjectSearcher("SELECT AddressWidth FROM Win32_Processor WHERE DeviceID=\'CPU0\'")
.Get())
foreach (var o in new ManagementObjectSearcher("SELECT AddressWidth FROM Win32_Processor WHERE DeviceID=\'CPU0\'").Get())
{
var managementObject = (ManagementObject)o;
var addressWidth = Convert.ToInt32(managementObject.GetPropertyValue("AddressWidth"));
@@ -118,8 +114,7 @@ namespace mRemoteNG.App.Initialization
private void LogCultureData()
{
var data =
$"System Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}";
var data = $"System Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}";
_messageCollector.AddMessage(MessageClass.InformationMsg, data, true);
}
}

View File

@@ -29,8 +29,7 @@ namespace mRemoteNG.Config.Connections.Multiuser
{
_updateChecker.UpdateCheckStarted += OnUpdateCheckStarted;
_updateChecker.UpdateCheckFinished += OnUpdateCheckFinished;
_updateChecker.ConnectionsUpdateAvailable +=
(sender, args) => ConnectionsUpdateAvailable?.Invoke(sender, args);
_updateChecker.ConnectionsUpdateAvailable += (sender, args) => ConnectionsUpdateAvailable?.Invoke(sender, args);
_updateTimer.Elapsed += (sender, args) => _updateChecker.IsUpdateAvailableAsync();
ConnectionsUpdateAvailable += Load;
}

View File

@@ -24,8 +24,7 @@ namespace mRemoteNG.Config.Connections
private void ConnectionsServiceOnConnectionsLoaded(object sender, ConnectionsLoadedEventArgs connectionsLoadedEventArgs)
{
connectionsLoadedEventArgs.NewConnectionTreeModel.CollectionChanged +=
ConnectionTreeModelOnCollectionChanged;
connectionsLoadedEventArgs.NewConnectionTreeModel.CollectionChanged += ConnectionTreeModelOnCollectionChanged;
connectionsLoadedEventArgs.NewConnectionTreeModel.PropertyChanged += ConnectionTreeModelOnPropertyChanged;
foreach (var oldTree in connectionsLoadedEventArgs.PreviousConnectionTreeModel)

View File

@@ -23,16 +23,9 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
SecureString encryptionKey,
SaveFilter saveFilter)
{
if (cryptographyProvider == null)
throw new ArgumentNullException(nameof(cryptographyProvider));
if (encryptionKey == null)
throw new ArgumentNullException(nameof(encryptionKey));
if (saveFilter == null)
throw new ArgumentNullException(nameof(saveFilter));
_cryptographyProvider = cryptographyProvider;
_encryptionKey = encryptionKey;
_saveFilter = saveFilter;
_cryptographyProvider = cryptographyProvider ?? throw new ArgumentNullException(nameof(cryptographyProvider));
_encryptionKey = encryptionKey ?? throw new ArgumentNullException(nameof(encryptionKey));
_saveFilter = saveFilter ?? throw new ArgumentNullException(nameof(saveFilter));
}
public XElement Serialize(ConnectionInfo connectionInfo)

View File

@@ -23,16 +23,9 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
SecureString encryptionKey,
SaveFilter saveFilter)
{
if (cryptographyProvider == null)
throw new ArgumentNullException(nameof(cryptographyProvider));
if (encryptionKey == null)
throw new ArgumentNullException(nameof(encryptionKey));
if (saveFilter == null)
throw new ArgumentNullException(nameof(saveFilter));
_cryptographyProvider = cryptographyProvider;
_encryptionKey = encryptionKey;
_saveFilter = saveFilter;
_cryptographyProvider = cryptographyProvider ?? throw new ArgumentNullException(nameof(cryptographyProvider));
_encryptionKey = encryptionKey ?? throw new ArgumentNullException(nameof(encryptionKey));
_saveFilter = saveFilter ?? throw new ArgumentNullException(nameof(saveFilter));
}
public XElement Serialize(ConnectionInfo connectionInfo)
@@ -168,8 +161,8 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
private void SetInheritanceAttributes(XContainer element, IInheritable connectionInfo)
{
if (_saveFilter.SaveInheritance)
{
if (!_saveFilter.SaveInheritance) return;
var inheritance = connectionInfo.Inheritance;
if (inheritance.CacheBitmaps)
@@ -324,4 +317,3 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
}
}
}
}

View File

@@ -69,8 +69,7 @@ namespace mRemoteNG.Connection
throw new SettingsPropertyNotFoundException($"No property with name '{expectedPropertyName}' found.");
// ensure value is of correct type
var value = Convert.ChangeType(property.GetValue(Instance, null),
propertyFromDestination.PropertyType);
var value = Convert.ChangeType(property.GetValue(Instance, null), propertyFromDestination.PropertyType);
propertyFromDestination.SetValue(destinationInstance, value, null);
}

View File

@@ -43,13 +43,13 @@ namespace mRemoteNGTests.Connection
{
var saveTarget = new SerializableConnectionInfoAllPropertiesOfType<string>();
// randomize default connnection values to ensure we dont get false passing tests
// randomize default connection values to ensure we don't get false passing tests
var randomizedValue = property.GetValue(_randomizedConnectionInfo);
property.SetValue(DefaultConnectionInfo.Instance, randomizedValue);
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
var valueInSource = property.GetValue(DefaultConnectionInfo.Instance).ToString();
var valueInSource = property.GetValue(DefaultConnectionInfo.Instance)?.ToString();
var valueInDestination = saveTarget.GetType().GetProperty(property.Name)?.GetValue(saveTarget)?.ToString();
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
}