Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- Below have no corresponding entries in Versions.Details.XML because they are not updated via Maestro -->
<PropertyGroup>
<SystemRuntimeCompilerServicesUnsafePackageVersion>6.1.2</SystemRuntimeCompilerServicesUnsafePackageVersion>
<MicrosoftWindowsCsWin32PackageVersion>0.3.151</MicrosoftWindowsCsWin32PackageVersion>
<MicrosoftWindowsCsWin32PackageVersion>0.3.287</MicrosoftWindowsCsWin32PackageVersion>
</PropertyGroup>

<!-- Docs / Intellisense -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public void CopyToHdevmode(IntPtr hdevmode)
{
int result = PInvoke.DocumentProperties(
HWND.Null,
HANDLE.Null,
global::Windows.Win32.Graphics.Printing.PRINTER_HANDLE.Null,
n,
devmode,
devmode,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@

<!--
CS3016: We don't care about CLS compliance since everything here is internal and we want to match native types.
CS3021: CsWin32-generated COM structs carry [CLSCompliant(false)]; we don't mark the assembly CLS-compliant.
SYSLIB5005: System.Formats.Nrbf is experimental
-->
<NoWarn>$(NoWarn);CS3016;SYSLIB5005</NoWarn>
<NoWarn>$(NoWarn);CS3016;CS3021;SYSLIB5005</NoWarn>

<!--
CA1822: The codebase contains a number of extension types where they reference instance state, but the analyzer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@

<!--
CS3016: We don't care about CLS compliance since everything here is internal and we want to match native types.
CS3021: CsWin32-generated COM structs carry [CLSCompliant(false)]; we don't mark the assembly CLS-compliant.
SYSLIB5005: System.Formats.Nrbf is experimental
-->
<NoWarn>$(NoWarn);CS3016;SYSLIB5005</NoWarn>
<NoWarn>$(NoWarn);CS3016;CS3021;SYSLIB5005</NoWarn>

<!--
CA1822: The codebase contains a number of extension types where they reference instance state, but the analyzer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,15 @@ static HRESULT SaveFileListToHGLOBAL(HGLOBAL hglobal, string[] files)

static HRESULT SaveDbcsToHGLOBAL(HGLOBAL hglobal, string value)
{
int byteCount = PInvokeCore.WideCharToMultiByte(PInvokeCore.CP_ACP, 0, value, value.Length, null, 0, null, null);
int byteCount = PInvokeCore.WideCharToMultiByte(PInvokeCore.CP_ACP, 0, value, value.Length, null, 0, null);

using GlobalBuffer buffer = new(hglobal, (uint)byteCount + 1);
if (buffer.Status.Failed)
{
return buffer.Status;
}

PInvokeCore.WideCharToMultiByte(PInvokeCore.CP_ACP, 0, value, value.Length, (PSTR)buffer.Pointer, byteCount, null, null);
PInvokeCore.WideCharToMultiByte(PInvokeCore.CP_ACP, 0, value, value.Length, (PSTR)buffer.Pointer, byteCount, null);

// Null terminate.
buffer.AsSpan()[byteCount] = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ HRESULT IsPropertyReadOnly(
/// Returns the class name for this object. The class name is the non-bolded text that appears in the properties
/// window selection combo. Returning any result other than <see cref="HRESULT.S_OK"/> will cause the default to
/// be used. The default is the name string from a call to
/// <see cref="ITypeInfo.GetDocumentation(int, BSTR*, BSTR*, out uint, BSTR*)"/> with <see cref="PInvoke.MEMBERID_NIL"/>.
/// <see cref="ITypeInfo.GetDocumentation(int, BSTR*, BSTR*, uint*, BSTR*)"/> with <see cref="PInvoke.MEMBERID_NIL"/>.
/// </summary>
[PreserveSig]
HRESULT GetClassName(
Expand Down
2 changes: 2 additions & 0 deletions src/System.Windows.Forms.Primitives/src/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ DestroyAcceleratorTable
DestroyCursor
DestroyMenu
DestroyWindow
DFC_TYPE
DFCS_STATE
DISPATCH_CONSTRUCT
DISPATCH_FLAGS
DispatchMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
<NoWarn>$(NoWarn);CS8981;CS3016</NoWarn>
<!--
We don't care about CLS compliance since everything here is internal and we want to match native types.
CS3019: CsWin32-generated COM structs carry [CLSCompliant] attributes on internal (non-visible) types.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wait, did that CLSCompliant change now cause us to trigger a CS3019 on callers? Or is this only going to happen when you make the projection public ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This happens when internal, not public. I could suppress this error as well in the generated code if you like.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes, please do that. I approved it because I assumed the attribute wouldn't matter to folks who don't care about CLSCompliant. I don't want noise for people. None of my code cares about CLS.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll create a PR that hits all of the corners of this.

-->
<NoWarn>$(NoWarn);CS3016</NoWarn>
<NoWarn>$(NoWarn);CS3016;CS3019</NoWarn>
<!--
IL Trim warnings which should be removed in order to make WinForms trimmable
See https://github.com/dotnet/winforms/issues/4649
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ public static unsafe string GetThemeDocumentationProperty(string pszThemeName, s
{
Span<char> buffer = stackalloc char[512];
fixed (char* pBuffer = buffer)
fixed (char* pszTheme = pszThemeName)
fixed (char* pszProperty = pszPropertyName)
{
GetThemeDocumentationProperty(pszThemeName, pszPropertyName, pBuffer, buffer.Length);
GetThemeDocumentationProperty(pszTheme, pszProperty, pBuffer, buffer.Length);
}

return buffer.SliceAtFirstNull().ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal static partial class PInvoke
public static unsafe IShellItem* SHCreateShellItem(string path)
{
IShellItem* ppsi = default;
if (SHParseDisplayName(path, pbc: null, out ITEMIDLIST* ppidl, sfgaoIn: 0, psfgaoOut: null).Succeeded)
if (SHParseDisplayName(path, pbc: null, out ITEMIDLIST* ppidl, sfgaoIn: 0).Succeeded)
{
// No parent specified
SHCreateShellItem(pidlParent: null, psfParent: null, ppidl, &ppsi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Windows.Win32;

internal static partial class PInvoke
{
/// <inheritdoc cref="RegLoadMUIString(System.Registry.HKEY, string, PWSTR, uint, uint*, uint, string)"/>
/// <inheritdoc cref="RegLoadMUIString(System.Registry.HKEY, PCWSTR, PWSTR, uint, uint*, uint, PCWSTR)"/>
[SkipLocalsInit]
public static unsafe bool RegLoadMUIString(RegistryKey key, string keyName, out string localizedValue)
{
Expand All @@ -17,11 +17,12 @@ public static unsafe bool RegLoadMUIString(RegistryKey key, string keyName, out
while (true)
{
fixed (char* pszOutBuf = buffer)
fixed (char* pszKeyName = keyName)
{
uint bytes = 0;
var errorCode = RegLoadMUIString(
Comment thread
JeremyKuhne marked this conversation as resolved.
(System.Registry.HKEY)key.Handle.DangerousGetHandle(),
keyName,
pszKeyName,
pszOutBuf,
(uint)(buffer.Length * sizeof(char)),
&bytes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public class ShellItemTests
public unsafe void SHParseDisplayName_ValidPath()
{
string path = Path.GetTempPath();
uint rgflnOut = default;
HRESULT result = PInvoke.SHParseDisplayName(path, pbc: null, out ITEMIDLIST* ppidl, 0, &rgflnOut);
HRESULT result = PInvoke.SHParseDisplayName(path, pbc: null, out ITEMIDLIST* ppidl, 0);
try
{
Assert.Equal(HRESULT.S_OK, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public static (int topic, BSTR helpFile) TryGetHelpTopic(this AgileComPointer<IA
}

BSTR file = default;
result = accessible.Value->get_accHelpTopic(&file, child, out int topicId);
result = accessible.Value->get_accHelpTopic(out file, child, out int topicId);
Debug.Assert(
result.Succeeded || result == HRESULT.DISP_E_MEMBERNOTFOUND,
$"{nameof(TryGetHelpTopic)}: put_accValue call failed with {result}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ private static Bitmap GetCheckBoxImage(Color checkColor, Rectangle fullSize, ref
PInvoke.DrawFrameControl(
hdc,
ref rcCheck,
DFC_TYPE.DFC_MENU,
DFCS_STATE.DFCS_MENUCHECK);
(uint)DFC_TYPE.DFC_MENU,
(uint)DFCS_STATE.DFCS_MENUCHECK);
}

bitmap.MakeTransparent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1361,8 +1361,8 @@ private Rectangle PaintPrivate(
PInvoke.DrawFrameControl(
hdc,
ref rcCheck,
DFC_TYPE.DFC_MENU,
DFCS_STATE.DFCS_MENUCHECK);
(uint)DFC_TYPE.DFC_MENU,
(uint)DFCS_STATE.DFCS_MENUCHECK);
}

bitmap.MakeTransparent();
Expand Down
16 changes: 8 additions & 8 deletions src/System.Windows.Forms/System/Windows/Forms/Help/Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@ private static unsafe void ShowHTML10Help(Control? parent, string? url, HelpNavi
{
string? localPath = (file is not null && file.IsFile) ? file.LocalPath : url;

// If this is a local path, convert it to a short path name. Pass 0 as the length the first time
uint requiredStringSize = PInvoke.GetShortPathName(localPath, null, 0);
if (requiredStringSize > 0)
// If this is a local path, convert it to a short path name. Pass an empty buffer the first time to get the size.
if (localPath is not null)
{
// It's able to make it a short path.
using BufferScope<char> shortName = new((int)requiredStringSize);
fixed (char* pShortName = shortName)
uint requiredStringSize = PInvoke.GetShortPathName(localPath, default);
if (requiredStringSize > 0)
{
requiredStringSize = PInvoke.GetShortPathName(localPath, pShortName, requiredStringSize);
// If it can't make it a short path, just leave the path we had.
// It's able to make it a short path.
using BufferScope<char> shortName = new((int)requiredStringSize);
Comment thread
JeremyKuhne marked this conversation as resolved.
requiredStringSize = PInvoke.GetShortPathName(localPath, shortName);
// If it can't make it a short path, just leave the path we had.
pathAndFileName = shortName[..(int)requiredStringSize].ToString();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,10 @@ protected override unsafe bool RunDialog(IntPtr hwndOwner)
Span<char> buffer = stackalloc char[2];
int result;
fixed (char* pBuffer = buffer)
fixed (char* pLocaleName = PInvoke.LOCALE_NAME_SYSTEM_DEFAULT)
{
result = PInvoke.GetLocaleInfoEx(
PInvoke.LOCALE_NAME_SYSTEM_DEFAULT,
pLocaleName,
PInvoke.LOCALE_IMEASURE,
pBuffer,
buffer.Length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal static unsafe DevModeScope GetDevMode(PrinterSettings printerSettings)

fixed (char* n = printerSettings.PrinterName)
{
modeSize = PInvoke.DocumentProperties(HWND.Null, HANDLE.Null, n, null, (DEVMODEW*)null, 0);
modeSize = PInvoke.DocumentProperties(HWND.Null, global::Windows.Win32.Graphics.Printing.PRINTER_HANDLE.Null, n, null, (DEVMODEW*)null, 0);
if (modeSize < 1)
{
throw new InvalidPrinterException(printerSettings);
Expand All @@ -37,7 +37,7 @@ internal static unsafe DevModeScope GetDevMode(PrinterSettings printerSettings)
{
modeSize = PInvoke.DocumentProperties(
HWND.Null,
HANDLE.Null,
global::Windows.Win32.Graphics.Printing.PRINTER_HANDLE.Null,
n,
(DEVMODEW*)b,
(DEVMODEW*)null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ private static void DrawFlatCheckBox(
{
g2.Clear(Color.Transparent);
using DeviceContextHdcScope dc = new(g2, applyGraphicsState: false);
PInvoke.DrawFrameControl(dc, ref rcCheck, DFC_TYPE.DFC_MENU, DFCS_STATE.DFCS_MENUCHECK);
PInvoke.DrawFrameControl(dc, ref rcCheck, (uint)DFC_TYPE.DFC_MENU, (uint)DFCS_STATE.DFCS_MENUCHECK);
}

bitmap.MakeTransparent();
Expand Down Expand Up @@ -1473,7 +1473,7 @@ private static void DrawFrameControl(
using (DeviceContextHdcScope hdc = new(g2, applyGraphicsState: false))
{
// Get Win32 dc with Graphics properties applied to it.
PInvoke.DrawFrameControl(hdc, ref rcFrame, kind, state);
PInvoke.DrawFrameControl(hdc, ref rcFrame, (uint)kind, (uint)state);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

FYI if DrawFrameControl only takes DFC_TYPE / DFC_STATE for these parameters, that type improvement (uint => DFC_TYPE) can be done in win32metadata. Feel free to file an issue on win32metadata to recommend that.

}

if (foreColor == Color.Empty || backColor == Color.Empty)
Expand Down
Loading