It is very difficult for us to fix a bug which we cannot replicate. We cannot even test whether the bug was fixed if we cannot replicate it. In the best case, when submitting a bug report, provide us a solution that allows us to replicate the bug.
Many people showed us a few lines of their code on the forum. In many cases, the code was running fine after we built an application around the code snippet. The problem was with the code that was not shown - and we wasted our time.
The key to have an issue resolved is to make it reproducible.
On Stack Overflow this is know as MCVE: a Minimal, Complete, and Verifiable Example
MCVE on Stack Overflow
See also: http://sscce.org/
We have created a solution for PDFsharp and MigraDoc issue reporting. Basically the solution contains minimal PDFsharp and MigraDoc programs, one for every build (Core, GDI+, and WPF). Thus there are six projects in the solution.
- Download the solution from https://github.com/empira/PDFsharp.IssueSubmissionTemplate
- Add your code that reproduces the issue
- Execute
.\dev\zip-solution.ps1
to zip the solution - Send us the zip file
- We prefer to receive files via https://github.com/empira/PDFsharp/issues
- If the zip file contains confidential data, please e-mail to issues[at]pdfsharp.net
The solution was developed with Visual Studio 2022. The .PS1 files in the DEV folder require PowerShell Core 7.0 or higher.
Note: The PowerShell script files included with this solution are not signed.
Set ExecutionPolicy to Undefined
to execute them under Windows.
Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope CurrentUser
We have three projects for PDFsharp, one for each of the builds Core, GDI, and WPF. Source code Program.cs
is contained in the IssueSubmission project under PDFsharp only. The other projects IssueSubmission-gdi and IssueSubmission-wpf use the same Program.cs
file by link.
Use these three projects to replicate issues with PDFsharp. The projects have references to PDFsharp only. Classes from MigraDoc should not be used here.
The same structure was also prepared for MigraDoc. To replicate issues with MigraDoc, use the projects listed unter MigraDoc that already have references to PDFsharp and MigraDoc.
If your code only works with a specific flavor, use #if
around your code to ensure that all six projects of the solution still compile.
Example that uses XImage.FromGdiPlusImage
only supported by the GDI build:
#if PDFsharp_GDI
var bitmap = ... // Code that creates the bitmap.
// Draw the bitmap.
var xImage = XImage.FromGdiPlusImage(bitmap);
gfx.DrawImage(xImage, new Point(10, 10));
#endif
When adding resources, like image files, we recommend to add them to the folder containing this README.md file and use relative paths beginning with ..\..\..\..\..\..\
to reference them.
Please ensure that all six projects compile without errors before submitting the issue report.
Thanks for your support.