Skip to content

Commit

Permalink
Fix IDE hints.
Browse files Browse the repository at this point in the history
  • Loading branch information
CXuesong committed Mar 21, 2020
1 parent 278b5e6 commit 82fbf7e
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 36 deletions.
3 changes: 1 addition & 2 deletions JsonRpc.AspNetCore/AspNetCoreFeatureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ internal class AspNetCoreFeatureCollection : IFeatureCollection

public AspNetCoreFeatureCollection(IFeatureCollection baseCollection, HttpContext context)
{
if (context == null) throw new ArgumentNullException(nameof(context));
BaseCollection = baseCollection;
Context = context;
Context = context ?? throw new ArgumentNullException(nameof(context));
}

public IFeatureCollection BaseCollection { get; }
Expand Down
3 changes: 1 addition & 2 deletions JsonRpc.AspNetCore/JsonRpcBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ internal class JsonRpcBuilder : IJsonRpcBuilder
public JsonRpcBuilder(JsonRpcOptions options, IServiceCollection serviceCollection)
{
if (options == null) throw new ArgumentNullException(nameof(options));
if (serviceCollection == null) throw new ArgumentNullException(nameof(serviceCollection));
this.serviceCollection = serviceCollection;
this.serviceCollection = serviceCollection ?? throw new ArgumentNullException(nameof(serviceCollection));
injectServices = options.InjectServiceTypes;
serviceHostBuilder = new JsonRpcServiceHostBuilder
{
Expand Down
25 changes: 25 additions & 0 deletions JsonRpc.Commons/Client/Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ namespace JsonRpc.Client
#endif
public class JsonRpcClientException : Exception
{
public JsonRpcClientException()
: this(null, null)
{
}

public JsonRpcClientException(string message)
: this(message, null)
{
Expand All @@ -43,6 +48,16 @@ protected JsonRpcClientException(SerializationInfo info, StreamingContext contex
#endif
public class JsonRpcContractException : JsonRpcClientException
{
public JsonRpcContractException()
: this(null, null, null)
{
}

public JsonRpcContractException(string message)
: this(message, null, null)
{
}

public JsonRpcContractException(string message, Exception innerException)
: this(message, null, innerException)
{
Expand Down Expand Up @@ -91,6 +106,16 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
#endif
public class JsonRpcRemoteException : JsonRpcClientException
{
public JsonRpcRemoteException()
: this(null, null, null)
{
}

public JsonRpcRemoteException(string message)
: this(message, null, null)
{
}

public JsonRpcRemoteException(string message, Exception innerException)
: this(message, null, innerException)
{
Expand Down
3 changes: 1 addition & 2 deletions JsonRpc.Commons/Client/JsonRpcClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public class JsonRpcClient
/// <param name="handler">Handler used to transmit the messages.</param>
public JsonRpcClient(IJsonRpcClientHandler handler)
{
if (handler == null) throw new ArgumentNullException(nameof(handler));
Handler = handler;
Handler = handler ?? throw new ArgumentNullException(nameof(handler));
requestIdPrefix = RuntimeHelpers.GetHashCode(this) + "#";
}

Expand Down
3 changes: 1 addition & 2 deletions JsonRpc.Commons/Contracts/IJsonValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public JsonValueConverter() : this(defaultSerializer)

public JsonValueConverter(JsonSerializer serializer)
{
if (serializer == null) throw new ArgumentNullException(nameof(serializer));
this.serializer = serializer;
this.serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
}

/// <inheritdoc />
Expand Down
3 changes: 1 addition & 2 deletions JsonRpc.Commons/Messages/MessageEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ public class MessageEventArgs : EventArgs

public MessageEventArgs(Message message)
{
if (message == null) throw new ArgumentNullException(nameof(message));
Message = message;
Message = message ?? throw new ArgumentNullException(nameof(message));
}
}
}
3 changes: 1 addition & 2 deletions JsonRpc.Commons/Server/JsonRpcServerHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public abstract class JsonRpcServerHandler

public JsonRpcServerHandler(IJsonRpcServiceHost serviceHost)
{
if (serviceHost == null) throw new ArgumentNullException(nameof(serviceHost));
ServiceHost = serviceHost;
ServiceHost = serviceHost ?? throw new ArgumentNullException(nameof(serviceHost));
}

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions JsonRpc.Commons/Server/JsonRpcServiceHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ internal class JsonRpcServiceHost : IJsonRpcServiceHost

internal JsonRpcServiceHost(JsonRpcServerContract contract)
{
if (contract == null) throw new ArgumentNullException(nameof(contract));
Contract = contract;
Contract = contract ?? throw new ArgumentNullException(nameof(contract));
}

internal JsonRpcServerContract Contract { get; }
Expand Down
6 changes: 2 additions & 4 deletions JsonRpc.Commons/Server/RequestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ public class RequestContext
public RequestContext(IJsonRpcServiceHost serviceHost, IServiceFactory serviceFactory,
IFeatureCollection features, RequestMessage request, CancellationToken cancellationToken)
{
if (serviceHost == null) throw new ArgumentNullException(nameof(serviceHost));
if (request == null) throw new ArgumentNullException(nameof(request));
ServiceHost = serviceHost;
ServiceHost = serviceHost ?? throw new ArgumentNullException(nameof(serviceHost));
ServiceFactory = serviceFactory;
Request = request;
Request = request ?? throw new ArgumentNullException(nameof(request));
Features = features;
if (!request.IsNotification)
Response = new ResponseMessage(request.Id);
Expand Down
6 changes: 2 additions & 4 deletions JsonRpc.Streams/ByLineTextMessageReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ public ByLineTextMessageReader(TextReader reader) : this(reader, "\n")
/// <remarks>Empty messages separated by <paramref name="delimiter"/> will be ignored.</remarks>
public ByLineTextMessageReader(TextReader reader, string delimiter)
{
if (reader == null) throw new ArgumentNullException(nameof(reader));
if (string.IsNullOrEmpty(delimiter)) throw new ArgumentException("delimiter cannot be null or empty.", nameof(delimiter));
Reader = reader;
Reader = reader ?? throw new ArgumentNullException(nameof(reader));
Delimiter = delimiter;
delimiterArray = delimiter.ToCharArray();
}
Expand All @@ -58,9 +57,8 @@ public ByLineTextMessageReader(Stream stream) : this(stream, "\n")
/// <remarks>Empty messages separated by <paramref name="delimiter"/> will be ignored.</remarks>
public ByLineTextMessageReader(Stream stream, string delimiter)
{
if (stream == null) throw new ArgumentNullException(nameof(stream));
if (string.IsNullOrEmpty(delimiter)) throw new ArgumentException("delimiter cannot be null or empty.", nameof(delimiter));
underlyingStream = stream;
underlyingStream = stream ?? throw new ArgumentNullException(nameof(stream));
Reader = new StreamReader(stream, Utility.UTF8NoBom, false, 1024, true);
Delimiter = delimiter;
delimiterArray = delimiter.ToCharArray();
Expand Down
6 changes: 2 additions & 4 deletions JsonRpc.Streams/ByLineTextMessageWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ public ByLineTextMessageWriter(TextWriter writer) : this(writer, "\n")
/// </param>
public ByLineTextMessageWriter(TextWriter writer, string delimiter)
{
if (writer == null) throw new ArgumentNullException(nameof(writer));
if (string.IsNullOrEmpty(delimiter)) throw new ArgumentException("delimiter cannot be null or empty.", nameof(delimiter));
Writer = writer;
Writer = writer ?? throw new ArgumentNullException(nameof(writer));
Delimiter = delimiter;
}

Expand All @@ -60,8 +59,7 @@ public ByLineTextMessageWriter(Stream stream) : this(stream, "\n")
/// <param name="delimiter">The delimiter between the messages.</param>
public ByLineTextMessageWriter(Stream stream, string delimiter)
{
if (stream == null) throw new ArgumentNullException(nameof(stream));
underlyingStream = stream;
underlyingStream = stream ?? throw new ArgumentNullException(nameof(stream));
Writer = new StreamWriter(stream);
Delimiter = delimiter;
}
Expand Down
3 changes: 1 addition & 2 deletions JsonRpc.Streams/PartwiseStreamMessageReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public class PartwiseStreamMessageReader : QueuedMessageReader
/// <param name="stream">The stream to read messages from.</param>
public PartwiseStreamMessageReader(Stream stream)
{
if (stream == null) throw new ArgumentNullException(nameof(stream));
Stream = stream;
Stream = stream ?? throw new ArgumentNullException(nameof(stream));
}

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions JsonRpc.Streams/PartwiseStreamMessageWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public class PartwiseStreamMessageWriter : MessageWriter
/// <param name="stream">The stream to write messages to.</param>
public PartwiseStreamMessageWriter(Stream stream)
{
if (stream == null) throw new ArgumentNullException(nameof(stream));
Stream = stream;
Stream = stream ?? throw new ArgumentNullException(nameof(stream));
}

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions UnitTestProject1/Helpers/JsonRpcHttpMessageDirectHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public class JsonRpcHttpMessageDirectHandler : HttpMessageHandler

public JsonRpcHttpMessageDirectHandler(IJsonRpcServiceHost serviceHost)
{
if (serviceHost == null) throw new ArgumentNullException(nameof(serviceHost));
ServiceHost = serviceHost;
ServiceHost = serviceHost ?? throw new ArgumentNullException(nameof(serviceHost));
}

public IJsonRpcServiceHost ServiceHost { get; }
Expand Down
6 changes: 2 additions & 4 deletions UnitTestProject1/Helpers/TestLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ public class TestLoggerProvider : ILoggerProvider

public TestLoggerProvider(ITestOutputHelper outputHelper)
{
if (outputHelper == null) throw new ArgumentNullException(nameof(outputHelper));
OutputHelper = outputHelper;
OutputHelper = outputHelper ?? throw new ArgumentNullException(nameof(outputHelper));
}

public ITestOutputHelper OutputHelper { get; }
Expand All @@ -33,8 +32,7 @@ public class TestLogger : ILogger

public TestLogger(ITestOutputHelper outputHelper, string name)
{
if (outputHelper == null) throw new ArgumentNullException(nameof(outputHelper));
OutputHelper = outputHelper;
OutputHelper = outputHelper ?? throw new ArgumentNullException(nameof(outputHelper));
Name = name;
}

Expand Down

0 comments on commit 82fbf7e

Please sign in to comment.