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

Aperta
#1,298 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp, visualbasic
Ambito
compilers

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
C#
Stelle
916
Fork
242
Merge medio
2g 15h
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di icsharpcode/CodeConverter

Tutte le issue di icsharpcode/CodeConverter

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.