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 for some of the disposable types. #1369

Merged
merged 2 commits into from
Oct 3, 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
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.

#nullable disable

using System.Threading;

namespace System.Reactive.Disposables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.

#nullable disable

using System.Reactive.Concurrency;
using System.Threading;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.

#nullable disable


namespace System.Reactive.Disposables
{
/// <summary>
/// Represents a disposable resource whose underlying disposable resource can be swapped for another disposable resource.
/// </summary>
public sealed class MultipleAssignmentDisposable : ICancelable
{
private IDisposable _current;
private IDisposable? _current;

/// <summary>
/// Initializes a new instance of the <see cref="MultipleAssignmentDisposable"/> class with no current underlying disposable.
Expand All @@ -30,7 +27,7 @@ public MultipleAssignmentDisposable()
/// Gets or sets the underlying disposable. After disposal, the result of getting this property is undefined.
/// </summary>
/// <remarks>If the <see cref="MultipleAssignmentDisposable"/> has already been disposed, assignment to this property causes immediate disposal of the given disposable object.</remarks>
public IDisposable Disposable
public IDisposable? Disposable
{
get => Disposables.Disposable.GetValueOrDefault(ref _current);
set => Disposables.Disposable.TrySetMultiple(ref _current, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.

#nullable disable

using System.Threading;

namespace System.Reactive.Disposables
Expand All @@ -14,7 +12,9 @@ namespace System.Reactive.Disposables
public sealed class RefCountDisposable : ICancelable
{
private readonly bool _throwWhenDisposed;
private IDisposable _disposable;

private IDisposable? _disposable;

/// <summary>
/// Holds the number of active child disposables and the
/// indicator bit (31) if the main _disposable has been marked
Expand Down Expand Up @@ -167,7 +167,7 @@ private void Release()

private sealed class InnerDisposable : IDisposable
{
private RefCountDisposable _parent;
private RefCountDisposable? _parent;

public InnerDisposable(RefCountDisposable parent)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.

#nullable disable

using System.Reactive.Concurrency;

namespace System.Reactive.Disposables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.

#nullable disable


namespace System.Reactive.Disposables
{
/// <summary>
/// Represents a disposable resource whose underlying disposable resource can be replaced by another disposable resource, causing automatic disposal of the previous underlying disposable resource.
/// </summary>
public sealed class SerialDisposable : ICancelable
{
private IDisposable _current;
private IDisposable? _current;

/// <summary>
/// Initializes a new instance of the <see cref="T:System.Reactive.Disposables.SerialDisposable"/> class.
Expand All @@ -30,7 +27,7 @@ public SerialDisposable()
/// Gets or sets the underlying disposable.
/// </summary>
/// <remarks>If the SerialDisposable has already been disposed, assignment to this property causes immediate disposal of the given disposable object. Assigning this property disposes the previous disposable object.</remarks>
public IDisposable Disposable
public IDisposable? Disposable
{
get => Disposables.Disposable.GetValue(ref _current);
set => Disposables.Disposable.TrySetSerial(ref _current, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.

#nullable disable


namespace System.Reactive.Disposables
{
/// <summary>
Expand All @@ -13,7 +10,7 @@ namespace System.Reactive.Disposables
/// </summary>
public sealed class SingleAssignmentDisposable : ICancelable
{
private IDisposable _current;
private IDisposable? _current;

/// <summary>
/// Initializes a new instance of the <see cref="SingleAssignmentDisposable"/> class.
Expand All @@ -31,7 +28,7 @@ public SingleAssignmentDisposable()
/// Gets or sets the underlying disposable. After disposal, the result of getting this property is undefined.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown if the <see cref="SingleAssignmentDisposable"/> has already been assigned to.</exception>
public IDisposable Disposable
public IDisposable? Disposable
{
get => Disposables.Disposable.GetValueOrDefault(ref _current);
set => Disposables.Disposable.SetSingle(ref _current, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ public interface ICancelable : System.IDisposable
public sealed class MultipleAssignmentDisposable : System.IDisposable, System.Reactive.Disposables.ICancelable
{
public MultipleAssignmentDisposable() { }
public System.IDisposable Disposable { get; set; }
public System.IDisposable? Disposable { get; set; }
public bool IsDisposed { get; }
public void Dispose() { }
}
Expand All @@ -621,14 +621,14 @@ public void Dispose() { }
public sealed class SerialDisposable : System.IDisposable, System.Reactive.Disposables.ICancelable
{
public SerialDisposable() { }
public System.IDisposable Disposable { get; set; }
public System.IDisposable? Disposable { get; set; }
public bool IsDisposed { get; }
public void Dispose() { }
}
public sealed class SingleAssignmentDisposable : System.IDisposable, System.Reactive.Disposables.ICancelable
{
public SingleAssignmentDisposable() { }
public System.IDisposable Disposable { get; set; }
public System.IDisposable? Disposable { get; set; }
public bool IsDisposed { get; }
public void Dispose() { }
}
Expand Down