New bug in ApplyTemplate method after V2.1.0 released
Chưa có ai nhận issue này.
Đá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
- 35/100
Hướng nghiên cứu
Start at ApplyTemplate(Stream templateStream, bool includeContent) and reproduce the failure with the provided code using a DOCX containing an empty paragraph. Read the Paragraphs collection behavior and paragraph.Remove(false), especially RemoveParagraphFromCache; done means ApplyTemplate with includeContent set to false completes without InvalidOperationException.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hello,
My old code stopped working after I updated nuget package from V2.0.0 to V2.3.0. The reason is that ApplyTemplate( Stream templateStream, bool includeContent ) method now throws an System.InvalidOperationException when includeContent is set to false because of those reasons:
if( !includeContent )
{
foreach( Paragraph paragraph in this.Paragraphs )
{
paragraph.Remove( false );
}
}
In this part of ApplyTemplate method paragraph.Remove( false ); modifies Paragraphs collection, and this causes foreach-loop to break. This is happening because in V2.1.0 (commit 9c431afb) realization of Paragraphs collection was changed and now there is underlying List<Paragraph> _editableParagraphsCollection list which is modified when paragraph.Remove( false ); calls RemoveParagraphFromCache( paragraph );
The code to reproduce the bug is as simple as that:
using (var document = DocX.Create("test.docx"))
{
using (var templateStream = new FileStream("template.docx", FileMode.Open, FileAccess.Read))
{
document.ApplyTemplate(templateStream, false);
}
document.Save();
}
where template.docx is any docx created in MS Word, because even empty document includes one empty paragraph. I'm not sure which is the most accurate way to fix this issue.
- Ngôn ngữ chính
- C#
- Star
- 1.9k
- Fork
- 482
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
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 xceedsoftware/DocX
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
xceedsoftware/DocX#489 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
xceedsoftware/DocX#488 · 1 bình luận · 1 reaction ·
-
keep formatĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
xceedsoftware/DocX#487 · 3 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
xceedsoftware/DocX#485 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
xceedsoftware/DocX#482 · 4 bình luận ·
Tất cả issue của xceedsoftware/DocX
Issue tương tự
-
S: Untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
space-wizards/space-station-14#46357 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Versioning_oM: Remove unneeded depeendecy on Test_oMCó thể đã có người làm @IsakNaslundBh đã nhận hôm nay. Đang mởtype:bug type:compliance
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
MicrosoftLearning/PL-400_Microsoft-Power-Platform-Developer#231 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
joinrpg/joinrpg-net#5313 ·
Maintainer thường phản hồi trong vòng 1 ngày