[Feature request, dotnet-codegencs] Be able to reuse code for templates
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu bằng cách đọc entry point dotnet-codegencs và các lớp TemplateBuilder và TemplateLoader được đề cập trong issue, sau đó theo dõi cách một template .csx và các tham chiếu #r của nó được xử lý. So sánh các tùy chọn tái sử dụng được yêu cầu—#load, nhiều template và các tham chiếu DLL cục bộ—và xác định hoàn thành là khi có một cách được hỗ trợ để dùng chung logic của template mà không phải sao chép logic đó giữa các template.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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!
- Ngôn ngữ chính
- C#
- Star
- 307
- Fork
- 40
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Drizin/CodegenCS
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
bug help wanted
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
Postgres support Đang mởgood first issue help wanted
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
Tất cả issue của Drizin/CodegenCS
Issue tương tự
-
effort:S P3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
nightscout/nocturne#1532 ·
-
core dependencies
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
C#/.NET Roslyn LSP Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Suspicious code fragments Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
DotNetNext/SqlSugar#1458 ·