diff --git a/Classes/Extensions.Azure.Blob.cs b/Classes/Extensions.Azure.Blob.cs index f6189d1..139349d 100644 --- a/Classes/Extensions.Azure.Blob.cs +++ b/Classes/Extensions.Azure.Blob.cs @@ -1,6 +1,4 @@ -//#pragma warning disable CS0162, CS1587, CS1591, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -16,7 +14,6 @@ using System.Linq; using System.Text.Json; using static Extensions.Core; //NuGet Extensions.cs -using static System.Logit; namespace Extensions.Azure { @@ -218,5 +215,3 @@ public static BlobObject ReadFromBlob(string blobName) } } } - -//#pragma warning restore CS0162, CS1587, CS1591, CS1998, IDE0059, IDE0028 diff --git a/Classes/Extensions.CMail.cs b/Classes/Extensions.CMail.cs index 39c6a98..60e7070 100644 --- a/Classes/Extensions.CMail.cs +++ b/Classes/Extensions.CMail.cs @@ -1,21 +1,16 @@ -#pragma warning disable CS0162, CS1587, CS1591, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: /// https://github.com/cjvandyk/Extensions/blob/main/LICENSE /// -using Microsoft.Graph; -using Microsoft.Graph.Me.SendMail; using Microsoft.Graph.Models; using System; using System.Collections.Generic; using System.IO; using System.Linq; using static Extensions.Core; -using static Extensions.Identity.AuthMan; namespace Extensions { @@ -166,5 +161,3 @@ internal static FileAttachment GetGraphFileAttachment( } } } - -#pragma warning restore CS0162, CS1587, CS1591, CS1998, IDE0059, IDE0028 diff --git a/Classes/Extensions.Config.cs b/Classes/Extensions.Configuration.cs similarity index 90% rename from Classes/Extensions.Config.cs rename to Classes/Extensions.Configuration.cs index 4deac29..2f1188b 100644 --- a/Classes/Extensions.Config.cs +++ b/Classes/Extensions.Configuration.cs @@ -1,18 +1,15 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Graph; -using Microsoft.Online.SharePoint.TenantAdministration; +/// +/// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk +/// This code is provided under GNU GPL 3.0 and is a copyrighted work of the +/// author and contributors. Please see: +/// https://github.com/cjvandyk/Extensions/blob/main/LICENSE +/// + using System; using System.Collections.Generic; -using System.Configuration; using System.IO; -using System.Linq; -using System.Text; using System.Text.Json; -using System.Text.Json.Serialization; -using System.Threading.Tasks; using static Extensions.Core; -using static Extensions.Identity.AuthMan; -using static System.Logit; namespace Extensions { @@ -20,7 +17,7 @@ namespace Extensions /// Class that carries the configuration for a given tenant. /// [Serializable] - public partial class Config + public partial class Configuration { /// /// Settings contains the dictionary of all settings. @@ -36,7 +33,7 @@ public partial class Config /// /// Empty constructor. /// - public Config() + public Configuration() { } @@ -47,7 +44,7 @@ public Config() /// The name of the tenant e.g. for /// contoso.sharepoint.us it would be 'contoso'. /// The filename of the configuration JSON file. - internal string GetConfigFileName(string tenantString) + internal static string GetConfigFileName(string tenantString) { return $"UniversalConfig.{tenantString}.json"; } @@ -59,7 +56,7 @@ internal string GetConfigFileName(string tenantString) /// The name of the tenant e.g. for /// contoso.sharepoint.us it would be 'contoso'. /// The filename of the label JSON file. - internal string GetLabelsFileName(string tenantString) + internal static string GetLabelsFileName(string tenantString) { return $"Labels.{tenantString}.json"; } @@ -85,7 +82,7 @@ internal void LoadConfig(string tenantString) /// /// The name of the file to load. /// A dictionary of strings from the JSON file. - internal Dictionary LoadJSON(string filePath) + internal static Dictionary LoadJSON(string filePath) { var result = new Dictionary(); using (StreamReader reader = new StreamReader(filePath)) diff --git a/Classes/Extensions.Constants.cs b/Classes/Extensions.Constants.cs index a3dac42..075b8aa 100644 --- a/Classes/Extensions.Constants.cs +++ b/Classes/Extensions.Constants.cs @@ -1,6 +1,4 @@ -//#pragma warning disable CS1587, CS1591 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -774,4 +772,3 @@ public enum TimeZone #endregion TimeZone } } -//#pragma warning restore CS1587, CS1591 diff --git a/Classes/Extensions.Core.cs b/Classes/Extensions.Core.cs index eeb47bd..7127cdc 100644 --- a/Classes/Extensions.Core.cs +++ b/Classes/Extensions.Core.cs @@ -5,23 +5,17 @@ /// https://github.com/cjvandyk/Extensions/blob/main/LICENSE /// -using Microsoft.Extensions.Logging; using Microsoft.Graph; using Microsoft.Graph.Models; -using Microsoft.SharePoint.News.DataModel; using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; -using System.Linq; using System.Net.Http; using System.Text.Json; using System.Text.Json.Nodes; using Extensions.Identity; using Extensions.Tenant; -using static Extensions.Identity.Auth; using static Extensions.Identity.AuthMan; -using static System.Logit; namespace Extensions { @@ -84,7 +78,7 @@ public enum AzureEnvironment /// /// TODO /// - public static Config config { get; set; } = new Config(); + public static Configuration Config { get; set; } = new Configuration(); ///// ///// The tenant name e.g. for contoso.sharepoint.us it would be "contoso". @@ -163,7 +157,30 @@ public static string GraphUserEndPointUrl private static readonly object LockManager = new object(); #endregion Properties - #region ActiveAuth + #region Auth + /// + /// Method to get a matching Auth object from the stack or if it + /// doesn't exist on the stack, generate the new Auth object and + /// push it to the stack. + /// + /// The scope type of the Auth. Default value + /// is Graph. + /// Boolean to trigger a clearing of the + /// Auth stack. Default value is false. + /// A valid Auth object from the stack. + public static Auth GetAuth( + ScopeType scopeType = ScopeType.Graph, + bool authStackReset = false) + { + return AuthMan.GetAuth( + ActiveTenant.TenantDirectoryId, + ActiveTenant.ApplicationClientId, + ActiveTenant.CertThumbprint, + ActiveTenant.TenantString, + scopeType, + authStackReset); + } + /// /// A method to set the current ActiveAuth. /// @@ -178,7 +195,7 @@ public static bool SetActiveAuth(string key) } return false; } - #endregion ActiveAuth + #endregion Auth #region InitializeTenant /// @@ -199,10 +216,10 @@ public static void InitializeTenant(string tenantString) string[] sp = Scopes.SharePoint; sp[0] = sp[0].Replace("Contoso", CoreBase.TenantString); Scopes.SharePoint = sp; - GetAuth(GetEnv("TenantDirectoryId"), - GetEnv("ApplicationClientId"), - GetEnv("CertThumbprint"), - tenantString); + AuthMan.GetAuth(GetEnv("TenantDirectoryId"), + GetEnv("ApplicationClientId"), + GetEnv("CertThumbprint"), + tenantString); } else { @@ -228,7 +245,7 @@ public static void InitializeTenant(string tenantString) /// The name of the EV to add to config. internal static void AddEnvSetting(string key) { - config.Settings.Add(key, GetEnv(key)); + Config.Settings.Add(key, GetEnv(key)); } /// @@ -243,7 +260,7 @@ internal static void AddEnvSetting(string[] keys) { try { - config.Settings.Add(key, GetEnv(key)); + Config.Settings.Add(key, GetEnv(key)); } catch (Exception ex) { @@ -262,19 +279,19 @@ internal static void AddEnvSetting(string[] keys) /// The name of the target tenant. internal static void LoadConfig(string tenantString) { - config.Settings = new Dictionary(); - config.Settings.Add("TenantString", tenantString); + Config.Settings = new Dictionary(); + Config.Settings.Add("TenantString", tenantString); if (Environment.UserInteractive) { Inf($"Loading config from [" + $"{GetRunFolder()}]\\{GetConfigFileName(tenantString)}]."); - config.Settings = LoadJSON( - $"{Core.GetRunFolder()}" + + Config.Settings = LoadJSON( + $"{GetRunFolder()}" + $"\\{GetConfigFileName(tenantString)}"); Inf($"Loading sensitivity labels from [" + $"{GetRunFolder()}]\\{GetLabelsFileName(tenantString)}]."); - config.Labels = LoadJSON( - $"{Core.GetRunFolder()}" + + Config.Labels = LoadJSON( + $"{GetRunFolder()}" + $"\\{GetLabelsFileName(tenantString)}"); Inf("Config and Labels loaded."); } @@ -362,14 +379,72 @@ internal static Dictionary LoadJSON(string filePath) /// returned else a blank string is returned. public static string GetSetting(string key) { - if (config.Settings.ContainsKey(key)) + if (Config.Settings.ContainsKey(key)) { - return config.Settings[key]; + return Config.Settings[key]; } return ""; } #endregion InitializeTenant + #region Logit + /// + /// Called to write "Information" entries. + /// + /// The string message to log. + /// The Event Log event ID to use. + /// Return value from Log() method. + public static void Inf( + string message, + int eventId = 0, + Logit.Instance instance = null) + { + Logit.Inf(message, eventId, instance); + } + + /// + /// Called to write "Warning" entries. + /// + /// The string message to log. + /// The Event Log event ID to use. + /// Return value from Log() method. + public static void Wrn( + string message, + int eventId = 0, + Logit.Instance instance = null) + { + Logit.Wrn(message, eventId, instance); + } + + /// + /// Called to write "Error" entries. + /// + /// The string message to log. + /// The Event Log event ID to use. + /// Return value from Log() method. + public static void Err( + string message, + int eventId = 0, + Logit.Instance instance = null) + { + Logit.Err(message, eventId, instance); + } + + /// + /// Called to write "Verbose" entries. + /// + /// The string message to log. + /// The Event Log event ID to use. + /// Return value from Log() method. + public static void Vrb( + string message, + int eventId = 0, + Logit.Instance instance = null) + { + Logit.Vrb(message, eventId, instance); + } + #endregion Logit + #region GetCVersion() /// /// Method to get the CVersion. @@ -652,7 +727,7 @@ public static bool AnyNull(this object[] objects) /// Overrideable text color, default to white. /// Overrideable background color, default to /// black. - public static void printf(object msg, + public static void Printf(object msg, ConsoleColor foreground = ConsoleColor.White, ConsoleColor background = ConsoleColor.Black) { @@ -1001,12 +1076,12 @@ public static Microsoft.Graph.Models.ListItem GetUserFromLookupId( public static string GetUserEmailUpn( Microsoft.Graph.Models.ListItem listItem) { - if (listItem.Fields.AdditionalData.Keys.Contains("EMail") && + if (listItem.Fields.AdditionalData.ContainsKey("EMail") && listItem.Fields.AdditionalData["EMail"] != null) { return listItem.Fields.AdditionalData["EMail"].ToString(); } - if (listItem.Fields.AdditionalData.Keys.Contains("EMail") && + if (listItem.Fields.AdditionalData.ContainsKey("EMail") && listItem.Fields.AdditionalData["EMail"] != null) { return listItem.Fields.AdditionalData["UserName"].ToString(); @@ -1031,7 +1106,7 @@ public static string GetUserEmailUpn( id); if ((userListItems != null) && (userListItems.Count > 0) && - (userListItems[0].Fields.AdditionalData.Keys.Contains("EMail")) && + (userListItems[0].Fields.AdditionalData.ContainsKey("EMail")) && (userListItems[0].Fields.AdditionalData["EMail"] != null)) { return userListItems[0].Fields.AdditionalData["EMail"].ToString(); @@ -1068,7 +1143,7 @@ public static string GetUserEmailUpn( } try { - if ((item.Fields.AdditionalData.Keys.Contains("EMail")) && + if ((item.Fields.AdditionalData.ContainsKey("EMail")) && (item.Fields.AdditionalData["EMail"] != null)) { return item.Fields.AdditionalData["EMail"].ToString(); @@ -1103,7 +1178,7 @@ public static bool TryAdd( { try { - if (!dic.Values.Contains(val)) + if (!dic.ContainsValue(val)) { dic.Add(key, val); return true; @@ -1181,7 +1256,7 @@ public static void DumpSettings() Inf($"[{setting.Key}] = [{setting.Value}]"); } Inf("Dumping Core settings..."); - foreach (var setting in Extensions.Core.config.Settings) + foreach (var setting in Core.Config.Settings) { Inf($"[{setting.Key}] = [{setting.Value}]"); } diff --git a/Classes/Extensions.CoreBase.cs b/Classes/Extensions.CoreBase.cs index f0f79c3..ac2a3e9 100644 --- a/Classes/Extensions.CoreBase.cs +++ b/Classes/Extensions.CoreBase.cs @@ -1,6 +1,4 @@ -//#pragma warning disable CS0162, CS0168//, CS1587, CS1998, IDE0028, IDE0059 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: diff --git a/Classes/Extensions.Graph.DriveItem.cs b/Classes/Extensions.Graph.DriveItem.cs index 099bff8..e7d4856 100644 --- a/Classes/Extensions.Graph.DriveItem.cs +++ b/Classes/Extensions.Graph.DriveItem.cs @@ -6,7 +6,6 @@ /// using System; -using System.Collections.Generic; using System.Runtime.Serialization; namespace Extensions @@ -22,9 +21,7 @@ public static partial class GraphExtensions public class DriveItem { [DataMember] - public Microsoft.Graph.Models.IdentitySet CreatedBy { get; set; } - - + public Microsoft.Graph.Models.IdentitySet CreatedBy { get; set; } } } } \ No newline at end of file diff --git a/Classes/Extensions.Graph.cs b/Classes/Extensions.Graph.cs index 8fc1a2b..50c7a59 100644 --- a/Classes/Extensions.Graph.cs +++ b/Classes/Extensions.Graph.cs @@ -1,6 +1,4 @@ -//#pragma warning disable CS0168, CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -8,24 +6,15 @@ /// using Microsoft.Graph; -using Microsoft.Graph.Groups; using static Microsoft.Graph.Groups.GroupsRequestBuilder; using static Microsoft.Graph.Users.UsersRequestBuilder; using Microsoft.Graph.Models; -using Microsoft.SharePoint.News.DataModel; using System; -using System.Collections; using System.Collections.Generic; -using System.Diagnostics; -using System.IO; using System.Linq; -//using System.Management.Automation; -using System.Net.Http; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using static Extensions.Core; -using static System.Logit; using static Microsoft.Graph.Users.Item.Drives.DrivesRequestBuilder; namespace Extensions @@ -1914,4 +1903,3 @@ internal static void WriteCount(int count) } } } -//#pragma warning restore CS0168, CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/Extensions.Identity.App.cs b/Classes/Extensions.Identity.App.cs index 32912e9..597ca9b 100644 --- a/Classes/Extensions.Identity.App.cs +++ b/Classes/Extensions.Identity.App.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS0162, CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -200,4 +198,3 @@ public static string GetAuthority(EnvironmentName environmentName, } } } -#pragma warning restore CS0162, CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/Extensions.Identity.Auth.ClientApplicationType.cs b/Classes/Extensions.Identity.Auth.ClientApplicationType.cs index 699bee8..4c078d9 100644 --- a/Classes/Extensions.Identity.Auth.ClientApplicationType.cs +++ b/Classes/Extensions.Identity.Auth.ClientApplicationType.cs @@ -1,7 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - - -using System; +using System; /// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the @@ -31,4 +28,3 @@ public enum ClientApplicationType } } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/Extensions.Identity.Auth.cs b/Classes/Extensions.Identity.Auth.cs index f5490fb..6fc6386 100644 --- a/Classes/Extensions.Identity.Auth.cs +++ b/Classes/Extensions.Identity.Auth.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -9,13 +7,10 @@ using Microsoft.Graph; using Microsoft.Identity.Client; -using Microsoft.SharePoint.Client; using System; using System.Net.Http; -using System.Net.Http.Headers; using System.Security.Cryptography.X509Certificates; using System.Threading; -using System.Threading.Tasks; using static Extensions.Identity.AuthMan; using static System.Logit; @@ -136,8 +131,8 @@ public Auth( App = Identity.App.GetApp(appId, thumbprint, tenantString); //Set the scopes for this Auth object. Scopes = Identity.Scopes.GetScopes(scopeType); - TenantCfg.Settings = Core.config.Settings; - TenantCfg.Labels = Core.config.Labels; + TenantCfg.Settings = Core.Config.Settings; + TenantCfg.Labels = Core.Config.Labels; if (!Core.Tenants.ContainsKey(tenantString)) { Core.Tenants.Add(tenantString, TenantCfg); @@ -181,8 +176,8 @@ public Auth( App = Identity.App.GetApp(appId, Cert.Thumbprint, tenantString); //Set the scopes for this Auth object. Scopes = Identity.Scopes.GetScopes(scopeType); - TenantCfg.Settings = Core.config.Settings; - TenantCfg.Labels = Core.config.Labels; + TenantCfg.Settings = Core.Config.Settings; + TenantCfg.Labels = Core.Config.Labels; if (!Core.Tenants.ContainsKey(tenantString)) { Core.Tenants.Add(tenantString, TenantCfg); @@ -286,4 +281,3 @@ public void RefreshAuth(Object obj) } } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/Extensions.Identity.AuthMan.cs b/Classes/Extensions.Identity.AuthMan.cs index 940d6e9..d8da51a 100644 --- a/Classes/Extensions.Identity.AuthMan.cs +++ b/Classes/Extensions.Identity.AuthMan.cs @@ -1,35 +1,23 @@ -#pragma warning disable IDE0079 // Remove unnecessary suppression -#pragma warning disable CS0168, CS1587, CS1998, IDE0028, IDE0059, IDE0060 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: /// https://github.com/cjvandyk/Extensions/blob/main/LICENSE /// -using Azure.Core; using Microsoft.Graph; -using Microsoft.Graph.Authentication; -using Microsoft.Graph.Core; using Microsoft.Identity.Client; using Microsoft.SharePoint.Client; using System; using System.Collections.Generic; -using System.Diagnostics.Eventing.Reader; using System.IO; using System.Net.Http; using System.Net.Http.Headers; -using System.Reflection; -using System.Runtime.CompilerServices; using System.Security.Cryptography.X509Certificates; using System.Text.Json; -using System.Text.Json.Nodes; -using System.Threading.Tasks; using static Extensions.Core; using static Extensions.Identity.App; using static Extensions.Identity.Auth; -using static System.Logit; namespace Extensions.Identity { @@ -137,19 +125,19 @@ public static Auth GetAuth( bool authStackReset = false) { //If logging location is static, don't write this output. - if (!ActiveLogitInstance.StaticConsoleLocation) + if (!Logit.ActiveLogitInstance.StaticConsoleLocation) { //Check if there's an active auth that can be used to log to //SharePoint and if logging to SharePoint is enabled. if ((ActiveAuth.AuthResult == null) && - (ActiveLogitInstance.LogToSPList)) + (Logit.ActiveLogitInstance.LogToSPList)) { //There isn't so don't log to list an active Logit instance. - ActiveLogitInstance.LogToSPList = false; + Logit.ActiveLogitInstance.LogToSPList = false; //Inf($"AuthMan.GetAuth({tenantId}, {appId}, {thumbPrint}, " + // $"{tenantString}, {scopeType.ToString()}, " + // $"{authStackReset.ToString()}"); - ActiveLogitInstance.LogToSPList = true; + Logit.ActiveLogitInstance.LogToSPList = true; } else { @@ -580,4 +568,3 @@ public static AuthenticationResult GetAuthResult( } } } -#pragma warning restore CS0168, CS1587, CS1998, IDE0028, IDE0059, IDE0079 diff --git a/Classes/Extensions.Identity.Cert.cs b/Classes/Extensions.Identity.Cert.cs index 7093614..5b20182 100644 --- a/Classes/Extensions.Identity.Cert.cs +++ b/Classes/Extensions.Identity.Cert.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -92,4 +90,3 @@ public static X509Certificate2 GetCertByThumbPrint( } } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/Extensions.Identity.Scopes.cs b/Classes/Extensions.Identity.Scopes.cs index 62adc35..46bfce6 100644 --- a/Classes/Extensions.Identity.Scopes.cs +++ b/Classes/Extensions.Identity.Scopes.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS0162, CS1587, CS1998, IDE0028, IDE0059 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -9,7 +7,6 @@ using System; using static Extensions.Core; -using static System.Logit; namespace Extensions.Identity { @@ -193,5 +190,3 @@ public static ScopeType GetScopeType(string[] scopes) } } } - -#pragma warning restore CS0162, CS1587, CS1998, IDE0028, IDE0059 diff --git a/Classes/Extensions.PrimeNumbers.cs b/Classes/Extensions.PrimeNumbers.cs index 9c5bc88..c47c297 100644 --- a/Classes/Extensions.PrimeNumbers.cs +++ b/Classes/Extensions.PrimeNumbers.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -37,4 +35,3 @@ public PrimeNumber(System.UInt64 target) } } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/Extensions.State.cs b/Classes/Extensions.State.cs index c0aae39..daaae41 100644 --- a/Classes/Extensions.State.cs +++ b/Classes/Extensions.State.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS0162, CS1570, CS1587, CS1591, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -232,5 +230,3 @@ public static void SaveStateList(string listName, #endregion Save } } - -#pragma warning restore CS0162, CS1570, CS1587, CS1591, CS1998, IDE0059, IDE0028 diff --git a/Classes/Extensions.Tenant.OpenId.cs b/Classes/Extensions.Tenant.OpenId.cs index 5380b81..c0015b2 100644 --- a/Classes/Extensions.Tenant.OpenId.cs +++ b/Classes/Extensions.Tenant.OpenId.cs @@ -1,8 +1,12 @@ -using System; +/// +/// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk +/// This code is provided under GNU GPL 3.0 and is a copyrighted work of the +/// author and contributors. Please see: +/// https://github.com/cjvandyk/Extensions/blob/main/LICENSE +/// + +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Extensions.Tenant { diff --git a/Classes/Extensions.TenantConfig.cs b/Classes/Extensions.TenantConfig.cs index 639d797..290b743 100644 --- a/Classes/Extensions.TenantConfig.cs +++ b/Classes/Extensions.TenantConfig.cs @@ -7,9 +7,7 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using static System.Logit; +using static Extensions.Core; namespace Extensions { @@ -204,7 +202,7 @@ public void Init(string tenantString) { if (tenantString != null) { - string authority = Core.GetAuthorityDomain(AzureEnvironment); + string authority = GetAuthorityDomain(AzureEnvironment); TenantString = tenantString.Trim(); TenantUrl = TenantString + ".sharepoint" + authority; TenantUri = new Uri("https://" + TenantUrl); diff --git a/Classes/Extensions.UniversalConfig.cs b/Classes/Extensions.UniversalConfig.cs index 78b9fe5..ed64bd2 100644 --- a/Classes/Extensions.UniversalConfig.cs +++ b/Classes/Extensions.UniversalConfig.cs @@ -1,19 +1,14 @@ -#pragma warning disable CS0162, CS1587, CS1591, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: /// https://github.com/cjvandyk/Extensions/blob/main/LICENSE /// -using Microsoft.Online.SharePoint.TenantAdministration; using System; -using System.Collections.Generic; using System.IO; using System.Text.Json; using static Extensions.Core; //NuGet Extensions.cs -using static System.Logit; //Nuget Extensions.Logit namespace Extensions { @@ -56,5 +51,3 @@ public static void InitializeTenant(string tenantString) } } } - -#pragma warning restore CS0162, CS1587, CS1591, CS1998, IDE0059, IDE0028 diff --git a/Classes/InstanceExceptionInfo.cs b/Classes/InstanceExceptionInfo.cs index 01f211c..8eb70a1 100644 --- a/Classes/InstanceExceptionInfo.cs +++ b/Classes/InstanceExceptionInfo.cs @@ -1,19 +1,12 @@ -#pragma warning disable IDE0079 // Remove unnecessary suppression -#pragma warning disable CS0168, CS1587, CS1998, IDE0028, IDE0059, IDE0060 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: /// https://github.com/cjvandyk/Extensions/blob/main/LICENSE /// -using Extensions; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Extensions { @@ -76,4 +69,3 @@ public InstanceExceptionInfo(string key, } } } -#pragma warning restore CS0168, CS1587, CS1998, IDE0028, IDE0059, IDE0079 diff --git a/Classes/Microsoft.Graph.ListItem.cs b/Classes/Microsoft.Graph.ListItem.cs index f486b42..41ccb06 100644 --- a/Classes/Microsoft.Graph.ListItem.cs +++ b/Classes/Microsoft.Graph.ListItem.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS0162, CS1587, CS1591, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -9,7 +7,7 @@ using Microsoft.Graph.Models; using System; -using static System.Logit; +using static Extensions.Core; namespace Extensions { @@ -76,5 +74,3 @@ public static string GetJsonString( } } } - -#pragma warning restore CS0162, CS1587, CS1591, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.Array.cs b/Classes/System.Array.cs index 55aa09f..bc7ecdf 100644 --- a/Classes/System.Array.cs +++ b/Classes/System.Array.cs @@ -1,7 +1,4 @@ -//#pragma warning disable IDE1006, IDE0017, CS0162, IDE0060, IDE0079 // Naming Styles, Simplify declaration (FQCN used), break after return, Remove unused (string[] args, Remove unnecessary suppression) -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -72,9 +69,8 @@ public static void Print(this byte[] bytes) (b < 10 ? " " : (b < 100 ? " " : " "))); } - Core.printf(str); + Core.Printf(str); } #endregion byte[] } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.Collections.Generic.List.cs b/Classes/System.Collections.Generic.List.cs index 7ba94ba..225a2e4 100644 --- a/Classes/System.Collections.Generic.List.cs +++ b/Classes/System.Collections.Generic.List.cs @@ -159,6 +159,8 @@ public static List MultiThread( /// The list of objects to process. /// The method to process /// each individual item. + /// The method + /// used in case of Exception to process said Exception. public static List SingleThread( this List lst, Action processLoopInstanceMethod, diff --git a/Classes/System.Console.cs b/Classes/System.Console.cs index 048023e..929a70a 100644 --- a/Classes/System.Console.cs +++ b/Classes/System.Console.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -44,9 +42,8 @@ public static void WriteHelp(string[] lines, ValidateNoNulls(lines, textColor); foreach (string str in lines) { - Core.printf(str, textColor); + Core.Printf(str, textColor); } } } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.DateTime.cs b/Classes/System.DateTime.cs index 7f3ad5f..ac0fe02 100644 --- a/Classes/System.DateTime.cs +++ b/Classes/System.DateTime.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS0162, CS1587, CS1591, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -198,4 +196,3 @@ public static System.DateTime ToTimeZone( #endregion ToTimeZone() } } -#pragma warning restore CS0162, CS1587, CS1591, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.Diagnostics.Process.cs b/Classes/System.Diagnostics.Process.cs index 27a9b18..5348c3c 100644 --- a/Classes/System.Diagnostics.Process.cs +++ b/Classes/System.Diagnostics.Process.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -49,4 +47,3 @@ public static bool Elevate(this System.Diagnostics.Process proc, #endregion Elevate() } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.Double.cs b/Classes/System.Double.cs index 6683470..c1a383e 100644 --- a/Classes/System.Double.cs +++ b/Classes/System.Double.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -586,4 +584,3 @@ public static bool IsPrime(this double number) #endregion IsPrime() } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.Guid.cs b/Classes/System.Guid.cs index f738384..b37961b 100644 --- a/Classes/System.Guid.cs +++ b/Classes/System.Guid.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -37,4 +35,3 @@ public static System.Guid NewCustomGuid(string StartWith = "") } } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.Logit.cs b/Classes/System.Logit.cs index 1785eaa..3e3d522 100644 --- a/Classes/System.Logit.cs +++ b/Classes/System.Logit.cs @@ -1,13 +1,10 @@ -//#pragma warning disable CA1416, CS0162, CS0168, CS1587, CS1591, CS1998, IDE0028, IDE0059 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: /// https://github.com/cjvandyk/Extensions/blob/main/LICENSE /// -using System; using System.Collections.Generic; using System.IO; using System.Threading; @@ -1054,5 +1051,3 @@ public static void Vrb( #endregion Worker Methods } } - -//#pragma warning restore CA1416, CS0162, CS0168, CS1587, CS1591, CS1998, IDE0028, IDE0059 diff --git a/Classes/System.Long.cs b/Classes/System.Long.cs index 9874877..049f644 100644 --- a/Classes/System.Long.cs +++ b/Classes/System.Long.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -57,4 +55,3 @@ public static bool IsPrime(this long number) #endregion IsPrime() } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.Net.WebException.cs b/Classes/System.Net.WebException.cs index 0d8dae2..cd731dc 100644 --- a/Classes/System.Net.WebException.cs +++ b/Classes/System.Net.WebException.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -54,10 +52,12 @@ public static System.Net.HttpWebResponse Retry( Convert.ToInt32( ex.Response.Headers["Retry-After"]) + 60) * 1000); //We add 60 seconds to the wait time for good measure. +#pragma warning disable SYSLIB0014 // Type or member is obsolete request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create( ex.Response.ResponseUri.ToString() .TrimStart('{') .TrimEnd('}')); +#pragma warning restore SYSLIB0014 // Type or member is obsolete request.Method = method; request.Accept = accept; System.Net.WebResponse response; @@ -78,4 +78,3 @@ public static System.Net.HttpWebResponse Retry( #endregion Retry() } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.Short.cs b/Classes/System.Short.cs index 163e7fb..843da80 100644 --- a/Classes/System.Short.cs +++ b/Classes/System.Short.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -57,4 +55,3 @@ public static bool IsPrime(this short number) #endregion IsPrime() } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.String.cs b/Classes/System.String.cs index 6338bbf..cd714c3 100644 --- a/Classes/System.String.cs +++ b/Classes/System.String.cs @@ -1,6 +1,4 @@ -//#pragma warning disable CA1416, CS1587, CS0162, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -2833,4 +2831,3 @@ public static int Words(this System.Text.StringBuilder str) //} } } -//#pragma warning restore CA1416, CS1587, CS0162, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.Text.StringBuilder.cs b/Classes/System.Text.StringBuilder.cs index 68bcaf8..5985d54 100644 --- a/Classes/System.Text.StringBuilder.cs +++ b/Classes/System.Text.StringBuilder.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS0162, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -81,4 +79,3 @@ public static int IndexOf(this System.Text.StringBuilder str, } } -#pragma warning restore CS1587, CS0162, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.TimeZoneInfo.cs b/Classes/System.TimeZoneInfo.cs index 8acfbda..31848d1 100644 --- a/Classes/System.TimeZoneInfo.cs +++ b/Classes/System.TimeZoneInfo.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -33,4 +31,3 @@ public static string GetTimeZoneString(Constants.TimeZone timeZone) #endregion GetTimeZoneString() } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/Classes/System.Timer.cs b/Classes/System.Timer.cs index 471ac94..b915a51 100644 --- a/Classes/System.Timer.cs +++ b/Classes/System.Timer.cs @@ -1,4 +1,4 @@ -#pragma warning disable CS1587, IDE1006, CS1998, IDE0059, IDE0028 +#pragma warning disable IDE1006 // Naming Styles /// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk @@ -88,4 +88,4 @@ public void Reset() #endregion Timer } } -#pragma warning restore CS1587, IDE1006, CS1998, IDE0059, IDE0028 +#pragma warning restore IDE1006 // Naming Styles diff --git a/Classes/System.ULong.cs b/Classes/System.ULong.cs index d36a0ec..1275df4 100644 --- a/Classes/System.ULong.cs +++ b/Classes/System.ULong.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS1587, CS1998, IDE0059, IDE0028 - -/// +/// /// Author: Cornelius J. van Dyk blog.cjvandyk.com @cjvandyk /// This code is provided under GNU GPL 3.0 and is a copyrighted work of the /// author and contributors. Please see: @@ -57,4 +55,3 @@ public static bool IsPrime(this ulong number) #endregion IsPrime() } } -#pragma warning restore CS1587, CS1998, IDE0059, IDE0028 diff --git a/GlobalSuppressions.cs b/GlobalSuppressions.cs index c62c5dd..cda8b79 100644 --- a/GlobalSuppressions.cs +++ b/GlobalSuppressions.cs @@ -12,13 +12,22 @@ using System.Diagnostics.CodeAnalysis; +[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "CvD")] +[assembly: SuppressMessage("CodeQuality", "IDE0052:Remove unread private members", Justification = "CvD")] [assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "CvD")] +[assembly: SuppressMessage("Maintainability", "CA1507:Use nameof to express symbol names", Justification = "CvD")] +[assembly: SuppressMessage("Style", "IDE0017:Simplify object initialization", Justification = "CvD")] [assembly: SuppressMessage("Style", "IDE0031:Use null propagation", Justification = "CvD")] [assembly: SuppressMessage("Style", "IDE0035:Unreachable code detected", Justification = "CvD")] [assembly: SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "CvD")] +[assembly: SuppressMessage("Style", "IDE0071:Simplify interpolation", Justification = "CvD")] [assembly: SuppressMessage("Style", "IDE0074:Use compound assignment", Justification = "CvD")] +[assembly: SuppressMessage("Style", "IDE0075:Simplify conditional expression", Justification = "CvD")] [assembly: SuppressMessage("Style", "IDE0090:Use 'new(...)'", Justification = "CvD")] [assembly: SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "CvD")] +[assembly: SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "CvD")] [assembly: SuppressMessage("Style", "IDE0300:Simplify collection initialization", Justification = "CvD")] -[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "CvD")] -[assembly: SuppressMessage("CodeQuality", "IDE0052:Remove unread private members", Justification = "CvD")] +[assembly: SuppressMessage("Style", "IDE0305:Simplify collection initialization", Justification = "CvD")] +[assembly: SuppressMessage("Style", "IDE1005:Delegate invocation can be simplified.", Justification = "CvD")] +[assembly: SuppressMessage("Usage", "CA2211:Non-constant fields should not be visible", Justification = "CvD")] +[assembly: SuppressMessage("Usage", "CA2254:Template should be a static expression", Justification = "CvD")] diff --git a/NuGet/Extensions.cs.5.5.800.nupkg b/NuGet/Extensions.cs.5.5.800.nupkg new file mode 100644 index 0000000..a4e9907 Binary files /dev/null and b/NuGet/Extensions.cs.5.5.800.nupkg differ diff --git a/NuGet/Extensions.cs.5.5.800.snupkg b/NuGet/Extensions.cs.5.5.800.snupkg new file mode 100644 index 0000000..4c4c91c Binary files /dev/null and b/NuGet/Extensions.cs.5.5.800.snupkg differ diff --git a/SECURITY.md b/SECURITY.md index e5b3887..8e7eecd 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,7 +6,7 @@ The following is our version matrix for current security update support. | Version | Supported | | ------- | ------------------ | -| 5.4.x | :white_check_mark: | +| 5.5.x | :white_check_mark: | | 5.x | :x: | | 4.8.x | :white_check_mark: | | < 4.8 | :x: | diff --git a/VersionHistory.md b/VersionHistory.md index 73c935a..0ddcc53 100644 --- a/VersionHistory.md +++ b/VersionHistory.md @@ -374,5 +374,7 @@ ### **5.4.800 (2024-02-13)**
- Fixed bug in InitializeTenant().
-### **5.5.800 (2024-02-13)**
- - Fixed bug in InitializeTenant().
+### **5.5.800 (2024-02-14)**
+ - Reorganized Core and Identity.AuthMan classes to eliminate the need for a using statement for Extensions.Identity.AuthMan.
+ - Added Inf(), Wrn(), Err() and Vrb() to Core as transit methods to eliminate the need for a using statment for System.Logit.
+ - Major code cleanup.