Skip to content

Commit

Permalink
fix minor code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
georg-jung committed May 19, 2020
1 parent 03a0bcc commit e15db3e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions WoL/Extensions/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public static async Task<T> WithCancellation<T>(this Task<T> task, CancellationT
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);

// This disposes the registration as soon as one of the tasks trigger
using (cancellationToken.Register(state =>
await using (cancellationToken.Register(state =>
{
((TaskCompletionSource<object>)state).TrySetResult(null);
((TaskCompletionSource<object>)state)!.TrySetResult(null);
},
tcs))
{
Expand Down
4 changes: 2 additions & 2 deletions WoL/Pages/Wake.razor
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@

private async Task LoopPinging()
{
int minInterval = 1500;
const int minInterval = 1500;
IsCheckingStatus = true;
while (PingTries < MaxPingTries && (model.Status == HostViewModel.HostStatus.Unreachable || model.Status == HostViewModel.HostStatus.Loading))
{
Expand All @@ -177,7 +177,7 @@

private async Task PingAndSetStatus()
{
var timeout = 2500;
const int timeout = 2500;
LastStatusCheck = DateTime.Now;
var res = await PingService.IsReachable(host.Hostname, TimeSpan.FromMilliseconds(timeout));
model.Status = res.ToHostStatus();
Expand Down
3 changes: 2 additions & 1 deletion WoL/Services/AddressLookupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Threading.Tasks;

namespace WoL.Services
Expand All @@ -12,7 +13,7 @@ public class AddressLookupService : IAddressLookupService
public async Task<(IPAddress, string)> GetIpAndName(string hostname)
{
var res = await Dns.GetHostEntryAsync(hostname).ConfigureAwait(false);
return (res.AddressList.Where(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).First(), res.HostName);
return (res.AddressList.First(ip => ip.AddressFamily == AddressFamily.InterNetwork), res.HostName);
}

public async Task<PhysicalAddress> GetMac(IPAddress ip)
Expand Down
2 changes: 1 addition & 1 deletion WoL/Services/DnsPingServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class DnsPingServiceBase : IPingService
private readonly IAddressLookupService addressLookupService;
private readonly ILogger logger;

public DnsPingServiceBase(IAddressLookupService addressLookupService, ILogger logger)
protected DnsPingServiceBase(IAddressLookupService addressLookupService, ILogger logger)
{
this.addressLookupService = addressLookupService;
this.logger = logger;
Expand Down

0 comments on commit e15db3e

Please sign in to comment.