[Feature request, dotnet-codegencs] Be able to reuse code for templates
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginne damit, den Einstiegspunkt dotnet-codegencs sowie die in diesem Issue erwähnten Klassen TemplateBuilder und TemplateLoader zu lesen, und verfolge anschließend, wie ein .csx-Template und seine #r-Referenzen verarbeitet werden. Vergleiche die angeforderten Möglichkeiten zur Wiederverwendung—#load, mehrere Templates und lokale DLL-Referenzen—und definiere „fertig“ als eine unterstützte Möglichkeit, Template-Logik gemeinsam zu nutzen, ohne sie über Templates hinweg zu kopieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Hi!
First of all, thank you very much for the tool! It is easy to use, it's simple and it keeps saving a lot of time for our team.
Second, I need an advice on how to to reuse code for templates while keeping "text template + codegen tool" approach. We do use dotnet-codegencs tool to scaffold boilerplate code for our projects. Something like dotnet new but with some logic involved. It will be nice to be able to reuse basic logic and do not copypaste it across csx templates.
What I have tried so far
Use #load directive
Sadly, this option is not supported. The TemplateBuilder supports only #r directives.
Pass multiple templates as args to the dotnet-codegencs tool
Not supported, there currently can be only one template
reference local dll (not nuget package)
#r "ScaffoldHelpers.dll"
...
or
dotnet-codegencs template run .\TestTemplate.csx -r .\ScaffoldHelpers.dll
Fail with
Unhandled exception: System.TypeInitializationException: The type initializer for 'TestTemplate' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'ScaffoldHelpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
the reason is that referenced assemblies are not copied into the build directory and are not loaded by TemplateLoader.
Write custom runner using TemplateBuilder / TemplateLoader classes
Sadly, these are not distributed as a nuget packages, only as a part of dotnet-codegencs tool
Fork the dotnet-codegencs
We are currently using custom fork but it looks like a hack, I'd prefer to keep using original tool:)
Thanks in advance, hope you have a good Holidays!
- Vorherrschende Sprache
- C#
- Sterne
- 307
- Forks
- 40
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Drizin/CodegenCS
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
-
bug help wanted
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
-
Postgres support Offengood first issue help wanted
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
Alle Issues in Drizin/CodegenCS
Ähnliche Issues
-
effort:S P3 refactor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
nightscout/nocturne#1532 ·
-
core dependencies
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 80/100
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
C#/.NET Roslyn LSP Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
DotNetNext/SqlSugar#1458 ·