VB -> C#: omitted parentheses cause conversion failures in delegates and custom-event raise accessors

Abierto
#1,298 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
62/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
csharp, visualbasic
Área
compilers

Línea de trabajo

Start in the DeclarationNodeVisitor.VisitDelegateStatement path, where a null parameter list reaches SyntaxFactory.DelegateDeclaration; supply an empty C# parameter list as ordinary methods already do. Then check how a parameterless RaiseEvent accessor is converted so that the On<EventName>() method is not dropped. Done when both VB inputs with and without parentheses produce identical C# output, matching the expected delegate lines.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

VB -> C#
VB.Net input code
Public Delegate Sub Callback
Public Delegate Function Provider As Integer
Erroneous output
Cannot convert DelegateStatementSyntax, CONVERSION ERROR:
Value cannot be null. (Parameter 'parameterList')

at Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DelegateDeclaration(...)
at ICSharpCode.CodeConverter.CSharp.DeclarationNodeVisitor.VisitDelegateStatement(...)
Expected output
public delegate void Callback();
public delegate int Provider();
Details
  • Product in use: VS extension, built locally from master.
  • Version in use: 10.0.1, local development build.
  • Did you see it working in a previous version, which? No.
  • Related to #1296: VB.NET permits parameterless delegate declarations without parentheses. Adding () after Callback or Provider avoids the failure, but both forms should convert identically.
  • The delegate visitor passes a null parameter list to the C# syntax factory when parentheses are omitted. Supplying an empty C# parameter list resolves the issue, consistent with the existing handling for ordinary methods and external declarations.
  • The same problem also affects a custom event's parameterless RaiseEvent accessor when declared without parentheses. In that case, the generated C# event is retained, but its corresponding On<EventName>() method is silently omitted.
Lenguaje dominante
C#
Estrellas
917
Forks
243
Merge medio
2 d 15 h
PR fusionados (30 d)
9

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de icsharpcode/CodeConverter

Todos los issues de icsharpcode/CodeConverter

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.