From 890ab9c2e8ac804891627f050ebfdf53ba022943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8A=BC?= Date: Mon, 15 Sep 2025 17:13:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E5=A4=84=20C29236?= =?UTF-8?q?=20(=E7=BC=96=E8=AF=91=E6=97=B6=E9=9C=80=E8=A6=81=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=20lambda=20=E8=A1=A8=E8=BE=BE=E5=BC=8F=E8=87=B3?= =?UTF-8?q?=E5=B0=91=20100=20=E6=AC=A1=E3=80=82=E8=AF=B7=E8=80=83=E8=99=91?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=98=BE=E5=BC=8F=E5=8F=82=E6=95=B0=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=A3=B0=E6=98=8E=20lambda=20=E8=A1=A8=E8=BE=BE?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=8C=85=E5=90=AB=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=B0=83=E7=94=A8=E6=98=AF=E6=B3=9B=E5=9E=8B?= =?UTF-8?q?=E7=9A=84=EF=BC=8C=E8=AF=B7=E8=80=83=E8=99=91=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=98=BE=E5=BC=8F=E7=B1=BB=E5=9E=8B=E5=8F=82=E6=95=B0=E3=80=82?= =?UTF-8?q?)=20=E5=8E=BB=E9=99=A4=E4=BA=86=E4=B8=80=E5=A4=84=E5=AE=8C?= =?UTF-8?q?=E5=85=A8=E6=97=A0=E6=84=8F=E4=B9=89=E7=9A=84=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=20WrapPanel=20=E5=8E=BB=E9=99=A4=E4=BA=86=E4=B8=80=E5=A4=84?= =?UTF-8?q?=E5=AE=8C=E5=85=A8=E6=97=A0=E6=84=8F=E4=B9=89=E7=9A=84=20?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=20HotkeyConfiguration=20Package.props=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=20NoWarn=20=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E4=B8=80=E4=B8=8B=E4=B8=8D=E5=BF=85=E5=85=B3=E5=BF=83=E7=9A=84?= =?UTF-8?q?=20warn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Package.props | 5 +++++ src/Ursa/Controls/ElasticWrapPanel.cs | 16 +++++++++++++--- .../Controls/Panels/WrapPanelWithTrailingItem.cs | 2 +- src/Ursa/Controls/SelectionList/SelectionList.cs | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Package.props b/src/Package.props index f93943b..4580111 100644 --- a/src/Package.props +++ b/src/Package.props @@ -7,6 +7,11 @@ MIT true https://github.com/irihitech/Ursa.Avalonia + + + IDE0130;IDE00056;IDE0306;IDE0305;IDE0300;IDE0290;IDE0251;IDE0090;IDE0079;IDE0066;IDE0062;IDE0060;IDE0057;IDE0056;IDE0044;IDE0042;IDE0039;IDE0031;IDE0028;IDE0017; + CA2208;CA1866;CA1861;CA1859;CA1847;CA1845;CA1822;CA1041; + diff --git a/src/Ursa/Controls/ElasticWrapPanel.cs b/src/Ursa/Controls/ElasticWrapPanel.cs index 6fb71b6..346e875 100644 --- a/src/Ursa/Controls/ElasticWrapPanel.cs +++ b/src/Ursa/Controls/ElasticWrapPanel.cs @@ -319,9 +319,19 @@ public class ElasticWrapPanel : WrapPanel { if (itemSetSize.U > 0) { - int maxElementCount = lineUVCollection - .Max(uiSet => uiSet.UICollection - .Sum(p => p.Value.ULengthCount)); + // 用 foreach 替换嵌套 LINQ,彻底避免类型推断和绑定压力 + // 修复 C29236 编译时需要绑定 lambda 表达式至少 100 次。请考虑使用显式参数类型声明 lambda 表达式,如果包含的方法调用是泛型的,请考虑使用显式类型参数。 + int maxElementCount = 0; + foreach (var uiSet in lineUVCollection) + { + int sum = 0; + foreach (var p in uiSet.UICollection) + { + sum += p.Value.ULengthCount; + } + if (sum > maxElementCount) + maxElementCount = sum; + } adaptULength = (uvFinalSize.U - maxElementCount * itemSetSize.U) / maxElementCount; adaptULength = Max(adaptULength, 0); } diff --git a/src/Ursa/Controls/Panels/WrapPanelWithTrailingItem.cs b/src/Ursa/Controls/Panels/WrapPanelWithTrailingItem.cs index f26d193..7b551d1 100644 --- a/src/Ursa/Controls/Panels/WrapPanelWithTrailingItem.cs +++ b/src/Ursa/Controls/Panels/WrapPanelWithTrailingItem.cs @@ -53,7 +53,7 @@ public class WrapPanelWithTrailingItem : Panel } } - WrapPanel p = new WrapPanel(); + // WrapPanel p = new WrapPanel(); } protected override Size MeasureOverride(Size availableSize) diff --git a/src/Ursa/Controls/SelectionList/SelectionList.cs b/src/Ursa/Controls/SelectionList/SelectionList.cs index 045421c..b0d4e63 100644 --- a/src/Ursa/Controls/SelectionList/SelectionList.cs +++ b/src/Ursa/Controls/SelectionList/SelectionList.cs @@ -159,7 +159,7 @@ public class SelectionList : SelectingItemsControl protected override void OnKeyDown(KeyEventArgs e) { - var hotkeys = Application.Current!.PlatformSettings?.HotkeyConfiguration; + // var hotkeys = Application.Current!.PlatformSettings?.HotkeyConfiguration; if (e.Key.ToNavigationDirection() is { } direction && direction.IsDirectional()) e.Handled |= MoveSelection(direction, WrapSelection);