Bug in framework/wcf/Basic/Contract/Data/NetDCSasDCSwithDCR/CS/DCSwithDCR/DCSwithDCR.cs
还没有人认领这个 Issue。
评估
调研方向
从 framework/wcf/Basic/Contract/Data/NetDCSasDCSwithDCR/CS/DCSwithDCR/DCSwithDCR.cs 开始,并结合字典字段检查 MyDataContractResolver.TryResolveType()。更新示例,使其使用预期的字典而不发生局部遮蔽,然后验证 .NET Framework 示例能够构建,并且 resolver 的行为仍然正确。
由索引模型根据 Issue 内容生成。
描述
Local variable dictionary or field dictionary?
In the MyDataContractResolver class in https://github.com/dotnet/samples/blob/main/framework/wcf/Basic/Contract/Data/NetDCSasDCSwithDCR/CS/DCSwithDCR/DCSwithDCR.cs, there is a field dictionary and there is also a local variable dictionary in the method TryResolveType(). So the field dictionary is never used. It seems to me that the original intent was to use the field dictionary and the local variable dictionary shouldn't have been there.
// DataContractResolver to be used by the DataContractSerializer
class MyDataContractResolver : DataContractResolver
{
private XmlDictionary dictionary = new XmlDictionary(); <-- Here **********
...
// Used at serialization
// Maps any Type to a new xsi:type representation
public override bool TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace)
{
if (!knownTypeResolver.TryResolveType(type, declaredType, null, out typeName, out typeNamespace))
{
XmlDictionary dictionary = new XmlDictionary(); <-- And here **********
typeName = dictionary.Add(type.FullName);
typeNamespace = dictionary.Add(type.Assembly.FullName);
}
return true;
}
}
Note that the same code is also on this page - https://learn.microsoft.com/en-us/dotnet/framework/wcf/samples/datacontractserializer-datacontractresolver-netdatacontractserializer.
Target framework
Check the .NET target framework(s) being used, and include the version number(s).
- .NET Core
- .NET Framework
- .NET Standard
- 主要语言
- C#
- 星标
- 3.7k
- 派生
- 5.1k
- 平均合并
- 19 小时 47 分钟
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/samples 的其他 Issue
-
dotnet-target-version
难度 2/5 1-3 小时 新手友好度 77/100
-
dotnet-target-version
难度 2/5 1-3 小时 新手友好度 76/100
-
dotnet-target-version
难度 2/5 1-3 小时 新手友好度 78/100
-
Race condition in orleans/ShoppingCart/Grains/InventoryGrain.cs#L48可能已有人在做 @TimonPasslick 于 160 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
-
dotnet-target-version
难度 2/5 1-3 小时 新手友好度 72/100
相似的 Issue
-
Audit by ear: boss warnings, other not-enough messages, ailments and barriers in a chapter 1 battle未关闭enhancement needs-game ready-for-agent
难度 2/5 1-3 小时 新手友好度 72/100
Sour-Dev-Home/metaphor-accessibility#1273 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
joinrpg/joinrpg-net#6336 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
muxinc/mux-csharp#88 ·
-
In-car displays show 0 km/h and P while the AV drives可能已有人在做 @bazilinskyy 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 66/100
bazilinskyy/coupled-sim#366 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 3 天内回复