From d6f0b3e68e3d2be793a577ee387d4d39bff1fc79 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 10:06:37 +0000 Subject: [PATCH 1/4] Initial plan From a02b5bb02ff0cea383a93f93e87652743b6985e0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 10:10:21 +0000 Subject: [PATCH 2/4] Optimize LINQ operations for better performance Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com> --- Engine/Generic/RuleSuppression.cs | 2 +- Engine/ScriptAnalyzer.cs | 8 ++++---- Engine/Settings.cs | 2 +- Rules/AvoidMultipleTypeAttributes.cs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Engine/Generic/RuleSuppression.cs b/Engine/Generic/RuleSuppression.cs index 7daab3e86..e9e021a74 100644 --- a/Engine/Generic/RuleSuppression.cs +++ b/Engine/Generic/RuleSuppression.cs @@ -342,7 +342,7 @@ public static List GetSuppressions(IEnumerable at if (targetAsts != null) { - if (targetAsts.Count() == 0) + if (!targetAsts.Any()) { if (String.IsNullOrWhiteSpace(scopeAst.Extent.File)) { diff --git a/Engine/ScriptAnalyzer.cs b/Engine/ScriptAnalyzer.cs index f250336b5..91abacf35 100644 --- a/Engine/ScriptAnalyzer.cs +++ b/Engine/ScriptAnalyzer.cs @@ -271,9 +271,9 @@ internal bool ParseProfile(object profileObject, PathIntrinsics path, IOutputWri return false; } - this.severity = (severityList.Count() == 0) ? null : severityList.ToArray(); - this.includeRule = (includeRuleList.Count() == 0) ? null : includeRuleList.ToArray(); - this.excludeRule = (excludeRuleList.Count() == 0) ? null : excludeRuleList.ToArray(); + this.severity = (severityList.Count == 0) ? null : severityList.ToArray(); + this.includeRule = (includeRuleList.Count == 0) ? null : includeRuleList.ToArray(); + this.excludeRule = (excludeRuleList.Count == 0) ? null : excludeRuleList.ToArray(); if (settings != null && settings.ContainsKey("Rules")) { @@ -613,7 +613,7 @@ private bool ParseProfileString(string profile, PathIntrinsics path, IOutputWrit IEnumerable hashTableAsts = profileAst.FindAll(item => item is HashtableAst, false); // no hashtable, raise warning - if (hashTableAsts.Count() == 0) + if (!hashTableAsts.Any()) { writer.WriteError(new ErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.InvalidProfile, profile)), Strings.ConfigurationFileHasNoHashTable, ErrorCategory.ResourceUnavailable, profile)); diff --git a/Engine/Settings.cs b/Engine/Settings.cs index b0c424c64..6c97fb098 100644 --- a/Engine/Settings.cs +++ b/Engine/Settings.cs @@ -453,7 +453,7 @@ private void parseSettingsFile(string settingsFilePath) IEnumerable hashTableAsts = profileAst.FindAll(item => item is HashtableAst, false); // no hashtable, raise warning - if (hashTableAsts.Count() == 0) + if (!hashTableAsts.Any()) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.InvalidProfile, settingsFilePath)); } diff --git a/Rules/AvoidMultipleTypeAttributes.cs b/Rules/AvoidMultipleTypeAttributes.cs index 77f63de21..fecb61772 100644 --- a/Rules/AvoidMultipleTypeAttributes.cs +++ b/Rules/AvoidMultipleTypeAttributes.cs @@ -37,7 +37,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) // Iterates all ParamAsts and check the number of its types. foreach (ParameterAst paramAst in paramAsts) { - if (paramAst.Attributes.Where(typeAst => typeAst is TypeConstraintAst).Count() > 1) + if (paramAst.Attributes.Count(typeAst => typeAst is TypeConstraintAst) > 1) { yield return new DiagnosticRecord( String.Format(CultureInfo.CurrentCulture, Strings.AvoidMultipleTypeAttributesError, paramAst.Name), From 2ccec007b4b6c84d2f7cd686d1828073455480d6 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Fri, 6 Mar 2026 18:01:16 +0000 Subject: [PATCH 3/4] Update Rules/AvoidMultipleTypeAttributes.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Rules/AvoidMultipleTypeAttributes.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rules/AvoidMultipleTypeAttributes.cs b/Rules/AvoidMultipleTypeAttributes.cs index fecb61772..590a058d9 100644 --- a/Rules/AvoidMultipleTypeAttributes.cs +++ b/Rules/AvoidMultipleTypeAttributes.cs @@ -37,7 +37,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) // Iterates all ParamAsts and check the number of its types. foreach (ParameterAst paramAst in paramAsts) { - if (paramAst.Attributes.Count(typeAst => typeAst is TypeConstraintAst) > 1) + if (paramAst.Attributes.OfType().Skip(1).Any()) { yield return new DiagnosticRecord( String.Format(CultureInfo.CurrentCulture, Strings.AvoidMultipleTypeAttributesError, paramAst.Name), From 3214bc33dfe0667788572f506707f60fb94077da Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Fri, 6 Mar 2026 18:01:43 +0000 Subject: [PATCH 4/4] Update Rules/AvoidMultipleTypeAttributes.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>