Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable nullable reference types for System.Windows.Forms.Primitives #3451

Merged
merged 16 commits into from
Jun 18, 2020
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;

internal static partial class Interop
Expand All @@ -27,10 +28,11 @@ public struct ToolInfoWrapper<T>
where T : IHandle
{
public TTOOLINFOW Info;
public string Text { get; set; }
public string? Text { get; set; }
[MaybeNull]
private readonly T _handle;

public unsafe ToolInfoWrapper(T handle, TTF flags = default, string text = null)
public unsafe ToolInfoWrapper(T handle, TTF flags = default, string? text = null)
{
Info = new TTOOLINFOW
{
Expand All @@ -42,7 +44,7 @@ public unsafe ToolInfoWrapper(T handle, TTF flags = default, string text = null)
_handle = handle;
}

public unsafe ToolInfoWrapper(T handle, IntPtr id, TTF flags = default, string text = null, RECT rect = default)
public unsafe ToolInfoWrapper(T handle, IntPtr id, TTF flags = default, string? text = null, RECT rect = default)
{
Info = new TTOOLINFOW
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public struct BITMAPINFO
public BITMAPINFOHEADER bmiHeader;

[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxColorSize * 4)]
public byte[] bmiColors; // RGBQUAD structs: repeating Blue-Green-Red-Reserved
public byte[]? bmiColors; // RGBQUAD structs: repeating Blue-Green-Red-Reserved
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ internal static partial class Gdi32
/// Calling with ("DISPLAY", null, null, IntPtr.Zero) will retrieve a DC for the entire desktop.
/// </remarks>
[DllImport(Libraries.Gdi32, SetLastError = true, CharSet = CharSet.Unicode)]
public static extern IntPtr CreateDC(string lpszDriver, string lpszDeviceName, string lpszOutput, IntPtr devMode);
public static extern IntPtr CreateDC(string lpszDriver, string? lpszDeviceName, string? lpszOutput, IntPtr devMode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void OnAppActivate(
/// </param>
[PreserveSig]
void OnActivationChange(
IMsoComponent pic,
IMsoComponent? pic,
BOOL fSameComponent,
MSOCRINFO* pcrinfo,
BOOL fHostIsActivating,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class OLEVERB
{
public OLEIVERB lVerb;
[MarshalAs(UnmanagedType.LPWStr)]
public string lpszVerbName;
public string? lpszVerbName;
public User32.MF fuFlags;
public OLEVERBATTRIB grfAttribs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ internal static partial class Ole32
public sealed class QACONTAINER
{
public uint cbSize;
public IOleClientSite pClientSite;
public IAdviseSink pAdviseSink;
public IPropertyNotifySink pPropertyNotifySink;
public IOleClientSite? pClientSite;
public IAdviseSink? pAdviseSink;
public IPropertyNotifySink? pPropertyNotifySink;
[MarshalAs(UnmanagedType.Interface)]
public object pUnkEventSink;
public object? pUnkEventSink;
public QACONTAINERFLAGS dwAmbientFlags;
public uint colorFore;
public uint colorBack;
public IFont pFont;
public IFont? pFont;
public IntPtr pUndoMgr;
public uint dwAppearance;
public int lcid;
public IntPtr hpal;
public IServiceProvider pBindHost;
public IServiceProvider? pBindHost;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public struct STATSTG
public uint grfStateBits;
public uint reserved;

public string GetName() => Marshal.PtrToStringUni(pwcsName);
public string? GetName() => Marshal.PtrToStringUni(pwcsName);

/// <summary>
/// Caller is responsible for freeing the name memory.
Expand All @@ -76,7 +76,7 @@ public void FreeName()
/// <summary>
/// Callee is repsonsible for allocating the name memory.
/// </summary>
public void AllocName(string name)
public void AllocName(string? name)
{
pwcsName = Marshal.StringToCoTaskMemUni(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static partial class Oleaut32
public struct FONTDESC
{
public uint cbSizeOfStruct;
public string lpstrName;
public string? lpstrName;
public long cySize;
public short sWeight;
public short sCharset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ HRESULT Skip(

[PreserveSig]
HRESULT Clone(
[Out, MarshalAs(UnmanagedType.LPArray)] IEnumVariant[] ppEnum);
[Out, MarshalAs(UnmanagedType.LPArray)] IEnumVariant[]? ppEnum);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -45,7 +45,7 @@ public void Clear()

public void Dispose() => Clear();

public object ToObject()
public object? ToObject()
{
IntPtr val = data1;
long longVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public unsafe ref struct VARIANTVector
{
public VARIANT[] Variants;

public VARIANTVector(object[] values)
public VARIANTVector(object[]? values)
{
if (values == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal static partial class Interop
internal static partial class Shell32
{
[DllImport(Libraries.Shell32, ExactSpelling = true, EntryPoint = "DragQueryFileW", CharSet = CharSet.Unicode)]
private static extern uint DragQueryFileWInternal(IntPtr hDrop, uint iFile, StringBuilder lpszFile, uint cch);
private static extern uint DragQueryFileWInternal(IntPtr hDrop, uint iFile, StringBuilder? lpszFile, uint cch);

public static uint DragQueryFileW(IntPtr hDrop, uint iFile, StringBuilder lpszFile)
public static uint DragQueryFileW(IntPtr hDrop, uint iFile, StringBuilder? lpszFile)
{
if (lpszFile == null || lpszFile.Capacity == 0 || iFile == 0xFFFFFFFF)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public unsafe struct BROWSEINFO
{
public IntPtr hwndOwner;

public CoTaskMemSafeHandle pidlRoot;
public CoTaskMemSafeHandle? pidlRoot;

public char* pszDisplayName;

public string lpszTitle;
public string? lpszTitle;

public uint ulFlags;

public BrowseCallbackProc lpfn;
public BrowseCallbackProc? lpfn;

public IntPtr lParam;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static partial class Shell32
[DllImport(Libraries.Shell32, ExactSpelling = true)]
private static extern BOOL SHGetPathFromIDListEx(IntPtr pidl, IntPtr pszPath, int cchPath, int flags);

public static bool SHGetPathFromIDListLongPath(IntPtr pidl, out string path)
public static bool SHGetPathFromIDListLongPath(IntPtr pidl, out string? path)
{
IntPtr pszPath = Marshal.AllocHGlobal((Kernel32.MAX_PATH + 1) * sizeof(char));
int length = Kernel32.MAX_PATH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public unsafe interface IAccessibleEx
/// IAccessible. Only idChild values that do not have a corresponding
/// IAccessible can be used here.
/// </summary>
IAccessibleEx GetObjectForChild(int idChild);
IAccessibleEx? GetObjectForChild(int idChild);

/// <summary>
/// Returns an IAccessible and idChild pair for this IAccessibleEx.
Expand All @@ -37,11 +37,11 @@ public unsafe interface IAccessibleEx
/// </summary>
[PreserveSig]
HRESULT GetIAccessiblePair(
[MarshalAs(UnmanagedType.Interface)] out object ppAcc,
[MarshalAs(UnmanagedType.Interface)] out object? ppAcc,
int* pidChild);

[return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_I4)]
int[] GetRuntimeId();
int[]? GetRuntimeId();

/// <summary>
/// Some wrapper-based implementations (notably UIABridge) can't reasonably wrap all
Expand All @@ -58,7 +58,7 @@ HRESULT GetIAccessiblePair(
[PreserveSig]
HRESULT ConvertReturnedElement(
IRawElementProviderSimple pIn,
out IAccessibleEx ppRetValOut);
out IAccessibleEx? ppRetValOut);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface IAccessibleInternal
[return: MarshalAs(UnmanagedType.IDispatch)]
[DispId(unchecked((int)0xFFFFEC78))]
[TypeLibFunc(0x0040)]
object get_accParent();
object? get_accParent();

[DispId(unchecked((int)0xFFFFEC77))]
[TypeLibFunc(0x0040)]
Expand All @@ -26,39 +26,39 @@ public interface IAccessibleInternal
[return: MarshalAs(UnmanagedType.IDispatch)]
[TypeLibFunc(0x0040)]
[DispId(unchecked((int)0xFFFFEC76))]
object get_accChild(
object? get_accChild(
[MarshalAs(UnmanagedType.Struct)] object varChild);

[DispId(unchecked((int)0xFFFFEC75))]
[TypeLibFunc(0x0040)]
string get_accName(
string? get_accName(
[Optional][MarshalAs(UnmanagedType.Struct)] object varChild);

[TypeLibFunc(0x0040)]
[DispId(unchecked((int)0xFFFFEC74))]
string get_accValue(
string? get_accValue(
[Optional][MarshalAs(UnmanagedType.Struct)] object varChild);

[DispId(unchecked((int)0xFFFFEC73))]
[TypeLibFunc(0x0040)]
string get_accDescription(
string? get_accDescription(
[Optional][MarshalAs(UnmanagedType.Struct)] object varChild);

[return: MarshalAs(UnmanagedType.Struct)]
[DispId(unchecked((int)0xFFFFEC72))]
[TypeLibFunc(0x0040)]
object get_accRole(
object? get_accRole(
[Optional][MarshalAs(UnmanagedType.Struct)] object varChild);

[return: MarshalAs(UnmanagedType.Struct)]
[TypeLibFunc(0x0040)]
[DispId(unchecked((int)0xFFFFEC71))]
object get_accState(
object? get_accState(
[Optional][MarshalAs(UnmanagedType.Struct)] object varChild);

[TypeLibFunc(0x0040)]
[DispId(unchecked((int)0xFFFFEC70))]
string get_accHelp(
string? get_accHelp(
[Optional][MarshalAs(UnmanagedType.Struct)] object varChild);

[DispId(unchecked((int)0xFFFFEC6F))]
Expand All @@ -69,23 +69,23 @@ int get_accHelpTopic(

[DispId(unchecked((int)0xFFFFEC6E))]
[TypeLibFunc(0x0040)]
string get_accKeyboardShortcut(
string? get_accKeyboardShortcut(
[Optional][MarshalAs(UnmanagedType.Struct)] object varChild);

[return: MarshalAs(UnmanagedType.Struct)]
[DispId(unchecked((int)0xFFFFEC6D))]
[TypeLibFunc(0x0040)]
object get_accFocus();
object? get_accFocus();

[return: MarshalAs(UnmanagedType.Struct)]
[DispId(unchecked((int)0xFFFFEC6C))]
[TypeLibFunc(0x0040)]
object get_accSelection();
object? get_accSelection();

[return: MarshalAs(UnmanagedType.BStr)]
[TypeLibFunc(0x0040)]
[DispId(unchecked((int)0xFFFFEC6B))]
string get_accDefaultAction(
string? get_accDefaultAction(
[Optional][MarshalAs(UnmanagedType.Struct)] object varChild);

[DispId(unchecked((int)0xFFFFEC6A))]
Expand All @@ -106,14 +106,14 @@ void accLocation(
[return: MarshalAs(UnmanagedType.Struct)]
[TypeLibFunc(0x0040)]
[DispId(unchecked((int)0xFFFFEC68))]
object accNavigate(
object? accNavigate(
int navDir,
[Optional][MarshalAs(UnmanagedType.Struct)] object varStart);

[return: MarshalAs(UnmanagedType.Struct)]
[TypeLibFunc(0x0040)]
[DispId(unchecked((int)0xFFFFEC67))]
object accHitTest(
object? accHitTest(
int xLeft,
int yTop);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface IGridItemProvider

int ColumnSpan { get; }

IRawElementProviderSimple ContainingGrid { get; }
IRawElementProviderSimple? ContainingGrid { get; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static partial class UiaCore
public interface IGridProvider
{
[return: MarshalAs(UnmanagedType.IUnknown)]
object /*IRawElementProviderSimple*/ GetItem(int row, int column);
object? /*IRawElementProviderSimple*/ GetItem(int row, int column);

int RowCount { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@ public interface ILegacyIAccessibleProvider

void SetValue([MarshalAs(UnmanagedType.LPWStr)] string szValue);

IAccessible GetIAccessible();
IAccessible? GetIAccessible();

int ChildId { get; }

string Name { get; }
string? Name { get; }

string Value { get; }
string? Value { get; }

string Description { get; }
string? Description { get; }

uint Role { get; }

uint State { get; }

string Help { get; }
string? Help { get; }

string KeyboardShortcut { get; }
string? KeyboardShortcut { get; }

object[] /* IRawElementProviderSimple[] */ GetSelection();
object[]? /* IRawElementProviderSimple[] */ GetSelection();

string DefaultAction { get; }
string? DefaultAction { get; }
}
}
}
Loading