microsoft / microsoft/CsWinRT

Win32: GridLength doesn't match UWP GridLength

Open
#1,417 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
665
Forks
134
Avg merge
1d 3h
Merged PRs (30d)
32

Description

Describe the bug
Microsoft.UI.Xaml.GridLength is very different on Win32 vs UWP.

For instance Microsoft.UI.Xaml.GridLength has different constructors between UWP and .NET Core, and the .NET Core one is immutable. So I had to do this:

#if NETFX_CORE
        var size = new Microsoft.UI.Xaml.GridLength() { Value = 1, GridUnitType = Microsoft.UI.Xaml.GridUnitType.Star };
#elif NETCOREAPP
        var size = new Microsoft.UI.Xaml.GridLength(1, Microsoft.UI.Xaml.GridUnitType.Star);
#endif

Win32 version:

    public struct GridLength
    {
        public GridLength(double pixels);
        public GridLength(double value, GridUnitType type);

        public static GridLength Auto { get; }
        public double Value { get; }
        public GridUnitType GridUnitType { get; }
        public bool IsAbsolute { get; }
        public bool IsAuto { get; }
        public bool IsStar { get; }

        public override bool Equals(object oCompare);
        public bool Equals(GridLength gridLength);
        public override int GetHashCode();
        public override string ToString();

        public static bool operator ==(GridLength gl1, GridLength gl2);
        public static bool operator !=(GridLength gl1, GridLength gl2);
    }

UWP version:

    public struct GridLength
    {
        public double Value;
        public GridUnitType GridUnitType;
    }

Steps to reproduce the bug
Inspect the Microsoft.UI.Xaml.GridLength type on both Win32 and UWP and notice the big differences.

Expected behavior
Win32 looks like UWP version.

Version Info
3.0.0-preview1.200515.3

NuGet package version: 3.0.0-preview1.200515.3

Windows 10 version Saw the problem?
Insider Build (xxxxx)
November 2019 Update (18363) Yes
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Mobile
Xbox
Surface Hub
IoT

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Microsoft.UI.Xaml.GridLength projection and compare its Win32 API surface with the UWP definition shown in the issue. Reproduce the constructor and mutability differences, then verify that the Win32 type exposes the expected UWP-compatible fields and behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.