VB -> C#: Lambda function should use dynamic type
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
Beginne mit der Application.Eval-Callback-Signatur und reproduziere die bereitgestellte VB-Eingabe in der VB-to-C#-Konvertierung. Vergleiche den generierten Callback-Parameter und den Zugriff auf das Application.Session-Mitglied mit der erwarteten C#-Ausgabe. Erledigt ist die Aufgabe, wenn die Konvertierung die beabsichtigte C#-Form erzeugt und ein Regressionstest diesen Input abdeckt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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))`
- Vorherrschende Sprache
- C#
- Sterne
- 918
- Forks
- 244
- Ø Merge
- 1 T. 10 Std.
- Gemergte PRs (30 T.)
- 29
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus icsharpcode/CodeConverter
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
icsharpcode/CodeConverter#1271 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
icsharpcode/CodeConverter#1243 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
VB -> C#: Enum Values as IntegerEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. OffenGood for coding agent VB -> C#
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
icsharpcode/CodeConverter#1212 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Good for coding agent VB -> C#
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
icsharpcode/CodeConverter#1211 ·
Maintainer antworten meist innerhalb von 1 Tag
-
C# -> VB
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 30/100
icsharpcode/CodeConverter#1171 · 7 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in icsharpcode/CodeConverter
Ähnliche Issues
-
hand-to-AI
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
CactuseSecurity/firewall-orchestrator#5803 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 3 Tagen
-
bug python
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
ilia-sokolov/OfficeAgent.NET#89 ·
Maintainer antworten meist innerhalb von 13 Tagen