Skip to content
Merged
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
6 changes: 3 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<PreReleaseVersionLabel>rc</PreReleaseVersionLabel>
<PreReleaseVersionIteration>1</PreReleaseVersionIteration>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<!-- Use the compiler in the CLI instead of in the sdk, since the sdk one doesn't work with netcoreapp5.0 yet -->
<UsingToolMicrosoftNetCompilers>false</UsingToolMicrosoftNetCompilers>
<UsingToolMicrosoftNetCompilers>true</UsingToolMicrosoftNetCompilers>
</PropertyGroup>
<!-- Below have corresponding entries in Versions.Details.XML because they are updated via Maestro -->
<PropertyGroup>
Expand Down Expand Up @@ -91,14 +90,15 @@
<CSharpIsNullAnalyzersVersion>0.1.329</CSharpIsNullAnalyzersVersion>
<DotNetAnalyzersDocumentationAnalyzersVersion>1.0.0-beta.59</DotNetAnalyzersDocumentationAnalyzersVersion>
<MicrosoftCodeAnalysisAnalyzersVersion>3.3.5-beta1.23327.3</MicrosoftCodeAnalysisAnalyzersVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.4.0</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.8.0-1.23378.8</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>$(MicrosoftCodeAnalysisCommonPackageVersion)</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisVisualBasicPackageVersion>$(MicrosoftCodeAnalysisCommonPackageVersion)</MicrosoftCodeAnalysisVisualBasicPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesVersion>$(MicrosoftCodeAnalysisCommonPackageVersion)</MicrosoftCodeAnalysisCSharpWorkspacesVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesVersion>$(MicrosoftCodeAnalysisCommonPackageVersion)</MicrosoftCodeAnalysisVisualBasicWorkspacesVersion>
<MicrosoftCodeAnalysisPackagesVersion>1.1.2-beta1.23322.1</MicrosoftCodeAnalysisPackagesVersion>
<MicrosoftCodeAnalysisPublicApiAnalyzersVersion>$(MicrosoftCodeAnalysisAnalyzersVersion)</MicrosoftCodeAnalysisPublicApiAnalyzersVersion>
<MicrosoftCodeAnalysisNetAnalyzersVersion>8.0.0-preview.23327.3</MicrosoftCodeAnalysisNetAnalyzersVersion>
<MicrosoftNetCompilersToolsetVersion>4.8.0-1.23403.1</MicrosoftNetCompilersToolsetVersion>
<StyleCopAnalyzersVersion>1.2.0-beta.507</StyleCopAnalyzersVersion>
</PropertyGroup>
<!-- Additional unchanging dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
namespace System.Drawing;

/// <summary>
/// The ComWrappers implementation for System.Drawing.Common's COM interop usages.
///
/// Supports IStream and IPicture COM interfaces.
/// The ComWrappers implementation for System.Drawing.Common's COM interop usages.
/// </summary>
/// <remarks>
/// <para>
/// Supports IStream and IPicture COM interfaces.
/// </para>
/// </remarks>
internal unsafe partial class DrawingCom : ComWrappers
{
private const int S_OK = (int)HRESULT.S_OK;
Expand Down Expand Up @@ -52,7 +55,11 @@ protected override object CreateObject(IntPtr externalComObject, CreateObjectFla
Debug.Assert(flags == CreateObjectFlags.UniqueInstance);

Guid pictureIID = IPicture.IID;
#if NET8_0_OR_GREATER
int hr = Marshal.QueryInterface(externalComObject, in pictureIID, out IntPtr comObject);
#else
int hr = Marshal.QueryInterface(externalComObject, ref pictureIID, out IntPtr comObject);
Copy link
Member

Choose a reason for hiding this comment

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

As a note, you could alternatively #pragma warning disable CS.... here for the multi-target case.

ref still works, you just get a warning recommending you use in for clarity.

#endif
if (hr == S_OK)
{
return new PictureWrapper(comObject);
Expand All @@ -71,11 +78,16 @@ internal static IStreamWrapper GetComWrapper(Ole32.IStream stream)
IntPtr streamWrapperPtr = Instance.GetOrCreateComInterfaceForObject(stream, CreateComInterfaceFlags.None);

Guid streamIID = IID_IStream;
int result = Marshal.QueryInterface(streamWrapperPtr, ref streamIID, out IntPtr streamPtr);

#if NET8_0_OR_GREATER
int hr = Marshal.QueryInterface(streamWrapperPtr, in streamIID, out IntPtr streamPtr);
#else
int hr = Marshal.QueryInterface(streamWrapperPtr, ref streamIID, out IntPtr streamPtr);
#endif

Marshal.Release(streamWrapperPtr);

ThrowExceptionForHR(result);
ThrowExceptionForHR(hr);

return new IStreamWrapper(streamPtr);
}
Expand Down Expand Up @@ -308,7 +320,12 @@ public unsafe int SaveAsFile(IntPtr pstm, int fSaveMemCopy, int* pcbSize)
{
// Get the IStream implementation, since the ComWrappers runtime returns a pointer to the IUnknown interface implementation
Guid streamIID = IID_IStream;

#if NET8_0_OR_GREATER
ThrowExceptionForHR(Marshal.QueryInterface(pstm, in streamIID, out IntPtr pstmImpl));
#else
ThrowExceptionForHR(Marshal.QueryInterface(pstm, ref streamIID, out IntPtr pstmImpl));
#endif

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected override object CreateObject(IntPtr externalComObject, CreateObjectFla
|| flags == CreateObjectFlags.None
|| flags == CreateObjectFlags.Unwrap);

int hr = Marshal.QueryInterface(externalComObject, ref IID.GetRef<IErrorInfo>(), out IntPtr errorInfoComObject);
int hr = Marshal.QueryInterface(externalComObject, in IID.GetRef<IErrorInfo>(), out IntPtr errorInfoComObject);
if (hr == S_OK)
{
Marshal.Release(externalComObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
See https://github.com/dotnet/winforms/issues/4649
-->
<NoWarn>$(NoWarn);IL2026;IL2050</NoWarn>
<!--
Libraries code has changed a number of APIs from `ref` to `in`. CSWin32 generates code that passes by `ref`
to some of these. Disabling for now until we can get https://github.com/microsoft/CsWin32/issues/1014 resolved.
-->
<NoWarn>$(NoWarn);CS9195</NoWarn>
<Deterministic>true</Deterministic>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<UsePublicApiAnalyzers>true</UsePublicApiAnalyzers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void Dispose()
if (Value is not null)
{
Marshal.FreeBSTR((nint)Value);
Unsafe.AsRef(this) = default;
Unsafe.AsRef(in this) = default;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ namespace Windows.Win32.Foundation;
public static implicit operator nint(in ComScope<T> scope) => scope._value;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator T**(in ComScope<T> scope) => (T**)Unsafe.AsPointer(ref Unsafe.AsRef(scope._value));
public static implicit operator T**(in ComScope<T> scope) => (T**)Unsafe.AsPointer(ref Unsafe.AsRef(in scope._value));

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator void**(in ComScope<T> scope) => (void**)Unsafe.AsPointer(ref Unsafe.AsRef(scope._value));
public static implicit operator void**(in ComScope<T> scope) => (void**)Unsafe.AsPointer(ref Unsafe.AsRef(in scope._value));

public bool IsNull => _value == 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class PInvoke
public static int FillRect<T>(T hDC, ref RECT lprc, HBRUSH hbr)
where T : IHandle<HDC>
{
int result = FillRect(hDC.Handle, ref lprc, hbr);
int result = FillRect(hDC.Handle, in lprc, hbr);
GC.KeepAlive(hDC.Wrapper);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ public unsafe void ScrollToCaret()

try
{
Marshal.QueryInterface(editOlePtr, ref iiTextDocumentGuid, out iTextDocument);
Marshal.QueryInterface(editOlePtr, in iiTextDocumentGuid, out iTextDocument);

if (Marshal.GetObjectForIUnknown(iTextDocument) is Richedit.ITextDocument textDocument)
{
Expand Down