AlexStocks commented on code in PR #39:
URL: https://github.com/apache/dubbo-net/pull/39#discussion_r4562095755


##########
DubboNet.csproj:
##########
@@ -33,6 +41,15 @@
     <PackageReference Include="DistributedLock.ZooKeeper" Version="1.0.0" />
     <PackageReference Include="nacos-sdk-csharp" Version="1.3.10" />
     <PackageReference Include="NHessian" Version="0.4.3" />
+    <!-- Directly used APIs: do not depend on Nacos to supply these 
transitively. -->
+    <PackageReference Include="Microsoft.Extensions.DependencyInjection" 
Version="8.0.1" />
+    <!-- Nacos' Standard dependency group otherwise selects DependencyModel 
3.1,
+         whose Framework asset pulls vulnerable Newtonsoft.Json 9.0.1. -->
+    <PackageReference Include="Microsoft.Extensions.DependencyModel" 
Version="8.0.2" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
+    <PackageReference Include="System.Text.Json" Version="8.0.6" />

Review Comment:
   [P2] `System.Text.Json` 未加 netstandard2.0 条件,会进入 net8/net10 资产的依赖组
   
   触发条件:任何以 net8.0 / net10.0 资产消费 DubboNet 包的项目——这两个 TFM 的 `System.Text.Json` 
属于共享框架,无需额外包。
   
   实际影响:multi-target 下不加条件的 `PackageReference` 会同时写进三个资产的依赖组,于是 net8/net10 
消费者多出一条 `System.Text.Json >= 8.0.6` 的传递依赖:消费者自身锁定更低版本时会得到 NU1605 降级错误;在未启用包裁剪的 
SDK 上还会引入与框架同名程序集的冲突解析。对比同一 ItemGroup 的 48、50、51、52 
行,`Microsoft.Extensions.DependencyModel` / `Microsoft.Bcl.AsyncInterfaces` / 
`System.Memory` / `System.Threading.Tasks.Extensions` 都带了 
`Condition="'$(TargetFramework)' == 'netstandard2.0'"`,只有本行没有,是不一致点。
   
   证据:head 版 `DubboNet.csproj` 49 行无 Condition,48/50/51/52 行均有。CI 的 
`PackageCompatibilitySmoke` 只校验包内资产选择与 RPC 行为,不会暴露依赖组差异。
   
   修复方向:若该引用只为补齐 netstandard2.0 缺失的 in-box 程序集,补上同样的 netstandard2.0 条件;若刻意对全部 
TFM 设 8.0.6 下限(例如统一安全补丁基线),建议在该行上方注明理由,避免被读成漏加条件。



##########
Compatibility/StringCompatibility.cs:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace DubboNet.Compatibility
+{
+    internal static class StringCompatibility
+    {
+#if NETSTANDARD2_0
+        internal static bool Contains(this string value, string search, 
StringComparison comparison) =>
+            value.IndexOf(search, comparison) >= 0;
+        internal static bool Contains(this string value, char search, 
StringComparison comparison) =>
+            value.IndexOf(search.ToString(), comparison) >= 0;
+        internal static string[] Split(this string value, string separator, 
StringSplitOptions options = StringSplitOptions.None) =>
+            value.Split(new[] { separator }, options);
+        internal static string[] Split(this string value, char separator, 
StringSplitOptions options) =>
+            value.Split(new[] { separator }, options);
+        internal static string[] Split(this string value, char separator, int 
count) =>
+            value.Split(new[] { separator }, count);
+#endif
+        internal static string[] SplitTrimmed(string value, string separator, 
int count = int.MaxValue)

Review Comment:
   [P2] `SplitTrimmed` 在空分隔符下无限循环,与 `String.Split` 的行为不同
   
   触发条件:`separator` 为空字符串(`""`)。
   
   实际影响:`value.IndexOf("", start, StringComparison.Ordinal)` 恒返回 `start`,随后 
`start = end + separator.Length`(58 行)等于 `start` 本身,`part` 恒为空串不入列,`while 
(start <= value.Length)` 永不推进——当前线程空转挂死,且不产生任何分配或异常可供观察。BCL 的 
`value.Split(new[] { "" }, ...)` 不拆分、直接返回原串,`StringCompatibility.Split` 的 
netstandard2.0 重载(同文件 32–35 行)也走 BCL,所以这是 `SplitTrimmed` 
独有的发散。当前两个调用点(`DubboStatusInfo` 的 `MES_SPLIT` / 
`MESVAL_SPLIT`)都是常量分隔符,因此暂不可触发;但这是新引入的共享工具方法,后续传入来自配置或变量的分隔符时即为挂死。
   
   证据:head 版 `Compatibility/StringCompatibility.cs` 46–58 行循环体;对照 30–35 行的 
`Split` 重载。
   
   修复方向:在方法入口加一行守卫,例如 `if (string.IsNullOrEmpty(separator)) return 
StringSplitOptions 处理后的整串(或按 BCL 语义返回 `new[] { value.Trim() }` / 空数组)`,使 ns2.0 
分支与 net8/net10 分支的 `Split` 语义保持一致。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to