diff --git a/mRemoteNG/App/Info/GeneralAppInfo.cs b/mRemoteNG/App/Info/GeneralAppInfo.cs index b40ae9e6..639922e1 100644 --- a/mRemoteNG/App/Info/GeneralAppInfo.cs +++ b/mRemoteNG/App/Info/GeneralAppInfo.cs @@ -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 = ""; diff --git a/mRemoteNG/App/Initialization/StartupDataLogger.cs b/mRemoteNG/App/Initialization/StartupDataLogger.cs index 58efbf8b..33faa4ba 100644 --- a/mRemoteNG/App/Initialization/StartupDataLogger.cs +++ b/mRemoteNG/App/Initialization/StartupDataLogger.cs @@ -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); } } diff --git a/mRemoteNG/Config/Connections/Multiuser/RemoteConnectionsSyncronizer.cs b/mRemoteNG/Config/Connections/Multiuser/RemoteConnectionsSyncronizer.cs index a9d25fa7..89c96a02 100644 --- a/mRemoteNG/Config/Connections/Multiuser/RemoteConnectionsSyncronizer.cs +++ b/mRemoteNG/Config/Connections/Multiuser/RemoteConnectionsSyncronizer.cs @@ -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; } diff --git a/mRemoteNG/Config/Connections/SaveConnectionsOnEdit.cs b/mRemoteNG/Config/Connections/SaveConnectionsOnEdit.cs index 25af6205..2e5e1cce 100644 --- a/mRemoteNG/Config/Connections/SaveConnectionsOnEdit.cs +++ b/mRemoteNG/Config/Connections/SaveConnectionsOnEdit.cs @@ -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) diff --git a/mRemoteNG/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer27.cs b/mRemoteNG/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer27.cs index d052ea1c..2a2d59f5 100644 --- a/mRemoteNG/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer27.cs +++ b/mRemoteNG/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer27.cs @@ -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) diff --git a/mRemoteNG/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer28.cs b/mRemoteNG/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer28.cs index f073a515..76f845ad 100644 --- a/mRemoteNG/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer28.cs +++ b/mRemoteNG/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer28.cs @@ -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,160 +161,159 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml private void SetInheritanceAttributes(XContainer element, IInheritable connectionInfo) { - if (_saveFilter.SaveInheritance) - { - var inheritance = connectionInfo.Inheritance; + if (!_saveFilter.SaveInheritance) return; - if (inheritance.CacheBitmaps) - element.Add(new XAttribute("InheritCacheBitmaps", inheritance.CacheBitmaps.ToString().ToLowerInvariant())); - if (inheritance.Colors) - element.Add(new XAttribute("InheritColors", inheritance.Colors.ToString().ToLowerInvariant())); - if (inheritance.Description) - element.Add(new XAttribute("InheritDescription", inheritance.Description.ToString().ToLowerInvariant())); - if (inheritance.DisplayThemes) - element.Add(new XAttribute("InheritDisplayThemes", inheritance.DisplayThemes.ToString().ToLowerInvariant())); - if (inheritance.DisplayWallpaper) - element.Add(new XAttribute("InheritDisplayWallpaper", inheritance.DisplayWallpaper.ToString().ToLowerInvariant())); - if (inheritance.EnableFontSmoothing) - element.Add(new XAttribute("InheritEnableFontSmoothing", inheritance.EnableFontSmoothing.ToString().ToLowerInvariant())); - if (inheritance.EnableDesktopComposition) - element.Add(new XAttribute("InheritEnableDesktopComposition", inheritance.EnableDesktopComposition.ToString().ToLowerInvariant())); - if (inheritance.DisableFullWindowDrag) - element.Add(new XAttribute("InheritDisableFullWindowDrag", inheritance.DisableFullWindowDrag.ToString().ToLowerInvariant())); - if (inheritance.DisableMenuAnimations) - element.Add(new XAttribute("InheritDisableMenuAnimations", inheritance.DisableMenuAnimations.ToString().ToLowerInvariant())); - if (inheritance.DisableCursorShadow) - element.Add(new XAttribute("InheritDisableCursorShadow", inheritance.DisableCursorShadow.ToString().ToLowerInvariant())); - if (inheritance.DisableCursorBlinking) - element.Add(new XAttribute("InheritDisableCursorBlinking", inheritance.DisableCursorBlinking.ToString().ToLowerInvariant())); - if (inheritance.Domain) - element.Add(new XAttribute("InheritDomain", inheritance.Domain.ToString().ToLowerInvariant())); - if (inheritance.Icon) - element.Add(new XAttribute("InheritIcon", inheritance.Icon.ToString().ToLowerInvariant())); - if (inheritance.Panel) - element.Add(new XAttribute("InheritPanel", inheritance.Panel.ToString().ToLowerInvariant())); - if (inheritance.Password) - element.Add(new XAttribute("InheritPassword", inheritance.Password.ToString().ToLowerInvariant())); - if (inheritance.Port) - element.Add(new XAttribute("InheritPort", inheritance.Port.ToString().ToLowerInvariant())); - if (inheritance.Protocol) - element.Add(new XAttribute("InheritProtocol", inheritance.Protocol.ToString().ToLowerInvariant())); - if (inheritance.RdpVersion) - element.Add(new XAttribute("InheritRdpVersion", inheritance.RdpVersion.ToString().ToLowerInvariant())); - if (inheritance.SSHTunnelConnectionName) - element.Add(new XAttribute("InheritSSHTunnelConnectionName", inheritance.SSHTunnelConnectionName.ToString().ToLowerInvariant())); - if (inheritance.OpeningCommand) - element.Add(new XAttribute("InheritOpeningCommand", inheritance.OpeningCommand.ToString().ToLowerInvariant())); - if (inheritance.SSHOptions) - element.Add(new XAttribute("InheritSSHOptions", inheritance.SSHOptions.ToString().ToLowerInvariant())); - if (inheritance.PuttySession) - element.Add(new XAttribute("InheritPuttySession", inheritance.PuttySession.ToString().ToLowerInvariant())); - if (inheritance.RedirectDiskDrives) - element.Add(new XAttribute("InheritRedirectDiskDrives", inheritance.RedirectDiskDrives.ToString().ToLowerInvariant())); - if (inheritance.RedirectDiskDrivesCustom) - element.Add(new XAttribute("InheritRedirectDiskDrivesCustom", inheritance.RedirectDiskDrivesCustom.ToString().ToLowerInvariant())); - if (inheritance.RedirectKeys) - element.Add(new XAttribute("InheritRedirectKeys", inheritance.RedirectKeys.ToString().ToLowerInvariant())); - if (inheritance.RedirectPorts) - element.Add(new XAttribute("InheritRedirectPorts", inheritance.RedirectPorts.ToString().ToLowerInvariant())); - if (inheritance.RedirectPrinters) - element.Add(new XAttribute("InheritRedirectPrinters", inheritance.RedirectPrinters.ToString().ToLowerInvariant())); - if (inheritance.RedirectClipboard) - element.Add(new XAttribute("InheritRedirectClipboard", inheritance.RedirectClipboard.ToString().ToLowerInvariant())); - if (inheritance.RedirectSmartCards) - element.Add(new XAttribute("InheritRedirectSmartCards", inheritance.RedirectSmartCards.ToString().ToLowerInvariant())); - if (inheritance.RedirectSound) - element.Add(new XAttribute("InheritRedirectSound", inheritance.RedirectSound.ToString().ToLowerInvariant())); - if (inheritance.SoundQuality) - element.Add(new XAttribute("InheritSoundQuality", inheritance.SoundQuality.ToString().ToLowerInvariant())); - if (inheritance.RedirectAudioCapture) - element.Add(new XAttribute("InheritRedirectAudioCapture", inheritance.RedirectAudioCapture.ToString().ToLowerInvariant())); - if (inheritance.Resolution) - element.Add(new XAttribute("InheritResolution", inheritance.Resolution.ToString().ToLowerInvariant())); - if (inheritance.AutomaticResize) - element.Add(new XAttribute("InheritAutomaticResize", inheritance.AutomaticResize.ToString().ToLowerInvariant())); - if (inheritance.UseConsoleSession) - element.Add(new XAttribute("InheritUseConsoleSession", inheritance.UseConsoleSession.ToString().ToLowerInvariant())); - if (inheritance.UseCredSsp) - element.Add(new XAttribute("InheritUseCredSsp", inheritance.UseCredSsp.ToString().ToLowerInvariant())); - if (inheritance.RenderingEngine) - element.Add(new XAttribute("InheritRenderingEngine", inheritance.RenderingEngine.ToString().ToLowerInvariant())); - if (inheritance.Username) - element.Add(new XAttribute("InheritUsername", inheritance.Username.ToString().ToLowerInvariant())); - if (inheritance.RDPAuthenticationLevel) - element.Add(new XAttribute("InheritRDPAuthenticationLevel", inheritance.RDPAuthenticationLevel.ToString().ToLowerInvariant())); - if (inheritance.RDPMinutesToIdleTimeout) - element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", inheritance.RDPMinutesToIdleTimeout.ToString().ToLowerInvariant())); - if (inheritance.RDPAlertIdleTimeout) - element.Add(new XAttribute("InheritRDPAlertIdleTimeout", inheritance.RDPAlertIdleTimeout.ToString().ToLowerInvariant())); - if (inheritance.LoadBalanceInfo) - element.Add(new XAttribute("InheritLoadBalanceInfo", inheritance.LoadBalanceInfo.ToString().ToLowerInvariant())); - if (inheritance.PreExtApp) - element.Add(new XAttribute("InheritPreExtApp", inheritance.PreExtApp.ToString().ToLowerInvariant())); - if (inheritance.PostExtApp) - element.Add(new XAttribute("InheritPostExtApp", inheritance.PostExtApp.ToString().ToLowerInvariant())); - if (inheritance.MacAddress) - element.Add(new XAttribute("InheritMacAddress", inheritance.MacAddress.ToString().ToLowerInvariant())); - if (inheritance.UserField) - element.Add(new XAttribute("InheritUserField", inheritance.UserField.ToString().ToLowerInvariant())); - if (inheritance.Favorite) - element.Add(new XAttribute("InheritFavorite", inheritance.Favorite.ToString().ToLowerInvariant())); - if (inheritance.ExtApp) - element.Add(new XAttribute("InheritExtApp", inheritance.ExtApp.ToString().ToLowerInvariant())); - if (inheritance.VNCCompression) - element.Add(new XAttribute("InheritVNCCompression", inheritance.VNCCompression.ToString().ToLowerInvariant())); - if (inheritance.VNCEncoding) - element.Add(new XAttribute("InheritVNCEncoding", inheritance.VNCEncoding.ToString().ToLowerInvariant())); - if (inheritance.VNCAuthMode) - element.Add(new XAttribute("InheritVNCAuthMode", inheritance.VNCAuthMode.ToString().ToLowerInvariant())); - if (inheritance.VNCProxyType) - element.Add(new XAttribute("InheritVNCProxyType", inheritance.VNCProxyType.ToString().ToLowerInvariant())); - if (inheritance.VNCProxyIP) - element.Add(new XAttribute("InheritVNCProxyIP", inheritance.VNCProxyIP.ToString().ToLowerInvariant())); - if (inheritance.VNCProxyPort) - element.Add(new XAttribute("InheritVNCProxyPort", inheritance.VNCProxyPort.ToString().ToLowerInvariant())); - if (inheritance.VNCProxyUsername) - element.Add(new XAttribute("InheritVNCProxyUsername", inheritance.VNCProxyUsername.ToString().ToLowerInvariant())); - if (inheritance.VNCProxyPassword) - element.Add(new XAttribute("InheritVNCProxyPassword", inheritance.VNCProxyPassword.ToString().ToLowerInvariant())); - if (inheritance.VNCColors) - element.Add(new XAttribute("InheritVNCColors", inheritance.VNCColors.ToString().ToLowerInvariant())); - if (inheritance.VNCSmartSizeMode) - element.Add(new XAttribute("InheritVNCSmartSizeMode", inheritance.VNCSmartSizeMode.ToString().ToLowerInvariant())); - if (inheritance.VNCViewOnly) - element.Add(new XAttribute("InheritVNCViewOnly", inheritance.VNCViewOnly.ToString().ToLowerInvariant())); - if (inheritance.RDGatewayUsageMethod) - element.Add(new XAttribute("InheritRDGatewayUsageMethod", inheritance.RDGatewayUsageMethod.ToString().ToLowerInvariant())); - if (inheritance.RDGatewayHostname) - element.Add(new XAttribute("InheritRDGatewayHostname", inheritance.RDGatewayHostname.ToString().ToLowerInvariant())); - if (inheritance.RDGatewayUseConnectionCredentials) - element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", inheritance.RDGatewayUseConnectionCredentials.ToString().ToLowerInvariant())); - if (inheritance.RDGatewayUsername) - element.Add(new XAttribute("InheritRDGatewayUsername", inheritance.RDGatewayUsername.ToString().ToLowerInvariant())); - if (inheritance.RDGatewayPassword) - element.Add(new XAttribute("InheritRDGatewayPassword", inheritance.RDGatewayPassword.ToString().ToLowerInvariant())); - if (inheritance.RDGatewayDomain) - element.Add(new XAttribute("InheritRDGatewayDomain", inheritance.RDGatewayDomain.ToString().ToLowerInvariant())); - if (inheritance.RDGatewayExternalCredentialProvider) - element.Add(new XAttribute("InheritRDGatewayExternalCredentialProvider", inheritance.RDGatewayExternalCredentialProvider.ToString().ToLowerInvariant())); - if (inheritance.RDGatewayUserViaAPI) - element.Add(new XAttribute("InheritRDGatewayUserViaAPI", inheritance.RDGatewayUserViaAPI.ToString().ToLowerInvariant())); + var inheritance = connectionInfo.Inheritance; - if (inheritance.VmId) - element.Add(new XAttribute("InheritVmId", inheritance.VmId.ToString().ToLowerInvariant())); - if (inheritance.UseVmId) - element.Add(new XAttribute("InheritUseVmId", inheritance.UseVmId.ToString().ToLowerInvariant())); - if (inheritance.UseEnhancedMode) - element.Add(new XAttribute("InheritUseEnhancedMode", inheritance.UseEnhancedMode.ToString().ToLowerInvariant())); - if (inheritance.ExternalCredentialProvider) - element.Add(new XAttribute("InheritExternalCredentialProvider", inheritance.ExternalCredentialProvider.ToString().ToLowerInvariant())); - if (inheritance.UserViaAPI) - element.Add(new XAttribute("InheritUserViaAPI", inheritance.UserViaAPI.ToString().ToLowerInvariant())); - if (inheritance.UseRCG) - element.Add(new XAttribute("InheritUseRCG", inheritance.UseRCG.ToString().ToLowerInvariant())); - if (inheritance.UseRestrictedAdmin) - element.Add(new XAttribute("InheritUseRestrictedAdmin", inheritance.UseRestrictedAdmin.ToString().ToLowerInvariant())); - } + if (inheritance.CacheBitmaps) + element.Add(new XAttribute("InheritCacheBitmaps", inheritance.CacheBitmaps.ToString().ToLowerInvariant())); + if (inheritance.Colors) + element.Add(new XAttribute("InheritColors", inheritance.Colors.ToString().ToLowerInvariant())); + if (inheritance.Description) + element.Add(new XAttribute("InheritDescription", inheritance.Description.ToString().ToLowerInvariant())); + if (inheritance.DisplayThemes) + element.Add(new XAttribute("InheritDisplayThemes", inheritance.DisplayThemes.ToString().ToLowerInvariant())); + if (inheritance.DisplayWallpaper) + element.Add(new XAttribute("InheritDisplayWallpaper", inheritance.DisplayWallpaper.ToString().ToLowerInvariant())); + if (inheritance.EnableFontSmoothing) + element.Add(new XAttribute("InheritEnableFontSmoothing", inheritance.EnableFontSmoothing.ToString().ToLowerInvariant())); + if (inheritance.EnableDesktopComposition) + element.Add(new XAttribute("InheritEnableDesktopComposition", inheritance.EnableDesktopComposition.ToString().ToLowerInvariant())); + if (inheritance.DisableFullWindowDrag) + element.Add(new XAttribute("InheritDisableFullWindowDrag", inheritance.DisableFullWindowDrag.ToString().ToLowerInvariant())); + if (inheritance.DisableMenuAnimations) + element.Add(new XAttribute("InheritDisableMenuAnimations", inheritance.DisableMenuAnimations.ToString().ToLowerInvariant())); + if (inheritance.DisableCursorShadow) + element.Add(new XAttribute("InheritDisableCursorShadow", inheritance.DisableCursorShadow.ToString().ToLowerInvariant())); + if (inheritance.DisableCursorBlinking) + element.Add(new XAttribute("InheritDisableCursorBlinking", inheritance.DisableCursorBlinking.ToString().ToLowerInvariant())); + if (inheritance.Domain) + element.Add(new XAttribute("InheritDomain", inheritance.Domain.ToString().ToLowerInvariant())); + if (inheritance.Icon) + element.Add(new XAttribute("InheritIcon", inheritance.Icon.ToString().ToLowerInvariant())); + if (inheritance.Panel) + element.Add(new XAttribute("InheritPanel", inheritance.Panel.ToString().ToLowerInvariant())); + if (inheritance.Password) + element.Add(new XAttribute("InheritPassword", inheritance.Password.ToString().ToLowerInvariant())); + if (inheritance.Port) + element.Add(new XAttribute("InheritPort", inheritance.Port.ToString().ToLowerInvariant())); + if (inheritance.Protocol) + element.Add(new XAttribute("InheritProtocol", inheritance.Protocol.ToString().ToLowerInvariant())); + if (inheritance.RdpVersion) + element.Add(new XAttribute("InheritRdpVersion", inheritance.RdpVersion.ToString().ToLowerInvariant())); + if (inheritance.SSHTunnelConnectionName) + element.Add(new XAttribute("InheritSSHTunnelConnectionName", inheritance.SSHTunnelConnectionName.ToString().ToLowerInvariant())); + if (inheritance.OpeningCommand) + element.Add(new XAttribute("InheritOpeningCommand", inheritance.OpeningCommand.ToString().ToLowerInvariant())); + if (inheritance.SSHOptions) + element.Add(new XAttribute("InheritSSHOptions", inheritance.SSHOptions.ToString().ToLowerInvariant())); + if (inheritance.PuttySession) + element.Add(new XAttribute("InheritPuttySession", inheritance.PuttySession.ToString().ToLowerInvariant())); + if (inheritance.RedirectDiskDrives) + element.Add(new XAttribute("InheritRedirectDiskDrives", inheritance.RedirectDiskDrives.ToString().ToLowerInvariant())); + if (inheritance.RedirectDiskDrivesCustom) + element.Add(new XAttribute("InheritRedirectDiskDrivesCustom", inheritance.RedirectDiskDrivesCustom.ToString().ToLowerInvariant())); + if (inheritance.RedirectKeys) + element.Add(new XAttribute("InheritRedirectKeys", inheritance.RedirectKeys.ToString().ToLowerInvariant())); + if (inheritance.RedirectPorts) + element.Add(new XAttribute("InheritRedirectPorts", inheritance.RedirectPorts.ToString().ToLowerInvariant())); + if (inheritance.RedirectPrinters) + element.Add(new XAttribute("InheritRedirectPrinters", inheritance.RedirectPrinters.ToString().ToLowerInvariant())); + if (inheritance.RedirectClipboard) + element.Add(new XAttribute("InheritRedirectClipboard", inheritance.RedirectClipboard.ToString().ToLowerInvariant())); + if (inheritance.RedirectSmartCards) + element.Add(new XAttribute("InheritRedirectSmartCards", inheritance.RedirectSmartCards.ToString().ToLowerInvariant())); + if (inheritance.RedirectSound) + element.Add(new XAttribute("InheritRedirectSound", inheritance.RedirectSound.ToString().ToLowerInvariant())); + if (inheritance.SoundQuality) + element.Add(new XAttribute("InheritSoundQuality", inheritance.SoundQuality.ToString().ToLowerInvariant())); + if (inheritance.RedirectAudioCapture) + element.Add(new XAttribute("InheritRedirectAudioCapture", inheritance.RedirectAudioCapture.ToString().ToLowerInvariant())); + if (inheritance.Resolution) + element.Add(new XAttribute("InheritResolution", inheritance.Resolution.ToString().ToLowerInvariant())); + if (inheritance.AutomaticResize) + element.Add(new XAttribute("InheritAutomaticResize", inheritance.AutomaticResize.ToString().ToLowerInvariant())); + if (inheritance.UseConsoleSession) + element.Add(new XAttribute("InheritUseConsoleSession", inheritance.UseConsoleSession.ToString().ToLowerInvariant())); + if (inheritance.UseCredSsp) + element.Add(new XAttribute("InheritUseCredSsp", inheritance.UseCredSsp.ToString().ToLowerInvariant())); + if (inheritance.RenderingEngine) + element.Add(new XAttribute("InheritRenderingEngine", inheritance.RenderingEngine.ToString().ToLowerInvariant())); + if (inheritance.Username) + element.Add(new XAttribute("InheritUsername", inheritance.Username.ToString().ToLowerInvariant())); + if (inheritance.RDPAuthenticationLevel) + element.Add(new XAttribute("InheritRDPAuthenticationLevel", inheritance.RDPAuthenticationLevel.ToString().ToLowerInvariant())); + if (inheritance.RDPMinutesToIdleTimeout) + element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", inheritance.RDPMinutesToIdleTimeout.ToString().ToLowerInvariant())); + if (inheritance.RDPAlertIdleTimeout) + element.Add(new XAttribute("InheritRDPAlertIdleTimeout", inheritance.RDPAlertIdleTimeout.ToString().ToLowerInvariant())); + if (inheritance.LoadBalanceInfo) + element.Add(new XAttribute("InheritLoadBalanceInfo", inheritance.LoadBalanceInfo.ToString().ToLowerInvariant())); + if (inheritance.PreExtApp) + element.Add(new XAttribute("InheritPreExtApp", inheritance.PreExtApp.ToString().ToLowerInvariant())); + if (inheritance.PostExtApp) + element.Add(new XAttribute("InheritPostExtApp", inheritance.PostExtApp.ToString().ToLowerInvariant())); + if (inheritance.MacAddress) + element.Add(new XAttribute("InheritMacAddress", inheritance.MacAddress.ToString().ToLowerInvariant())); + if (inheritance.UserField) + element.Add(new XAttribute("InheritUserField", inheritance.UserField.ToString().ToLowerInvariant())); + if (inheritance.Favorite) + element.Add(new XAttribute("InheritFavorite", inheritance.Favorite.ToString().ToLowerInvariant())); + if (inheritance.ExtApp) + element.Add(new XAttribute("InheritExtApp", inheritance.ExtApp.ToString().ToLowerInvariant())); + if (inheritance.VNCCompression) + element.Add(new XAttribute("InheritVNCCompression", inheritance.VNCCompression.ToString().ToLowerInvariant())); + if (inheritance.VNCEncoding) + element.Add(new XAttribute("InheritVNCEncoding", inheritance.VNCEncoding.ToString().ToLowerInvariant())); + if (inheritance.VNCAuthMode) + element.Add(new XAttribute("InheritVNCAuthMode", inheritance.VNCAuthMode.ToString().ToLowerInvariant())); + if (inheritance.VNCProxyType) + element.Add(new XAttribute("InheritVNCProxyType", inheritance.VNCProxyType.ToString().ToLowerInvariant())); + if (inheritance.VNCProxyIP) + element.Add(new XAttribute("InheritVNCProxyIP", inheritance.VNCProxyIP.ToString().ToLowerInvariant())); + if (inheritance.VNCProxyPort) + element.Add(new XAttribute("InheritVNCProxyPort", inheritance.VNCProxyPort.ToString().ToLowerInvariant())); + if (inheritance.VNCProxyUsername) + element.Add(new XAttribute("InheritVNCProxyUsername", inheritance.VNCProxyUsername.ToString().ToLowerInvariant())); + if (inheritance.VNCProxyPassword) + element.Add(new XAttribute("InheritVNCProxyPassword", inheritance.VNCProxyPassword.ToString().ToLowerInvariant())); + if (inheritance.VNCColors) + element.Add(new XAttribute("InheritVNCColors", inheritance.VNCColors.ToString().ToLowerInvariant())); + if (inheritance.VNCSmartSizeMode) + element.Add(new XAttribute("InheritVNCSmartSizeMode", inheritance.VNCSmartSizeMode.ToString().ToLowerInvariant())); + if (inheritance.VNCViewOnly) + element.Add(new XAttribute("InheritVNCViewOnly", inheritance.VNCViewOnly.ToString().ToLowerInvariant())); + if (inheritance.RDGatewayUsageMethod) + element.Add(new XAttribute("InheritRDGatewayUsageMethod", inheritance.RDGatewayUsageMethod.ToString().ToLowerInvariant())); + if (inheritance.RDGatewayHostname) + element.Add(new XAttribute("InheritRDGatewayHostname", inheritance.RDGatewayHostname.ToString().ToLowerInvariant())); + if (inheritance.RDGatewayUseConnectionCredentials) + element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", inheritance.RDGatewayUseConnectionCredentials.ToString().ToLowerInvariant())); + if (inheritance.RDGatewayUsername) + element.Add(new XAttribute("InheritRDGatewayUsername", inheritance.RDGatewayUsername.ToString().ToLowerInvariant())); + if (inheritance.RDGatewayPassword) + element.Add(new XAttribute("InheritRDGatewayPassword", inheritance.RDGatewayPassword.ToString().ToLowerInvariant())); + if (inheritance.RDGatewayDomain) + element.Add(new XAttribute("InheritRDGatewayDomain", inheritance.RDGatewayDomain.ToString().ToLowerInvariant())); + if (inheritance.RDGatewayExternalCredentialProvider) + element.Add(new XAttribute("InheritRDGatewayExternalCredentialProvider", inheritance.RDGatewayExternalCredentialProvider.ToString().ToLowerInvariant())); + if (inheritance.RDGatewayUserViaAPI) + element.Add(new XAttribute("InheritRDGatewayUserViaAPI", inheritance.RDGatewayUserViaAPI.ToString().ToLowerInvariant())); + + if (inheritance.VmId) + element.Add(new XAttribute("InheritVmId", inheritance.VmId.ToString().ToLowerInvariant())); + if (inheritance.UseVmId) + element.Add(new XAttribute("InheritUseVmId", inheritance.UseVmId.ToString().ToLowerInvariant())); + if (inheritance.UseEnhancedMode) + element.Add(new XAttribute("InheritUseEnhancedMode", inheritance.UseEnhancedMode.ToString().ToLowerInvariant())); + if (inheritance.ExternalCredentialProvider) + element.Add(new XAttribute("InheritExternalCredentialProvider", inheritance.ExternalCredentialProvider.ToString().ToLowerInvariant())); + if (inheritance.UserViaAPI) + element.Add(new XAttribute("InheritUserViaAPI", inheritance.UserViaAPI.ToString().ToLowerInvariant())); + if (inheritance.UseRCG) + element.Add(new XAttribute("InheritUseRCG", inheritance.UseRCG.ToString().ToLowerInvariant())); + if (inheritance.UseRestrictedAdmin) + element.Add(new XAttribute("InheritUseRestrictedAdmin", inheritance.UseRestrictedAdmin.ToString().ToLowerInvariant())); } } } \ No newline at end of file diff --git a/mRemoteNG/Connection/DefaultConnectionInfo.cs b/mRemoteNG/Connection/DefaultConnectionInfo.cs index 21b596d8..ebe86d79 100644 --- a/mRemoteNG/Connection/DefaultConnectionInfo.cs +++ b/mRemoteNG/Connection/DefaultConnectionInfo.cs @@ -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); } diff --git a/mRemoteNGTests/Connection/DefaultConnectionInfoTests.cs b/mRemoteNGTests/Connection/DefaultConnectionInfoTests.cs index bafb4e14..7407a366 100644 --- a/mRemoteNGTests/Connection/DefaultConnectionInfoTests.cs +++ b/mRemoteNGTests/Connection/DefaultConnectionInfoTests.cs @@ -43,13 +43,13 @@ namespace mRemoteNGTests.Connection { var saveTarget = new SerializableConnectionInfoAllPropertiesOfType(); - // 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)); }