Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Generic IEnumerator not disposed

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp
領域
tooling

調査の方向性

Mapster.Tool から始め、示されている NewConfig<TSource, TDestination>().GenerateMapper(...) 登録を使用して、生成された拡張メソッドを再現します。該当する場合はインターフェイスから生成されたコードを含め、GetEnumerator() の生成経路を調査します。生成されたジェネリック列挙子が反復処理中に破棄され、反復処理の動作が変わらないことを完了条件とします。

索引モデルが issue の本文から書いたものです。

説明

improvement

I'm using Mapster.Tool to generate extension methods from my mapping registrations like so:

config.NewConfig<TSource, TDestination>().GenerateMapper(MapType.Map | MapType.MapToTarget);

When inspecting the generated code I noticed that anywhere GetEnumerator() is used, the generic Enumerator is never disposed.

This is a snippet of what is being generated:

...
IEnumerator<string> enumerator = p2.GetEnumerator();
            
while (enumerator.MoveNext())
 {
    string item = enumerator.Current;
    result.Add(item);
}

return result;

I believe what it should be generating is the following:

using IEnumerator<string> enumerator = p2.GetEnumerator();
            
while (enumerator.MoveNext())
 {
    string item = enumerator.Current;
    result.Add(item);
}

return result;

I'm not sure if this issue arises in other areas (e.g. generated code from interfaces) as I haven't tested it personally, but I would expect the Mapster.Tool generates the code the same way.

主要言語
C#
スター
5.2k
フォーク
409
平均マージ
3日 4時間
マージ済み PR(30日)
3

環境構築

はじめの一歩

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

MapsterMapper/Mapster のほかの issue

MapsterMapper/Mapster の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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