FormUrlEncodedJson calls wrong overload of Error.Argument
还没有人认领这个 Issue。
评估
调研方向
从 src/System.Net.Http.Formatting/Formatting/FormUrlEncodedJson.cs 开始,重点检查 FormUrlEncodedJson.AddToArray,并将其中对 Error.Argument 的调用与 src/Common/Error.cs 中的重载进行比较。确认仅使用格式字符串和格式参数的调用会解析到预期的重载;当格式字符串不再被视为参数名时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
src/System.Net.Http.Formatting/Formatting/FormUrlEncodedJson.cs contains several Error.Argument calls that do not specify the parameter name. For example, in the FormUrlEncodedJson.AddToArray method:
The arguments in this call are a format string from resources, and a string to use as a format argument. The call is intended to go to the internal static ArgumentException Argument(string messageFormat, params object[] messageArgs) method that is defined here:
Instead, it goes to the internal static ArgumentException Argument(string parameterName, string messageFormat, params object[] messageArgs) method that is defined here:
The format string that was read from Properties.Resources.FormUrlEncodedMismatchingTypes thus becomes misused as the parameter name.
I have not tried to reproduce this bug in practice, but the incorrect call is evident from the IL disassembly of lib/netstandard2.0/System.Net.Http.Formatting.dll in the Microsoft.AspNet.WebApi.Client 6.0.0 package:
IL_001b: call string System.Net.Http.Properties.Resources::get_FormUrlEncodedMismatchingTypes()
IL_0020: ldarg.1
IL_0021: ldarg.1
IL_0022: ldlen
IL_0023: conv.i4
IL_0024: ldc.i4.1
IL_0025: sub
IL_0026: call string System.Net.Http.Formatting.FormUrlEncodedJson::BuildPathString(string[],
int32)
IL_002b: call !!0[] [netstandard]System.Array::Empty<object>()
IL_0030: call class [netstandard]System.ArgumentException System.Web.Http.Error::Argument(string,
string,
object[])
IL_0035: throw
In the Microsoft.AspNet.WebApi.Client 4.0.20505 package (released on 31 May 2012), the FormUrlEncodedJson.AddToArray method did not have this bug yet. In the Microsoft.AspNet.WebApi.Client 4.0.20710 package (released on 11 August 2012), the method had the bug. I think the bug was introduced by commit f19f4683cc36ebb2666fa36f6dcd1825f4b214aa in May 2012.
Because the bug is so old and is not known to cause any problems in practice, I suspect you might decide not to fix it.
- 主要语言
- C#
- 星标
- 897
- 派生
- 358
- 平均合并
- 40 分钟
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aspnet/AspNetWebStack 的其他 Issue
-
Needs: Author Feedback
难度 4/5 3-5 天 新手友好度 25/100
aspnet/AspNetWebStack#430 · 2 条评论 ·
-
Needs: Author Feedback
难度 4/5 3-5 天 新手友好度 25/100
aspnet/AspNetWebStack#429 · 1 条评论 ·
-
Needs: Author Feedback
难度 5/5 一周以上 新手友好度 25/100
aspnet/AspNetWebStack#428 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 45/100
aspnet/AspNetWebStack#407 · 1 条评论 ·
-
bug
aspnet/AspNetWebStack#399 · 2 条评论 · 已指派 1 人 ·
查看 aspnet/AspNetWebStack 的全部 Issue
相似的 Issue
-
core dependencies
难度 1/5 1 小时以内 新手友好度 80/100
-
bug frontend good first issue
难度 2/5 1-3 小时 新手友好度 75/100
-
NavigationViewItemAutomationPeer implements IInvokeProvider but never advertises the Invoke pattern 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
unoplatform/uno#24629 ·
-
agentic-workflows Needs: Triage :mag: State: In-PR
难度 2/5 1-3 小时 新手友好度 70/100
-
Down / Waiting for removal
难度 2/5 1-3 小时 新手友好度 70/100