VB -> C#: Lambda function should use dynamic type
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 45/100
Direção de pesquisa
Comece pela assinatura do callback de Application.Eval e reproduza a entrada VB fornecida na conversão de VB-to-C#. Compare o parâmetro do callback gerado e o acesso ao membro Application.Session com a saída C# esperada. Está concluído quando a conversão produzir a forma C# pretendida e um caso de regressão cobrir essa entrada.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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))`
- Linguagem predominante
- C#
- Estrelas
- 918
- Forks
- 244
- Merge médio
- 1d 10h
- PRs com merge (30d)
- 29
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de icsharpcode/CodeConverter
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
icsharpcode/CodeConverter#1271 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 52/100
icsharpcode/CodeConverter#1243 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
VB -> C#: Enum Values as IntegerTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. AbertaGood for coding agent VB -> C#
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 45/100
icsharpcode/CodeConverter#1212 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Good for coding agent VB -> C#
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 48/100
icsharpcode/CodeConverter#1211 ·
Mantenedores costumam responder em até 1 dia
-
C# -> VB
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 30/100
icsharpcode/CodeConverter#1171 · 7 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de icsharpcode/CodeConverter
Issues semelhantes
-
hand-to-AI
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
CactuseSecurity/firewall-orchestrator#5803 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 1 dia
-
DXF with empty names failsAbertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 3 dias
-
bug python
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
ilia-sokolov/OfficeAgent.NET#89 ·
Mantenedores costumam responder em até 13 dias