VB -> C#: Local variables should be pulled before labels
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
ローカル変数の宣言とラベルを処理する VB.NET から C# への変換パスから始め、提示された入力および期待される出力と比較してください。例の回帰テストを追加し、生成されたローカル宣言がラベルより前に配置されることを確認してください。これにより、変換後のプログラムが無限ループに陥らなくなります。
索引モデルが issue の本文から書いたものです。
説明
VB.Net input code
Public Shared Sub Main()
Label:
Dim number As Integer
number += 1
If number = 1 Then GoTo Label
Console.WriteLine(number) ' will print 2
End Sub
Erroneous output
public static void Main()
{
Label:
; // that's ugly but still compiles
var number = default(int);
number += 1;
if (number == 1)
goto Label;
Console.WriteLine(number); // will never be called, infinite loop
}
Expected output
public static void Main()
{
var number = default(int);
Label:
number += 1;
if (number == 1)
goto Label;
Console.WriteLine(number);
}
Details
- Product in use: e.g. codeconverter.icsharpcode.net / VS extension / both
- Version in use: e.g. 5.6.3 or a commit hash https://github.com/icsharpcode/CodeConverter/commit/73d55b29c6c1e09dd9e3b6e9b30073d639d9e00d
- Did you see it working in a previous version, which? no
- Any other relevant information to the issue, or your interest in contributing a fix.
Very rare but unfortunately possible to happen in large, legacy code bases.
Maybe every variable initialization should be moved to the beginning of the procedure/before all labels when there are goto statements?
Related to #897
Even if the scope of a variable is limited to a block, its lifetime is still that of the entire procedure. If you enter the block more than once during the procedure, each block variable retains its previous value. To avoid unexpected results in such a case, it is wise to initialize block variables at the beginning of the block.
- 主要言語
- C#
- スター
- 918
- フォーク
- 244
- 平均マージ
- 1日 10時間
- マージ済み PR(30日)
- 29
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
icsharpcode/CodeConverter のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
icsharpcode/CodeConverter#1271 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
icsharpcode/CodeConverter#1243 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
VB -> C#: Enum Values as Integer再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンGood for coding agent VB -> C#
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
icsharpcode/CodeConverter#1212 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Good for coding agent VB -> C#
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
icsharpcode/CodeConverter#1211 ·
メンテナーはふだん 1 日以内に返信
-
C# -> VB
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
icsharpcode/CodeConverter#1171 · コメント 7 件 ·
メンテナーはふだん 1 日以内に返信
icsharpcode/CodeConverter の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
umbraco/Umbraco.Automate#612 ·
メンテナーはふだん 1 日以内に返信
-
崩溃日志只按 CRLF 分行オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
PCL-Community/PCL-CE#3872 ·
メンテナーはふだん 1 日以内に返信
-
type:task ux
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
elsa-workflows/elsa-foundation#5253 ·
メンテナーはふだん 1 日以内に返信