Skip to content

Commit

Permalink
Nullable: src\System\Runtime\InteropServices (dotnet/coreclr#23936)
Browse files Browse the repository at this point in the history
* Nullable: src\System\Runtime\InteropServices

* Address PR feedback

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
  • Loading branch information
stephentoub authored and jkotas committed Apr 19, 2019
1 parent eae1fa9 commit fe20ef4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/System.Private.CoreLib/shared/System/Delegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public abstract partial class Delegate : ICloneable, ISerializable
{
public virtual object Clone() => MemberwiseClone();

public static Delegate? Combine(Delegate? a, Delegate? b)
public static Delegate? Combine(Delegate? a, Delegate? b) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
{
if (a is null)
return b;

return a.CombineImpl(b);
}

public static Delegate? Combine(params Delegate?[]? delegates)
public static Delegate? Combine(params Delegate?[]? delegates) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
{
if (delegates == null || delegates.Length == 0)
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/System.Private.CoreLib/shared/System/Gen2GcCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static void Register(Func<object, bool> callback, object targetObj)
~Gen2GcCallback()
{
// Check to see if the target object is still alive.
object targetObj = _weakTargetObj.Target;
object? targetObj = _weakTargetObj.Target;
if (targetObj == null)
{
// The target object is dead, so this callback object is no longer needed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
Expand Down Expand Up @@ -34,7 +35,7 @@ public partial struct GCHandle
private IntPtr _handle;

// Allocate a handle storing the object and the type.
private GCHandle(object value, GCHandleType type)
private GCHandle(object? value, GCHandleType type)
{
// Make sure the type parameter is within the valid range for the enum.
if ((uint)type > (uint)GCHandleType.Pinned) // IMPORTANT: This must be kept in sync with the GCHandleType enum.
Expand Down Expand Up @@ -64,13 +65,13 @@ private GCHandle(object value, GCHandleType type)
/// <summary>Creates a new GC handle for an object.</summary>
/// <param name="value">The object that the GC handle is created for.</param>
/// <returns>A new GC handle that protects the object.</returns>
public static GCHandle Alloc(object value) => new GCHandle(value, GCHandleType.Normal);
public static GCHandle Alloc(object? value) => new GCHandle(value, GCHandleType.Normal);

/// <summary>Creates a new GC handle for an object.</summary>
/// <param name="value">The object that the GC handle is created for.</param>
/// <param name="type">The type of GC handle to create.</param>
/// <returns>A new GC handle that protects the object.</returns>
public static GCHandle Alloc(object value, GCHandleType type) => new GCHandle(value, type);
public static GCHandle Alloc(object? value, GCHandleType type) => new GCHandle(value, type);

/// <summary>Frees a GC handle.</summary>
public void Free()
Expand All @@ -82,7 +83,7 @@ public void Free()
}

// Target property - allows getting / updating of the handle's referent.
public object Target
public object? Target
{
get
{
Expand Down Expand Up @@ -168,7 +169,7 @@ public static GCHandle FromIntPtr(IntPtr value)

public override int GetHashCode() => _handle.GetHashCode();

public override bool Equals(object o) => o is GCHandle && _handle == ((GCHandle)o)._handle;
public override bool Equals(object? o) => o is GCHandle && _handle == ((GCHandle)o)._handle;

public static bool operator ==(GCHandle a, GCHandle b) => a._handle == b._handle;

Expand Down

0 comments on commit fe20ef4

Please sign in to comment.