fix for Warning CA1416

This commit is contained in:
Dimitrij
2023-03-11 01:46:11 +00:00
parent 93fe32491b
commit 40af584afe
94 changed files with 252 additions and 183 deletions

View File

@@ -8,10 +8,12 @@ using mRemoteNG.Connection.Protocol;
using mRemoteNG.Container;
using mRemoteNG.Tools;
using mRemoteNG.Resources.Language;
using System.Runtime.Versioning;
namespace mRemoteNG.App
{
public static class Import
[SupportedOSPlatform("windows")]
public static class Import
{
public static void ImportFromFile(ContainerInfo importDestinationContainer)
{

View File

@@ -1,12 +1,12 @@
using System;
namespace mRemoteNG.App.Info
{
public static class ConnectionsFileInfo
{
public static readonly string DefaultConnectionsPath = SettingsFileInfo.SettingsPath;
public static readonly string DefaultConnectionsFile = "confCons.xml";
public static readonly string DefaultConnectionsFileNew = "confConsNew.xml";
public static readonly Version ConnectionFileVersion = new Version(2, 9);
}
namespace mRemoteNG.App.Info
{
public static class ConnectionsFileInfo
{
public static readonly string DefaultConnectionsPath = SettingsFileInfo.SettingsPath;
public static readonly string DefaultConnectionsFile = "confCons.xml";
public static readonly string DefaultConnectionsFileNew = "confConsNew.xml";
public static readonly Version ConnectionFileVersion = new Version(2, 9);
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.Versioning;
using System.Threading;
using System.Windows.Forms;
using static System.Environment;
@@ -9,6 +10,7 @@ using static System.Environment;
namespace mRemoteNG.App.Info
{
[SupportedOSPlatform("windows")]
public static class GeneralAppInfo
{
public const string UrlHome = "https://www.mremoteng.org";

View File

@@ -1,11 +1,13 @@
using System;
using System.IO;
using System.Reflection;
using System.Runtime.Versioning;
using System.Windows.Forms;
using mRemoteNG.Connection;
namespace mRemoteNG.App.Info
{
[SupportedOSPlatform("windows")]
public static class SettingsFileInfo
{
private static readonly string ExePath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(ConnectionInfo))?.Location);

View File

@@ -1,10 +1,12 @@
using System;
using System.Runtime.Versioning;
using mRemoteNG.Properties;
// ReSharper disable InconsistentNaming
namespace mRemoteNG.App.Info
{
[SupportedOSPlatform("windows")]
public static class UpdateChannelInfo
{
public const string STABLE = "Stable";

View File

@@ -1,10 +1,12 @@
using System;
using System.IO;
using System.Runtime.Versioning;
using mRemoteNG.Connection;
namespace mRemoteNG.App.Initialization
{
[SupportedOSPlatform("windows")]
public class ConnectionIconLoader
{
private readonly string _path;

View File

@@ -1,9 +1,11 @@
using System.IO;
using System.Runtime.Versioning;
using mRemoteNG.Config.Connections;
using mRemoteNG.Properties;
namespace mRemoteNG.App.Initialization
{
[SupportedOSPlatform("windows")]
public class CredsAndConsSetup
{
public void LoadCredsAndCons()

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Versioning;
using mRemoteNG.Messages;
using mRemoteNG.Messages.MessageFilteringOptions;
using mRemoteNG.Messages.MessageWriters;
@@ -7,6 +8,7 @@ using mRemoteNG.Messages.WriterDecorators;
namespace mRemoteNG.App.Initialization
{
[SupportedOSPlatform("windows")]
public class MessageCollectorSetup
{
public static void SetupMessageCollector(MessageCollector messageCollector,

View File

@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Reflection;
using System.Runtime.Versioning;
using System.Windows.Forms;
using log4net;
using log4net.Appender;
@@ -11,6 +12,7 @@ using mRemoteNG.Properties;
namespace mRemoteNG.App
{
[SupportedOSPlatform("windows")]
public class Logger
{
public static readonly Logger Instance = new Logger();

View File

@@ -2,6 +2,7 @@
using System.Drawing;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
#pragma warning disable 649
@@ -9,6 +10,7 @@ using System.Text;
namespace mRemoteNG.App
{
[SupportedOSPlatform("windows")]
public static class NativeMethods
{
#region Functions

View File

@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.Versioning;
using System.Threading;
using System.Windows;
using System.Windows.Forms;
@@ -9,6 +10,7 @@ using mRemoteNG.UI.Forms;
namespace mRemoteNG.App
{
[SupportedOSPlatform("windows")]
public static class ProgramRoot
{
private static Mutex _mutex;

View File

@@ -1,4 +1,5 @@
using System.Windows.Forms;
using System.Runtime.Versioning;
using System.Windows.Forms;
using mRemoteNG.UI.Forms;
using WeifenLuo.WinFormsUI.Docking;
@@ -6,6 +7,7 @@ namespace mRemoteNG.App
{
public static class Screens
{
[SupportedOSPlatform("windows")]
public static void SendFormToScreen(Screen screen)
{
var frmMain = FrmMain.Default;

View File

@@ -2,6 +2,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using mRemoteNG.App.Info;
using mRemoteNG.App.Initialization;
@@ -18,6 +19,7 @@ using mRemoteNG.UI.Forms;
namespace mRemoteNG.App
{
[SupportedOSPlatform("windows")]
public class Startup
{
private AppUpdater _appUpdate;

View File

@@ -3,12 +3,14 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using mRemoteNG.Properties;
// ReSharper disable ArrangeAccessorOwnerBody
namespace mRemoteNG.App
{
[SupportedOSPlatform("windows")]
[Serializable]
public sealed class SupportedCultures : Dictionary<string, string>
{

View File

@@ -8,6 +8,7 @@ using mRemoteNG.Security.SymmetricEncryption;
using System.Security.Cryptography;
using System.Threading.Tasks;
using mRemoteNG.Properties;
using System.Runtime.Versioning;
#if !PORTABLE
using mRemoteNG.Tools;
@@ -19,6 +20,7 @@ using System.Windows.Forms;
namespace mRemoteNG.App.Update
{
[SupportedOSPlatform("windows")]
public class AppUpdater
{
private const int _bufferLength = 8192;

View File

@@ -1,5 +1,6 @@
#region Usings
using System;
using System.Runtime.Versioning;
using mRemoteNG.Resources.Language;
using mRemoteNG.UI;
using mRemoteNG.UI.Forms;
@@ -8,6 +9,7 @@ using mRemoteNG.UI.Window;
namespace mRemoteNG.App
{
[SupportedOSPlatform("windows")]
public static class Windows
{
private static ActiveDirectoryImportWindow _adimportForm;

View File

@@ -1,4 +1,5 @@
using System;
using System.Runtime.Versioning;
using mRemoteNG.App;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers.ConnectionSerializers.Csv;
@@ -7,6 +8,7 @@ using mRemoteNG.Tree;
namespace mRemoteNG.Config.Connections
{
[SupportedOSPlatform("windows")]
public class CsvConnectionsSaver : ISaver<ConnectionTreeModel>
{
private readonly string _connectionFileName;

View File

@@ -1,11 +1,13 @@
using mRemoteNG.App;
using System;
using System.Runtime.Versioning;
using System.Timers;
// ReSharper disable ArrangeAccessorOwnerBody
namespace mRemoteNG.Config.Connections.Multiuser
{
[SupportedOSPlatform("windows")]
public class RemoteConnectionsSyncronizer : IConnectionsUpdateChecker
{
private readonly System.Timers.Timer _updateTimer;

View File

@@ -4,9 +4,11 @@ using System.ComponentModel;
using mRemoteNG.Connection;
using mRemoteNG.UI.Forms;
using mRemoteNG.Properties;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Connections
{
[SupportedOSPlatform("windows")]
public class SaveConnectionsOnEdit
{
private readonly ConnectionsService _connectionsService;

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Versioning;
using System.Security;
using mRemoteNG.Config.DatabaseConnectors;
using mRemoteNG.Config.DataProviders;
@@ -17,6 +18,7 @@ using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Connections
{
[SupportedOSPlatform("windows")]
public class SqlConnectionsLoader : IConnectionsLoader
{
private readonly IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>>

View File

@@ -19,10 +19,12 @@ using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using mRemoteNG.Resources.Language;
using mRemoteNG.Properties;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Connections
{
public class SqlConnectionsSaver : ISaver<ConnectionTreeModel>
[SupportedOSPlatform("windows")]
public class SqlConnectionsSaver : ISaver<ConnectionTreeModel>
{
private readonly SaveFilter _saveFilter;
private readonly ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string> _localPropertiesSerializer;

View File

@@ -5,9 +5,11 @@ using System;
using System.IO;
using System.Security;
using mRemoteNG.Config.Serializers.ConnectionSerializers.Xml;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Connections
{
[SupportedOSPlatform("windows")]
public class XmlConnectionsLoader : IConnectionsLoader
{
private readonly string _connectionFilePath;

View File

@@ -8,9 +8,11 @@ using mRemoteNG.Security.Factories;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using mRemoteNG.Properties;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Connections
{
[SupportedOSPlatform("windows")]
public class XmlConnectionsSaver : ISaver<ConnectionTreeModel>
{
private readonly string _connectionFileName;

View File

@@ -38,9 +38,7 @@ namespace mRemoteNG.Config
if (ConnectionToCredentialMap.Values.Contains(newCredential, _credentialComparer))
{
var existingCredential =
ConnectionToCredentialMap.Values.First(record =>
_credentialComparer.Equals(newCredential, record));
var existingCredential = ConnectionToCredentialMap.Values.First(record => _credentialComparer.Equals(newCredential, record));
ConnectionToCredentialMap.Add(connectionId, existingCredential);
}
else
@@ -50,17 +48,14 @@ namespace mRemoteNG.Config
return ConnectionToCredentialMap.Values.Distinct(_credentialComparer);
}
private ICredentialRecord BuildCredential(XElement element,
ICryptographyProvider cryptographyProvider,
SecureString decryptionKey)
private ICredentialRecord BuildCredential(XElement element, ICryptographyProvider cryptographyProvider, SecureString decryptionKey)
{
var credential = new CredentialRecord
{
Title = $"{element.Attribute("Username")?.Value}\\{element.Attribute("Domain")?.Value}",
Username = element.Attribute("Username")?.Value,
Domain = element.Attribute("Domain")?.Value,
Password = cryptographyProvider.Decrypt(element.Attribute("Password")?.Value, decryptionKey)
.ConvertToSecureString()
Password = cryptographyProvider.Decrypt(element.Attribute("Password")?.Value, decryptionKey).ConvertToSecureString()
};
return credential;
}

View File

@@ -13,8 +13,7 @@ namespace mRemoteNG.Config
private readonly IDataProvider<string> _dataProvider;
private readonly ISecureSerializer<IEnumerable<ICredentialRecord>, string> _serializer;
public CredentialRecordSaver(IDataProvider<string> dataProvider,
ISecureSerializer<IEnumerable<ICredentialRecord>, string> serializer)
public CredentialRecordSaver(IDataProvider<string> dataProvider, ISecureSerializer<IEnumerable<ICredentialRecord>, string> serializer)
{
if (dataProvider == null)
throw new ArgumentNullException(nameof(dataProvider));

View File

@@ -11,8 +11,7 @@ namespace mRemoteNG.Config
private readonly IDataProvider<string> _dataProvider;
private readonly CredentialRepositoryListDeserializer _deserializer;
public CredentialRepositoryListLoader(IDataProvider<string> dataProvider,
CredentialRepositoryListDeserializer deserializer)
public CredentialRepositoryListLoader(IDataProvider<string> dataProvider, CredentialRepositoryListDeserializer deserializer)
{
if (dataProvider == null)
throw new ArgumentNullException(nameof(dataProvider));

View File

@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Runtime.Versioning;
using mRemoteNG.App;
using mRemoteNG.Messages;
using mRemoteNG.Resources.Language;
@@ -8,6 +9,7 @@ namespace mRemoteNG.Config.DataProviders
{
public class FileBackupCreator
{
[SupportedOSPlatform("windows")]
public void CreateBackupFile(string fileName)
{
try

View File

@@ -1,11 +1,14 @@
using System;
using System.IO;
using System.Runtime.Versioning;
using mRemoteNG.App;
namespace mRemoteNG.Config.DataProviders
{
[SupportedOSPlatform("windows")]
public class FileDataProvider : IDataProvider<string>
{
[SupportedOSPlatform("windows")]
public string FilePath { get; set; }
public FileDataProvider(string filePath)

View File

@@ -1,5 +1,8 @@
namespace mRemoteNG.Config.DataProviders
using System.Runtime.Versioning;
namespace mRemoteNG.Config.DataProviders
{
[SupportedOSPlatform("windows")]
public class FileDataProviderWithRollingBackup : FileDataProvider
{
private readonly FileBackupCreator _fileBackupCreator;

View File

@@ -5,9 +5,11 @@ using mRemoteNG.App;
using mRemoteNG.Properties;
using MySql.Data.MySqlClient;
using System.Data.SqlClient;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.DataProviders
{
[SupportedOSPlatform("windows")]
public class SqlDataProvider : IDataProvider<DataTable>
{
public IDatabaseConnector DatabaseConnector { get; }

View File

@@ -1,9 +1,11 @@
using mRemoteNG.App;
using mRemoteNG.Properties;
using mRemoteNG.Security.SymmetricEncryption;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.DatabaseConnectors
{
[SupportedOSPlatform("windows")]
public class DatabaseConnectorFactory
{
public static IDatabaseConnector DatabaseConnectorFromSettings()

View File

@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Runtime.Versioning;
using mRemoteNG.App;
using mRemoteNG.Config.Serializers.MiscSerializers;
using mRemoteNG.Container;
@@ -7,6 +8,7 @@ using mRemoteNG.Tools;
namespace mRemoteNG.Config.Import
{
[SupportedOSPlatform("windows")]
public class ActiveDirectoryImporter : IConnectionImporter<string>
{
public void Import(string ldapPath, ContainerInfo destinationContainer)

View File

@@ -1,5 +1,6 @@
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using mRemoteNG.App;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers.ConnectionSerializers.Csv;
@@ -8,6 +9,7 @@ using mRemoteNG.Messages;
namespace mRemoteNG.Config.Import
{
[SupportedOSPlatform("windows")]
public class MRemoteNGCsvImporter : IConnectionImporter<string>
{
public void Import(string filePath, ContainerInfo destinationContainer)

View File

@@ -1,5 +1,6 @@
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using mRemoteNG.App;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers.ConnectionSerializers.Xml;
@@ -9,6 +10,7 @@ using mRemoteNG.Messages;
namespace mRemoteNG.Config.Import
{
[SupportedOSPlatform("windows")]
// ReSharper disable once InconsistentNaming
public class MRemoteNGXmlImporter : IConnectionImporter<string>
{

View File

@@ -1,4 +1,5 @@
using System.Linq;
using System.Runtime.Versioning;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers.MiscSerializers;
using mRemoteNG.Container;
@@ -6,6 +7,7 @@ using mRemoteNG.Container;
namespace mRemoteNG.Config.Import
{
[SupportedOSPlatform("windows")]
public class RemoteDesktopConnectionManagerImporter : IConnectionImporter<string>
{
public void Import(string filePath, ContainerInfo destinationContainer)

View File

@@ -1,6 +1,7 @@
#region
using System.IO;
using System.Runtime.Versioning;
using Castle.Core.Internal;
using mRemoteNG.App;
using mRemoteNG.Config.DataProviders;
@@ -10,38 +11,39 @@ using mRemoteNG.Messages;
#endregion
namespace mRemoteNG.Config.Import;
public class RemoteDesktopManagerImporter : IConnectionImporter<string>
namespace mRemoteNG.Config.Import
{
public void Import(string filePath, ContainerInfo destinationContainer)
[SupportedOSPlatform("windows")]
public class RemoteDesktopManagerImporter : IConnectionImporter<string>
{
if (string.IsNullOrEmpty(filePath))
public void Import(string filePath, ContainerInfo destinationContainer)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Unable to import file. File path is null.");
return;
}
if (string.IsNullOrEmpty(filePath))
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File path is null.");
return;
}
if (!File.Exists(filePath))
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
$"Unable to import file. File does not exist. Path: {filePath}");
if (!File.Exists(filePath))
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {filePath}");
var dataProvider = new FileDataProvider(filePath);
var csvString = dataProvider.Load();
var dataProvider = new FileDataProvider(filePath);
var csvString = dataProvider.Load();
if (!string.IsNullOrEmpty(csvString))
{
var csvDeserializer = new CsvConnectionsDeserializerRdmFormat();
var connectionTreeModel = csvDeserializer.Deserialize(csvString);
if (!string.IsNullOrEmpty(csvString))
{
var csvDeserializer = new CsvConnectionsDeserializerRdmFormat();
var connectionTreeModel = csvDeserializer.Deserialize(csvString);
var rootContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(filePath) };
rootContainer.AddChildRange(connectionTreeModel.RootNodes);
destinationContainer.AddChild(rootContainer);
}
else
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Unable to import file. File is empty.");
return;
var rootContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(filePath) };
rootContainer.AddChildRange(connectionTreeModel.RootNodes);
destinationContainer.AddChild(rootContainer);
}
else
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Unable to import file. File is empty.");
return;
}
}
}
}

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Runtime.Versioning;
using mRemoteNG.Tools;
using mRemoteNG.Tree.Root;
@@ -8,6 +9,7 @@ using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Putty
{
[SupportedOSPlatform("windows")]
public class PuttySessionsManager
{
public static PuttySessionsManager Instance { get; } = new PuttySessionsManager();

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Versioning;
using System.Security;
using mRemoteNG.App;
using mRemoteNG.Connection;
@@ -17,6 +18,7 @@ using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
{
[SupportedOSPlatform("windows")]
public class DataTableDeserializer : IDeserializer<DataTable, ConnectionTreeModel>
{
private readonly ICryptographyProvider _cryptographyProvider;

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Versioning;
using System.Security;
using mRemoteNG.Connection;
using mRemoteNG.Container;
@@ -12,6 +13,7 @@ using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
{
[SupportedOSPlatform("windows")]
public class DataTableSerializer : ISerializer<ConnectionInfo, DataTable>
{
public readonly int DELETE = 0;

View File

@@ -1,6 +1,7 @@
using System;
using System.Data.Common;
using System.Globalization;
using System.Runtime.Versioning;
using mRemoteNG.App;
using mRemoteNG.App.Info;
using mRemoteNG.Config.DatabaseConnectors;
@@ -12,6 +13,7 @@ using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
{
[SupportedOSPlatform("windows")]
public class SqlDatabaseMetaDataRetriever
{
public SqlConnectionListMetaData GetDatabaseMetaData(IDatabaseConnector databaseConnector)

View File

@@ -1,4 +1,5 @@
using System;
using System.Runtime.Versioning;
using System.Security;
using System.Xml.Linq;
using mRemoteNG.App;
@@ -9,6 +10,7 @@ using mRemoteNG.Security;
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
{
// ReSharper disable once InconsistentNaming
[SupportedOSPlatform("windows")]
public class XmlConnectionNodeSerializer27 : ISerializer<ConnectionInfo, XElement>
{
private readonly ICryptographyProvider _cryptographyProvider;

View File

@@ -18,9 +18,11 @@ using mRemoteNG.Tree.Root;
using mRemoteNG.UI.Forms;
using mRemoteNG.UI.TaskDialog;
using mRemoteNG.Resources.Language;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
{
[SupportedOSPlatform("windows")]
public class XmlConnectionsDeserializer : IDeserializer<string, ConnectionTreeModel>
{
private XmlDocument _xmlDocument;

View File

@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using System.Text;
using System.Xml;
using System.Xml.Linq;
@@ -12,6 +13,7 @@ using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
{
[SupportedOSPlatform("windows")]
public class XmlConnectionsSerializer : ISerializer<ConnectionTreeModel, string>,
ISerializer<ConnectionInfo, string>
{

View File

@@ -7,10 +7,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
{
public class XmlRootNodeSerializer
{
public XElement SerializeRootNodeInfo(RootNodeInfo rootNodeInfo,
ICryptographyProvider cryptographyProvider,
Version version,
bool fullFileEncryption = false)
public XElement SerializeRootNodeInfo(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider, Version version, bool fullFileEncryption = false)
{
XNamespace xmlNamespace = "http://mremoteng.org";
var element = new XElement(xmlNamespace + "Connections");
@@ -20,15 +17,13 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
element.Add(new XAttribute(XName.Get("EncryptionEngine"), cryptographyProvider.CipherEngine));
element.Add(new XAttribute(XName.Get("BlockCipherMode"), cryptographyProvider.CipherMode));
element.Add(new XAttribute(XName.Get("KdfIterations"), cryptographyProvider.KeyDerivationIterations));
element.Add(new XAttribute(XName.Get("FullFileEncryption"),
fullFileEncryption.ToString().ToLowerInvariant()));
element.Add(new XAttribute(XName.Get("FullFileEncryption"), fullFileEncryption.ToString().ToLowerInvariant()));
element.Add(CreateProtectedAttribute(rootNodeInfo, cryptographyProvider));
element.Add(new XAttribute(XName.Get("ConfVersion"), version.ToString(2)));
return element;
}
private XAttribute CreateProtectedAttribute(RootNodeInfo rootNodeInfo,
ICryptographyProvider cryptographyProvider)
private XAttribute CreateProtectedAttribute(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider)
{
var attribute = new XAttribute(XName.Get("Protected"), "");
var plainText = rootNodeInfo.Password ? "ThisIsProtected" : "ThisIsNotProtected";

View File

@@ -44,9 +44,7 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
return xdoc.ToString();
}
private void DecryptAuthHeader(XElement rootElement,
ICryptographyProvider cryptographyProvider,
SecureString key)
private void DecryptAuthHeader(XElement rootElement, ICryptographyProvider cryptographyProvider, SecureString key)
{
var authAttribute = rootElement.Attribute("Auth");
if (authAttribute == null)

View File

@@ -12,9 +12,7 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
private readonly ISerializer<IEnumerable<ICredentialRecord>, string> _baseSerializer;
private readonly ICryptographyProvider _cryptographyProvider;
public XmlCredentialPasswordEncryptorDecorator(ICryptographyProvider cryptographyProvider,
ISerializer<IEnumerable<ICredentialRecord>, string>
baseSerializer)
public XmlCredentialPasswordEncryptorDecorator(ICryptographyProvider cryptographyProvider, ISerializer<IEnumerable<ICredentialRecord>, string> baseSerializer)
{
if (baseSerializer == null)
throw new ArgumentNullException(nameof(baseSerializer));
@@ -56,9 +54,7 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
xdoc.Root?.SetAttributeValue("EncryptionEngine", _cryptographyProvider.CipherEngine);
xdoc.Root?.SetAttributeValue("BlockCipherMode", _cryptographyProvider.CipherMode);
xdoc.Root?.SetAttributeValue("KdfIterations", _cryptographyProvider.KeyDerivationIterations);
xdoc.Root?.SetAttributeValue("Auth",
_cryptographyProvider.Encrypt(RandomGenerator.RandomString(20),
encryptionKey));
xdoc.Root?.SetAttributeValue("Auth", _cryptographyProvider.Encrypt(RandomGenerator.RandomString(20), encryptionKey));
}
}
}

View File

@@ -34,8 +34,7 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
{
var docSchemaVersion = rootElement?.Attribute("SchemaVersion")?.Value;
if (docSchemaVersion != SchemaVersion)
throw new Exception(
$"The schema version of this document is not supported by this class. Document Version: {docSchemaVersion} Supported Version: {SchemaVersion}");
throw new Exception($"The schema version of this document is not supported by this class. Document Version: {docSchemaVersion} Supported Version: {SchemaVersion}");
}
}
}

View File

@@ -22,9 +22,7 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
new XAttribute("Title", r.Title),
new XAttribute("Username", r.Username),
new XAttribute("Domain", r.Domain),
new XAttribute("Password",
r.Password
.ConvertToUnsecureString())
new XAttribute("Password", r.Password.ConvertToUnsecureString())
)
)
)

View File

@@ -82,8 +82,7 @@ namespace mRemoteNG.Config.Serializers.MiscSerializers
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.ImportComputers() failed.",
ex);
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.ImportComputers() failed.", ex);
}
}

View File

@@ -4,9 +4,11 @@ using mRemoteNG.Config.DatabaseConnectors;
using mRemoteNG.Messages;
using mRemoteNG.Resources.Language;
using System;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Serializers.Versioning
{
[SupportedOSPlatform("windows")]
public class SqlDatabaseVersionVerifier
{
protected readonly Version currentSupportedVersion = new Version(2, 9);

View File

@@ -2,9 +2,11 @@
using mRemoteNG.Config.DatabaseConnectors;
using mRemoteNG.Messages;
using System;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Serializers.Versioning
{
[SupportedOSPlatform("windows")]
public class SqlVersion22To23Upgrader : IVersionUpgrader
{
private readonly IDatabaseConnector _databaseConnector;
@@ -24,8 +26,7 @@ namespace mRemoteNG.Config.Serializers.Versioning
public Version Upgrade()
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
"Upgrading database from version 2.2 to version 2.3.");
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.2 to version 2.3.");
const string sqlText = @"
ALTER TABLE tblCons
ADD EnableFontSmoothing bit NOT NULL DEFAULT 0,

View File

@@ -2,9 +2,11 @@
using mRemoteNG.Config.DatabaseConnectors;
using mRemoteNG.Messages;
using System;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Serializers.Versioning
{
[SupportedOSPlatform("windows")]
public class SqlVersion23To24Upgrader : IVersionUpgrader
{
private readonly IDatabaseConnector _databaseConnector;

View File

@@ -2,9 +2,11 @@
using mRemoteNG.Config.DatabaseConnectors;
using mRemoteNG.Messages;
using System;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Serializers.Versioning
{
[SupportedOSPlatform("windows")]
public class SqlVersion24To25Upgrader : IVersionUpgrader
{
private readonly IDatabaseConnector _databaseConnector;

View File

@@ -2,9 +2,11 @@
using mRemoteNG.Config.DatabaseConnectors;
using mRemoteNG.Messages;
using System;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Serializers.Versioning
{
[SupportedOSPlatform("windows")]
public class SqlVersion25To26Upgrader : IVersionUpgrader
{
private readonly IDatabaseConnector _databaseConnector;

View File

@@ -3,9 +3,11 @@ using mRemoteNG.Config.DatabaseConnectors;
using mRemoteNG.Messages;
using System;
using System.Data.SqlClient;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Serializers.Versioning
{
[SupportedOSPlatform("windows")]
public class SqlVersion26To27Upgrader : IVersionUpgrader
{
private readonly IDatabaseConnector _databaseConnector;

View File

@@ -4,9 +4,11 @@ using mRemoteNG.Messages;
using System;
using System.Data.Common;
using System.Data.SqlClient;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Serializers.Versioning
{
[SupportedOSPlatform("windows")]
public class SqlVersion27To28Upgrader : IVersionUpgrader
{
private readonly IDatabaseConnector _databaseConnector;

View File

@@ -3,9 +3,11 @@ using mRemoteNG.Config.DatabaseConnectors;
using mRemoteNG.Messages;
using System;
using System.Data.Common;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Serializers.Versioning
{
[SupportedOSPlatform("windows")]
public class SqlVersion28To29Upgrader : IVersionUpgrader
{
private readonly Version version = new Version(2, 9);

View File

@@ -29,9 +29,7 @@ namespace mRemoteNG.Config.Serializers
_rootNodeInfo = rootNodeInfo;
}
public XmlConnectionsDecryptor(BlockCipherEngines blockCipherEngine,
BlockCipherModes blockCipherMode,
RootNodeInfo rootNodeInfo)
public XmlConnectionsDecryptor(BlockCipherEngines blockCipherEngine, BlockCipherModes blockCipherMode, RootNodeInfo rootNodeInfo)
{
_cryptographyProvider = new CryptoProviderFactory(blockCipherEngine, blockCipherMode).Build();
_rootNodeInfo = rootNodeInfo;
@@ -54,8 +52,7 @@ namespace mRemoteNG.Config.Serializers
try
{
decryptedContent =
_cryptographyProvider.Decrypt(xml, _rootNodeInfo.PasswordString.ConvertToSecureString());
decryptedContent = _cryptographyProvider.Decrypt(xml, _rootNodeInfo.PasswordString.ConvertToSecureString());
notDecr = decryptedContent == xml;
}
catch (Exception)
@@ -88,17 +85,13 @@ namespace mRemoteNG.Config.Serializers
var connectionsFileIsNotEncrypted = false;
try
{
connectionsFileIsNotEncrypted =
_cryptographyProvider.Decrypt(protectedString,
_rootNodeInfo.PasswordString.ConvertToSecureString()) ==
"ThisIsNotProtected";
connectionsFileIsNotEncrypted = _cryptographyProvider.Decrypt(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString()) == "ThisIsNotProtected";
}
catch (EncryptionException)
{
}
return connectionsFileIsNotEncrypted ||
Authenticate(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString());
return connectionsFileIsNotEncrypted || Authenticate(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString());
}
private bool Authenticate(string cipherText, SecureString password)

View File

@@ -6,9 +6,11 @@ using System;
using System.IO;
using mRemoteNG.Messages;
using WeifenLuo.WinFormsUI.Docking;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Settings
{
[SupportedOSPlatform("windows")]
public class DockPanelLayoutLoader
{
private readonly FrmMain _mainForm;

View File

@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Runtime.Versioning;
using mRemoteNG.App;
using mRemoteNG.App.Info;
using mRemoteNG.Config.DataProviders;
@@ -9,6 +10,7 @@ using WeifenLuo.WinFormsUI.Docking;
namespace mRemoteNG.Config.Settings
{
[SupportedOSPlatform("windows")]
public class DockPanelLayoutSaver
{
private readonly ISerializer<DockPanel, string> _dockPanelSerializer;

View File

@@ -7,18 +7,18 @@ using System.Xml;
using mRemoteNG.Messages;
using mRemoteNG.Tools;
using mRemoteNG.UI.Controls;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Settings
{
[SupportedOSPlatform("windows")]
public class ExternalAppsLoader
{
private readonly FrmMain _mainForm;
private readonly MessageCollector _messageCollector;
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
public ExternalAppsLoader(FrmMain mainForm,
MessageCollector messageCollector,
ExternalToolsToolStrip externalToolsToolStrip)
public ExternalAppsLoader(FrmMain mainForm, MessageCollector messageCollector, ExternalToolsToolStrip externalToolsToolStrip)
{
if (mainForm == null)
throw new ArgumentNullException(nameof(mainForm));
@@ -57,15 +57,13 @@ namespace mRemoteNG.Config.Settings
#endif
else
{
_messageCollector.AddMessage(MessageClass.WarningMsg,
"Loading External Apps failed: Could not FIND file!");
_messageCollector.AddMessage(MessageClass.WarningMsg, "Loading External Apps failed: Could not FIND file!");
return;
}
if (xDom.DocumentElement == null)
{
_messageCollector.AddMessage(MessageClass.WarningMsg,
"Loading External Apps failed: Could not LOAD file!");
_messageCollector.AddMessage(MessageClass.WarningMsg, "Loading External Apps failed: Could not LOAD file!");
return;
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Versioning;
using System.Text;
using System.Xml;
using mRemoteNG.App;
@@ -9,6 +10,7 @@ using mRemoteNG.Tools;
namespace mRemoteNG.Config.Settings
{
[SupportedOSPlatform("windows")]
public class ExternalAppsSaver
{
public void Save(IEnumerable<ExternalTool> externalTools)

View File

@@ -11,10 +11,11 @@ using mRemoteNG.Messages;
using mRemoteNG.Tools;
using mRemoteNG.UI.Controls;
using mRemoteNG.UI.Forms;
using System.Runtime.Versioning;
namespace mRemoteNG.Config.Settings
{
[SupportedOSPlatform("windows")]
public class SettingsLoader
{
private readonly ExternalAppsLoader _externalAppsLoader;

View File

@@ -1,4 +1,5 @@
using System;
using System.Runtime.Versioning;
using System.Windows.Forms;
using mRemoteNG.App;
using mRemoteNG.App.Info;
@@ -9,6 +10,7 @@ using mRemoteNG.UI.Forms;
namespace mRemoteNG.Config.Settings
{
[SupportedOSPlatform("windows")]
public static class SettingsSaver
{
public static void SaveSettings(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)

View File

@@ -41,9 +41,7 @@ namespace mRemoteNG.Connection
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg,
$"Couldn\'t get Icon from String" + Environment.NewLine +
ex.Message);
Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, $"Couldn\'t get Icon from String" + Environment.NewLine + ex.Message);
}
return null;

View File

@@ -18,9 +18,11 @@ using mRemoteNG.Properties;
using mRemoteNG.Tree;
using mRemoteNG.Resources.Language;
using mRemoteNG.Tree.Root;
using System.Runtime.Versioning;
namespace mRemoteNG.Connection
{
[SupportedOSPlatform("windows")]
[DefaultProperty("Name")]
public class ConnectionInfo : AbstractConnectionRecord, IHasParent, IInheritable
{
@@ -215,8 +217,7 @@ namespace mRemoteNG.Connection
{
var inheritType = Inheritance.GetType();
var inheritPropertyInfo = inheritType.GetProperty(propertyName);
var inheritPropertyValue = inheritPropertyInfo != null &&
Convert.ToBoolean(inheritPropertyInfo.GetValue(Inheritance, null));
var inheritPropertyValue = inheritPropertyInfo != null && Convert.ToBoolean(inheritPropertyInfo.GetValue(Inheritance, null));
return inheritPropertyValue;
}
@@ -236,9 +237,7 @@ namespace mRemoteNG.Connection
}
catch (Exception e)
{
Runtime.MessageCollector.AddExceptionStackTrace(
$"Error retrieving inherited property '{propertyName}'", e
);
Runtime.MessageCollector.AddExceptionStackTrace($"Error retrieving inherited property '{propertyName}'", e);
inheritedValue = default(TPropertyType);
return false;
}

View File

@@ -78,8 +78,7 @@ namespace mRemoteNG.Connection
if (connectionInfo.Hostname == "" && connectionInfo.Protocol != ProtocolType.IntApp)
{
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
Language.ConnectionOpenFailedNoHostname);
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, Language.ConnectionOpenFailedNoHostname);
return;
}
@@ -108,8 +107,7 @@ namespace mRemoteNG.Connection
connectionInfoSshTunnel = getSSHConnectionInfoByName(Runtime.ConnectionsService.ConnectionTreeModel.RootNodes, connectionInfoOriginal.SSHTunnelConnectionName);
if (connectionInfoSshTunnel == null)
{
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
string.Format(Language.SshTunnelConfigProblem, connectionInfoOriginal.Name, connectionInfoOriginal.SSHTunnelConnectionName));
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, string.Format(Language.SshTunnelConfigProblem, connectionInfoOriginal.Name, connectionInfoOriginal.SSHTunnelConnectionName));
return;
}
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg,

View File

@@ -1,11 +1,13 @@
using System;
using System.ComponentModel;
using System.Configuration;
using System.Runtime.Versioning;
using mRemoteNG.App;
namespace mRemoteNG.Connection
{
[SupportedOSPlatform("windows")]
public class DefaultConnectionInfo : ConnectionInfo
{
[Browsable(false)]

View File

@@ -1,10 +1,12 @@
using System;
using System.ComponentModel;
using System.Runtime.Versioning;
using mRemoteNG.App;
namespace mRemoteNG.Connection
{
[SupportedOSPlatform("windows")]
public class DefaultConnectionInheritance : ConnectionInfoInheritance
{
[Browsable(false)]

View File

@@ -5,10 +5,11 @@ using System.Drawing;
using System.Windows.Forms;
using mRemoteNG.UI.Tabs;
using WeifenLuo.WinFormsUI.Docking;
using System.Runtime.Versioning;
namespace mRemoteNG.Connection
{
[SupportedOSPlatform("windows")]
public sealed partial class InterfaceControl
{
public ProtocolBase Protocol { get; set; }

View File

@@ -5,10 +5,11 @@ using mRemoteNG.Tools;
using mRemoteNG.App;
using mRemoteNG.UI.Tabs;
using mRemoteNG.Resources.Language;
using System.Runtime.Versioning;
namespace mRemoteNG.Connection.Protocol.Http
{
[SupportedOSPlatform("windows")]
public class HTTPBase : ProtocolBase
{
#region Private Properties

View File

@@ -8,9 +8,11 @@ using mRemoteNG.Messages;
using mRemoteNG.Properties;
using mRemoteNG.Tools;
using mRemoteNG.Resources.Language;
using System.Runtime.Versioning;
namespace mRemoteNG.Connection.Protocol
{
[SupportedOSPlatform("windows")]
public class IntegratedProgram : ProtocolBase
{
#region Private Fields

View File

@@ -1,5 +1,6 @@
using System;
using System.Drawing;
using System.Runtime.Versioning;
using System.Windows.Forms;
using mRemoteNG.App;
using mRemoteNG.Messages;
@@ -7,6 +8,7 @@ using mRemoteNG.Resources.Language;
namespace mRemoteNG.Connection.Protocol.PowerShell
{
[SupportedOSPlatform("windows")]
public class ProtocolPowerShell : ProtocolBase
{
#region Private Fields
@@ -28,8 +30,7 @@ namespace mRemoteNG.Connection.Protocol.PowerShell
{
try
{
Runtime.MessageCollector?.AddMessage(MessageClass.InformationMsg,
"Attempting to start remote PowerShell session.", true);
Runtime.MessageCollector?.AddMessage(MessageClass.InformationMsg, "Attempting to start remote PowerShell session.", true);
_consoleControl = new ConsoleControl.ConsoleControl
{

View File

@@ -9,9 +9,11 @@ using System;
using mRemoteNG.Connection.Protocol.PowerShell;
using mRemoteNG.Properties;
using mRemoteNG.Resources.Language;
using System.Runtime.Versioning;
namespace mRemoteNG.Connection.Protocol
{
[SupportedOSPlatform("windows")]
public class ProtocolFactory
{
private readonly RdpProtocolFactory _rdpProtocolFactory = new RdpProtocolFactory();

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Specialized;
@@ -27,8 +27,7 @@ namespace mRemoteNG.Connection.Protocol
public void Add(ProtocolBase cProt)
{
List.Add(cProt);
RaiseCollectionChangedEvent(this,
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, cProt));
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, cProt));
}
public void AddRange(ProtocolBase[] cProt)
@@ -38,8 +37,7 @@ namespace mRemoteNG.Connection.Protocol
List.Add(cP);
}
RaiseCollectionChangedEvent(this,
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, cProt));
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, cProt));
}
public void Remove(ProtocolBase cProt)
@@ -50,9 +48,7 @@ namespace mRemoteNG.Connection.Protocol
return;
List.Remove(cProt);
RaiseCollectionChangedEvent(this,
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove,
cProt));
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, cProt));
}
catch (Exception)
{
@@ -65,8 +61,7 @@ namespace mRemoteNG.Connection.Protocol
return;
List.Clear();
RaiseCollectionChangedEvent(this,
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
public event NotifyCollectionChangedEventHandler CollectionChanged;

View File

@@ -1,5 +1,8 @@
using System.Runtime.Versioning;
namespace mRemoteNG.Connection.Protocol.RAW
{
[SupportedOSPlatform("windows")]
public class RawProtocol : PuttyBase
{
public RawProtocol()

View File

@@ -1,10 +1,12 @@
using System;
using System.Collections;
using System.Runtime.Versioning;
using mRemoteNG.App;
using mRemoteNG.Resources.Language;
namespace mRemoteNG.Connection.Protocol.RDP
{
[SupportedOSPlatform("windows")]
public static class RdpErrorCodes
{
private static Hashtable _description;

View File

@@ -4,9 +4,11 @@ using MSTSCLib;
using System;
using System.Windows.Forms;
using mRemoteNG.Resources.Language;
using System.Runtime.Versioning;
namespace mRemoteNG.Connection.Protocol.RDP
{
[SupportedOSPlatform("windows")]
public class RdpProtocol7 : RdpProtocol6
{
protected override RdpVersion RdpProtocolVersion => RdpVersion.Rdc7;

View File

@@ -6,9 +6,11 @@ using mRemoteNG.App;
using mRemoteNG.Messages;
using MSTSCLib;
using mRemoteNG.Resources.Language;
using System.Runtime.Versioning;
namespace mRemoteNG.Connection.Protocol.RDP
{
[SupportedOSPlatform("windows")]
/* RDP v8 requires Windows 7 with:
* https://support.microsoft.com/en-us/kb/2592687
* OR

View File

@@ -1,14 +1,15 @@
using System;
using System.Runtime.Versioning;
using System.Windows.Forms;
using AxMSTSCLib;
using MSTSCLib;
namespace mRemoteNG.Connection.Protocol.RDP
{
[SupportedOSPlatform("windows")]
public class RdpProtocol9 : RdpProtocol8
{
private MsRdpClient9NotSafeForScripting RdpClient9 =>
(MsRdpClient9NotSafeForScripting)((AxHost)Control).GetOcx();
private MsRdpClient9NotSafeForScripting RdpClient9 => (MsRdpClient9NotSafeForScripting)((AxHost)Control).GetOcx();
protected override RdpVersion RdpProtocolVersion => RdpVersion.Rdc9;

View File

@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Versioning;
namespace mRemoteNG.Connection.Protocol.RDP
{
[SupportedOSPlatform("windows")]
public class RdpProtocolFactory
{
public RdpProtocol6 Build(RdpVersion rdpVersion)

View File

@@ -1,5 +1,8 @@
using System.Runtime.Versioning;
namespace mRemoteNG.Connection.Protocol.Rlogin
{
[SupportedOSPlatform("windows")]
public class ProtocolRlogin : PuttyBase
{
public ProtocolRlogin()

View File

@@ -1,5 +1,8 @@
using System.Runtime.Versioning;
namespace mRemoteNG.Connection.Protocol.SSH
{
[SupportedOSPlatform("windows")]
public class ProtocolSSH2 : PuttyBase
{
public ProtocolSSH2()

View File

@@ -1,5 +1,8 @@
using System.Runtime.Versioning;
namespace mRemoteNG.Connection.Protocol.Serial
{
[SupportedOSPlatform("windows")]
public class ProtocolSerial : PuttyBase
{
public ProtocolSerial()

View File

@@ -1,5 +1,8 @@
using System.Runtime.Versioning;
namespace mRemoteNG.Connection.Protocol.Telnet
{
[SupportedOSPlatform("windows")]
public class ProtocolTelnet : PuttyBase
{
public ProtocolTelnet()

View File

@@ -7,10 +7,11 @@ using mRemoteNG.Connection.Protocol;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using mRemoteNG.Resources.Language;
using System.Runtime.Versioning;
namespace mRemoteNG.Connection
{
[SupportedOSPlatform("windows")]
public sealed class PuttySessionInfo : ConnectionInfo, IComponent
{
#region Properties

View File

@@ -1,9 +1,11 @@
using mRemoteNG.App;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Resources.Language;
using System.Runtime.Versioning;
namespace mRemoteNG.Connection
{
[SupportedOSPlatform("windows")]
public class WebHelper
{
public static void GoToUrl(string url)

View File

@@ -79,9 +79,7 @@ namespace mRemoteNG.Container
newChildItem.Parent = this;
Children.Insert(index, newChildItem);
SubscribeToChildEvents(newChildItem);
RaiseCollectionChangedEvent(this,
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,
newChildItem));
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newChildItem));
}
public void AddChildRange(IEnumerable<ConnectionInfo> newChildren)
@@ -98,9 +96,7 @@ namespace mRemoteNG.Container
removalTarget.Parent = null;
Children.Remove(removalTarget);
UnsubscribeToChildEvents(removalTarget);
RaiseCollectionChangedEvent(this,
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove,
removalTarget));
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, removalTarget));
}
public void RemoveChildRange(IEnumerable<ConnectionInfo> removalTargets)
@@ -118,10 +114,7 @@ namespace mRemoteNG.Container
Children.Remove(child);
if (newIndex > Children.Count) newIndex = Children.Count;
Children.Insert(newIndex, child);
RaiseCollectionChangedEvent(this,
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, child,
newIndex,
originalIndex));
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, child, newIndex, originalIndex));
}
public void SetChildAbove(ConnectionInfo childToPromote, ConnectionInfo reference)
@@ -171,8 +164,7 @@ namespace mRemoteNG.Container
SortOn(connectionInfo => connectionInfo.Name, sortDirection);
}
public void SortOn<TProperty>(Func<ConnectionInfo, TProperty> propertyToCompare,
ListSortDirection sortDirection = ListSortDirection.Ascending)
public void SortOn<TProperty>(Func<ConnectionInfo, TProperty> propertyToCompare, ListSortDirection sortDirection = ListSortDirection.Ascending)
where TProperty : IComparable<TProperty>
{
var connectionComparer = new ConnectionInfoComparer<TProperty>(propertyToCompare)
@@ -180,8 +172,7 @@ namespace mRemoteNG.Container
SortDirection = sortDirection
};
Children.Sort(connectionComparer);
RaiseCollectionChangedEvent(this,
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
public void SortRecursive(ListSortDirection sortDirection = ListSortDirection.Ascending)
@@ -189,8 +180,7 @@ namespace mRemoteNG.Container
SortOnRecursive(connectionInfo => connectionInfo.Name, sortDirection);
}
public void SortOnRecursive<TProperty>(Func<ConnectionInfo, TProperty> propertyToCompare,
ListSortDirection sortDirection = ListSortDirection.Ascending)
public void SortOnRecursive<TProperty>(Func<ConnectionInfo, TProperty> propertyToCompare, ListSortDirection sortDirection = ListSortDirection.Ascending)
where TProperty : IComparable<TProperty>
{
foreach (var child in Children.OfType<ContainerInfo>())

View File

@@ -26,20 +26,13 @@ namespace mRemoteNG.Credential
var targetsArray = confirmationTargets.ToArray();
if (targetsArray.Length == 0) return false;
if (targetsArray.Length > 1)
return PromptUser(
string.Format(
"Are you sure you want to delete these {0} selected credentials?",
targetsArray.Length));
return PromptUser(
string.Format(
Language.ConfirmDeleteCredentialRecord,
targetsArray.First().Title));
return PromptUser(string.Format("Are you sure you want to delete these {0} selected credentials?", targetsArray.Length));
return PromptUser(string.Format(Language.ConfirmDeleteCredentialRecord,targetsArray.First().Title));
}
private bool PromptUser(string promptMessage)
{
var msgBoxResponse = _confirmationFunc.Invoke(promptMessage, Application.ProductName,
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
var msgBoxResponse = _confirmationFunc.Invoke(promptMessage, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
return msgBoxResponse == DialogResult.Yes;
}
}

View File

@@ -2,30 +2,26 @@
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Runtime.Versioning;
using mRemoteNG.App;
namespace mRemoteNG.Credential
{
[SupportedOSPlatform("windows")]
public class CredentialRecordTypeConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(Guid) ||
base.CanConvertFrom(context, sourceType);
return sourceType == typeof(Guid) || base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(Guid) ||
destinationType == typeof(ICredentialRecord) ||
base.CanConvertTo(context, destinationType);
return destinationType == typeof(Guid) || destinationType == typeof(ICredentialRecord) || base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture,
object value,
Type destinationType)
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (value is ICredentialRecord && destinationType == typeof(Guid))
return ((ICredentialRecord)value).Id;

View File

@@ -13,9 +13,7 @@ namespace mRemoteNG.Credential
public IEnumerable<ICredentialRepository> CredentialRepositories => _repositoryList;
public CredentialServiceFacade(ICredentialRepositoryList repositoryList,
ILoader<IEnumerable<ICredentialRepository>> loader,
ISaver<IEnumerable<ICredentialRepository>> saver)
public CredentialServiceFacade(ICredentialRepositoryList repositoryList, ILoader<IEnumerable<ICredentialRepository>> loader, ISaver<IEnumerable<ICredentialRepository>> saver)
{
if (repositoryList == null)
throw new ArgumentNullException(nameof(repositoryList));

View File

@@ -1,4 +1,5 @@
using System.IO;
using System.Runtime.Versioning;
using mRemoteNG.App;
using mRemoteNG.App.Info;
using mRemoteNG.Config;
@@ -9,25 +10,19 @@ using mRemoteNG.Security.Factories;
namespace mRemoteNG.Credential
{
[SupportedOSPlatform("windows")]
public class CredentialServiceFactory
{
// When we get a true CompositionRoot we can move this to that class. We should only require 1 instance of this service at a time
public CredentialServiceFacade Build()
{
var cryptoFromSettings = new CryptoProviderFactoryFromSettings();
var credRepoSerializer = new XmlCredentialPasswordEncryptorDecorator(
cryptoFromSettings.Build(),
new XmlCredentialRecordSerializer());
var credRepoDeserializer =
new XmlCredentialPasswordDecryptorDecorator(new XmlCredentialRecordDeserializer());
var credRepoSerializer = new XmlCredentialPasswordEncryptorDecorator(cryptoFromSettings.Build(), new XmlCredentialRecordSerializer());
var credRepoDeserializer = new XmlCredentialPasswordDecryptorDecorator(new XmlCredentialRecordDeserializer());
var credentialRepoListPath = Path.Combine(SettingsFileInfo.SettingsPath, "credentialRepositories.xml");
var repoListDataProvider = new FileDataProvider(credentialRepoListPath);
var repoListLoader = new CredentialRepositoryListLoader(
repoListDataProvider,
new
CredentialRepositoryListDeserializer(credRepoSerializer,
credRepoDeserializer));
var repoListLoader = new CredentialRepositoryListLoader(repoListDataProvider, new CredentialRepositoryListDeserializer(credRepoSerializer, credRepoDeserializer));
var repoListSaver = new CredentialRepositoryListSaver(repoListDataProvider);
return new CredentialServiceFacade(Runtime.CredentialProviderCatalog, repoListLoader, repoListSaver);

View File

@@ -3,11 +3,13 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Runtime.Versioning;
// ReSharper disable ArrangeAccessorOwnerBody
namespace mRemoteNG.Messages
{
[SupportedOSPlatform("windows")]
public class MessageCollector : INotifyCollectionChanged
{
private readonly IList<IMessage> _messageList;
@@ -44,19 +46,13 @@ namespace mRemoteNG.Messages
RaiseCollectionChangedEvent(NotifyCollectionChangedAction.Add, newMessages);
}
public void AddExceptionMessage(string message,
Exception ex,
MessageClass msgClass = MessageClass.ErrorMsg,
bool logOnly = true)
public void AddExceptionMessage(string message, Exception ex, MessageClass msgClass = MessageClass.ErrorMsg, bool logOnly = true)
{
AddMessage(msgClass, message + Environment.NewLine + Tools.MiscTools.GetExceptionMessageRecursive(ex),
logOnly);
}
public void AddExceptionStackTrace(string message,
Exception ex,
MessageClass msgClass = MessageClass.ErrorMsg,
bool logOnly = true)
public void AddExceptionStackTrace(string message, Exception ex, MessageClass msgClass = MessageClass.ErrorMsg, bool logOnly = true)
{
AddMessage(msgClass, message + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace,
logOnly);

View File

@@ -1,4 +1,5 @@
using System;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using System.Windows.Forms;
using mRemoteNG.Messages.MessageFilteringOptions;
@@ -9,6 +10,7 @@ using WeifenLuo.WinFormsUI.Docking;
namespace mRemoteNG.Messages.WriterDecorators
{
[SupportedOSPlatform("windows")]
public class MessageFocusDecorator : IMessageWriter
{
private readonly IMessageTypeFilteringOptions _filter;
@@ -16,9 +18,7 @@ namespace mRemoteNG.Messages.WriterDecorators
private readonly ErrorAndInfoWindow _messageWindow;
private readonly FrmMain _frmMain = FrmMain.Default;
public MessageFocusDecorator(ErrorAndInfoWindow messageWindow,
IMessageTypeFilteringOptions filter,
IMessageWriter decoratedWriter)
public MessageFocusDecorator(ErrorAndInfoWindow messageWindow, IMessageTypeFilteringOptions filter, IMessageWriter decoratedWriter)
{
_filter = filter ?? throw new ArgumentNullException(nameof(filter));
_messageWindow = messageWindow ?? throw new ArgumentNullException(nameof(messageWindow));