API for C# code generation
Název práce v češtině: | Rozhraní pro generování C# kódu |
---|---|
Název v anglickém jazyce: | API for C# code generation |
Klíčová slova: | generování kódu, C#, ILSpy, Coberec |
Klíčová slova anglicky: | code generation, C#, ILSpy, Coberec |
Akademický rok vypsání: | 2019/2020 |
Typ práce: | bakalářská práce |
Jazyk práce: | angličtina |
Ústav: | Katedra aplikované matematiky (32-KAM) |
Vedoucí / školitel: | doc. Mgr. Jan Hubička, Ph.D. |
Řešitel: | skrytý - zadáno a potvrzeno stud. odd. |
Datum přihlášení: | 24.02.2020 |
Datum zadání: | 26.02.2020 |
Datum potvrzení stud. oddělením: | 16.03.2020 |
Datum a čas obhajoby: | 14.09.2020 09:00 |
Datum odevzdání elektronické podoby: | 17.07.2020 |
Datum odevzdání tištěné podoby: | 31.07.2020 |
Datum proběhlé obhajoby: | 14.09.2020 |
Oponenti: | Mgr. Filip Kliber |
Zásady pro vypracování |
The goal of this project is to design and implement a library for
writing code generators. Its API will provide a semantic way to describe the result code, similar to System.Linq.Expressions from the .NET Framework. Unlike in System.Linq.Expressions, it will not rely on System.Reflection to provide the metadata (methods, types and other symbols) but will have its own API for declaring and using symbols from the C#/.NET typesystem. The API should help the programmer in following ways (compared to string concatenation and other syntax-only methods): * Early error checks - type, mutability inconsistencies should be reported as soon as possible, certainly before the code is emitted and the user tries to compile it. This should make it much easier to test the code generator. * Handling of edge cases that parametrized code generation easily run into - naming symbols, implicit conversion, choosing right method overrides. These should be handled without polluting the generated code with too much explicitness (global:: prefix everywhere, and so on) * Composability - the API will be expression-based, which allows the programmer to write generic helpers without worrying if the parameter will be an expression or a statement. * It should be also possible to write a function that processes the expression. It may, for example, remove dead code or lower an extension node into standard expressions. Implementation of the library will be based on a fork of the ILSpy decompiler since it had to handle many of the same edge cases when generating code. Part of the project will be a non-trivial code generator based on this library. It will translate GraphQL schema (types, scalars, and unions) into immutable C# classes. Note that this is just a reimplementation of an existing project on top of the new API. |
Seznam odborné literatury |
* System.Linq.Expression:
https://docs.microsoft.com/en-us/dotnet/api/system.linq.expressions?view=netframework-4.7.2 * ILSpy project: https://github.com/icsharpcode/ILSpy/ * GraphQL Schema: https://graphql.org/learn/schema/ |