From b10f40dd289d54b19767d0256cc8e3ab18e0eff6 Mon Sep 17 00:00:00 2001 From: Jorge Burgos Date: Fri, 31 Jan 2025 16:16:50 -0500 Subject: [PATCH] Migrate the Strata.Base.Internal to C# --- .../Strata.Base.Internal.Tests.csproj | 4 +- .../Strata.Base.Internal.Tests.csproj.bak | 27 + vb-migration/Strata.Base.Internal.sln | 12 +- vb-migration/Strata.Base.Internal.sln.bak | 30 + .../Encryptors/IPasswordEncryptionMethod.cs | 13 + .../Encryptors/UberEncryptionMethod.cs | 56 ++ .../Encryptors/UserGUIDEncryptionMethod.cs | 52 ++ .../Encryptors/UserSaltEncryptionMethod.cs | 65 ++ .../Strata.Base.Internal/InternalConstants.cs | 11 + .../My Project/Application.Designer.cs | 11 + .../My Project/AssemblyInfo.cs | 36 + .../MyNamespace.Static.1.Designer.cs | 468 ++++++++++ .../MyNamespace.Static.2.Designer.cs | 241 ++++++ .../MyNamespace.Static.3.Designer.cs | 16 + .../My Project/Resources.Designer.cs | 70 ++ .../My Project/Settings.Designer.cs | 100 +++ .../Security/Encryption.cs | 819 ++++++++++++++++++ .../Security/SecurityUtils.cs | 87 ++ .../Strata.Base.Internal.csproj | 82 ++ .../Strata.Base.Internal.xml | 301 +++++++ 20 files changed, 2493 insertions(+), 8 deletions(-) create mode 100644 vb-migration/Strata.Base.Internal.Tests/Strata.Base.Internal.Tests.csproj.bak create mode 100644 vb-migration/Strata.Base.Internal.sln.bak create mode 100644 vb-migration/Strata.Base.Internal/Encryptors/IPasswordEncryptionMethod.cs create mode 100644 vb-migration/Strata.Base.Internal/Encryptors/UberEncryptionMethod.cs create mode 100644 vb-migration/Strata.Base.Internal/Encryptors/UserGUIDEncryptionMethod.cs create mode 100644 vb-migration/Strata.Base.Internal/Encryptors/UserSaltEncryptionMethod.cs create mode 100644 vb-migration/Strata.Base.Internal/InternalConstants.cs create mode 100644 vb-migration/Strata.Base.Internal/My Project/Application.Designer.cs create mode 100644 vb-migration/Strata.Base.Internal/My Project/AssemblyInfo.cs create mode 100644 vb-migration/Strata.Base.Internal/My Project/MyNamespace.Static.1.Designer.cs create mode 100644 vb-migration/Strata.Base.Internal/My Project/MyNamespace.Static.2.Designer.cs create mode 100644 vb-migration/Strata.Base.Internal/My Project/MyNamespace.Static.3.Designer.cs create mode 100644 vb-migration/Strata.Base.Internal/My Project/Resources.Designer.cs create mode 100644 vb-migration/Strata.Base.Internal/My Project/Settings.Designer.cs create mode 100644 vb-migration/Strata.Base.Internal/Security/Encryption.cs create mode 100644 vb-migration/Strata.Base.Internal/Security/SecurityUtils.cs create mode 100644 vb-migration/Strata.Base.Internal/Strata.Base.Internal.csproj create mode 100644 vb-migration/Strata.Base.Internal/Strata.Base.Internal.xml diff --git a/vb-migration/Strata.Base.Internal.Tests/Strata.Base.Internal.Tests.csproj b/vb-migration/Strata.Base.Internal.Tests/Strata.Base.Internal.Tests.csproj index 7303785..d654950 100644 --- a/vb-migration/Strata.Base.Internal.Tests/Strata.Base.Internal.Tests.csproj +++ b/vb-migration/Strata.Base.Internal.Tests/Strata.Base.Internal.Tests.csproj @@ -1,4 +1,4 @@ - + net8.0-windows @@ -21,7 +21,7 @@ - + diff --git a/vb-migration/Strata.Base.Internal.Tests/Strata.Base.Internal.Tests.csproj.bak b/vb-migration/Strata.Base.Internal.Tests/Strata.Base.Internal.Tests.csproj.bak new file mode 100644 index 0000000..7303785 --- /dev/null +++ b/vb-migration/Strata.Base.Internal.Tests/Strata.Base.Internal.Tests.csproj.bak @@ -0,0 +1,27 @@ + + + + net8.0-windows + enable + enable + false + true + Strata.Base.Internal.Tests + Strata.Base.Internal.Tests + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/vb-migration/Strata.Base.Internal.sln b/vb-migration/Strata.Base.Internal.sln index 8ee16b9..a731175 100644 --- a/vb-migration/Strata.Base.Internal.sln +++ b/vb-migration/Strata.Base.Internal.sln @@ -1,8 +1,8 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.0.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Strata.Base.Internal", "Strata.Base.Internal\Strata.Base.Internal.vbproj", "{DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Strata.Base.Internal", "Strata.Base.Internal\Strata.Base.Internal.csproj", "{6948FC8A-673B-0B97-11F1-2FBDDF225514}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Strata.Base.Internal.Tests", "Strata.Base.Internal.Tests\Strata.Base.Internal.Tests.csproj", "{11111111-1111-1111-1111-111111111111}" EndProject @@ -12,10 +12,10 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Release|Any CPU.Build.0 = Release|Any CPU + {6948FC8A-673B-0B97-11F1-2FBDDF225514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6948FC8A-673B-0B97-11F1-2FBDDF225514}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6948FC8A-673B-0B97-11F1-2FBDDF225514}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6948FC8A-673B-0B97-11F1-2FBDDF225514}.Release|Any CPU.Build.0 = Release|Any CPU {11111111-1111-1111-1111-111111111111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {11111111-1111-1111-1111-111111111111}.Debug|Any CPU.Build.0 = Debug|Any CPU {11111111-1111-1111-1111-111111111111}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/vb-migration/Strata.Base.Internal.sln.bak b/vb-migration/Strata.Base.Internal.sln.bak new file mode 100644 index 0000000..8ee16b9 --- /dev/null +++ b/vb-migration/Strata.Base.Internal.sln.bak @@ -0,0 +1,30 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.0.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Strata.Base.Internal", "Strata.Base.Internal\Strata.Base.Internal.vbproj", "{DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Strata.Base.Internal.Tests", "Strata.Base.Internal.Tests\Strata.Base.Internal.Tests.csproj", "{11111111-1111-1111-1111-111111111111}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DB6C7DE1-AB63-4466-93A9-E5C3BDB561B4}.Release|Any CPU.Build.0 = Release|Any CPU + {11111111-1111-1111-1111-111111111111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {11111111-1111-1111-1111-111111111111}.Debug|Any CPU.Build.0 = Debug|Any CPU + {11111111-1111-1111-1111-111111111111}.Release|Any CPU.ActiveCfg = Release|Any CPU + {11111111-1111-1111-1111-111111111111}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5C6D0F1F-E91E-4F6A-9E9F-B3E2DA7F2B4D} + EndGlobalSection +EndGlobal diff --git a/vb-migration/Strata.Base.Internal/Encryptors/IPasswordEncryptionMethod.cs b/vb-migration/Strata.Base.Internal/Encryptors/IPasswordEncryptionMethod.cs new file mode 100644 index 0000000..c82743f --- /dev/null +++ b/vb-migration/Strata.Base.Internal/Encryptors/IPasswordEncryptionMethod.cs @@ -0,0 +1,13 @@ +using System; + +namespace Strata.Base.Internal.Encryptors +{ + + public interface IPasswordEncryptionMethod + { + + string Encode(string username, string anOrgPin, string aNewPassword, Guid aUserGUID, string aSalt); + + } + +} \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/Encryptors/UberEncryptionMethod.cs b/vb-migration/Strata.Base.Internal/Encryptors/UberEncryptionMethod.cs new file mode 100644 index 0000000..04b3010 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/Encryptors/UberEncryptionMethod.cs @@ -0,0 +1,56 @@ +using System; +using System.Configuration; +using Microsoft.VisualBasic; +using Strata.Configuration.Client.Models.Jazz; + +namespace Strata.Base.Internal.Encryptors +{ + + public class UberEncryptionMethod : IPasswordEncryptionMethod + { + + public UberEncryptionMethod() + { + + } + + #region Methods + + public static string GetUberMonet(string anOrgPin) + { + return GetUberMonet(DateTime.Today, anOrgPin, ConfigurationManager.AppSettings[nameof(StrataJazzOptions.UberMonetKey)]); + } + + private static string GetUberMonet(DateTime aDate, string anOrgPIN, string aKey) + { + var ha = new EncryptionUtils.Hasher(EncryptionUtils.Hasher.Provider.SHA256); + + string lsHashBefore; + string lsResult; + + lsHashBefore = Strings.Format(aDate, "dd-MM-yyyy") + "-" + anOrgPIN + "-" + aKey; + + var d = new EncryptionUtils.Data(lsHashBefore); + + var dResult = ha.Calculate(d); + lsResult = Strings.Left(dResult.Hex, 6); + + ha = null; + + return lsResult; + } + + #endregion + + #region IPasswordEncryptionMethod + + public string Encode(string username, string anOrgPin, string aNewPassword, Guid aUserGUID, string aSalt) + { + return GetUberMonet(anOrgPin); + } + + #endregion + + } + +} \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/Encryptors/UserGUIDEncryptionMethod.cs b/vb-migration/Strata.Base.Internal/Encryptors/UserGUIDEncryptionMethod.cs new file mode 100644 index 0000000..bbd50aa --- /dev/null +++ b/vb-migration/Strata.Base.Internal/Encryptors/UserGUIDEncryptionMethod.cs @@ -0,0 +1,52 @@ +using System; +using System.Configuration; +using System.Security.Cryptography; +using System.Text; +using Strata.Configuration.Client.Models.Jazz; + +namespace Strata.Base.Internal.Encryptors +{ + + public class UserGUIDEncryptionMethod : IPasswordEncryptionMethod + { + + #region Declarations + + private const int NUMBER_ITERATIONS = 100000; + + #endregion + + #region Methods + + public string Encode(string username, string anOrgPin, string aNewPassword, Guid aUserGUID, string aSalt) + { + string salt = aUserGUID.ToString() + ConfigurationManager.AppSettings[nameof(StrataJazzOptions.UserGuidEncryptionKey)]; + + string result = GetHashedValue(aNewPassword, salt); + for (int i = 1; i <= NUMBER_ITERATIONS; i++) + result = GetHashedValue(result); + + return result; + } + + private static string GetHashedValue(string aValue) + { + + // Create an instance of the sha encrypter + using (HashAlgorithm hasher = SHA256.Create()) + { + return Convert.ToBase64String(hasher.ComputeHash(Encoding.UTF8.GetBytes(aValue))); + } + + } + + private static string GetHashedValue(string aValue, string aSalt) + { + return GetHashedValue(aValue + aSalt); + } + + #endregion + + } + +} \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/Encryptors/UserSaltEncryptionMethod.cs b/vb-migration/Strata.Base.Internal/Encryptors/UserSaltEncryptionMethod.cs new file mode 100644 index 0000000..2992138 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/Encryptors/UserSaltEncryptionMethod.cs @@ -0,0 +1,65 @@ +using System; +using System.Configuration; +using System.Security.Cryptography; +using System.Text; +using Strata.Configuration.Client.Models.Jazz; + +namespace Strata.Base.Internal.Encryptors +{ + + public class UserSaltEncryptionMethod : IPasswordEncryptionMethod + { + + #region Declarations + + private const int NUMBER_ITERATIONS = 100000; + + #endregion + + #region Methods + + public string Encode(string username, string anOrgPin, string aNewPassword, Guid aUserGUID, string aSalt) + { + if (username is null) + { + throw new ArgumentNullException(nameof(username)); + } + + if (anOrgPin is null) + { + throw new ArgumentNullException(nameof(anOrgPin)); + } + + if (aNewPassword is null) + { + throw new ArgumentNullException(nameof(aNewPassword)); + } + + if (aSalt is null) + { + throw new ArgumentNullException(nameof(aSalt)); + } + + // Get encryption key from config, throw if not found + string encryptionKey = ConfigurationManager.AppSettings[nameof(StrataJazzOptions.UserSaltEncryptionKey)]; + if (string.IsNullOrEmpty(encryptionKey)) + { + throw new ConfigurationErrorsException("UserSaltEncryptionKey not found in configuration"); + } + + // Combine salt with encryption key + string saltAndPepper = aSalt + encryptionKey; + + // Use UTF8 encoding to properly handle Unicode characters + using (var deriveBytes = new Rfc2898DeriveBytes(aNewPassword, Encoding.UTF8.GetBytes(saltAndPepper), NUMBER_ITERATIONS, HashAlgorithmName.SHA256)) + { + byte[] password = deriveBytes.GetBytes(24); + return Convert.ToBase64String(password); + } + } + + #endregion + + } + +} \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/InternalConstants.cs b/vb-migration/Strata.Base.Internal/InternalConstants.cs new file mode 100644 index 0000000..df65057 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/InternalConstants.cs @@ -0,0 +1,11 @@ + +namespace Strata.Base.Internal +{ + internal class InternalConstants + { + + // WARNING: This should always match the value in Strata.Base.Constants.XConstants.APPLICATION_VERSION + public const string APPLICATION_VERSION = "2025.11"; + + } +} \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/My Project/Application.Designer.cs b/vb-migration/Strata.Base.Internal/My Project/Application.Designer.cs new file mode 100644 index 0000000..5e9e2a0 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/My Project/Application.Designer.cs @@ -0,0 +1,11 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ + + diff --git a/vb-migration/Strata.Base.Internal/My Project/AssemblyInfo.cs b/vb-migration/Strata.Base.Internal/My Project/AssemblyInfo.cs new file mode 100644 index 0000000..4c14cc9 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/My Project/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +// Review the values of the assembly attributes + +[assembly: AssemblyTitle("Strata.Biz.Internal")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyCompany("Strata Decision Technology, LLC")] +[assembly: AssemblyProduct("Strata.Biz.Internal")] +[assembly: AssemblyCopyright("© 2006-2012 Strata Decision Technology, LLC")] +[assembly: AssemblyTrademark("")] + +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("dfd98904-a580-4549-90ea-95c9a5504029")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// + +[assembly: AssemblyVersion(Strata.Base.Internal.InternalConstants.APPLICATION_VERSION)] +[assembly: AssemblyFileVersion(Strata.Base.Internal.InternalConstants.APPLICATION_VERSION)] + diff --git a/vb-migration/Strata.Base.Internal/My Project/MyNamespace.Static.1.Designer.cs b/vb-migration/Strata.Base.Internal/My Project/MyNamespace.Static.1.Designer.cs new file mode 100644 index 0000000..aef3bd8 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/My Project/MyNamespace.Static.1.Designer.cs @@ -0,0 +1,468 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Diagnostics; +using Microsoft.VisualBasic; + +/* TODO ERROR: Skipped IfDirectiveTrivia +#If TARGET = "module" AndAlso _MYTYPE = "" Then +*//* TODO ERROR: Skipped DisabledTextTrivia +#Const _MYTYPE="Empty" +*//* TODO ERROR: Skipped EndIfDirectiveTrivia +#End If +*/ +/* TODO ERROR: Skipped IfDirectiveTrivia +#If _MYTYPE = "WindowsForms" Then +*//* TODO ERROR: Skipped DisabledTextTrivia + +#Const _MYFORMS = True +#Const _MYWEBSERVICES = True +#Const _MYUSERTYPE = "Windows" +#Const _MYCOMPUTERTYPE = "Windows" +#Const _MYAPPLICATIONTYPE = "WindowsForms" + +*//* TODO ERROR: Skipped ElifDirectiveTrivia +#ElseIf _MYTYPE = "WindowsFormsWithCustomSubMain" Then +*//* TODO ERROR: Skipped DisabledTextTrivia + +#Const _MYFORMS = True +#Const _MYWEBSERVICES = True +#Const _MYUSERTYPE = "Windows" +#Const _MYCOMPUTERTYPE = "Windows" +#Const _MYAPPLICATIONTYPE = "Console" + +*//* TODO ERROR: Skipped ElifDirectiveTrivia +#ElseIf _MYTYPE = "Windows" OrElse _MYTYPE = "" Then +*/ +/* TODO ERROR: Skipped DefineDirectiveTrivia +#Const _MYWEBSERVICES = True +*//* TODO ERROR: Skipped DefineDirectiveTrivia +#Const _MYUSERTYPE = "Windows" +*//* TODO ERROR: Skipped DefineDirectiveTrivia +#Const _MYCOMPUTERTYPE = "Windows" +*//* TODO ERROR: Skipped DefineDirectiveTrivia +#Const _MYAPPLICATIONTYPE = "Windows" +*/ +/* TODO ERROR: Skipped ElifDirectiveTrivia +#ElseIf _MYTYPE = "Console" Then +*//* TODO ERROR: Skipped DisabledTextTrivia + +#Const _MYWEBSERVICES = True +#Const _MYUSERTYPE = "Windows" +#Const _MYCOMPUTERTYPE = "Windows" +#Const _MYAPPLICATIONTYPE = "Console" + +*//* TODO ERROR: Skipped ElifDirectiveTrivia +#ElseIf _MYTYPE = "Web" Then +*//* TODO ERROR: Skipped DisabledTextTrivia + +#Const _MYFORMS = False +#Const _MYWEBSERVICES = False +#Const _MYUSERTYPE = "Web" +#Const _MYCOMPUTERTYPE = "Web" + +*//* TODO ERROR: Skipped ElifDirectiveTrivia +#ElseIf _MYTYPE = "WebControl" Then +*//* TODO ERROR: Skipped DisabledTextTrivia + +#Const _MYFORMS = False +#Const _MYWEBSERVICES = True +#Const _MYUSERTYPE = "Web" +#Const _MYCOMPUTERTYPE = "Web" + +*//* TODO ERROR: Skipped ElifDirectiveTrivia +#ElseIf _MYTYPE = "Custom" Then +*//* TODO ERROR: Skipped DisabledTextTrivia + +*//* TODO ERROR: Skipped ElifDirectiveTrivia +#ElseIf _MYTYPE <> "Empty" Then +*//* TODO ERROR: Skipped DisabledTextTrivia + +#Const _MYTYPE = "Empty" + +*//* TODO ERROR: Skipped EndIfDirectiveTrivia +#End If +*/ +/* TODO ERROR: Skipped IfDirectiveTrivia +#If _MYTYPE <> "Empty" Then +*/ +namespace Strata.Base.Internal.My +{ + + /* TODO ERROR: Skipped IfDirectiveTrivia + #If _MYAPPLICATIONTYPE = "WindowsForms" OrElse _MYAPPLICATIONTYPE = "Windows" OrElse _MYAPPLICATIONTYPE = "Console" Then + */ + [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + + /* TODO ERROR: Skipped IfDirectiveTrivia + #If _MYAPPLICATIONTYPE = "WindowsForms" Then + *//* TODO ERROR: Skipped DisabledTextTrivia + Inherits Global.Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase + #If TARGET = "winexe" Then + _ + Friend Shared Sub Main(ByVal Args As String()) + Try + Global.System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(MyApplication.UseCompatibleTextRendering()) + Finally + End Try + My.Application.Run(Args) + End Sub + #End If + + *//* TODO ERROR: Skipped ElifDirectiveTrivia + #ElseIf _MYAPPLICATIONTYPE = "Windows" Then + */ + internal partial class MyApplication : Microsoft.VisualBasic.ApplicationServices.ApplicationBase + { + /* TODO ERROR: Skipped ElifDirectiveTrivia + #ElseIf _MYAPPLICATIONTYPE = "Console" Then + *//* TODO ERROR: Skipped DisabledTextTrivia + Inherits Global.Microsoft.VisualBasic.ApplicationServices.ConsoleApplicationBase + *//* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If '_MYAPPLICATIONTYPE = "WindowsForms" + */ + } + + /* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If '#If _MYAPPLICATIONTYPE = "WindowsForms" Or _MYAPPLICATIONTYPE = "Windows" or _MYAPPLICATIONTYPE = "Console" + */ + /* TODO ERROR: Skipped IfDirectiveTrivia + #If _MYCOMPUTERTYPE <> "" Then + */ + [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + + /* TODO ERROR: Skipped IfDirectiveTrivia + #If _MYCOMPUTERTYPE = "Windows" Then + */ + internal partial class MyComputer : Microsoft.VisualBasic.Devices.Computer + { + /* TODO ERROR: Skipped ElifDirectiveTrivia + #ElseIf _MYCOMPUTERTYPE = "Web" Then + *//* TODO ERROR: Skipped DisabledTextTrivia + Inherits Global.Microsoft.VisualBasic.Devices.ServerComputer + *//* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If + */ + [DebuggerHidden()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public MyComputer() : base() + { + } + } + /* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If + */ + [HideModuleName()] + [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] + internal static class MyProject + { + + /* TODO ERROR: Skipped IfDirectiveTrivia + #If _MYCOMPUTERTYPE <> "" Then + */ + [System.ComponentModel.Design.HelpKeyword("My.Computer")] + internal static MyComputer Computer + { + [DebuggerHidden()] + get + { + return m_ComputerObjectProvider.GetInstance; + } + } + + private readonly static ThreadSafeObjectProvider m_ComputerObjectProvider = new ThreadSafeObjectProvider(); + /* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If + */ + /* TODO ERROR: Skipped IfDirectiveTrivia + #If _MYAPPLICATIONTYPE = "Windows" Or _MYAPPLICATIONTYPE = "WindowsForms" Or _MYAPPLICATIONTYPE = "Console" Then + */ + [System.ComponentModel.Design.HelpKeyword("My.Application")] + internal static MyApplication Application + { + [DebuggerHidden()] + get + { + return m_AppObjectProvider.GetInstance; + } + } + private readonly static ThreadSafeObjectProvider m_AppObjectProvider = new ThreadSafeObjectProvider(); + /* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If + */ + /* TODO ERROR: Skipped IfDirectiveTrivia + #If _MYUSERTYPE = "Windows" Then + */ + [System.ComponentModel.Design.HelpKeyword("My.User")] + internal static Microsoft.VisualBasic.ApplicationServices.User User + { + [DebuggerHidden()] + get + { + return m_UserObjectProvider.GetInstance; + } + } + private readonly static ThreadSafeObjectProvider m_UserObjectProvider = new ThreadSafeObjectProvider(); + /* TODO ERROR: Skipped ElifDirectiveTrivia + #ElseIf _MYUSERTYPE = "Web" Then + *//* TODO ERROR: Skipped DisabledTextTrivia + _ + Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.WebUser + _ + Get + Return m_UserObjectProvider.GetInstance() + End Get + End Property + Private ReadOnly m_UserObjectProvider As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.WebUser) + *//* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If + */ + /* TODO ERROR: Skipped IfDirectiveTrivia + #If _MYFORMS = True Then + *//* TODO ERROR: Skipped DisabledTextTrivia + + #Const STARTUP_MY_FORM_FACTORY = "My.MyProject.Forms" + + _ + Friend ReadOnly Property Forms() As MyForms + _ + Get + Return m_MyFormsObjectProvider.GetInstance() + End Get + End Property + + _ + _ + Friend NotInheritable Class MyForms + _ + Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Forms.Form})(ByVal Instance As T) As T + If Instance Is Nothing OrElse Instance.IsDisposed Then + If m_FormBeingCreated IsNot Nothing Then + If m_FormBeingCreated.ContainsKey(GetType(T)) = True Then + Throw New Global.System.InvalidOperationException(Global.Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString("WinForms_RecursiveFormCreate")) + End If + Else + m_FormBeingCreated = New Global.System.Collections.Hashtable() + End If + m_FormBeingCreated.Add(GetType(T), Nothing) + Try + Return New T() + Catch ex As Global.System.Reflection.TargetInvocationException When ex.InnerException IsNot Nothing + Dim BetterMessage As String = Global.Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString("WinForms_SeeInnerException", ex.InnerException.Message) + Throw New Global.System.InvalidOperationException(BetterMessage, ex.InnerException) + Finally + m_FormBeingCreated.Remove(GetType(T)) + End Try + Else + Return Instance + End If + End Function + + _ + Private Sub Dispose__Instance__(Of T As Global.System.Windows.Forms.Form)(ByRef instance As T) + instance.Dispose() + instance = Nothing + End Sub + + _ + _ + Public Sub New() + MyBase.New() + End Sub + + Private Shared m_FormBeingCreated As Global.System.Collections.Hashtable + + Public Overrides Function Equals(ByVal o As Object) As Boolean + Return MyBase.Equals(o) + End Function + Public Overrides Function GetHashCode() As Integer + Return MyBase.GetHashCode + End Function + _ + Friend Overloads Function [GetType]() As Global.System.Type + Return GetType(MyForms) + End Function + Public Overrides Function ToString() As String + Return MyBase.ToString + End Function + End Class + + Private m_MyFormsObjectProvider As New ThreadSafeObjectProvider(Of MyForms) + + *//* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If + */ + /* TODO ERROR: Skipped IfDirectiveTrivia + #If _MYWEBSERVICES = True Then + */ + [System.ComponentModel.Design.HelpKeyword("My.WebServices")] + internal static MyWebServices WebServices + { + [DebuggerHidden()] + get + { + return m_MyWebServicesObjectProvider.GetInstance; + } + } + + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [MyGroupCollection("System.Web.Services.Protocols.SoapHttpClientProtocol", "Create__Instance__", "Dispose__Instance__", "")] + internal sealed class MyWebServices + { + + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [DebuggerHidden()] + public override bool Equals(object o) + { + return base.Equals(o); + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [DebuggerHidden()] + public override int GetHashCode() + { + return base.GetHashCode(); + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [DebuggerHidden()] + internal new Type GetType() + { + return typeof(MyWebServices); + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [DebuggerHidden()] + public override string ToString() + { + return base.ToString(); + } + + [DebuggerHidden()] + private static T Create__Instance__(T instance) where T : new() + { + if (instance is null) + { + return new T(); + } + else + { + return instance; + } + } + + [DebuggerHidden()] + private void Dispose__Instance__(ref T instance) + { + instance = default; + } + + [DebuggerHidden()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public MyWebServices() : base() + { + } + } + + private readonly static ThreadSafeObjectProvider m_MyWebServicesObjectProvider = new ThreadSafeObjectProvider(); + /* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If + */ + /* TODO ERROR: Skipped IfDirectiveTrivia + #If _MYTYPE = "Web" Then + *//* TODO ERROR: Skipped DisabledTextTrivia + + _ + Friend ReadOnly Property Request() As Global.System.Web.HttpRequest + _ + Get + Dim CurrentContext As Global.System.Web.HttpContext = Global.System.Web.HttpContext.Current + If CurrentContext IsNot Nothing Then + Return CurrentContext.Request + End If + Return Nothing + End Get + End Property + + _ + Friend ReadOnly Property Response() As Global.System.Web.HttpResponse + _ + Get + Dim CurrentContext As Global.System.Web.HttpContext = Global.System.Web.HttpContext.Current + If CurrentContext IsNot Nothing Then + Return CurrentContext.Response + End If + Return Nothing + End Get + End Property + + _ + Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.AspLog + _ + Get + Return m_LogObjectProvider.GetInstance() + End Get + End Property + + Private ReadOnly m_LogObjectProvider As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.AspLog) + + *//* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If '_MYTYPE="Web" + */ + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.InteropServices.ComVisible(false)] + internal sealed class ThreadSafeObjectProvider where T : new() + { + internal T GetInstance + { + /* TODO ERROR: Skipped IfDirectiveTrivia + #If TARGET = "library" Then + */ + [DebuggerHidden()] + get + { + var Value = m_Context.Value; + if (Value is null) + { + Value = new T(); + m_Context.Value = Value; + } + return Value; + } + /* TODO ERROR: Skipped ElseDirectiveTrivia + #Else + *//* TODO ERROR: Skipped DisabledTextTrivia + _ + Get + If m_ThreadStaticValue Is Nothing Then m_ThreadStaticValue = New T + Return m_ThreadStaticValue + End Get + *//* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If + */ + } + + [DebuggerHidden()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public ThreadSafeObjectProvider() : base() + { + } + + /* TODO ERROR: Skipped IfDirectiveTrivia + #If TARGET = "library" Then + */ + private readonly Microsoft.VisualBasic.MyServices.Internal.ContextValue m_Context = new Microsoft.VisualBasic.MyServices.Internal.ContextValue(); + /* TODO ERROR: Skipped ElseDirectiveTrivia + #Else + *//* TODO ERROR: Skipped DisabledTextTrivia + Private Shared m_ThreadStaticValue As T + *//* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If + */ + } + } +} +/* TODO ERROR: Skipped EndIfDirectiveTrivia +#End If +*/ \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/My Project/MyNamespace.Static.2.Designer.cs b/vb-migration/Strata.Base.Internal/My Project/MyNamespace.Static.2.Designer.cs new file mode 100644 index 0000000..6f0b8f2 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/My Project/MyNamespace.Static.2.Designer.cs @@ -0,0 +1,241 @@ +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Xml.Linq; +using Microsoft.VisualBasic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// See Compiler::LoadXmlSolutionExtension +namespace Strata.Base.Internal.My +{ + [Embedded()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal sealed class InternalXmlHelper + { + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + private InternalXmlHelper() + { + } + public static string get_Value(IEnumerable source) + { + foreach (XElement item in source) + return item.Value; + return null; + } + + public static void set_Value(IEnumerable source, string value) + { + foreach (XElement item in source) + { + item.Value = value; + break; + } + } + public static string get_AttributeValue(IEnumerable source, XName name) + { + foreach (XElement item in source) + return (string)item.Attribute(name); + return null; + } + + public static void set_AttributeValue(IEnumerable source, XName name, string value) + { + foreach (XElement item in source) + { + item.SetAttributeValue(name, value); + break; + } + } + public static string get_AttributeValue(XElement source, XName name) + { + return (string)source.Attribute(name); + } + + public static void set_AttributeValue(XElement source, XName name, string value) + { + source.SetAttributeValue(name, value); + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static XAttribute CreateAttribute(XName name, object value) + { + if (value is null) + { + return null; + } + return new XAttribute(name, value); + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static XAttribute CreateNamespaceAttribute(XName name, XNamespace ns) + { + var a = new XAttribute(name, ns.NamespaceName); + a.AddAnnotation(ns); + return a; + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static object RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, object obj) + { + if (obj is not null) + { + XElement elem = obj as XElement; + if (elem is not null) + { + return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elem); + } + else + { + IEnumerable elems = obj as IEnumerable; + if (elems is not null) + { + return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elems); + } + } + } + return obj; + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static IEnumerable RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, IEnumerable obj) + { + if (obj is not null) + { + IEnumerable elems = obj as IEnumerable; + if (elems is not null) + { + return elems.Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessXElement); + } + else + { + return obj.Cast().Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessObject); + } + } + return obj; + } + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + private sealed class RemoveNamespaceAttributesClosure + { + private readonly string[] m_inScopePrefixes; + private readonly XNamespace[] m_inScopeNs; + private readonly List m_attributes; + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal RemoveNamespaceAttributesClosure(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes) + { + m_inScopePrefixes = inScopePrefixes; + m_inScopeNs = inScopeNs; + m_attributes = attributes; + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal XElement ProcessXElement(XElement elem) + { + return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + internal object ProcessObject(object obj) + { + XElement elem = obj as XElement; + if (elem is not null) + { + return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); + } + else + { + return obj; + } + } + } + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, XElement e) + { + if (e is not null) + { + var a = e.FirstAttribute; + + while (a is not null) + { + var nextA = a.NextAttribute; + + if (a.IsNamespaceDeclaration) + { + var ns = a.Annotation(); + string prefix = a.Name.LocalName; + + if (ns is not null) + { + if (inScopePrefixes is not null && inScopeNs is not null) + { + int lastIndex = inScopePrefixes.Length - 1; + + for (int i = 0, loopTo = lastIndex; i <= loopTo; i++) + { + string currentInScopePrefix = inScopePrefixes[i]; + var currentInScopeNs = inScopeNs[i]; + if (prefix.Equals(currentInScopePrefix)) + { + if (ns == currentInScopeNs) + { + // prefix and namespace match. Remove the unneeded ns attribute + a.Remove(); + } + + // prefix is in scope but refers to something else. Leave the ns attribute. + a = null; + break; + } + } + } + + if (a is not null) + { + // Prefix is not in scope + // Now check whether it's going to be in scope because it is in the attributes list + + if (attributes is not null) + { + int lastIndex = attributes.Count - 1; + for (int i = 0, loopTo1 = lastIndex; i <= loopTo1; i++) + { + var currentA = attributes[i]; + string currentInScopePrefix = currentA.Name.LocalName; + var currentInScopeNs = currentA.Annotation(); + if (currentInScopeNs is not null) + { + if (prefix.Equals(currentInScopePrefix)) + { + if (ns == currentInScopeNs) + { + // prefix and namespace match. Remove the unneeded ns attribute + a.Remove(); + } + + // prefix is in scope but refers to something else. Leave the ns attribute. + a = null; + break; + } + } + } + } + + if (a is not null) + { + // Prefix is definitely not in scope + a.Remove(); + // namespace is not defined either. Add this attributes list + attributes.Add(a); + } + } + } + } + + a = nextA; + } + } + return e; + } + + } +} \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/My Project/MyNamespace.Static.3.Designer.cs b/vb-migration/Strata.Base.Internal/My Project/MyNamespace.Static.3.Designer.cs new file mode 100644 index 0000000..e39b420 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/My Project/MyNamespace.Static.3.Designer.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +namespace Microsoft.VisualBasic +{ + [Embedded()] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Module | AttributeTargets.Assembly, Inherited = false)] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.CompilerServices.CompilerGenerated()] + internal sealed class Embedded : Attribute + { + } +} \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/My Project/Resources.Designer.cs b/vb-migration/Strata.Base.Internal/My Project/Resources.Designer.cs new file mode 100644 index 0000000..31a80a9 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/My Project/Resources.Designer.cs @@ -0,0 +1,70 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ + + +using System.Diagnostics; +using Microsoft.VisualBasic; + +namespace Strata.Base.Internal.My.Resources +{ + + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + [System.CodeDom.Compiler.GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + [HideModuleName()] + internal static class Resources + { + + private static System.Resources.ResourceManager resourceMan; + + private static System.Globalization.CultureInfo resourceCulture; + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Resources.ResourceManager ResourceManager + { + get + { + if (ReferenceEquals(resourceMan, null)) + { + var temp = new System.Resources.ResourceManager("Strata.Base.Internal.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/My Project/Settings.Designer.cs b/vb-migration/Strata.Base.Internal/My Project/Settings.Designer.cs new file mode 100644 index 0000000..d591377 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/My Project/Settings.Designer.cs @@ -0,0 +1,100 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ + +using System.Diagnostics; +using Microsoft.VisualBasic; +using Microsoft.VisualBasic.CompilerServices; + + +namespace Strata.Base.Internal.My +{ + + [System.Runtime.CompilerServices.CompilerGenerated()] + [System.CodeDom.Compiler.GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.12.0.0")] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] + internal sealed partial class MySettings : System.Configuration.ApplicationSettingsBase + { + + private static MySettings defaultInstance = (MySettings)Synchronized(new MySettings()); + + #region My.Settings Auto-Save Functionality + /* TODO ERROR: Skipped IfDirectiveTrivia + #If _MyType = "WindowsForms" Then + *//* TODO ERROR: Skipped DisabledTextTrivia + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub + *//* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If + */ + #endregion + + public static MySettings Default + { + get + { + + /* TODO ERROR: Skipped IfDirectiveTrivia + #If _MyType = "WindowsForms" Then + *//* TODO ERROR: Skipped DisabledTextTrivia + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If + *//* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If + */ + return defaultInstance; + } + } + + [System.Configuration.ApplicationScopedSetting()] + [DebuggerNonUserCode()] + [System.Configuration.DefaultSettingValue("Development")] + public string Environment + { + get + { + return Conversions.ToString(this["Environment"]); + } + } + } +} + +namespace Strata.Base.Internal.My +{ + + [HideModuleName()] + [DebuggerNonUserCode()] + [System.Runtime.CompilerServices.CompilerGenerated()] + internal static class MySettingsProperty + { + + [System.ComponentModel.Design.HelpKeyword("My.Settings")] + internal static MySettings Settings + { + get + { + return MySettings.Default; + } + } + } +} \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/Security/Encryption.cs b/vb-migration/Strata.Base.Internal/Security/Encryption.cs new file mode 100644 index 0000000..7281e83 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/Security/Encryption.cs @@ -0,0 +1,819 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace Strata.Base.Internal.EncryptionUtils +{ + + #region Hash + + /// + /// Hash functions are fundamental to modern cryptography. These functions map binary + /// strings of an arbitrary length to small binary strings of a fixed length, known as + /// hash values. A cryptographic hash function has the property that it is computationally + /// infeasible to find two distinct inputs that hash to the same value. Hash functions + /// are commonly used with digital signatures and for data integrity. + /// + public class Hasher + { + + /// + /// Type of hash; some are security oriented, others are fast and simple + /// + internal enum Provider + { + /// + /// Secure Hashing Algorithm provider, SHA-2 variant, 256-bit + /// + SHA256, + /// + /// Secure Hashing Algorithm provider, SHA-2 variant, 384-bit + /// + SHA384, + /// + /// Secure Hashing Algorithm provider, SHA-2 variant, 512-bit + /// + SHA512 + } + + private HashAlgorithm _Hash; + private Data _HashValue = new Data(); + + internal Hasher() + { + } + + /// + /// Instantiate a new hash of the specified type + /// + internal Hasher(Provider p) + { + switch (p) + { + case Provider.SHA256: + { + _Hash = SHA256.Create(); + break; + } + case Provider.SHA384: + { + _Hash = SHA384.Create(); + break; + } + case Provider.SHA512: + { + _Hash = SHA512.Create(); + break; + } + + default: + { + _Hash = SHA256.Create(); // Default to SHA256 for unknown providers + break; + } + } + } + + /// + /// Returns the previously calculated hash + /// + internal Data Value + { + get + { + return _HashValue; + } + } + + /// + /// Calculates hash on a stream of arbitrary length + /// + internal Data Calculate(ref Stream s) + { + _HashValue.Bytes = _Hash.ComputeHash(s); + return _HashValue; + } + + /// + /// Calculates hash for fixed length + /// + internal Data Calculate(Data d) + { + return CalculatePrivate(d.Bytes); + } + + /// + /// Calculates hash for a string with a prefixed salt value. + /// A "salt" is random data prefixed to every hashed value to prevent + /// common dictionary attacks. + /// + internal Data Calculate(Data d, Data salt) + { + var nb = new byte[(d.Bytes.Length + salt.Bytes.Length)]; + salt.Bytes.CopyTo(nb, 0); + d.Bytes.CopyTo(nb, salt.Bytes.Length); + return CalculatePrivate(nb); + } + + /// + /// Calculates hash for an array of bytes + /// + private Data CalculatePrivate(byte[] b) + { + _HashValue.Bytes = _Hash.ComputeHash(b); + return _HashValue; + } + + } + #endregion + + #region Symmetric + + /// + /// Symmetric encryption uses a single key to encrypt and decrypt. + /// Both parties (encryptor and decryptor) must share the same secret key. + /// + internal class SymmetricEncryptor + { + + private const string _DefaultIntializationVector = "%1Az=-@qT"; + private const int _BufferSize = 2048; + + internal enum Provider + { + /// + /// Advanced Encryption Standard (AES) provider + /// + AES + } + + private Data _data; + private Data _key; + private Data _iv; + private SymmetricAlgorithm _crypto; + private byte[] _EncryptedBytes; + private bool _UseDefaultInitializationVector; + + private SymmetricEncryptor() + { + } + + /// + /// Instantiates a new symmetric encryption object using the specified provider. + /// + internal SymmetricEncryptor(Provider provider, bool useDefaultInitializationVector = true) + { + _crypto = Aes.Create(); // Always use AES as it's the most secure option + + // -- make sure key and IV are always set, no matter what + Key = RandomKey(); + if (useDefaultInitializationVector) + { + IntializationVector = new Data(_DefaultIntializationVector); + } + else + { + IntializationVector = RandomInitializationVector(); + } + } + + /// + /// Key size in bytes. We use the default key size for any given provider; if you + /// want to force a specific key size, set this property + /// + internal int KeySizeBytes + { + get + { + return _crypto.KeySize / 8; + } + set + { + _crypto.KeySize = value * 8; + _key.MaxBytes = value; + } + } + + /// + /// Key size in bits. We use the default key size for any given provider; if you + /// want to force a specific key size, set this property + /// + internal int KeySizeBits + { + get + { + return _crypto.KeySize; + } + set + { + _crypto.KeySize = value; + _key.MaxBits = value; + } + } + + /// + /// The key used to encrypt/decrypt data + /// + internal Data Key + { + get + { + return _key; + } + set + { + _key = value; + _key.MaxBytes = _crypto.LegalKeySizes[0].MaxSize / 8; + _key.MinBytes = _crypto.LegalKeySizes[0].MinSize / 8; + _key.StepBytes = _crypto.LegalKeySizes[0].SkipSize / 8; + } + } + + /// + /// Using the default Cipher Block Chaining (CBC) mode, all data blocks are processed using + /// the value derived from the previous block; the first data block has no previous data block + /// to use, so it needs an InitializationVector to feed the first block + /// + internal Data IntializationVector + { + get + { + return _iv; + } + set + { + _iv = value; + _iv.MaxBytes = _crypto.BlockSize / 8; + _iv.MinBytes = _crypto.BlockSize / 8; + } + } + + /// + /// generates a random Initialization Vector, if one was not provided + /// + internal Data RandomInitializationVector() + { + _crypto.GenerateIV(); + var d = new Data(_crypto.IV); + return d; + } + + /// + /// generates a random Key, if one was not provided + /// + internal Data RandomKey() + { + _crypto.GenerateKey(); + var d = new Data(_crypto.Key); + return d; + } + + /// + /// Ensures that _crypto object has valid Key and IV + /// prior to any attempt to encrypt/decrypt anything + /// + private void ValidateKeyAndIv(bool isEncrypting) + { + if (_key.IsEmpty) + { + if (isEncrypting) + { + _key = RandomKey(); + } + else + { + throw new CryptographicException("No key was provided for the decryption operation!"); + } + } + if (_iv.IsEmpty) + { + if (isEncrypting) + { + _iv = RandomInitializationVector(); + } + else + { + throw new CryptographicException("No initialization vector was provided for the decryption operation!"); + } + } + try + { + _crypto.Key = _key.Bytes; + _crypto.IV = _iv.Bytes; + } + catch (CryptographicException ex) + { + throw new CryptographicException("Invalid key or initialization vector.", ex); + } + } + + /// + /// Encrypts the specified Data using provided key + /// + internal Data Encrypt(Data d, Data key) + { + Key = key; + return Encrypt(d); + } + + /// + /// Encrypts the specified Data using preset key and preset initialization vector + /// + internal Data Encrypt(Data d) + { + var ms = new MemoryStream(); + + ValidateKeyAndIv(true); + + var cs = new CryptoStream(ms, _crypto.CreateEncryptor(), CryptoStreamMode.Write); + cs.Write(d.Bytes, 0, d.Bytes.Length); + cs.Close(); + ms.Close(); + + return new Data(ms.ToArray()); + } + + /// + /// Encrypts the stream to memory using provided key and provided initialization vector + /// + internal Data Encrypt(Stream s, Data key, Data iv) + { + IntializationVector = iv; + Key = key; + return Encrypt(s); + } + + /// + /// Encrypts the stream to memory using specified key + /// + internal Data Encrypt(Stream s, Data key) + { + Key = key; + return Encrypt(s); + } + + /// + /// Encrypts the specified stream to memory using preset key and preset initialization vector + /// + internal Data Encrypt(Stream s) + { + var ms = new MemoryStream(); + var b = new byte[2049]; + int i; + + ValidateKeyAndIv(true); + + var cs = new CryptoStream(ms, _crypto.CreateEncryptor(), CryptoStreamMode.Write); + i = s.Read(b, 0, _BufferSize); + while (i > 0) + { + cs.Write(b, 0, i); + i = s.Read(b, 0, _BufferSize); + } + + cs.Close(); + ms.Close(); + + return new Data(ms.ToArray()); + } + + /// + /// Decrypts the specified data using provided key and preset initialization vector + /// + internal Data Decrypt(Data encryptedData, Data key) + { + Key = key; + return Decrypt(encryptedData); + } + + /// + /// Decrypts the specified stream using provided key and preset initialization vector + /// + internal Data Decrypt(Stream encryptedStream, Data key) + { + Key = key; + return Decrypt(encryptedStream); + } + + /// + /// Decrypts the specified stream using preset key and preset initialization vector + /// + internal Data Decrypt(Stream encryptedStream) + { + var ms = new MemoryStream(); + var b = new byte[2049]; + + ValidateKeyAndIv(false); + var cs = new CryptoStream(encryptedStream, _crypto.CreateDecryptor(), CryptoStreamMode.Read); + + int i; + i = cs.Read(b, 0, _BufferSize); + + while (i > 0) + { + ms.Write(b, 0, i); + i = cs.Read(b, 0, _BufferSize); + } + cs.Close(); + ms.Close(); + + return new Data(ms.ToArray()); + } + + /// + /// Decrypts the specified data using preset key and preset initialization vector + /// + internal Data Decrypt(Data encryptedData) + { + using (var ms = new MemoryStream(encryptedData.Bytes, 0, encryptedData.Bytes.Length)) + { + ValidateKeyAndIv(false); + using (var cs = new CryptoStream(ms, _crypto.CreateDecryptor(), CryptoStreamMode.Read)) + { + using (var outputMs = new MemoryStream()) + { + try + { + cs.CopyTo(outputMs); + return new Data(outputMs.ToArray()); + } + catch (CryptographicException ex) + { + throw new CryptographicException("Unable to decrypt data. The provided key may be invalid.", ex); + } + } + } + } + } + + } + + #endregion + + #region Data + + /// + /// represents Hex, Byte, Base64, or String data to encrypt/decrypt; + /// use the .Text property to set/get a string representation + /// use the .Hex property to set/get a string-based Hexadecimal representation + /// + internal class Data + { + private byte[] _b = null; + private int _MaxBytes = 0; + private int _MinBytes = 0; + private int _StepBytes = 0; + + /// + /// Determines the default text encoding for this Data instance + /// + private Encoding _encoding = Encoding.UTF8; + + /// + /// Creates new, empty encryption data + /// + internal Data() + { + } + + /// + /// Creates new encryption data with the specified byte array + /// + internal Data(byte[] b) + { + _b = b; + } + + /// + /// Creates new encryption data with the specified string; + /// will be converted to byte array using UTF8 encoding + /// + internal Data(string s) + { + if (s is null) + { + throw new ArgumentNullException(nameof(s)); + } + Text = s; + } + + /// + /// Creates new encryption data using the specified string and the + /// specified encoding to convert the string to a byte array. + /// + internal Data(string s, Encoding encoding) + { + if (s is null) + { + throw new ArgumentNullException(nameof(s)); + } + if (encoding is null) + { + throw new ArgumentNullException(nameof(encoding)); + } + _encoding = encoding; + Text = s; + } + + /// + /// returns true if no data is present + /// + internal bool IsEmpty + { + get + { + if (_b is null) + { + return true; + } + if (_b.Length == 0) + { + return true; + } + return false; + } + } + + /// + /// allowed step interval, in bytes, for this data; if 0, no limit + /// + internal int StepBytes + { + get + { + return _StepBytes; + } + set + { + _StepBytes = value; + } + } + + /// + /// allowed step interval, in bits, for this data; if 0, no limit + /// + internal int StepBits + { + get + { + return _StepBytes * 8; + } + set + { + _StepBytes = value / 8; + } + } + + /// + /// minimum number of bytes allowed for this data; if 0, no limit + /// + internal int MinBytes + { + get + { + return _MinBytes; + } + set + { + _MinBytes = value; + } + } + + /// + /// minimum number of bits allowed for this data; if 0, no limit + /// + internal int MinBits + { + get + { + return _MinBytes * 8; + } + set + { + _MinBytes = value / 8; + } + } + + /// + /// maximum number of bytes allowed for this data; if 0, no limit + /// + internal int MaxBytes + { + get + { + return _MaxBytes; + } + set + { + _MaxBytes = value; + } + } + + /// + /// maximum number of bits allowed for this data; if 0, no limit + /// + internal int MaxBits + { + get + { + return _MaxBytes * 8; + } + set + { + _MaxBytes = value / 8; + } + } + + /// + /// Returns the byte representation of the data; + /// This will be padded to MinBytes and trimmed to MaxBytes as necessary! + /// + internal byte[] Bytes + { + get + { + if (_b is null) + { + return Array.Empty(); + } + + if (_MaxBytes > 0 && _b.Length > _MaxBytes) + { + var b = new byte[_MaxBytes]; + Array.Copy(_b, b, b.Length); + _b = b; + } + + if (_MinBytes > 0 && _b.Length < _MinBytes) + { + var b = new byte[_MinBytes]; + Array.Copy(_b, b, _b.Length); + _b = b; + } + + return _b; + } + set + { + _b = value; + } + } + + /// + /// Sets or returns text representation of bytes using UTF8 encoding + /// + internal string Text + { + get + { + if (_b is null || _b.Length == 0) + { + return string.Empty; + } + + try + { + return _encoding.GetString(_b); + } + catch (Exception ex) + { + // If there's an encoding error, try to salvage what we can + int i = Array.IndexOf(_b, (byte)0); + if (i >= 0) + { + return _encoding.GetString(_b, 0, i); + } + throw; + } + } + set + { + if (value is null) + { + _b = Array.Empty(); + } + else + { + _b = _encoding.GetBytes(value); + } + } + } + + /// + /// Sets or returns Hex string representation of this data + /// + internal string Hex + { + get + { + return Utils.ToHex(_b); + } + set + { + _b = Utils.FromHex(value); + } + } + + /// + /// Sets or returns Base64 string representation of this data + /// + internal string Base64 + { + get + { + return Utils.ToBase64(_b); + } + set + { + _b = Utils.FromBase64(value); + } + } + + } + + #endregion + + #region Utils + + /// + /// Friend class for shared utility methods used by multiple Encryption classes + /// + internal class Utils + { + + /// + /// converts an array of bytes to a string Hex representation + /// + internal static string ToHex(byte[] ba) + { + if (ba is null || ba.Length == 0) + { + return ""; + } + const string HexFormat = "{0:X2}"; + var sb = new StringBuilder(); + foreach (byte b in ba) + sb.Append(string.Format(HexFormat, b)); + return sb.ToString(); + } + + /// + /// converts from a string Hex representation to an array of bytes + /// + internal static byte[] FromHex(string hexEncoded) + { + if (hexEncoded is null || hexEncoded.Length == 0) + { + return null; + } + try + { + int l = Convert.ToInt32(hexEncoded.Length / 2d); + var b = new byte[l]; + for (int i = 0, loopTo = l - 1; i <= loopTo; i++) + b[i] = Convert.ToByte(hexEncoded.Substring(i * 2, 2), 16); + return b; + } + catch (Exception ex) + { + throw new FormatException("The provided string does not appear to be Hex encoded:" + Environment.NewLine + hexEncoded + Environment.NewLine, ex); + } + } + + /// + /// converts from a string Base64 representation to an array of bytes + /// + internal static byte[] FromBase64(string base64Encoded) + { + if (base64Encoded is null || base64Encoded.Length == 0) + { + return null; + } + try + { + return Convert.FromBase64String(base64Encoded); + } + catch (FormatException ex) + { + throw new FormatException("The provided string does not appear to be Base64 encoded:" + Environment.NewLine + base64Encoded + Environment.NewLine, ex); + } + } + + /// + /// converts from an array of bytes to a string Base64 representation + /// + internal static string ToBase64(byte[] b) + { + if (b is null || b.Length == 0) + { + return ""; + } + return Convert.ToBase64String(b); + } + + } + + #endregion + +} \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/Security/SecurityUtils.cs b/vb-migration/Strata.Base.Internal/Security/SecurityUtils.cs new file mode 100644 index 0000000..2503f70 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/Security/SecurityUtils.cs @@ -0,0 +1,87 @@ +using System; + +namespace Strata.Base.Internal +{ + public class SecurityUtils + { + + #region Declarations + private const string ENCRYPTION_KEY_SUFFIX = "SDT"; + private const int KEY_SIZE_BYTES = 32; // 256 bits for AES-256 + #endregion + + #region Methods + + private static string PadKey(string key) + { + if (key is null) + { + throw new ArgumentNullException(nameof(key)); + } + + string paddedKey = key + ENCRYPTION_KEY_SUFFIX; + if (paddedKey.Length < KEY_SIZE_BYTES) + { + paddedKey = paddedKey.PadRight(KEY_SIZE_BYTES, 'X'); + } + else if (paddedKey.Length > KEY_SIZE_BYTES) + { + paddedKey = paddedKey.Substring(0, KEY_SIZE_BYTES); + } + return paddedKey; + } + + public static string EncryptValue(string value, string key) + { + if (value is null) + { + return null; + } + + if (string.IsNullOrEmpty(value)) + { + return string.Empty; + } + + if (key is null) + { + throw new ArgumentNullException(nameof(key)); + } + + // Create encryptor with default IV + var encryption = new EncryptionUtils.SymmetricEncryptor(EncryptionUtils.SymmetricEncryptor.Provider.AES); + + var result = encryption.Encrypt(new EncryptionUtils.Data(value), new EncryptionUtils.Data(PadKey(key))); + return result.Base64; + } + + public static string DecryptValue(string encryptedValue, string key) + { + if (encryptedValue is null) + { + return null; + } + + if (string.IsNullOrEmpty(encryptedValue)) + { + return string.Empty; + } + + if (key is null) + { + throw new ArgumentNullException(nameof(key)); + } + + var encryption = new EncryptionUtils.SymmetricEncryptor(EncryptionUtils.SymmetricEncryptor.Provider.AES); + + // note EncryptValue returns Base64 string so we need to initialized encryptedData as Base64 + var encryptedData = new EncryptionUtils.Data(); + encryptedData.Base64 = encryptedValue; + + return encryption.Decrypt(encryptedData, new EncryptionUtils.Data(PadKey(key))).Text; + } + + #endregion + + } +} \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/Strata.Base.Internal.csproj b/vb-migration/Strata.Base.Internal/Strata.Base.Internal.csproj new file mode 100644 index 0000000..77bf1ef --- /dev/null +++ b/vb-migration/Strata.Base.Internal/Strata.Base.Internal.csproj @@ -0,0 +1,82 @@ + + + net8.0-windows + Library + Windows + + + + + On + + false + true + true + Strata.Biz.Internal + Strata Decision Technology, LLC + Strata.Biz.Internal + 2006-2012 Strata Decision Technology, LLC + $(DefaultItemExcludes);$(ProjectDir)**\*.vb + latest + + + Strata.Base.Internal.xml + 42353,42354,42355 + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + false + -Microsoft.Design#CA1012;-Microsoft.Design#CA2210;-Microsoft.Design#CA1040;-Microsoft.Design#CA1005;-Microsoft.Design#CA1020;-Microsoft.Design#CA1021;-Microsoft.Design#CA1010;-Microsoft.Design#CA1011;-Microsoft.Design#CA1009;-Microsoft.Design#CA1050;-Microsoft.Design#CA1026;-Microsoft.Design#CA1019;-Microsoft.Design#CA1031;-Microsoft.Design#CA1047;-Microsoft.Design#CA1000;-Microsoft.Design#CA1048;-Microsoft.Design#CA1051;-Microsoft.Design#CA1002;-Microsoft.Design#CA1061;-Microsoft.Design#CA1006;-Microsoft.Design#CA1046;-Microsoft.Design#CA1045;-Microsoft.Design#CA1065;-Microsoft.Design#CA1038;-Microsoft.Design#CA1008;-Microsoft.Design#CA1028;-Microsoft.Design#CA1064;-Microsoft.Design#CA1004;-Microsoft.Design#CA1035;-Microsoft.Design#CA1063;-Microsoft.Design#CA1032;-Microsoft.Design#CA1023;-Microsoft.Design#CA1033;-Microsoft.Design#CA1039;-Microsoft.Design#CA1016;-Microsoft.Design#CA1014;-Microsoft.Design#CA1017;-Microsoft.Design#CA1018;-Microsoft.Design#CA1027;-Microsoft.Design#CA1059;-Microsoft.Design#CA1060;-Microsoft.Design#CA1034;-Microsoft.Design#CA1013;-Microsoft.Design#CA1036;-Microsoft.Design#CA1044;-Microsoft.Design#CA1041;-Microsoft.Design#CA1025;-Microsoft.Design#CA1052;-Microsoft.Design#CA1053;-Microsoft.Design#CA1057;-Microsoft.Design#CA1058;-Microsoft.Design#CA1001;-Microsoft.Design#CA1049;-Microsoft.Design#CA1054;-Microsoft.Design#CA1056;-Microsoft.Design#CA1055;-Microsoft.Design#CA1030;-Microsoft.Design#CA1003;-Microsoft.Design#CA1007;-Microsoft.Design#CA1043;-Microsoft.Design#CA1024;-Microsoft.Globalization#CA1301;-Microsoft.Globalization#CA1302;-Microsoft.Globalization#CA1308;-Microsoft.Globalization#CA1306;-Microsoft.Globalization#CA1304;-Microsoft.Globalization#CA1305;-Microsoft.Globalization#CA2101;-Microsoft.Globalization#CA1300;-Microsoft.Globalization#CA1307;-Microsoft.Globalization#CA1309;-Microsoft.Interoperability#CA1403;-Microsoft.Interoperability#CA1406;-Microsoft.Interoperability#CA1413;-Microsoft.Interoperability#CA1402;-Microsoft.Interoperability#CA1407;-Microsoft.Interoperability#CA1404;-Microsoft.Interoperability#CA1410;-Microsoft.Interoperability#CA1411;-Microsoft.Interoperability#CA1405;-Microsoft.Interoperability#CA1409;-Microsoft.Interoperability#CA1415;-Microsoft.Interoperability#CA1408;-Microsoft.Interoperability#CA1414;-Microsoft.Interoperability#CA1412;-Microsoft.Interoperability#CA1400;-Microsoft.Interoperability#CA1401;-Microsoft.Maintainability#CA1506;-Microsoft.Maintainability#CA1502;-Microsoft.Maintainability#CA1501;-Microsoft.Maintainability#CA1505;-Microsoft.Maintainability#CA1504;-Microsoft.Maintainability#CA1500;-Microsoft.Mobility#CA1600;-Microsoft.Mobility#CA1601;-Microsoft.Naming#CA1702;-Microsoft.Naming#CA1700;-Microsoft.Naming#CA1712;-Microsoft.Naming#CA1713;-Microsoft.Naming#CA1714;-Microsoft.Naming#CA1709;-Microsoft.Naming#CA1704;-Microsoft.Naming#CA1708;-Microsoft.Naming#CA1715;-Microsoft.Naming#CA1710;-Microsoft.Naming#CA1720;-Microsoft.Naming#CA1707;-Microsoft.Naming#CA1722;-Microsoft.Naming#CA1711;-Microsoft.Naming#CA1716;-Microsoft.Naming#CA1717;-Microsoft.Naming#CA1725;-Microsoft.Naming#CA1719;-Microsoft.Naming#CA1721;-Microsoft.Naming#CA1701;-Microsoft.Naming#CA1703;-Microsoft.Naming#CA1724;-Microsoft.Naming#CA1726;-Microsoft.Performance#CA1809;-Microsoft.Performance#CA1811;-Microsoft.Performance#CA1813;-Microsoft.Performance#CA1816;-Microsoft.Performance#CA1800;-Microsoft.Performance#CA1805;-Microsoft.Performance#CA1810;-Microsoft.Performance#CA1824;-Microsoft.Performance#CA1822;-Microsoft.Performance#CA1814;-Microsoft.Performance#CA1819;-Microsoft.Performance#CA1821;-Microsoft.Performance#CA1820;-Microsoft.Performance#CA1802;-Microsoft.Portability#CA1901;-Microsoft.Portability#CA1900;-Microsoft.Reliability#CA2001;-Microsoft.Reliability#CA2002;-Microsoft.Reliability#CA2003;-Microsoft.Reliability#CA2004;-Microsoft.Reliability#CA2006;-Microsoft.Security#CA2116;-Microsoft.Security#CA2117;-Microsoft.Security#CA2105;-Microsoft.Security#CA2115;-Microsoft.Security#CA2102;-Microsoft.Security#CA2104;-Microsoft.Security#CA2122;-Microsoft.Security#CA2114;-Microsoft.Security#CA2123;-Microsoft.Security#CA2111;-Microsoft.Security#CA2108;-Microsoft.Security#CA2107;-Microsoft.Security#CA2103;-Microsoft.Security#CA2118;-Microsoft.Security#CA2109;-Microsoft.Security#CA2119;-Microsoft.Security#CA2106;-Microsoft.Security#CA2112;-Microsoft.Security#CA2120;-Microsoft.Security#CA2121;-Microsoft.Security#CA2126;-Microsoft.Security#CA2124;-Microsoft.Security#CA2127;-Microsoft.Security#CA2128;-Microsoft.Security#CA2129;-Microsoft.Usage#CA2243;-Microsoft.Usage#CA2236;-Microsoft.Usage#CA2227;-Microsoft.Usage#CA2213;-Microsoft.Usage#CA2216;-Microsoft.Usage#CA2214;-Microsoft.Usage#CA2222;-Microsoft.Usage#CA1806;-Microsoft.Usage#CA2217;-Microsoft.Usage#CA2212;-Microsoft.Usage#CA2219;-Microsoft.Usage#CA2201;-Microsoft.Usage#CA2228;-Microsoft.Usage#CA2221;-Microsoft.Usage#CA2220;-Microsoft.Usage#CA2240;-Microsoft.Usage#CA2229;-Microsoft.Usage#CA2238;-Microsoft.Usage#CA2207;-Microsoft.Usage#CA2208;-Microsoft.Usage#CA2235;-Microsoft.Usage#CA2237;-Microsoft.Usage#CA2232;-Microsoft.Usage#CA2223;-Microsoft.Usage#CA2211;-Microsoft.Usage#CA2233;-Microsoft.Usage#CA2225;-Microsoft.Usage#CA2226;-Microsoft.Usage#CA2231;-Microsoft.Usage#CA2224;-Microsoft.Usage#CA2218;-Microsoft.Usage#CA2234;-Microsoft.Usage#CA2239;-Microsoft.Usage#CA2200;-Microsoft.Usage#CA1801;-Microsoft.Usage#CA2242;-Microsoft.Usage#CA2205;-Microsoft.Usage#CA2230 + Strata.Base.Internal.ruleset + + + Strata.Base.Internal.xml + 42353,42354,42355 + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + Strata.Base.Internal.ruleset + + + bin\ReleaseDeploy\ + bin\ReleaseDeploy\Strata.Base.Internal.xml + true + 42353,42354,42355 + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + Strata.Base.Internal.ruleset + TRACE + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MyApplicationCodeGenerator + Application.Designer.cs + + + + + SonarLint.xml + + + + + 8.44.0 + + + + + \ No newline at end of file diff --git a/vb-migration/Strata.Base.Internal/Strata.Base.Internal.xml b/vb-migration/Strata.Base.Internal/Strata.Base.Internal.xml new file mode 100644 index 0000000..10bf176 --- /dev/null +++ b/vb-migration/Strata.Base.Internal/Strata.Base.Internal.xml @@ -0,0 +1,301 @@ + + + + Strata.Base.Internal + + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + Hash functions are fundamental to modern cryptography. These functions map binary + strings of an arbitrary length to small binary strings of a fixed length, known as + hash values. A cryptographic hash function has the property that it is computationally + infeasible to find two distinct inputs that hash to the same value. Hash functions + are commonly used with digital signatures and for data integrity. + + + + + Type of hash; some are security oriented, others are fast and simple + + + + + Secure Hashing Algorithm provider, SHA-2 variant, 256-bit + + + + + Secure Hashing Algorithm provider, SHA-2 variant, 384-bit + + + + + Secure Hashing Algorithm provider, SHA-2 variant, 512-bit + + + + + Instantiate a new hash of the specified type + + + + + Returns the previously calculated hash + + + + + Calculates hash on a stream of arbitrary length + + + + + Calculates hash for fixed length + + + + + Calculates hash for a string with a prefixed salt value. + A "salt" is random data prefixed to every hashed value to prevent + common dictionary attacks. + + + + + Calculates hash for an array of bytes + + + + + Symmetric encryption uses a single key to encrypt and decrypt. + Both parties (encryptor and decryptor) must share the same secret key. + + + + + Advanced Encryption Standard (AES) provider + + + + + Instantiates a new symmetric encryption object using the specified provider. + + + + + Key size in bytes. We use the default key size for any given provider; if you + want to force a specific key size, set this property + + + + + Key size in bits. We use the default key size for any given provider; if you + want to force a specific key size, set this property + + + + + The key used to encrypt/decrypt data + + + + + Using the default Cipher Block Chaining (CBC) mode, all data blocks are processed using + the value derived from the previous block; the first data block has no previous data block + to use, so it needs an InitializationVector to feed the first block + + + + + generates a random Initialization Vector, if one was not provided + + + + + generates a random Key, if one was not provided + + + + + Ensures that _crypto object has valid Key and IV + prior to any attempt to encrypt/decrypt anything + + + + + Encrypts the specified Data using provided key + + + + + Encrypts the specified Data using preset key and preset initialization vector + + + + + Encrypts the stream to memory using provided key and provided initialization vector + + + + + Encrypts the stream to memory using specified key + + + + + Encrypts the specified stream to memory using preset key and preset initialization vector + + + + + Decrypts the specified data using provided key and preset initialization vector + + + + + Decrypts the specified stream using provided key and preset initialization vector + + + + + Decrypts the specified stream using preset key and preset initialization vector + + + + + Decrypts the specified data using preset key and preset initialization vector + + + + + represents Hex, Byte, Base64, or String data to encrypt/decrypt; + use the .Text property to set/get a string representation + use the .Hex property to set/get a string-based Hexadecimal representation + + + + + Determines the default text encoding for this Data instance + + + + + Creates new, empty encryption data + + + + + Creates new encryption data with the specified byte array + + + + + Creates new encryption data with the specified string; + will be converted to byte array using UTF8 encoding + + + + + Creates new encryption data using the specified string and the + specified encoding to convert the string to a byte array. + + + + + returns true if no data is present + + + + + allowed step interval, in bytes, for this data; if 0, no limit + + + + + allowed step interval, in bits, for this data; if 0, no limit + + + + + minimum number of bytes allowed for this data; if 0, no limit + + + + + minimum number of bits allowed for this data; if 0, no limit + + + + + maximum number of bytes allowed for this data; if 0, no limit + + + + + maximum number of bits allowed for this data; if 0, no limit + + + + + Returns the byte representation of the data; + This will be padded to MinBytes and trimmed to MaxBytes as necessary! + + + + + Sets or returns text representation of bytes using UTF8 encoding + + + + + Sets or returns Hex string representation of this data + + + + + Sets or returns Base64 string representation of this data + + + + + Friend class for shared utility methods used by multiple Encryption classes + + + + + converts an array of bytes to a string Hex representation + + + + + converts from a string Hex representation to an array of bytes + + + + + converts from a string Base64 representation to an array of bytes + + + + + converts from an array of bytes to a string Base64 representation + + + +