Skip to content

Commit a8e73ba

Browse files
CopilotPureWeen
andcommitted
Start fresh implementation: Fix RealParent GC warnings based on PR #30156 with enhancements
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
1 parent a73d1ca commit a8e73ba

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

.github/copilot-instructions.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -163,24 +163,6 @@ Since coding agents function as both CI and pair programmers, they need to handl
163163
- **Always reset changes to `cgmanifest.json` files** - These are generated during CI builds and should not be committed by coding agents
164164
- **Always reset changes to `templatestrings.json` files** - These localization files are auto-generated and should not be committed by coding agents
165165

166-
### Handling Existing PRs for Assigned Issues
167-
When working on an issue that already has an open PR created by someone else:
168-
169-
1. **Review the existing PR thoroughly** - Examine the proposed changes, implementation approach, and any discussion in comments
170-
2. **Provide analysis and opinion** - Evaluate whether the existing solution addresses the issue effectively and follows best practices
171-
3. **Always include a summary** - In your PR description, always include a summary of what you think about any other open PRs for the issue you are working on
172-
4. **Don't force using existing approach** - Don't try too hard to base your work off the existing PR if you're not confident in that approach
173-
5. **It's OK to abandon existing PRs** - If you're not confident enough in the existing PR's approach, it's completely acceptable to abandon it and implement a different solution
174-
6. **Document abandonment reasoning** - If you do abandon an existing PR approach, make sure to add clear notes explaining why you abandoned that approach and what concerns or issues you identified
175-
7. **Use existing PR as foundation when valid** - If the existing solution is solid and you're confident in the approach, use it as the starting point and foundation for your work
176-
8. **Identify improvement opportunities** - Look for areas where you can enhance the solution, such as:
177-
- Adding comprehensive test coverage
178-
- Improving code quality, performance, or maintainability
179-
- Enhancing error handling or edge case coverage
180-
- Better documentation or code comments
181-
- More robust implementation patterns
182-
9. **Build upon, don't duplicate** - When using an existing approach, extend and improve the existing work rather than creating a competing solution from scratch
183-
184166
### Branching
185167
- `main` - For bug fixes without API changes
186168
- `net10.0` - For new features and API changes

src/Controls/src/Core/Element/Element.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,6 @@ internal Element ParentOverride
334334

335335
WeakReference<Element> _realParent;
336336

337-
/// <summary>
338-
/// Gets the real parent element with optional warning logging when the parent has been garbage collected.
339-
/// </summary>
340-
/// <param name="logWarningIfParentHasBeenCollected">If true, logs a warning when the parent reference is invalid due to garbage collection.</param>
341-
/// <returns>The real parent element, or null if no parent exists or has been garbage collected.</returns>
342337
Element GetRealParent(bool logWarningIfParentHasBeenCollected = true)
343338
{
344339
if (_realParent is null)
@@ -352,8 +347,9 @@ Element GetRealParent(bool logWarningIfParentHasBeenCollected = true)
352347
else
353348
{
354349
// Clear the weak reference since the target has been garbage collected
350+
// This prevents repeated checks and warnings on subsequent accesses
355351
_realParent = null;
356-
352+
357353
if (logWarningIfParentHasBeenCollected)
358354
{
359355
Application.Current?

0 commit comments

Comments
 (0)