Skip to content

Commit

Permalink
Merge branch 'feature/stylecop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
coder2000 committed Jun 8, 2018
2 parents c8059aa + ab07fff commit cbf984f
Show file tree
Hide file tree
Showing 17 changed files with 314 additions and 197 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ coverage.xml
coverage.json
coverage-hits.txt

Cake/
tools/
!tools/packages.config
!tools/packages.config.md5sum
!tools/tools.csproj

# Build Results of an ATL Project
[Dd]ebugPS/
Expand Down
29 changes: 27 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#addin "nuget:?package=Cake.Sonar"
#tool "nuget:?package=MSBuild.SonarQube.Runner.Tool"

///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var target = Argument("target", "Sonar");
var configuration = Argument("configuration", "Debug");

///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
Expand Down Expand Up @@ -38,6 +41,28 @@ Task("Restore")
DotNetCoreRestore(projectDir);
});

Task("SonarBegin")
.Does(() => {
SonarBegin(new SonarBeginSettings{
Url = "https://sonarcloud.io",
Key = "dns",
Organization = "coder2000-github",
Login = "6a7700a6bfbe29e25e38e7996631c142ef24480a"
});
});

Task("SonarEnd")
.Does(() => {
SonarEnd(new SonarEndSettings{
Login = "6a7700a6bfbe29e25e38e7996631c142ef24480a"
});
});

Task("Sonar")
.IsDependentOn("SonarBegin")
.IsDependentOn("Build")
.IsDependentOn("SonarEnd");

Task("Build")
.IsDependentOn("Restore")
.Does(() => {
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ CAKE_ARGUMENTS=()
for i in "$@"; do
case $1 in
-s|--script) SCRIPT="$2"; shift ;;
-t|--target) TARGET="$2"; shift ;;
--version) SHOW_VERSION=true ;;
--) shift; CAKE_ARGUMENTS+=("$@"); break ;;
*) CAKE_ARGUMENTS+=("$1") ;;
esac
Expand Down
17 changes: 17 additions & 0 deletions src/Ubiety.Dns.Core/AdditionalRR.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Ubiety.Dns.Core
{
/// <summary>
/// Additional resource record
/// </summary>
public class AdditionalRR : ResourceRecord
{
/// <summary>
/// Initializes a new instance of the <see cref="AdditionalRR" /> class
/// </summary>
/// <param name="br"><see cref="ResourceRecord" /> for the record data</param>
public AdditionalRR(RecordReader br)
: base(br)
{
}
}
}
17 changes: 17 additions & 0 deletions src/Ubiety.Dns.Core/AnswerRR.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Ubiety.Dns.Core
{
/// <summary>
/// Answer resource record
/// </summary>
public class AnswerRR : ResourceRecord
{
/// <summary>
/// Initializes a new instance of the <see cref="AnswerRR" /> class
/// </summary>
/// <param name="br"><see cref="RecordReader" /> for the record data</param>
public AnswerRR(RecordReader br)
: base(br)
{
}
}
}
17 changes: 17 additions & 0 deletions src/Ubiety.Dns.Core/AuthorityRR.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Ubiety.Dns.Core
{
/// <summary>
/// Authority resource record
/// </summary>
public class AuthorityRR : ResourceRecord
{
/// <summary>
/// Initializes a new instance of the <see cref="AuthorityRR" /> class
/// </summary>
/// <param name="br"><see cref="ResourceRecord" /> for the record data</param>
public AuthorityRR(RecordReader br)
: base(br)
{
}
}
}
58 changes: 57 additions & 1 deletion src/Ubiety.Dns.Core/Records/RecordKX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Ubiety.Dns.Core.Records
/// <summary>
/// Key exchange record
/// </summary>
public class RecordKx : Record, IComparable
public class RecordKx : Record, IComparable, IEquatable<RecordKx>
{
/// <summary>
/// Initializes a new instance of the <see cref="RecordKx" /> class
Expand Down Expand Up @@ -95,5 +95,61 @@ public Int32 CompareTo(Object obj)
return String.Compare(this.Exchanger, recordKX.Exchanger, true, CultureInfo.InvariantCulture);
}
}

/// <summary>
/// Overrides equals
/// </summary>
/// <param name="obj">Object to compare to</param>
/// <returns>Boolean indicating whether the instances are equal</returns>
public override Boolean Equals(Object obj)
{
if (obj == null || this.GetType() != obj.GetType())
{
return false;
}

if (ReferenceEquals(null, obj))
{
return false;
}

if (ReferenceEquals(this, obj))
{
return true;
}

return this.Equals(obj as RecordKx);
}

/// <summary>
/// Are two instances of <see cref="RecordKx" /> equal
/// </summary>
/// <param name="other"><see cref="RecordKx" /> to compare to</param>
/// <returns>Boolean indicating whether the two instances are equal</returns>
public Boolean Equals(RecordKx other)
{
if (other == null)
{
return false;
}

return String.Equals(this.Exchanger, other.Exchanger, StringComparison.InvariantCulture);
}

/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Integer value of the hash</returns>
public override Int32 GetHashCode()
{
unchecked
{
var hashcode = 13;
hashcode = (hashcode * 397) ^ this.Preference;
var exHash = !String.IsNullOrEmpty(this.Exchanger) ? this.Exchanger.GetHashCode() : 0;
hashcode = (hashcode * 397) ^ exHash;
return hashcode;
}
}
}
}
12 changes: 8 additions & 4 deletions src/Ubiety.Dns.Core/Records/RecordTKEY.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;

/*
Expand Down Expand Up @@ -30,6 +31,9 @@ namespace Ubiety.Dns.Core.Records
/// </summary>
public class RecordTkey : Record
{
private Byte[] keyData;
private Byte[] otherData;

/// <summary>
/// Initializes a new instance of the <see cref="RecordTkey" /> class
/// </summary>
Expand All @@ -42,9 +46,9 @@ public RecordTkey(RecordReader rr)
this.Mode = rr.ReadUInt16();
this.Error = rr.ReadUInt16();
this.KeySize = rr.ReadUInt16();
this.KeyData = rr.ReadBytes(this.KeySize);
this.keyData = rr.ReadBytes(this.KeySize);
this.OtherSize = rr.ReadUInt16();
this.OtherData = rr.ReadBytes(this.OtherSize);
this.otherData = rr.ReadBytes(this.OtherSize);
}

/// <summary>
Expand Down Expand Up @@ -80,7 +84,7 @@ public RecordTkey(RecordReader rr)
/// <summary>
/// Gets the key data
/// </summary>
public byte[] KeyData { get; }
public List<Byte> KeyData { get => new List<Byte>(this.keyData); }

/// <summary>
/// Gets the other size from the record (Future use)
Expand All @@ -90,7 +94,7 @@ public RecordTkey(RecordReader rr)
/// <summary>
/// Gets the other data from the record (Future use)
/// </summary>
public byte[] OtherData { get; }
public List<Byte> OtherData { get => new List<Byte>(this.otherData); }

/// <summary>
/// String representation of the record data
Expand Down
16 changes: 10 additions & 6 deletions src/Ubiety.Dns.Core/Records/RecordTSIG.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;

/*
Expand Down Expand Up @@ -29,6 +30,9 @@ namespace Ubiety.Dns.Core.Records
/// </summary>
public class RecordTsig : Record
{
private Byte[] mac;
private Byte[] otherData;

/// <summary>
/// Initializes a new instance of the <see cref="RecordTsig" /> class
/// </summary>
Expand All @@ -39,11 +43,11 @@ public RecordTsig(RecordReader rr)
this.TimeSigned = rr.ReadUInt32() << 32 | rr.ReadUInt32();
this.Fudge = rr.ReadUInt16();
this.MacSize = rr.ReadUInt16();
this.Mac = rr.ReadBytes(this.MacSize);
this.mac = rr.ReadBytes(this.MacSize);
this.OriginalId = rr.ReadUInt16();
this.Error = rr.ReadUInt16();
this.OtherLength = rr.ReadUInt16();
this.OtherData = rr.ReadBytes(this.OtherLength);
this.otherData = rr.ReadBytes(this.OtherLength);
}

/// <summary>
Expand All @@ -67,9 +71,9 @@ public RecordTsig(RecordReader rr)
public UInt16 MacSize { get; set; }

/// <summary>
/// Gets or sets the MAC
/// Gets the MAC
/// </summary>
public Byte[] Mac { get; set; }
public List<Byte> Mac { get => new List<Byte>(this.mac); }

/// <summary>
/// Gets or sets the original id
Expand All @@ -87,9 +91,9 @@ public RecordTsig(RecordReader rr)
public UInt16 OtherLength { get; set; }

/// <summary>
/// Gets or sets the other record data
/// Gets the other record data
/// </summary>
public Byte[] OtherData { get; set; }
public List<Byte> OtherData { get => new List<Byte>(this.otherData); }

/// <summary>
/// String representation of the record data
Expand Down
13 changes: 8 additions & 5 deletions src/Ubiety.Dns.Core/Records/RecordWKS.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.ObjectModel;
using System.Globalization;

/*
Expand Down Expand Up @@ -53,8 +54,10 @@ namespace Ubiety.Dns.Core.Records
/// </summary>
public class RecordWks : Record
{
private Byte[] bitmap;

/// <summary>
/// Intializes a new instance of the <see cref="RecordWks" /> class
/// Initializes a new instance of the <see cref="RecordWks" /> class
/// </summary>
/// <param name="rr">Record reader for record data</param>
public RecordWks(RecordReader rr)
Expand All @@ -69,8 +72,8 @@ public RecordWks(RecordReader rr)
rr.ReadByte());
this.Protocol = (Int32)rr.ReadByte();
length -= 5;
this.Bitmap = new Byte[length];
this.Bitmap = rr.ReadBytes(length);
this.bitmap = new Byte[length];
this.bitmap = rr.ReadBytes(length);
}

/// <summary>
Expand All @@ -84,9 +87,9 @@ public RecordWks(RecordReader rr)
public Int32 Protocol { get; set; }

/// <summary>
/// Gets or sets the service bitmap
/// Gets the service bitmap
/// </summary>
public Byte[] Bitmap { get; set; }
public Collection<Byte> Bitmap { get => new Collection<Byte>(this.bitmap); }

/// <summary>
/// Return a string of the well known service record
Expand Down
4 changes: 2 additions & 2 deletions src/Ubiety.Dns.Core/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public Request()
/// </summary>
public Header Header { get; set; }


/// <summary>
/// Gets the request as a byte array
/// </summary>
public byte[] GetData()
/// <returns>Byte array of the data</returns>
public Byte[] GetData()
{
List<byte> data = new List<byte>();
this.Header.QuestionCount = (ushort)this.questions.Count;
Expand Down
Loading

0 comments on commit cbf984f

Please sign in to comment.