More Net8.0 nullability fixes

nullableenabled
David Hall 2023-12-30 20:42:33 -07:00
parent 7cb35c9a78
commit 49da77df90
5 changed files with 14 additions and 10 deletions

View File

@ -5084,7 +5084,9 @@ public static partial class NCrypt
/// </summary>
public NCryptBuffer[] pBuffers
{
#pragma warning disable CA2021 // Do not call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
get => _pBuffers.ToIEnum<_NCryptBuffer>((int)cBuffers).Cast<NCryptBuffer>().ToArray();
#pragma warning restore CA2021 // Do not call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
set
{
((IDisposable)this).Dispose();

View File

@ -659,7 +659,9 @@ public static partial class Gdi32
throw new ArgumentException($"The supplied type cannot be enumerated by this function.");
var l = new List<IntPtr>();
EnumObjects(hdc, ev, EnumProc);
#pragma warning disable CA2021 // Do not call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
return l.Cast<T>();
#pragma warning restore CA2021 // Do not call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
int EnumProc(IntPtr Arg1, IntPtr Arg2)
{

View File

@ -35,7 +35,7 @@ public class ShellDataObject : DataObject
/// <summary>Initializes a new instance of the <see cref="ShellDataObject"/> class.</summary>
/// <param name="items">A list of ShellItem instances.</param>
public ShellDataObject(IEnumerable<ShellItem> items) : base((items as ShellItemArray ?? new ShellItemArray(items)).ToDataObject())
public ShellDataObject(IEnumerable<ShellItem> items) : base((items as ShellItemArray ?? new ShellItemArray(items)).ToDataObject()!)
{
}
@ -58,7 +58,7 @@ public class ShellDataObject : DataObject
/// </summary>
public System.Globalization.CultureInfo Culture
{
get => base.GetDataPresent(DataFormats.Locale) ? new((int)base.GetData(DataFormats.Locale, false)) : System.Globalization.CultureInfo.CurrentCulture;
get => base.GetDataPresent(DataFormats.Locale) ? new((int)base.GetData(DataFormats.Locale, false)!) : System.Globalization.CultureInfo.CurrentCulture;
set => base.SetData(DataFormats.Locale, false, value.LCID);
}
@ -74,7 +74,7 @@ public class ShellDataObject : DataObject
/// <value><see langword="true"/> if the data object is within a drag-and-drop loop; otherwise, <see langword="false"/>.</value>
public bool InDragLoop
{
get => base.GetDataPresent(ShellClipboardFormat.CFSTR_INDRAGLOOP) && (int)base.GetData(ShellClipboardFormat.CFSTR_INDRAGLOOP, false) != 0;
get => base.GetDataPresent(ShellClipboardFormat.CFSTR_INDRAGLOOP) && (int)base.GetData(ShellClipboardFormat.CFSTR_INDRAGLOOP, false)! != 0;
set => base.SetData(ShellClipboardFormat.CFSTR_INDRAGLOOP, false, value ? 1 : 0);
}
@ -109,7 +109,7 @@ public class ShellDataObject : DataObject
/// <value>Specifies whether its preferred method of data transfer is move or copy.</value>
public DragDropEffects PreferredDropEffect
{
get => base.GetDataPresent(ShellClipboardFormat.CFSTR_PREFERREDDROPEFFECT) ? (DragDropEffects)(int)base.GetData(ShellClipboardFormat.CFSTR_PREFERREDDROPEFFECT, false) : 0;
get => base.GetDataPresent(ShellClipboardFormat.CFSTR_PREFERREDDROPEFFECT) ? (DragDropEffects)(int)base.GetData(ShellClipboardFormat.CFSTR_PREFERREDDROPEFFECT, false)! : 0;
set => base.SetData(ShellClipboardFormat.CFSTR_PREFERREDDROPEFFECT, false, (int)value);
}
@ -124,7 +124,7 @@ public class ShellDataObject : DataObject
/// <value>The CLSID.</value>
public Guid TargetClsid
{
get => base.GetDataPresent(ShellClipboardFormat.CFSTR_TARGETCLSID) ? (Guid)base.GetData(ShellClipboardFormat.CFSTR_TARGETCLSID, false) : default;
get => base.GetDataPresent(ShellClipboardFormat.CFSTR_TARGETCLSID) ? (Guid)base.GetData(ShellClipboardFormat.CFSTR_TARGETCLSID, false)! : default;
set => base.SetData(ShellClipboardFormat.CFSTR_TARGETCLSID, false, value);
}
@ -187,7 +187,7 @@ public class ShellDataObject : DataObject
case ShellClipboardFormat.CFSTR_SHELLIDLIST:
return GetShellIdList() ?? new ShellItemArray();
}
return base.GetData(format, autoConvert);
return base.GetData(format, autoConvert)!;
}
/// <summary>Retrieves the data associated with the specified data format at the specified index.</summary>
@ -272,7 +272,7 @@ public class ShellDataObject : DataObject
/// <param name="data">The data.</param>
/// <returns></returns>
/// <exception cref="ArgumentException">Data value must be of type DROPDESCRIPTION., nameof(data)</exception>
public override void SetData(string format, object data)
public override void SetData(string format, object? data)
{
if (format == ShellClipboardFormat.CFSTR_DROPDESCRIPTION)
{

View File

@ -242,7 +242,7 @@ public class ShellBrowser : UserControl, IWin32Window, IShellBrowser, Shell32.IS
/// </summary>
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override Image BackgroundImage => base.BackgroundImage;
public override Image BackgroundImage => base.BackgroundImage!;
/// <inheritdoc/>
protected override Size DefaultSize => new(200, 150);
@ -614,7 +614,7 @@ public class ShellBrowser : UserControl, IWin32Window, IShellBrowser, Shell32.IS
{
var forward = (keyData & Keys.Shift) != Keys.Shift;
Parent.SelectNextControl(ActiveControl, forward: forward, tabStopOnly: true, nested: true, wrap: true);
Parent!.SelectNextControl(ActiveControl, forward: forward, tabStopOnly: true, nested: true, wrap: true);
return true;
}

View File

@ -10,7 +10,7 @@ public partial class ThumbnailToolbarButton
private string key = string.Empty;
private bool useIntegerIndex = true;
public virtual int ActualIndex => useIntegerIndex ? Index : (ImageList is null ? -1 : ImageList.Images.IndexOfKey(Key));
public virtual int ActualIndex => useIntegerIndex ? Index : (ImageList is null ? -1 : ImageList.Images.IndexOfKey(Key ?? ""));
public virtual ImageList? ImageList { get; set; }