Bug in framework/wcf/Basic/Contract/Data/NetDCSasDCSwithDCR/CS/DCSwithDCR/DCSwithDCR.cs

オープン
#6,467 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
50/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
csharp
領域
backend

調査の方向性

framework/wcf/Basic/Contract/Data/NetDCSasDCSwithDCR/CS/DCSwithDCR/DCSwithDCR.cs から始め、辞書フィールドと併せて MyDataContractResolver.TryResolveType() を確認します。意図した Dictionary がローカルでシャドーイングされずに使用されるようにサンプルを更新し、その後、.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分
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/samples のほかの issue

dotnet/samples の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。