microsoft / microsoft/CsWin32

Windows.Win32.Foundation.FILETIME is not used in PROPVARIANT

Open
#835 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
2.5k
Forks
124
Avg merge
1d 3h
Merged PRs (30d)
9

Description

Is your feature request related to a problem? Please describe.
In the PROPVARIANT struct and in PInvoke.PropVariantGetFileTimeElem System.Runtime.InteropServices.ComTypes.FILETIME is used. I think, it may be a good idea to use the FILETIME from namespace Windows.Win32.Foundation. At the moment there is nearly no difference between the System.Runtime.InteropServices.ComTypes.FILETIME and Windows.Win32.Foundation.FILETIME. But in a later version of Windows.Win32.Foundation.FILETIME I expect converters to the .NET type System.DateTime like the code example.

using FT = System.Runtime.InteropServices.ComTypes.FILETIME;

namespace Windows.Win32.Foundation
{
    partial struct FILETIME
    {
        public FILETIME(DateTime dateTime)
        {
            long hFT = dateTime.ToFileTime();
            dwLowDateTime = (uint)(hFT & 0xFFFFFFFF);
            dwHighDateTime = (uint)((ulong)hFT >> 32);
        }

        public FILETIME(FT ft) { dwLowDateTime = (uint)ft.dwLowDateTime; dwHighDateTime = (uint)ft.dwHighDateTime; }

        public DateTime FromFileTime => DateTime.FromFileTime((long)(((ulong)dwHighDateTime) << 32) + dwLowDateTime);

        public FT ToComTypesFileTime
        {
            get
            {
                FT result = new FT();
                result.dwLowDateTime = (int)dwLowDateTime;
                result.dwHighDateTime = (int)dwHighDateTime;
                return result;
            }
        }
    }
}

Describe the solution you'd like
Change the FILETIME in PROPVARIANT, PropVariantGetFileTimeElem, and in other functions (I don't know) and add the extended functions I describe.

Describe alternatives you've considered

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 tracing the PROPVARIANT definition and PInvoke.PropVariantGetFileTimeElem, then identify the other functions that expose System.Runtime.InteropServices.ComTypes.FILETIME. Compare their generated Windows.Win32.Foundation.FILETIME usage with the requested DateTime conversion helpers. Done means the relevant APIs consistently use the Windows.Win32.Foundation type and the requested conversions are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.