CONVERTING CONTROLS INTO SOURCE CODE
Aspects of the subject matter described herein relate to converting controls into source code. In aspects, a control is created via a designer. The control may include properties, code, and a visual representation. The control may be represented at least in part via a markup language. At one or more times during or after development of a software project, source code for the control may be generated, transformed, and placed into the project. This may be done, among other reasons, to simplify software development.
1 . A method implemented at least in part by a computer, the method comprising:
receiving a data structure that corresponds to server code of a control, the server code including instructions for generating client code corresponding to the control, the data structure including a child class that inherits from a first parent class;
modifying the data structure at least by causing the child class to inherit from a second parent class instead of the first parent class;
providing the data structure as modified to a code generator; and
generating source code from the data structure as modified, the source code including server instructions for generating code to provide to a client.
2 . The method of claim 1 , wherein receiving a data structure that corresponds to server code of a control comprises receiving a tree data structure that corresponds to a document object model of the server code.
3 . The method of claim 1 , further comprising parsing markup language code corresponding to the control to generate the data structure.
4 . The method of claim 1 , further comprising storing the source code in a partial class, the partial class having a portion designated as modifiable and a portion designated as auto-generated.
5 . The method of claim 4 , further comprising adding a statement in the portion designated as modifiable to call initialization code in the portion designated as auto-generated.
6 . The method of claim 1 , further comprising modifying the data structure to remove an override call, the override call referencing a method of the first parent that does not exist in the second parent.
7 . The method of claim 1 , further comprising modifying the data structure to change a namespace of the data structure.
8 . The method of claim 1 , further comprising aborting creation of an assembly derived at least in part from the source code.
9 . The method of claim 1 , further comprising inserting the source code into a project that includes files related to a Web site and refraining from placing markup code for the control in the project.
10 . A computer storage medium having computer-executable instructions, which when executed perform actions, comprising:
parsing markup code for a control that is represented at least in part via a markup language;
generating a data structure that represents server code of the control;
modifying the data structure at least to change inheritance of a class of the server code;
generating source code from the data structure as modified, the source code in a language other than the markup language; and
placing the source code in a project.
11 . The computer storage medium of claim 10 , wherein placing the source code in a project comprises placing the source code in a partial class, the partial class having a portion designated as modifiable and a portion designated as auto-generated.
12 . The computer storage medium of claim 11 , further comprising indicating via text inserted in the portion designated as auto-generated that the portion designated as auto-generated may be regenerated.
13 . The computer storage medium of claim 10 , further comprising generating an assembly that is derived at least in part from the source code, the assembly, when executed, generating code to supply to a client to implement functionality of the control via an Internet browser of the client.
14 . In a computing environment, an apparatus, comprising:
a user interface operable to display a graphical representation of a control;
a designer operable to receive design information regarding the control;
a update manager operable to determine whether to generate source code corresponding to the control; and
a translator operable to receive a data structure that represents the control and to at least change, in the data structure, inheritance of a class of the control.
15 . The apparatus of claim 14 , wherein the designer is further operable to generate markup language code that represents the control to a server capable of hosting a Web page that includes the control.
16 . The apparatus of claim 14 , wherein the data of the control comprises source code and properties of the control.
17 . The apparatus of claim 14 , wherein the translator being operable to receive a data structure that represents the control comprises the translator being operable to receive a tree data structure that represents source code of the control.
18 . The apparatus of claim 14 , wherein the update manager being operable to determine whether to generate source code corresponding to the control comprises the generation manager determining whether a change has occurred to the control.
19 . The apparatus of claim 14 , wherein the translator is further operable to modify the data structure to delete an override statement that is no longer applicable when the inheritance of the class is changed.
20 . The apparatus of claim 14 , wherein the translator is further operable to modify the data structure to change a namespace of the data structure, namespace including the class after the inheritance of the class is changed.