Expose TreeDefinition entry names
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
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- csharp, git
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Xem xét các API TreeDefinition và Tree để hiểu hành vi hiện có của chúng đối với việc thêm, xóa, tra cứu và liệt kê. Xác định liệu thay đổi được dự định có hiển thị tên các mục hay hỗ trợ lặp qua toàn bộ dictionary hay không, sau đó xác minh rằng có thể kiểm tra metadata mà không commit các đối tượng tạm thời vào ODB.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
TreeDefinition has kind of a weird API. You can add to it, remove from it, and get a specific item, but there's no way to get a list of the entries in the tree or the like. For that, you have to commit the TreeDefinition to the ODB to get a regular Tree back, which supports enumeration. This seems ridiculous, not to mention inefficient.
For a recent project, I wanted a way to pass around and modify (several times) tree metadata only, before committing the final version. TreeDefinition worked well for this... until I wanted to look at which entries were in it. I used the above mentioned workaround to convert TreeDefinitions into Trees when I wanted to read their entries. In practice, this was far too slow. Profiling revealed my application was spending 60% of its time writing temporary TreeDefinitions to the ODB. Plus, it was cluttering up the repo with temporary objects.
That led me to create this terrible hack just to be able to use TreeDefinition:
class TreeMetadata : TreeDefinition
{
private static readonly FieldInfo baseEntriesField = typeof(TreeDefinition)
.GetField("entries", BindingFlags.NonPublic | BindingFlags.Instance);
private readonly Dictionary<string, TreeEntryDefinition> baseEntries;
public IEnumerable<string> EntryNames => baseEntries.Keys;
public TreeMetadata()
{
baseEntries = baseEntriesField.GetValue(this) as Dictionary<string, TreeEntryDefinition>;
}
// Snip factory methods copy/pasted from TreeDefinition
}
Would you guys be open to changing the API in some way to make it more usable? I'm not opposed to submitting a PR for it.
Follow-on: is just exposing the entry dictionary keys enough, or should we support full blown dictionary iteration?
- Ngôn ngữ chính
- C#
- Star
- 3.5k
- Fork
- 925
- 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
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 libgit2/libgit2sharp
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
libgit2/libgit2sharp#2193 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
libgit2/libgit2sharp#2192 · 1 bình luận ·
-
Website is down Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
libgit2/libgit2sharp#2191 · 2 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
libgit2/libgit2sharp#2189 · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
libgit2/libgit2sharp#2187 · 2 bình luận ·
Tất cả issue của libgit2/libgit2sharp
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
SubtitleEdit/subtitleedit#15108 · 1 bình luận ·
-
area/docs-content Bug pulumi/docs
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 94/100
-
agentic-workflows untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100