dotnet / pinvoke

A library containing all P/Invoke code so you don't have to import it every time. Maintained and updated to support the latest Windows OS.
MIT License
2.11k stars 220 forks source link

Change NTSTATUS/HResult FACILITY_CODE to match CsWin32 definitions #600

Closed BinToss closed 1 year ago

BinToss commented 2 years ago

e.g. property generated by CsWin32:

public Severity SeverityCode => (Severity)(((uint)this.Value & 0xc0000000) >> 30);

Why?

I was having trouble determining the "true" values of the Facility Codes and nearly opened a separate issue after seeing FACILITY_DEBUGGER was not assigned 1.

AArnott commented 2 years ago

Can you send a PR with the proposed change?

BinToss commented 2 years ago

Sure! I should have time to work on it in the next few days.

BinToss commented 2 years ago

While working on it, I noticed a minor compatibility issue. If a downstream library explicitly depends on the existing, bit-shifted enum values, the library/app will no longer behave as expected when they update their package references.

In light of this, I'll submit a followup PR for SeverityCode FacilityCode so these two compatibility changes can be published together.

I'll leave fields such as CustomerCode as-is for now. "*Shifted" properties can be added later if needed e.g. "CustomerCodeShifted".

P.S. I've been spending a lot of today figuring out a GPG issue that's preventing me from committing.

P.P.S. Finally re-learned that Git needs gpg4win registered as its gpg application. Haven't done that in a few years.