VB -> C#: Lambda function should use dynamic type
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 Application.Eval 回呼簽章開始,並在 VB-to-C# 轉換中重現提供的 VB 輸入。將產生的回呼參數和 Application.Session 成員存取與預期的 C# 輸出進行比較。當轉換產生預期的 C# 形式,且有一個回歸案例涵蓋此輸入時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
I believe I have the correct C# code at the end, although I am not 100% certain.
In VB I was able to have the lambda function have a boolean, but in C# it appears it needs dynamic.
Also, note the different syntax for accessing members of Application.Session. In VB it is this
Public Shared ReadOnly Property Session As <Dynamic> Object
but in C# it is this.
public static dynamic Session { get; }`
VB.Net input code
Public Sub DetectIOSWebAppStandalone()
'does a one-time check of window.navigator.standalone and writes a session flag
'so we know if we have been launched in iOS webview
Application.Eval("window.navigator.standalone", Sub(a As Boolean)
If a = True Then
Application.Session("isIOSstandalone") = True 'its standalone mode
Else
Application.Session("isIOSstandalone") = False 'its not standalone mode
End If
End Sub)
End Sub
Erroneous output
public void DetectIOSWebAppStandalone()
{
// does a one-time check of window.navigator.standalone and writes a session flag
// so we know if we have been launched in iOS webview (or at least "Add To Homescreen App"
// need to combine this with hybrid flag... not sure if returns true in hybrid app!
Application.Eval("window.navigator.standalone", (bool a) => { if (a == true) { Application.Session("isIOSstandalone") = (object)true; } else { Application.Session("isIOSstandalone") = (object)false; } }); // its standalone mode
// its not standalone mode
}
Expected output
public void DetectIOSWebAppStandalone()
{
// does a one-time check of window.navigator.standalone and writes a session flag
// so we know if we have been launched in iOS webview (or at least "Add To Homescreen App"
// need to combine this with hybrid flag... not sure if returns true in hybrid app!
Application.Eval("window.navigator.standalone", (dynamic a) =>
{
if (a == true)
{
Application.Session.isIOSstandalone = true;
} else
{
Application.Session.isIOSstandalone = false;
}
});
//Application.Eval("window.navigator.standalone", (bool a) => { if (a == true) { Application.Session.isIOSstandalone = true; } else { Application.Session.isIOSstandalone = false; } }); // its standalone mode
// its not standalone mode
}
Details
CodeConverter 8.41
Signature of Application.Eval method in C#
//
// Summary:
// Executes the JavaScript script on the client and receives the return value (or
// null) in the callback method.
//
// Parameters:
// script:
// The script to evaluate.
//
// callback:
// Asynchronous callback method that receives the return value.
public static void Eval(string script, Action<dynamic> callback);
Signature of Application.Eval method in VB
'
' Summary:
' Executes the JavaScript script on the client and receives the return value (or
' null) in the callback method.
'
' Parameters:
' script:
' The script to evaluate.
'
' callback:
' Asynchronous callback method that receives the return value.
Public Shared Sub Eval(script As String, <Dynamic({False, True})> callback As System.Action(Of Object))`
- 主要語言
- C#
- 星號
- 918
- 分支
- 244
- 平均合併
- 1 天 10 小時
- 30 天內合併 PR
- 29
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 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可能重新可做 關聯的 PR 已關閉且未合併。 未關閉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
-
hand-to-AI
難度 2/5 1-3 小時 新手友好度 72/100
CactuseSecurity/firewall-orchestrator#5803 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 3 天內回覆
-
bug python
難度 1/5 1 小時以內 新手友好度 88/100
ilia-sokolov/OfficeAgent.NET#89 ·
維護者通常 13 天內回覆