Skip to content

Fix Rectangle Rendering as a Thin Line for Small Heights - #37319

Merged
kubaflo merged 8 commits into
dotnet:inflight/currentfrom
Dhivya-SF4094:Issue-fix-31330
Oct 16, 2026
Merged

kubaflo merged 8 commits into
dotnet:inflight/currentfrom
Dhivya-SF4094:Issue-fix-31330

Conversation

@Dhivya-SF4094

@Dhivya-SF4094 Dhivya-SF4094 commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Detail

When height is a small non-integer value (e.g., 1.2), the shape renders incorrectly as a thin stroked line instead of a filled rectangle.

Root Cause

  • Shape.StrokeThicknessProperty defaults to 1.0. The path and measurement logic in Shape.TransformPathForBounds, Shape.MeasureOverride, Rectangle.GetPath, Ellipse.GetPath, and RoundRectangle.GetInnerPath / InnerPath always applies an inset of StrokeThickness / 2 on each side, even when Stroke is null and no stroke is actually rendered.
  • For example, a Rectangle with HeightRequest="1.2" and no Stroke would still apply the default stroke inset. This consumed 1.0of the available 1.2 height as a phantom stroke, leaving only a 0.2-pixel-tall fill area. As a result, the rectangle appeared as a thin line instead of a filled rectangle.
  • BoxView is unaffected because it does not have Stroke or StrokeThickness properties.
  • Shape geometry is also consumed by Border, which must preserve stroke-aware geometry even when the same Shape would not apply an inset when rendered standalone.

Description of Change

  • Standalone Shapes now apply the stroke inset only when their own Stroke is present.
  • Added an internal IShapeWithStroke contract so Border renderers can explicitly request stroke-aware geometry.
  • Updated Android, iOS, Mac Catalyst, Windows, and Tizen Border rendering paths to use the appropriate geometry context.
  • Kept the rendering decision with the consumer instead of storing mutable Border state on shared Shape instances.
  • Changed the default Border.StrokeShape to create a separate Rectangle for each Border.
  • Updated Rectangle, Ellipse, and RoundRectangle path and measurement calculations.

Validated the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed:

Fixes #31330

Screenshots

Before  After 
     

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37319

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37319"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Aug 11, 2026
@vishnumenon2684 vishnumenon2684 added the community ✨ Community Contribution label Aug 14, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Aug 30, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 5 findings

See inline comments for details.

Comment thread src/Controls/src/Core/Shapes/Shape.cs Outdated

if (!double.IsNaN(minimumDimension) &&
!double.IsInfinity(minimumDimension) &&
minimumDimension <= strokeThickness * 2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Logic and Correctness — The minimumDimension <= strokeThickness * 2 threshold makes the rendered fill non-monotonic in the requested size. With the default StrokeThickness = 1 and Stroke = null: a Rectangle with HeightRequest = 2.0 takes the return 0 branch and paints a 2.0pt-tall fill, while HeightRequest = 2.01 falls through to return strokeThickness and paints a 1.01pt-tall fill. Growing the requested height by 0.01 halves the visible shape, and the mismatch with BoxView that this PR fixes below the threshold still exists above it (height 3 renders 2).

Second scenario — the suppression is keyed on strokeThickness * 2, not on a small absolute size, so it also fires on large shapes: a fill-only Rectangle with StrokeThickness = 20 (no Stroke brush) at 40x40 previously painted a 20x20 centered fill and now paints the full 40x40. That is a much wider behavior change than the reported small-height case, and nothing in the PR exercises it.

A continuous rule avoids both: either suppress the inset whenever Stroke is null (no stroke is ever painted, so there is no stroke to inset for), or clamp it continuously, e.g. Math.Min(strokeThickness, minimumDimension), so the rendered size never decreases as the shape grows.

Comment thread src/Controls/src/Core/Shapes/Shape.cs Outdated

widthConstraint -= StrokeThickness;
heightConstraint -= StrokeThickness;
var strokeInset = GetPathStrokeInset(widthConstraint, heightConstraint);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Layout Measure-Arrange — The inset here is decided from widthConstraint/heightConstraint (available size), but Rectangle.GetPath()/Ellipse.GetPath() decide it from WidthForPathComputation/HeightForPathComputation (arranged size). The two can disagree, so measure and the drawn path use different geometry rules. Concrete scenario: a fill-only shape reaches this fallback branch with heightConstraint = 1.5 (<= 2 * 1), so strokeInset = 0 and line 538 adds no stroke space to DesiredSize; the shape is then arranged taller than the threshold, and GetPath() uses strokeInset = 1, shrinking the path by 1pt that measure never accounted for. The reverse (measure with an infinite constraint → inset 1, arrange at 1.2 → inset 0) also occurs. Derive the inset from a single source for both passes.

Comment thread src/Controls/src/Core/Shapes/Shape.cs Outdated
viewBounds.Y += StrokeThickness / 2;
viewBounds.Width -= StrokeThickness;
viewBounds.Height -= StrokeThickness;
var strokeInset = GetPathStrokeInset(viewBounds.Width, viewBounds.Height);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Layout Measure-Arrange — TransformPathForBounds computes the inset from viewBounds, but the path it is transforming was built by GetPath() using WidthForPathComputation/HeightForPathComputation. These only agree while the shape is unarranged (Width == -1, where PathForBounds seeds _fallbackWidth/_fallbackHeight from viewBounds just above). Once Width/Height have real values and PathForBounds is called with bounds that differ from them — e.g. a resize where the platform view bounds arrive before the new arranged size — a fill-only shape can cross the threshold in one call site but not the other: GetPath() emits a full-bounds rect (inset 0) while this code shrinks viewBounds by StrokeThickness, and the non-Stretch.None scale path then scales that path against the shrunken bounds, rendering the shape at the wrong size/offset. Pass the same width/height used by GetPath().


// Rectangle should render as a filled shape just like BoxView,
// not collapse into a thin stroked line for small height values.
VerifyScreenshot();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Regression Prevention and Test Coverage — VerifyScreenshot() is called from a shared test with no platform exclusion, but the PR only adds baselines for TestCases.Android.Tests/snapshots/android, TestCases.iOS.Tests/snapshots/ios and snapshots/ios-26. TestCases.Mac.Tests/snapshots/mac and TestCases.WinUI.Tests/snapshots/windows both exist in the repo (1537 and 1527 baselines respectively) and receive no RectangleWithSmallHeightRendersAsFilledShape.png, so this test fails with a missing-baseline error on Mac and Windows. The change in Shape.cs is platform-agnostic and affects Windows/Mac rendering too, so those baselines should be added rather than the platforms excluded.

{
App.WaitForElement("TestBoxView");

// Rectangle should render as a filled shape just like BoxView,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Regression Prevention and Test Coverage — This exercises only the positive case (fill-only shape below the threshold). The new branch in Shape.GetPathStrokeInset has no test for the inputs that must NOT trip it: (a) a small shape that does have a Stroke brush, which must keep the legacy inset and still render its stroke, and (b) the threshold boundary itself (minimumDimension == strokeThickness * 2 vs slightly above), where the rendered size currently jumps. A single full-page screenshot cannot discriminate those. GetPathStrokeInset is internal and pure, so cheap Controls.Core.UnitTests cases over (Stroke set/null, StrokeThickness, width/height including NaN/infinity) would cover the branch deterministically without new baselines.

MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 30, 2026

@kubaflo kubaflo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the status of this one? Is it ready for review?

@Dhivya-SF4094 Dhivya-SF4094 changed the title [WIP]Fix Rectangle Rendering as a Thin Line for Small Heights Fix Rectangle Rendering as a Thin Line for Small Heights Sep 10, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Sep 10, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 2 findings

See inline comments for details.

MauiBot

This comment was marked as outdated.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Sep 10, 2026
@Dhivya-SF4094

Copy link
Copy Markdown
Contributor Author

#37319 (review)

Validated the AI summary, addressed the valid concern, and updated the implementation accordingly.

@vishnumenon2684

Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review Summary

@Dhivya-SF4094 — new AI review results are available based on commit ec97155.

Gate Passed Confidence Medium Platform Android


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: ANDROID · Base: main · Merge base: 51cf98f2

✅ Verified (new API / feature) — this PR adds new API and a test that references it in the same project, so reverting the fix un-compiles the test: there is no valid "fails without the fix" baseline to establish (a compile-coupled baseline). The gate instead verified the fix by a clean build + pass with the fix, so this is a real PASS rather than a non-committal INCONCLUSIVE.

Test Without Fix (expect FAIL) With Fix (expect PASS)
🧪 StrokeShapeTests StrokeShapeTests 🛠️ BUILD ERROR ✅ PASS — 94s
🖥️ Issue31330 Issue31330 ✅ FAIL — 2399s ✅ PASS — 642s
🔴 Without fix — 🧪 StrokeShapeTests: 🛠️ BUILD ERROR · 151s

Error-relevant lines (filtered from the build log):

/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/StrokeShapeTests.cs(405,101): error CS1739: The best overload for 'InnerPathForBounds' does not have a parameter named 'includeShapeStroke' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/StrokeShapeTests.cs(421,101): error CS1739: The best overload for 'InnerPathForBounds' does not have a parameter named 'includeShapeStroke' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/StrokeShapeTests.cs(426,40): error CS0246: The type or namespace name 'IShapeWithStroke' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
🟢 With fix — 🧪 StrokeShapeTests: PASS ✅ · 94s

(no coded error found; showing last 1200 chars)

ed TestRectangleConstructor(value: "rectangle") [< 1 ms]
  Passed DefaultBorderStrokeShapeRetainsPathInset [1 ms]
  Passed TestRoundRectangleSingleValue(value: "20") [< 1 ms]
  Passed ReplacingBorderStrokeShapeDoesNotChangeEitherShapesStandaloneGeometry [2 ms]
  Passed TestEllipseConstructor(value: "ellipse") [< 1 ms]
  Passed TestEllipseConstructor(value: "Ellipse") [< 1 ms]
  Passed EllipseWithStrokeInsetsPath [3 ms]
  Passed RoundRectangleWithStrokeInsetsInnerPath [< 1 ms]
  Passed DynamicStrokeShapeAssignmentsImmediatelyUpdateBorderGeometry [88 ms]
  Passed RectangleWithStrokeInsetsPath [< 1 ms]
  Passed RectangleUsedAsBorderStrokeShapeRetainsPathInset [< 1 ms]
  Passed SharedShapeRetainsBorderGeometryWhenRemovedFromAnotherBorder [< 1 ms]
  Passed PolygonChangingStrokeFromNullToNonNullInvalidatesMeasure [1 ms]
  Passed RoundRectangleUsedAsBorderShadowShapeWithoutStrokeRetainsInnerPathInset [1 ms]
  Passed EllipseWithoutStrokeUsesFullBounds [< 1 ms]
[xUnit.net 00:00:01.70]   Finished:    Microsoft.Maui.Controls.Core.UnitTests
  Passed PolygonChangingStrokeFromNonNullToNullInvalidatesMeasure [< 1 ms]
Test Run Successful.
Total tests: 55
     Passed: 55
 Total time: 2.2152 Seconds
🔴 Without fix — 🖥️ Issue31330: FAIL ✅ · 2399s

Error-relevant lines (filtered from the build log):

   at Microsoft.Maui.TestCases.Tests.UtilExtensions.WaitForGoToTestButtonWithRecovery(IApp app, String timeoutMessage) in /_/src/Controls/tests/TestCases.Shared.Tests/UtilExtensions.cs:line 91
   at Microsoft.Maui.TestCases.Tests._IssuesUITest.NavigateToIssue(String issue) in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs:line 54
   at Microsoft.Maui.TestCases.Tests._IssuesUITest.TryToResetTestState() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs:line 25
   at Microsoft.Maui.TestCases.Tests.UITest.FixtureSetup() in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 579
   at UITest.Appium.NUnit.UITestBase.OneTimeSetup() in /_/src/TestUtils/src/UITest.NUnit/UITestBase.cs:line 221
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
🟢 With fix — 🖥️ Issue31330: PASS ✅ · 642s

(no coded error found; showing last 1200 chars)

g test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.13)
[xUnit.net 00:00:00.13]   Discovering: Controls.TestCases.Android.Tests
[xUnit.net 00:00:00.42]   Discovered:  Controls.TestCases.Android.Tests
NUnit Adapter 4.5.0.0: Test execution started
Running selected tests in /home/vsts/work/1/s/artifacts/bin/Controls.TestCases.Android.Tests/Debug/net10.0/Controls.TestCases.Android.Tests.dll
   NUnit3TestExecutor discovered 1 of 1 NUnit test cases using Current Discovery mode, Non-Explicit run
>>>>> 10/15/2026 13:35:56 FixtureSetup for Issue31330(Android)
>>>>> 10/15/2026 13:35:59 RectangleWithSmallHeightRendersAsFilledShape Start
>>>>> 10/15/2026 13:36:03 RectangleWithSmallHeightRendersAsFilledShape Stop
  Passed RectangleWithSmallHeightRendersAsFilledShape [3 s]
NUnit Adapter 4.5.0.0: Test execution complete
Results File: /home/vsts/work/1/s/CustomAgentLogsTmp/UITests/TestResults/Issue31330.trx
Test Run Successful.
Total tests: 1
     Passed: 1
 Total time: 20.3951 Seconds
>>> TRX_RESULT_FILE: /home/vsts/work/1/s/CustomAgentLogsTmp/UITests/TestResults/Issue31330.trx

⚠️ Failure Details

  • 🛠️ StrokeShapeTests without fix: build failed before tests could run
    • /home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/StrokeShapeTests.cs(405,101): error CS1739: The best overload for 'InnerPathForBounds' does not have a parameter named 'includeShapeStroke' [/home...
📁 Fix files reverted (14 files)
  • src/Controls/src/Core/Border/Border.cs
  • src/Controls/src/Core/Shapes/Ellipse.cs
  • src/Controls/src/Core/Shapes/Rectangle.cs
  • src/Controls/src/Core/Shapes/RoundRectangle.cs
  • src/Controls/src/Core/Shapes/Shape.cs
  • src/Core/src/Graphics/IShape.cs
  • src/Core/src/Graphics/MauiDrawable.Android.cs
  • src/Core/src/Graphics/MauiDrawable.Tizen.cs
  • src/Core/src/Platform/Android/ContentViewGroup.cs
  • src/Core/src/Platform/Android/ShapeExtensions.cs
  • src/Core/src/Platform/Windows/BorderExtensions.cs
  • src/Core/src/Platform/Windows/ContentPanel.cs
  • src/Core/src/Platform/iOS/ContentView.cs
  • src/Core/src/Platform/iOS/MauiCALayer.cs

📋 Pre-Flight — Context & Validation

Pre-Flight Context

PR snapshot: #37319 is open against main, from base 904c03280b833515a5518c49d9c08462a620a152 to submitted head ec971551a0b23c2e506c4fdc14508595aa39f9d7. GitHub reports 140 changed files, 548 additions, 41 deletions, and 8 commits. Its merge state is blocked; the specific blocking reason was not established.

Reported problem

Linked issue #31330 reports that a Rectangle sized approximately 20 × 1.2 inside an AbsoluteLayout renders as a thin horizontal line instead of a filled rectangle, while an equivalently sized BoxView renders correctly. The issue narrative mentions iOS and Android, while its structured affected-platform field and a verification comment specifically identify Android. The reported version is .NET MAUI 9.0.100 SR10 on Android API 35; whether this is a regression and the last working version are unknown.

The submitted explanation attributes the behavior to the default Shape.StrokeThickness of 1: path and measurement calculations reserve that thickness even when Stroke is null. For a 1.2-high rectangle, this leaves approximately 0.2 units for the fill.

Changed mechanism and relevant files

The central change makes stroke inset depend on rendering context:

  • src/Controls/src/Core/Shapes/Shape.cs
    • Adds GetPathStrokeInset(bool includeStroke = false), returning zero when Stroke is absent unless a consumer explicitly requests stroke-inclusive geometry.
    • Uses that inset consistently when generating/translating bounded paths and in MeasureOverride.
    • Invalidates measure when Stroke changes between null and non-null.
    • Implements the new internal IShapeWithStroke contract.
  • src/Controls/src/Core/Shapes/Rectangle.cs and Ellipse.cs
    • Add internal path overloads accepting the selected inset.
    • Standalone fill-only instances use their full arranged bounds; stroked instances retain the inset.
  • src/Controls/src/Core/Shapes/RoundRectangle.cs
    • Adds stroke-context-aware bounded and inner-path generation.
  • src/Core/src/Graphics/IShape.cs
    • Adds internal IShapeWithStroke.PathForBounds(bounds, includeStroke).
    • Extends the internal IRoundRectangle.InnerPathForBounds contract with includeShapeStroke.
  • src/Controls/src/Core/Border/Border.cs
    • Changes the default StrokeShape from one shared Rectangle instance to a per-Border default-value instance.
    • This complements the consumer-driven geometry approach and avoids shared mutable shape context.

Border remains intentionally different from a standalone shape: border drawing and clipping explicitly request stroke-inclusive geometry even if the reused shape itself has no Stroke. This preserves the border’s existing inset while allowing the same shape to use full bounds when rendered standalone.

Platform-sensitive paths

  • Android
    • src/Core/src/Platform/Android/ShapeExtensions.cs preserves the public conversion overload with includeShapeStroke: false and adds an internal context-aware overload.
    • src/Core/src/Platform/Android/ContentViewGroup.cs requests stroke-inclusive geometry for border content clipping.
    • src/Core/src/Graphics/MauiDrawable.Android.cs requests stroke-inclusive geometry for border clip paths and full clip paths.
    • Android density conversion, round-rectangle inner paths, border drawing, and content clipping are therefore directly in scope.
  • iOS and Mac Catalyst
    • src/Core/src/Platform/iOS/ContentView.cs and MauiCALayer.cs request stroke-inclusive border and clip geometry. These paths are relevant to both iOS and Mac Catalyst behavior.
  • Windows
    • src/Core/src/Platform/Windows/BorderExtensions.cs and ContentPanel.cs use stroke-inclusive paths for border rendering and content clipping, including non-round shapes.
  • Tizen
    • src/Core/src/Graphics/MauiDrawable.Tizen.cs distinguishes border geometry from ordinary shape/clip geometry.
  • The shared Shape measurement and path changes are platform-independent, so behavior outside the explicitly modified renderer paths remains relevant.

Test and validation context

Confirmed test-related changes include:

  • src/Controls/tests/Core.UnitTests/StrokeShapeTests.cs adds coverage for:
    • Unstroked rectangles at heights 1.2, 2.0, 2.01, and 20.0.
    • Stroked rectangle and ellipse insets.
    • Round-rectangle inner paths.
    • Null/non-null Stroke transitions invalidating measure.
    • Default, dynamically replaced, and shared border stroke shapes.
    • Independent standalone versus border geometry.
  • src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31330.cs adds a screenshot test which waits for Issue31330_label and captures both the documented fill case and the original BackgroundColor reproduction.
  • The PR contains extensive snapshot changes under Android, Mac, WinUI, and iOS directories. A new Android and iOS RectangleWithSmallHeightRendersAsFilledShape.png baseline was directly observed; the complete 140-file snapshot inventory was not enumerated.

Required platform: Android.

Provided Gate evidence: Gate passed, with tests failing without the fix and passing with the submitted fix. This was not rerun.

Android validation should specifically preserve these distinctions:

  1. A fill-only Rectangle at the reported fractional height uses its full bounds.
  2. A shape with an actual Stroke still reserves the configured thickness.
  3. Border drawing and content clipping continue using stroke-inclusive geometry.
  4. Reusing or replacing a shape does not leak border-specific geometry into standalone rendering.
  5. Changing Stroke between null and non-null causes layout to be remeasured.

Remaining uncertainties

  • The supplied diff was explicitly partial, and the full snapshot set was not inspected; this is context gathering, not an exhaustive review.
  • The PR description claims validation on Android, Windows, iOS, and Mac, but no independent platform-run or CI evidence was queried beyond the supplied Gate result.
  • One current unresolved discussion asks for a direct assertion of the desired size produced by MeasureOverride; existing visible tests assert path bounds and measure invalidation, but the submitted evidence did not establish whether a desired-size comparison exists elsewhere.
  • Earlier discussion questioned missing Mac and Windows screenshot baselines. A later duplicate thread was resolved and subsequent commits mention baseline additions, but exact current per-platform baseline completeness was not fully confirmed.
  • The linked issue’s attached reproduction artifacts were not inspected. Workaround, regression origin, and last-known-good version remain unknown.
  • The reason GitHub currently reports the PR as blocked is unknown.

🔬 Code Review — Deep Analysis

Expert Review — PR #37319

Independent Assessment

What this changes: The submitted fix makes standalone shapes reserve stroke space only when they have an actual Stroke, while allowing Border renderers and clip paths to request stroke-inclusive geometry explicitly. It also gives each Border its own default Rectangle, invalidates measure when stroke presence changes, and adds unit and screenshot coverage for the affected geometry.

Inferred motivation: A fill-only shape with the default StrokeThickness currently loses one logical unit of usable size even though no stroke is drawn. At a requested height such as 1.2, that phantom inset collapses the fill to approximately 0.2.

Review Evidence

  • The single required maui-expert-reviewer pass completed with its normal platform tracing and dimension fanout.
  • inline-findings.json was written and schema-validated as an empty JSON array.
  • No concrete error, warning, unresolved behavioral mechanism, or prior error-level finding survived expert validation.
  • The trusted Android Gate passed: the relevant tests fail without the submitted fix and pass with it. Gate verification was not rerun.
  • Full CI state beyond the trusted Gate was not independently established in this phase; this evaluation does not claim that every repository check is complete.

Blast Radius and Failure-Mode Probing

  • Fill-only standalone shape: Uses the full arranged bounds because no stroke is rendered.
  • Actually stroked shape: Continues to reserve the configured stroke inset.
  • Border drawing and clipping: Explicitly request stroke-inclusive geometry and therefore preserve existing border semantics.
  • Shared or replaced shape: Consumer-selected geometry avoids storing mutable border context on a shared shape instance; the submitted tests cover standalone and border reuse.
  • Dynamic stroke transition: Null/non-null Stroke transitions invalidate measure so desired size and geometry are recomputed.
  • Startup/static state: The change introduces no startup path or global mutable state. The per-Border default shape removes the prior shared default instance.

External Output Contract

Not applicable.

Findings

No actionable findings.

Verdict: LGTM

Confidence: medium

Summary: The submitted mechanism matches the reported failure, preserves the distinct border geometry contract across platform renderers, and is covered by targeted shared and UI tests. The trusted Gate passed and the expert pass found no blocking or discussion-level issue, so the evidence threshold for a reviewer refinement was not met.


🛠️ Try-Fix — Analysis & Comparison

Alternative generation: not requested

Evidence-first mode intentionally omits routine Try-Fix attempts. This is not a failed
attempt, a completed alternative search, or evidence that alternatives have no value.
The expert review may still produce one evidence-backed PR refinement.


📝 PR Finalize — Recommended Title & Description

Assessment: ✏️ Recommend updating — the current title omits the cross-platform Shapes component and describes only Rectangle, while the submitted fix changes shared Shape, Rectangle, Ellipse, RoundRectangle, and Border geometry behavior.

Recommended title

[All] Shapes: Preserve full bounds for unstroked standalone shapes

Recommended description

### Issue Detail

When height is a small non-integer value (for example, `1.2`), a standalone shape renders incorrectly as a thin stroked line instead of a filled shape.

### Root Cause

- `Shape.StrokeThicknessProperty` defaults to `1.0`. The path and measurement logic in `Shape.TransformPathForBounds`, `Shape.MeasureOverride`, `Rectangle.GetPath`, `Ellipse.GetPath`, and `RoundRectangle.GetInnerPath` / `InnerPath` always applied an inset of `StrokeThickness / 2` on each side, even when `Stroke` was `null` and no stroke was rendered.
- For example, a `Rectangle` with `HeightRequest="1.2"` and no `Stroke` still applied the default stroke inset. This consumed `1.0` of the available `1.2` height as a phantom stroke, leaving only a `0.2`-pixel-tall fill area. As a result, the rectangle appeared as a thin line instead of a filled rectangle.
- `BoxView` is unaffected because it does not have `Stroke` or `StrokeThickness` properties.
- Shape geometry is also consumed by `Border`, which must preserve stroke-aware geometry even when the same shape would not apply an inset when rendered standalone.

### Description of Change

- Standalone shapes now apply the stroke inset only when their own `Stroke` is present.
- Added an internal `IShapeWithStroke` contract so `Border` renderers can explicitly request stroke-aware geometry.
- Updated Android, iOS, Mac Catalyst, Windows, and Tizen `Border` rendering paths to use the appropriate geometry context.
- Kept the rendering decision with the consumer instead of storing mutable `Border` state on shared `Shape` instances.
- Changed the default `Border.StrokeShape` to create a separate `Rectangle` for each `Border`.
- Updated shared `Shape` measurement and `Rectangle`, `Ellipse`, and `RoundRectangle` path calculations.

### Validated the behavior on the following platforms

- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac Catalyst

### Issues Fixed

Fixes #31330

### Screenshots

| Before | After |
|--------|-------|
| <img src="https://github.com/user-attachments/assets/ed5ef7d2-7324-4855-af8c-69201ea2152f"> | <img src="https://github.com/user-attachments/assets/8ef27d00-0af8-495b-a616-d441d0f0ed22"> |

🏁 Report — Final Recommendation

✅ Final Recommendation: APPROVE

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE Trusted read-only evidence-first context consumed
Expert Review LGTM (medium) 0 actionable findings; inline findings persisted
Gate ✅ PASSED Android; tests fail without the fix and pass with it
Try-Fix Not requested Intentional evidence-first omission; no alternatives generated
Refinement Not generated No concrete source/test-backed defect met the refinement threshold
Report ✅ COMPLETE

Code Review and Candidate Comparison

Rank Candidate Evidence Result
1 pr Trusted Gate passed; expert review found no blocking or discussion-level issue Winner

The raw submitted PR is the only real candidate. No pr-plus-reviewer patch was implemented because the expert review identified no actionable defect or unresolved behavioral mechanism. Routine Try-Fix alternatives were intentionally not requested, not attempted, and not treated as an exhausted search.

Summary

The submitted fix wins because it addresses the phantom stroke inset while retaining stroke-aware geometry for Border rendering and clipping. The trusted Android Gate validates the submitted candidate, and the expert review produced no inline findings. This recommendation does not assert the state of repository checks outside the supplied Gate evidence.

Root Cause

Shape path and measurement calculations reserved the default StrokeThickness even when Stroke was null. For very small fractional heights, the unused inset consumed nearly all available fill space and made a filled rectangle appear as a thin line.

Fix Quality

The fix keeps geometry selection with the consumer: standalone unstroked shapes use their full bounds, actually stroked shapes retain their inset, and border renderers explicitly request stroke-inclusive paths. Per-instance default border shapes avoid shared mutable context, null/non-null stroke changes invalidate measure, and the submitted tests cover fractional sizes, stroked shapes, border reuse/replacement, and the reported rendering scenario.


📱 UI Tests — Border,Shape,ViewBaseTests

Detected UI test categories: Border,Shape,ViewBaseTests

✅ Deep UI tests — 245 passed, 0 failed, 1 skipped across 3 categories on platform-pool agent (replaces in-process counts above).

🧪 UI Test Execution Results (deep, platform pool)

Category Tests Snapshot diffs
Border 65/65 ✓ —
Shape 62/62 ✓ —
ViewBaseTests 118/119 (1 skipped) ✓ —
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs)

🧭 Next Steps — review latest findings

No alternative fix was selected for this run. Review the session findings and CI results before merging.

@MauiBot MauiBot added s/agent-approved AI agent recommends approval - PR fix is correct and optimal and removed s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-review-in-progress AI review is currently running for this PR labels Oct 15, 2026
@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@Dhivya-SF4094 — test-failure analysis for commit ec97155.

Scope CI failures Commit ec97155


🧪 CI Analysis — click to expand
📊 maui-pr

No failures found.


🧪 maui-pr-devicetests

🧪 maui-pr-uitests

Insufficient data — UI coverage: canceled Shell legs and truncated current/history results prevent exhaustive attribution. Publish-step errors report test failures.


🧭 Follow-up — actions and refresh

Next action: Inspect unresolved screenshots/crashes and restore complete result collection.

Maintainers: comment /review tests to refresh this report.

@kubaflo
kubaflo changed the base branch from main to inflight/current October 16, 2026 22:22
@kubaflo
kubaflo merged commit fce3120 into dotnet:inflight/current Oct 16, 2026
178 of 199 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR12 milestone Oct 16, 2026
kubaflo pushed a commit that referenced this pull request Oct 18, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Issue Detail
When height is a small non-integer value (e.g., 1.2), the shape renders
incorrectly as a thin stroked line instead of a filled rectangle.

### Root Cause

- Shape.StrokeThicknessProperty defaults to 1.0. The path and
measurement logic
in Shape.TransformPathForBounds, Shape.MeasureOverride, Rectangle.GetPath, Ellipse.GetPath,
and RoundRectangle.GetInnerPath / InnerPath always applies an inset
of StrokeThickness / 2 on each side, even when Stroke is null and no
stroke is actually rendered.
- For example, a Rectangle with HeightRequest="1.2" and no Stroke would
still apply the default stroke inset. This consumed 1.0of the
available 1.2 height as a phantom stroke, leaving only a 0.2-pixel-tall
fill area. As a result, the rectangle appeared as a thin line instead of
a filled rectangle.
- BoxView is unaffected because it does not
have Stroke or StrokeThickness properties.
- Shape geometry is also consumed by `Border`, which must preserve
stroke-aware geometry even when the same Shape would not apply an inset
when rendered standalone.

### Description of Change

- Standalone Shapes now apply the stroke inset only when their own
`Stroke` is present.
- Added an internal `IShapeWithStroke` contract so Border renderers can
explicitly request stroke-aware geometry.
- Updated Android, iOS, Mac Catalyst, Windows, and Tizen Border
rendering paths to use the appropriate geometry context.
- Kept the rendering decision with the consumer instead of storing
mutable Border state on shared Shape instances.
- Changed the default `Border.StrokeShape` to create a separate
`Rectangle` for each Border.
- Updated Rectangle, Ellipse, and RoundRectangle path and measurement
calculations.

### Validated the behaviour in the following platforms
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

### Issues Fixed:
Fixes #31330 

### Screenshots

| Before  | After |
|---------|--------|
|  <img
src="https://github.com/user-attachments/assets/ed5ef7d2-7324-4855-af8c-69201ea2152f">
|  <img
src="https://github.com/user-attachments/assets/8ef27d00-0af8-495b-a616-d441d0f0ed22"> 
|
kubaflo pushed a commit that referenced this pull request Oct 21, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Issue Detail
When height is a small non-integer value (e.g., 1.2), the shape renders
incorrectly as a thin stroked line instead of a filled rectangle.

### Root Cause

- Shape.StrokeThicknessProperty defaults to 1.0. The path and
measurement logic
in Shape.TransformPathForBounds, Shape.MeasureOverride, Rectangle.GetPath, Ellipse.GetPath,
and RoundRectangle.GetInnerPath / InnerPath always applies an inset
of StrokeThickness / 2 on each side, even when Stroke is null and no
stroke is actually rendered.
- For example, a Rectangle with HeightRequest="1.2" and no Stroke would
still apply the default stroke inset. This consumed 1.0of the
available 1.2 height as a phantom stroke, leaving only a 0.2-pixel-tall
fill area. As a result, the rectangle appeared as a thin line instead of
a filled rectangle.
- BoxView is unaffected because it does not
have Stroke or StrokeThickness properties.
- Shape geometry is also consumed by `Border`, which must preserve
stroke-aware geometry even when the same Shape would not apply an inset
when rendered standalone.

### Description of Change

- Standalone Shapes now apply the stroke inset only when their own
`Stroke` is present.
- Added an internal `IShapeWithStroke` contract so Border renderers can
explicitly request stroke-aware geometry.
- Updated Android, iOS, Mac Catalyst, Windows, and Tizen Border
rendering paths to use the appropriate geometry context.
- Kept the rendering decision with the consumer instead of storing
mutable Border state on shared Shape instances.
- Changed the default `Border.StrokeShape` to create a separate
`Rectangle` for each Border.
- Updated Rectangle, Ellipse, and RoundRectangle path and measurement
calculations.

### Validated the behaviour in the following platforms
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

### Issues Fixed:
Fixes #31330 

### Screenshots

| Before  | After |
|---------|--------|
|  <img
src="https://github.com/user-attachments/assets/ed5ef7d2-7324-4855-af8c-69201ea2152f">
|  <img
src="https://github.com/user-attachments/assets/8ef27d00-0af8-495b-a616-d441d0f0ed22"> 
|
kubaflo pushed a commit that referenced this pull request Oct 25, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Issue Detail
When height is a small non-integer value (e.g., 1.2), the shape renders
incorrectly as a thin stroked line instead of a filled rectangle.

### Root Cause

- Shape.StrokeThicknessProperty defaults to 1.0. The path and
measurement logic
in Shape.TransformPathForBounds, Shape.MeasureOverride, Rectangle.GetPath, Ellipse.GetPath,
and RoundRectangle.GetInnerPath / InnerPath always applies an inset
of StrokeThickness / 2 on each side, even when Stroke is null and no
stroke is actually rendered.
- For example, a Rectangle with HeightRequest="1.2" and no Stroke would
still apply the default stroke inset. This consumed 1.0of the
available 1.2 height as a phantom stroke, leaving only a 0.2-pixel-tall
fill area. As a result, the rectangle appeared as a thin line instead of
a filled rectangle.
- BoxView is unaffected because it does not
have Stroke or StrokeThickness properties.
- Shape geometry is also consumed by `Border`, which must preserve
stroke-aware geometry even when the same Shape would not apply an inset
when rendered standalone.

### Description of Change

- Standalone Shapes now apply the stroke inset only when their own
`Stroke` is present.
- Added an internal `IShapeWithStroke` contract so Border renderers can
explicitly request stroke-aware geometry.
- Updated Android, iOS, Mac Catalyst, Windows, and Tizen Border
rendering paths to use the appropriate geometry context.
- Kept the rendering decision with the consumer instead of storing
mutable Border state on shared Shape instances.
- Changed the default `Border.StrokeShape` to create a separate
`Rectangle` for each Border.
- Updated Rectangle, Ellipse, and RoundRectangle path and measurement
calculations.

### Validated the behaviour in the following platforms
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

### Issues Fixed:
Fixes #31330 

### Screenshots

| Before  | After |
|---------|--------|
|  <img
src="https://github.com/user-attachments/assets/ed5ef7d2-7324-4855-af8c-69201ea2152f">
|  <img
src="https://github.com/user-attachments/assets/8ef27d00-0af8-495b-a616-d441d0f0ed22"> 
|
kubaflo pushed a commit that referenced this pull request Oct 26, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Issue Detail
When height is a small non-integer value (e.g., 1.2), the shape renders
incorrectly as a thin stroked line instead of a filled rectangle.

### Root Cause

- Shape.StrokeThicknessProperty defaults to 1.0. The path and
measurement logic
in Shape.TransformPathForBounds, Shape.MeasureOverride, Rectangle.GetPath, Ellipse.GetPath,
and RoundRectangle.GetInnerPath / InnerPath always applies an inset
of StrokeThickness / 2 on each side, even when Stroke is null and no
stroke is actually rendered.
- For example, a Rectangle with HeightRequest="1.2" and no Stroke would
still apply the default stroke inset. This consumed 1.0of the
available 1.2 height as a phantom stroke, leaving only a 0.2-pixel-tall
fill area. As a result, the rectangle appeared as a thin line instead of
a filled rectangle.
- BoxView is unaffected because it does not
have Stroke or StrokeThickness properties.
- Shape geometry is also consumed by `Border`, which must preserve
stroke-aware geometry even when the same Shape would not apply an inset
when rendered standalone.

### Description of Change

- Standalone Shapes now apply the stroke inset only when their own
`Stroke` is present.
- Added an internal `IShapeWithStroke` contract so Border renderers can
explicitly request stroke-aware geometry.
- Updated Android, iOS, Mac Catalyst, Windows, and Tizen Border
rendering paths to use the appropriate geometry context.
- Kept the rendering decision with the consumer instead of storing
mutable Border state on shared Shape instances.
- Changed the default `Border.StrokeShape` to create a separate
`Rectangle` for each Border.
- Updated Rectangle, Ellipse, and RoundRectangle path and measurement
calculations.

### Validated the behaviour in the following platforms
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

### Issues Fixed:
Fixes #31330 

### Screenshots

| Before  | After |
|---------|--------|
|  <img
src="https://github.com/user-attachments/assets/ed5ef7d2-7324-4855-af8c-69201ea2152f">
|  <img
src="https://github.com/user-attachments/assets/8ef27d00-0af8-495b-a616-d441d0f0ed22"> 
|
github-actions Bot pushed a commit that referenced this pull request Oct 28, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Issue Detail
When height is a small non-integer value (e.g., 1.2), the shape renders
incorrectly as a thin stroked line instead of a filled rectangle.

### Root Cause

- Shape.StrokeThicknessProperty defaults to 1.0. The path and
measurement logic
in Shape.TransformPathForBounds, Shape.MeasureOverride, Rectangle.GetPath, Ellipse.GetPath,
and RoundRectangle.GetInnerPath / InnerPath always applies an inset
of StrokeThickness / 2 on each side, even when Stroke is null and no
stroke is actually rendered.
- For example, a Rectangle with HeightRequest="1.2" and no Stroke would
still apply the default stroke inset. This consumed 1.0of the
available 1.2 height as a phantom stroke, leaving only a 0.2-pixel-tall
fill area. As a result, the rectangle appeared as a thin line instead of
a filled rectangle.
- BoxView is unaffected because it does not
have Stroke or StrokeThickness properties.
- Shape geometry is also consumed by `Border`, which must preserve
stroke-aware geometry even when the same Shape would not apply an inset
when rendered standalone.

### Description of Change

- Standalone Shapes now apply the stroke inset only when their own
`Stroke` is present.
- Added an internal `IShapeWithStroke` contract so Border renderers can
explicitly request stroke-aware geometry.
- Updated Android, iOS, Mac Catalyst, Windows, and Tizen Border
rendering paths to use the appropriate geometry context.
- Kept the rendering decision with the consumer instead of storing
mutable Border state on shared Shape instances.
- Changed the default `Border.StrokeShape` to create a separate
`Rectangle` for each Border.
- Updated Rectangle, Ellipse, and RoundRectangle path and measurement
calculations.

### Validated the behaviour in the following platforms
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

### Issues Fixed:
Fixes #31330 

### Screenshots

| Before  | After |
|---------|--------|
|  <img
src="https://github.com/user-attachments/assets/ed5ef7d2-7324-4855-af8c-69201ea2152f">
|  <img
src="https://github.com/user-attachments/assets/8ef27d00-0af8-495b-a616-d441d0f0ed22"> 
|
kubaflo added a commit that referenced this pull request Nov 10, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Description of Change

<!-- Enter description of the fix in this section -->

Restore custom Shape implementations of `IShape.PathForBounds` when a
renderer requests stroke-aware geometry.

**Regression introduced by**

[PR #37319 — Fix Rectangle Rendering as a Thin Line for Small
Heights](#37319).

The supplied reproduction works on MAUI `10.0.120` and fails on
`10.0.130` on Android and iOS.

**Root cause**

That PR introduced the internal `IShapeWithStroke` interface to
distinguish standalone shape geometry from Border stroke-aware geometry.
Platform renderers were updated to prefer this interface over
`IShape.PathForBounds`.

Custom Shapes inherit `IShapeWithStroke` from `Shape`, even when they
re-implement the public `IShape.PathForBounds` contract. The inherited
stroke-aware implementation directly calls the base path-building
method, bypassing the custom implementation. Applications cannot
re-implement `IShapeWithStroke` because it is internal.

In the reported `FieldShape`, the skipped method initializes the
fallback width and height used to construct the outline. Without that
call, the shape uses incorrect dimensions, producing a malformed outline
instead of the expected rounded border and label gap.

**Fix**

- Dispatch `Shape.IShapeWithStroke.PathForBounds` through
`IShape.PathForBounds`, honoring custom implementations.
- Preserve the requested stroke context for built-in shapes using the
base implementation.
- Save and restore that context with `try`/`finally`, including when
path generation throws.
- Leave RoundRectangle's dedicated implementation unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40129

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 11, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Description of Change

<!-- Enter description of the fix in this section -->

Restore custom Shape implementations of `IShape.PathForBounds` when a
renderer requests stroke-aware geometry.

**Regression introduced by**

[PR #37319 — Fix Rectangle Rendering as a Thin Line for Small
Heights](#37319).

The supplied reproduction works on MAUI `10.0.120` and fails on
`10.0.130` on Android and iOS.

**Root cause**

That PR introduced the internal `IShapeWithStroke` interface to
distinguish standalone shape geometry from Border stroke-aware geometry.
Platform renderers were updated to prefer this interface over
`IShape.PathForBounds`.

Custom Shapes inherit `IShapeWithStroke` from `Shape`, even when they
re-implement the public `IShape.PathForBounds` contract. The inherited
stroke-aware implementation directly calls the base path-building
method, bypassing the custom implementation. Applications cannot
re-implement `IShapeWithStroke` because it is internal.

In the reported `FieldShape`, the skipped method initializes the
fallback width and height used to construct the outline. Without that
call, the shape uses incorrect dimensions, producing a malformed outline
instead of the expected rounded border and label gap.

**Fix**

- Dispatch `Shape.IShapeWithStroke.PathForBounds` through
`IShape.PathForBounds`, honoring custom implementations.
- Preserve the requested stroke context for built-in shapes using the
base implementation.
- Save and restore that context with `try`/`finally`, including when
path generation throws.
- Leave RoundRectangle's dedicated implementation unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40129

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
rafalka pushed a commit to rafalka/MauiSkiaUi that referenced this pull request Nov 13, 2026
- Maui11Version 11.0.10 (net11 floor; 11.0.0 had dropped effective visibility, 11.0.10 restores it).
- SkUiDecimal.FromDouble: .NET 11 converts double to decimal exactly; keep .NET 10's 15 significant
  digits for screen readers setting decimal steppers (both layers), the numeric entry writing out
  large doubles and the typed stepper demo's check.
- Shapes follow MAUI 11's stroke inset (dotnet/maui#37319): no Stroke, no room for StrokeThickness
  on net11 (SkUiShapeGeometry.StrokeInset, both layers); a stroke appearing or going re-measures.
- MauiApiParityTests: MAUI 11's BoxView.Fill and Editor.ReturnCommand(Parameter) as net11 known gaps.
- Tests follow the per-line shape inset; plan and roadmap record the findings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kubaflo added a commit that referenced this pull request Nov 13, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Description of Change

<!-- Enter description of the fix in this section -->

Restore custom Shape implementations of `IShape.PathForBounds` when a
renderer requests stroke-aware geometry.

**Regression introduced by**

[PR #37319 — Fix Rectangle Rendering as a Thin Line for Small
Heights](#37319).

The supplied reproduction works on MAUI `10.0.120` and fails on
`10.0.130` on Android and iOS.

**Root cause**

That PR introduced the internal `IShapeWithStroke` interface to
distinguish standalone shape geometry from Border stroke-aware geometry.
Platform renderers were updated to prefer this interface over
`IShape.PathForBounds`.

Custom Shapes inherit `IShapeWithStroke` from `Shape`, even when they
re-implement the public `IShape.PathForBounds` contract. The inherited
stroke-aware implementation directly calls the base path-building
method, bypassing the custom implementation. Applications cannot
re-implement `IShapeWithStroke` because it is internal.

In the reported `FieldShape`, the skipped method initializes the
fallback width and height used to construct the outline. Without that
call, the shape uses incorrect dimensions, producing a malformed outline
instead of the expected rounded border and label gap.

**Fix**

- Dispatch `Shape.IShapeWithStroke.PathForBounds` through
`IShape.PathForBounds`, honoring custom implementations.
- Preserve the requested stroke context for built-in shapes using the
base implementation.
- Save and restore that context with `try`/`finally`, including when
path generation throws.
- Leave RoundRectangle's dedicated implementation unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40129

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rectangle renders as thin line instead of filled shape for small height values

5 participants