VB -> C#: Lambda function should use dynamic type
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia dalla firma del callback Application.Eval e riproduci l’input VB fornito nella conversione da VB a C#. Confronta il parametro del callback generato e l’accesso al membro Application.Session con l’output C# previsto. Il lavoro è completato quando la conversione produce la forma C# prevista e un caso di regressione copre questo input.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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))`
- Lingua principale
- C#
- Stelle
- 918
- Fork
- 244
- Merge medio
- 1g 10h
- PR unite (30g)
- 29
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di icsharpcode/CodeConverter
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
icsharpcode/CodeConverter#1271 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
icsharpcode/CodeConverter#1243 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
VB -> C#: Enum Values as IntegerForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. ApertaGood for coding agent VB -> C#
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
icsharpcode/CodeConverter#1212 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Good for coding agent VB -> C#
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
icsharpcode/CodeConverter#1211 ·
I maintainer di solito rispondono entro 1 giorno
-
C# -> VB
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
icsharpcode/CodeConverter#1171 · 7 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di icsharpcode/CodeConverter
Issue simili
-
DXF with empty names failsApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 3 giorni
-
bug python
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
ilia-sokolov/OfficeAgent.NET#89 ·
I maintainer di solito rispondono entro 13 giorni
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
juandresrodca/AdminForge#66 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
umbraco/Umbraco.Automate#612 ·
I maintainer di solito rispondono entro 1 giorno