Adding the first C# library reference fails when the project has no ItemGroup
Maintainer thường phản hồi trong vòng 1 ngày
@pcbeingused333 đang làm issue này rồi.
Từ ngày 22/11/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- build-system, cli
Hướng nghiên cứu
Start by reading LibraryManager._add_csharp_project_to_csproj and _add_csharp_package_to_csproj in lean/commands/library/add.py, then find the existing tests for C# library and NuGet insertion. Reproduce with a valid SDK style .csproj containing no ItemGroup and run the relevant tests. Done means both insertion paths create the first ItemGroup on the project root and the regression case passes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
Adding a Lean C# library fails when the consuming .csproj has no ItemGroup. The library is nevertheless recorded in config.json, so repeating the command reports that it is already added while the .csproj still has no ProjectReference.
Reproduced on master at 3842533.
Reproduction
-
In an initialized Lean CLI directory, have C# projects
AppandLibrary/Lib. -
Give
App/App.csprojthis valid SDK-style content:<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net10.0</TargetFramework> </PropertyGroup> </Project> -
Run
lean library add App Library/Lib --no-local.
Observed: exit 1 with Argument '_parent' has incorrect type (expected lxml.etree._Element, got NoneType).
- Run the same command again.
Observed: exit 0 and Library Lib has already been added to the project App, but App.csproj still has no ProjectReference.
Cause and expected result
LibraryManager._add_csharp_project_to_csproj tries to create the first ItemGroup beneath csproj_tree.find(".//Project"). The parsed tree is already the Project element, so that descendant lookup returns None. _add_csharp_package_to_csproj in lean/commands/library/add.py contains the same insertion pattern.
Adding the first library reference should create the necessary ItemGroup on the project root and succeed for a valid project without one. Add regression coverage for this minimal .csproj case. Suggestion: reuse the correct root-insertion handling for both C# library-reference and NuGet-package insertion.
Impact is limited to projects without an existing ItemGroup; retaining an empty <ItemGroup /> before the first add avoids the crash.
- Ngôn ngữ chính
- Python
- Star
- 335
- Fork
- 172
- Merge trung bình
- 6 giờ 54 phút
- Pull request đã merge (30 ngày)
- 37
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 QuantConnect/lean-cli
-
priority:P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
QuantConnect/lean-cli#792 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
QuantConnect/lean-cli#786 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
QuantConnect/lean-cli#785 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A partially written live command result aborts polling with JSONDecodeErrorCó thể đã có người làm @pcbeingused333 đã nhận 3 ngày trước. Đang mởpriority:P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
QuantConnect/lean-cli#784 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Container lookup failures during result polling are masked by UnboundLocalErrorCó thể đã có người làm @pcbeingused333 đã nhận 5 ngày trước. Đang mởpriority:P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
QuantConnect/lean-cli#783 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của QuantConnect/lean-cli
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pimutils/vdirsyncer#1242 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
open-webui/open-webui#35360 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Suggest link: Destiny Verify (MIT zero-dependency pre-commit security, citation & link hygiene CLI)Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày