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

Options for migration of string comparisons (helper method?)

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
csharp, visualbasic
領域
tooling

調査の方向性

この issue では、具体的なファイル、テスト、エントリポイントは指定されていません。まず CodeConverter のソースで Option Compare Text が CultureInfo.CurrentCulture.CompareInfo.Compare に変換される流れを追跡し、次に比較結果をヘルパーメソッドによって設定または表現できるかどうかを判断してください。合意されたアプローチと、それに伴う実装範囲が決まれば完了です。

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

説明

enhancement

Perhaps this should not be an issue or a feature request but I think it's worthy of discussion, and we can always delete later if needed.

I'm about to Migrate perhaps 50k to 100k lines of code from VB to C#. Almost all of it has Option Compare Text.

Now when we migrate, code like this

If kv.Key = sVariableName Then

It gets converted to this:

if (CultureInfo.CurrentCulture.CompareInfo.Compare(kv.Key ?? "", sVariableName ?? "", CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth) == 0)

I'm sure I'm not the only one who doesn't want to live with that kind of code going forward, especially in a large project.

Ideally I would like improve the syntactic elegance using something like an Extension method

    [Extension]
    public static bool EqualsIgnoreCase(this string str1, string str2)
    {
        return string.Equals(str1 ?? "", str2 ?? "", StringComparison.OrdinalIgnoreCase);
    }

Then the migrated c# would be

                if (kv.Key.EqualsIgnoreCase(sVariableName)) {

I would have liked to overload the string == operator but that doesn't sound possible.

So, before I start digging in the CodeConverter source code for how to implement this, are there any other options or ways to influence the conversion as above, and does anyone else feel that there would be value in changing the code if appropriate for something like the above ?

主要言語
C#
スター
913
フォーク
244
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

icsharpcode/CodeConverter のほかの issue

icsharpcode/CodeConverter の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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