Skip to content

Code review#1

Open
Milos-Curcic-MS wants to merge 7 commits into
masterfrom
code-review
Open

Code review#1
Milos-Curcic-MS wants to merge 7 commits into
masterfrom
code-review

Conversation

@Milos-Curcic-MS
Copy link
Copy Markdown
Owner

No description provided.

@nimiljko
Copy link
Copy Markdown
Collaborator

Add readme.md on how application should be used,
Add --help or -h flag which will print out help to users.
Add a bit more descriptive info on how to use inside of application(line 274 e.g.)

using System.Text.RegularExpressions;
using System.Diagnostics;

namespace Connectivity_Tester
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CamelCase, no underscores

Console.WriteLine($"\t\tSupports IPv6: {networkInterface.Supports(System.Net.NetworkInformation.NetworkInterfaceComponent.IPv6)}");

Console.WriteLine("\t\tUnicast address list:");
if (properties.UnicastAddresses.Count == 0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the count is checked then iterated, can it be done by just iterating UnicastAddresses ?


Console.WriteLine($"\t{host} resolved to:");

if (entry.AddressList.Length == 0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above here, no need to check count if foreach will be used.


public static IPAddress[] TestSubnetConnectivity(string subnetAddressPrefix, int port, IPAddress[] resolvedAddresses = null)
{
string[] split = subnetAddressPrefix.Split('.', '/');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comments of what is done here

ip[2]++;
ip[3] = 0;
}
else
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
}


var sucConnections = new LinkedList<IPAddress>();

for (int i = 0; i < (int)Math.Pow(2, 32 - mask); i++)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment what is done here

asyncResults.Add(client, ipAddress);
client.BeginConnect(ipAddress, port, null, null);

if ((i + 1) % 16777216 == 0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too

{
static class ConnectivityTester
{
private const double TimeLimitSeconds = 10.0;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add cli argument for these constants so that user can change these parameters.

Console.WriteLine($"\t\tInterface description: {networkInterface.Description}");
Console.WriteLine($"\t\tInterface type: {networkInterface.NetworkInterfaceType}");
Console.WriteLine($"\t\tOperational status: {networkInterface.OperationalStatus}");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No Double lines.


Console.WriteLine("\t\tDNS server address list:");

foreach (var address in properties.DnsAddresses)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just suggestion to try using JOIN instead of foreach loops.

https://docs.microsoft.com/en-us/dotnet/api/system.string.join?view=netframework-4.8

IPAddress[] successfulConnections = TestSubnetConnectivity(args[0], 1433, resolvedAddresses);
MeasureAverageResponseTimeForSuccessfulConnections(successfulConnections, 1433);
PingTCP(args[1], 3342);
} catch (Exception e)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit separate line

Copy link
Copy Markdown
Collaborator

@nimiljko nimiljko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants