Conversation
Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
…t namespace usage Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix unhandled exception while saving flame graph
Fix unhandled ArgumentOutOfRangeException when exporting FlameGraph with unrendered canvas
Nov 21, 2025
brianrob
reviewed
Nov 21, 2025
| // Validate that the canvas has a valid size before attempting to export | ||
| if (width <= 0 || height <= 0) | ||
| { | ||
| throw new InvalidOperationException( |
Member
There was a problem hiding this comment.
Suggested change
| throw new InvalidOperationException( | |
| throw new ArgumentOutOfRangeException( |
| { | ||
| throw new InvalidOperationException( | ||
| $"Cannot export flame graph: the canvas has an invalid size (width={width}, height={height}). " + | ||
| "Please ensure the flame graph is visible and has been rendered before attempting to export."); |
Member
There was a problem hiding this comment.
The text here is too long to appear in the status bar. Please use this text: "Please ensure the flame graph is visible and has been rendered before attempting to export."
Contributor
Author
There was a problem hiding this comment.
Done in 0699b4a - shortened the error message to just the essential guidance
| FlameGraph.Export(FlameGraphCanvas, saveDialog.FileName); | ||
| StatusBar.Log($"Saved flame graph to {saveDialog.FileName}"); | ||
| } | ||
| catch (InvalidOperationException ex) |
Member
There was a problem hiding this comment.
Suggested change
| catch (InvalidOperationException ex) | |
| catch (ArgumentOutOfRangeException ex) |
| try | ||
| { | ||
| // Attempt to export should throw InvalidOperationException with a meaningful message | ||
| var exception = Assert.Throws<InvalidOperationException>(() => |
Member
There was a problem hiding this comment.
Suggested change
| var exception = Assert.Throws<InvalidOperationException>(() => | |
| var exception = Assert.Throws<ArgumentOutOfRangeException>(() => |
…r message Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
Contributor
Author
Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
brianrob
reviewed
Nov 21, 2025
| { | ||
| throw new ArgumentOutOfRangeException( | ||
| "flameGraphCanvas", | ||
| $"canvas has an invalid size (width={width}, height={height}). Please ensure the flame graph is visible and has been rendered before attempting to export."); |
Member
There was a problem hiding this comment.
Suggested change
| $"canvas has an invalid size (width={width}, height={height}). Please ensure the flame graph is visible and has been rendered before attempting to export."); | |
| $"Canvas has an invalid size (width={width}, height={height}). Please ensure the flame graph is visible and has been rendered before attempting to export."); |
| }); | ||
|
|
||
| // Verify the exception message is helpful | ||
| Assert.Contains("canvas has an invalid size", exception.Message); |
Member
There was a problem hiding this comment.
Suggested change
| Assert.Contains("canvas has an invalid size", exception.Message); | |
| Assert.Contains("Canvas has an invalid size", exception.Message); |
Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
Contributor
Author
leculver
previously approved these changes
Nov 21, 2025
Collaborator
leculver
left a comment
There was a problem hiding this comment.
One nitpick, but otherwise looks good to me.
Co-authored-by: leculver <8496639+leculver@users.noreply.github.com>
leculver
approved these changes
Nov 21, 2025
This was referenced Jan 29, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed unhandled
ArgumentOutOfRangeExceptionthat occurred when saving a FlameGraph with an unrendered or invalid-sized canvas. The fix includes:FlameGraph.Export()to ensure canvas width and height are greater than zero before creatingRenderTargetBitmapArgumentOutOfRangeExceptionwhich matches the original error fromRenderTargetBitmapStatusBar.LogError()nameof()operator for parameter namesAll review comments have been addressed. The changes are minimal, focused, and directly address the reported issue.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.