VB -> C#: ASP.NET Inherits-attribute in aspx file does not get renamed properly

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

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
csharp, visualbasic
Ambito
tooling, web-dev

Direzione di ricerca

Inizia dalla pagina .aspx e dal relativo code-behind SomeClass.aspx.vb, quindi segui il modo in cui la conversione rinomina la classe. Assicurati che l’attributo Inherits della pagina faccia riferimento alla classe rinominata e valuta l’aggiornamento di CodeBehind da .vb a .cs come suggerito dall’issue. Il lavoro è completato quando la pagina generata risolve la classe convertita a runtime.

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

Descrizione

VB -> C#
VB.Net input code
In VB.net, a class can contain a method with the same name as the class. Lets call this class 'someclass'. In the aspx file, a reference is made to this file using 
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="SomeClass.aspx.vb" Inherits="SomeClass" ViewStateMode="Disabled" %>

with someclass.aspx.vb looking like this:
Public Class SomeClass
    Inherits BaseWebPage

    Private Sub SomeClass()
    'do nothing
    End Sub
End Class
Erroneous output
When converted to c#, the method name can't be the same as the classname, so the converter changes the classname, and appends 'Type', resulting in:
public class SomeClassType : BaseWebPage
{   
    private void SomeClass()
    {
        //do nothing
    }
}

However, the attribute Inherits="SomeClass" in the aspx file should also be changed into Inherits="SomeClassType", which does not happen currently. This won't be picked up during compilation, only at runtime, where the page will throw a 500 error, because the class-behind can't be found. 
Currently, the aspx-file is not touched at all: the reference to the vb-codehind stays unchanged (instead it should be changed to .cs, but this doesn't actually impact the application so just mentioning this as a side-note). 
Expected output
Must have: In the aspx-files, it should have it's Inherits-attribute changed if the classname changes.
Should have: In the aspx-files, change the CodeBehind value from .vb to .cs :)
Details
  • Product in use: e.g. both
  • Version in use: e.g. 9.2.5.0
  • Did you see it working in a previous version: no
Lingua principale
C#
Stelle
913
Fork
244
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

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.