Skip to content

Commit 8490ead

Browse files
Code style updates
1 parent c055197 commit 8490ead

File tree

9 files changed

+43
-35
lines changed

9 files changed

+43
-35
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ indent_style = space
1212
# Code files
1313
[*.{cs,csx,vb,vbx}]
1414
indent_size = 4
15+
insert_final_newline = true
16+
charset = utf-8-bom
1517

1618
# Xml project files
1719
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]

Zeroconf/Dns/Header.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ ushort SetBits(ushort oldValue, int position, int length, ushort newValue)
181181
return oldValue;
182182

183183
// get some mask to put on
184-
int mask = (2 << (length - 1)) - 1;
184+
var mask = (2 << (length - 1)) - 1;
185185

186186
// clear out value
187187
oldValue &= (ushort)~(mask << position);
@@ -198,7 +198,7 @@ ushort GetBits(ushort oldValue, int position, int length)
198198
return 0;
199199

200200
// get some mask to put on
201-
int mask = (2 << (length - 1)) - 1;
201+
var mask = (2 << (length - 1)) - 1;
202202

203203
// shift down to get some value and mask it
204204
return (ushort)((oldValue >> position) & mask);
@@ -211,7 +211,7 @@ public byte[] Data
211211
{
212212
get
213213
{
214-
List<byte> data = new List<byte>();
214+
var data = new List<byte>();
215215
data.AddRange(WriteShort(ID));
216216
data.AddRange(WriteShort(Flags));
217217
data.AddRange(WriteShort(QDCOUNT));

Zeroconf/Dns/RecordNSEC.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class RecordNSEC : Record
1212
public RecordNSEC(RecordReader rr)
1313
{
1414
// re-read length
15-
ushort RDLENGTH = rr.ReadUInt16(-2);
15+
var RDLENGTH = rr.ReadUInt16(-2);
1616

1717
RDATA = rr.ReadBytes(RDLENGTH);
1818
}

Zeroconf/Dns/RecordReader.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public UInt32 ReadUInt32()
7171
public string ReadDomainName()
7272
{
7373
var bytes = new List<byte>();
74-
int length = 0;
74+
var length = 0;
7575

7676
// get the length of the first label
7777
while ((length = ReadByte()) != 0)
@@ -80,7 +80,7 @@ public string ReadDomainName()
8080
if ((length & 0xc0) == 0xc0)
8181
{
8282
// work out the existing domain name, copy this pointer
83-
RecordReader newRecordReader = new RecordReader(m_Data, (length & 0x3f) << 8 | ReadByte());
83+
var newRecordReader = new RecordReader(m_Data, (length & 0x3f) << 8 | ReadByte());
8484
if (bytes.Count > 0)
8585
{
8686
return Encoding.UTF8.GetString(bytes.ToArray(), 0, bytes.Count) + newRecordReader.ReadDomainName();
@@ -105,16 +105,16 @@ public string ReadString()
105105
{
106106
short length = ReadByte();
107107
var bytes = new List<byte>();
108-
for (int i=0;i<length;i++)
108+
for (var i=0;i<length;i++)
109109
bytes.Add(ReadByte());
110110
return Encoding.UTF8.GetString(bytes.ToArray(), 0, bytes.Count);
111111
}
112112

113113
// changed 28 augustus 2008
114114
public byte[] ReadBytes(int intLength)
115115
{
116-
byte[] list = new byte[intLength];
117-
for (int intI = 0; intI < intLength; intI++)
116+
var list = new byte[intLength];
117+
for (var intI = 0; intI < intLength; intI++)
118118
list[intI] = ReadByte();
119119
return list;
120120
}

Zeroconf/Dns/RecordTXT.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RecordTXT : Record
2828

2929
public RecordTXT(RecordReader rr, int Length)
3030
{
31-
int pos = rr.Position;
31+
var pos = rr.Position;
3232
TXT = new List<string>();
3333
while (
3434
((rr.Position - pos) < Length) &&
@@ -41,8 +41,8 @@ public RecordTXT(RecordReader rr, int Length)
4141

4242
public override string ToString()
4343
{
44-
StringBuilder sb = new StringBuilder();
45-
foreach (string txt in TXT)
44+
var sb = new StringBuilder();
45+
foreach (var txt in TXT)
4646
sb.AppendFormat("\"{0}\" ", txt);
4747
return sb.ToString().TrimEnd();
4848
}

Zeroconf/Dns/RecordUnknown.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class RecordUnknown : Record
88
public RecordUnknown(RecordReader rr)
99
{
1010
// re-read length
11-
ushort RDLENGTH = rr.ReadUInt16(-2);
11+
var RDLENGTH = rr.ReadUInt16(-2);
1212
RDATA = rr.ReadBytes(RDLENGTH);
1313
}
1414
}

Zeroconf/Dns/Response.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public Response(/*IPEndPoint iPEndPoint,*/ byte[] data)
6868
//Server = iPEndPoint;
6969
TimeStamp = DateTime.Now;
7070
MessageSize = data.Length;
71-
RecordReader rr = new RecordReader(data);
71+
var rr = new RecordReader(data);
7272

7373
Questions = new List<Question>();
7474
Answers = new List<AnswerRR>();
@@ -80,21 +80,21 @@ public Response(/*IPEndPoint iPEndPoint,*/ byte[] data)
8080
//if (header.RCODE != RCode.NoError)
8181
// Error = header.RCODE.ToString();
8282

83-
for (int intI = 0; intI < header.QDCOUNT; intI++)
83+
for (var intI = 0; intI < header.QDCOUNT; intI++)
8484
{
8585
Questions.Add(new Question(rr));
8686
}
8787

88-
for (int intI = 0; intI < header.ANCOUNT; intI++)
88+
for (var intI = 0; intI < header.ANCOUNT; intI++)
8989
{
9090
Answers.Add(new AnswerRR(rr));
9191
}
9292

93-
for (int intI = 0; intI < header.NSCOUNT; intI++)
93+
for (var intI = 0; intI < header.NSCOUNT; intI++)
9494
{
9595
Authorities.Add(new AuthorityRR(rr));
9696
}
97-
for (int intI = 0; intI < header.ARCOUNT; intI++)
97+
for (var intI = 0; intI < header.ARCOUNT; intI++)
9898
{
9999
Additionals.Add(new AdditionalRR(rr));
100100
}
@@ -126,8 +126,8 @@ public RecordTXT[] RecordsTXT
126126
{
127127
get
128128
{
129-
List<RecordTXT> list = new List<RecordTXT>();
130-
foreach (AnswerRR answerRR in this.Answers)
129+
var list = new List<RecordTXT>();
130+
foreach (var answerRR in this.Answers)
131131
{
132132
if (answerRR.RECORD is RecordTXT record)
133133
list.Add(record);
@@ -143,8 +143,8 @@ public RecordA[] RecordsA
143143
{
144144
get
145145
{
146-
List<RecordA> list = new List<RecordA>();
147-
foreach (AnswerRR answerRR in this.Answers)
146+
var list = new List<RecordA>();
147+
foreach (var answerRR in this.Answers)
148148
{
149149
if (answerRR.RECORD is RecordA record)
150150
list.Add(record);
@@ -160,8 +160,8 @@ public RecordPTR[] RecordsPTR
160160
{
161161
get
162162
{
163-
List<RecordPTR> list = new List<RecordPTR>();
164-
foreach (AnswerRR answerRR in this.Answers)
163+
var list = new List<RecordPTR>();
164+
foreach (var answerRR in this.Answers)
165165
{
166166
if (answerRR.RECORD is RecordPTR record)
167167
list.Add(record);
@@ -195,8 +195,8 @@ public RecordAAAA[] RecordsAAAA
195195
{
196196
get
197197
{
198-
List<RecordAAAA> list = new List<RecordAAAA>();
199-
foreach (AnswerRR answerRR in this.Answers)
198+
var list = new List<RecordAAAA>();
199+
foreach (var answerRR in this.Answers)
200200
{
201201
if (answerRR.RECORD is RecordAAAA record)
202202
list.Add(record);
@@ -245,7 +245,7 @@ public RR[] RecordsRR
245245
{
246246
get
247247
{
248-
List<RR> list = new List<RR>();
248+
var list = new List<RR>();
249249
foreach (RR rr in this.Answers)
250250
{
251251
list.Add(rr);

Zeroconf/ZeroconfResolver.Async.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public static bool IsiOSWorkaroundEnabled
276276
{
277277
get
278278
{
279-
bool result = false;
279+
var result = false;
280280

281281
#if __IOS__
282282
if (UIDevice.CurrentDevice.CheckSystemVersion(14, 5) && !UseBSDSocketsZeroconfOniOS)
@@ -296,7 +296,7 @@ public static bool IsiOSWorkaroundEnabled
296296
/// <returns></returns>
297297
public static IReadOnlyList<string> GetiOSInfoPlistServices(string domain = null)
298298
{
299-
List<string> serviceList = new List<string>();
299+
var serviceList = new List<string>();
300300

301301
#if __IOS__
302302
if (UIDevice.CurrentDevice.CheckSystemVersion(14, 5) && !UseBSDSocketsZeroconfOniOS)
@@ -314,19 +314,25 @@ public static IReadOnlyList<string> GetiOSInfoPlistServices(string domain = null
314314
/// <param name="scanTime">How long NSNetServiceBrowser will scan for mDNS domains (default is 2 seconds)</param>
315315
/// <param name="cancellationToken"></param>
316316
/// <returns></returns>
317-
public static async Task<IReadOnlyList<string>> GetiOSDomains(TimeSpan scanTime = default(TimeSpan),
317+
public static
318+
#if __IOS__
319+
async
320+
#endif
321+
Task<IReadOnlyList<string>> GetiOSDomains(TimeSpan scanTime = default(TimeSpan),
318322
CancellationToken cancellationToken = default(CancellationToken))
319323
{
320-
List<string> domainList = new List<string>();
321-
322324
#if __IOS__
325+
var domainList = new List<string>();
326+
323327
if (UIDevice.CurrentDevice.CheckSystemVersion(14, 5) && !UseBSDSocketsZeroconfOniOS)
324328
{
325329
domainList.AddRange(await ZeroconfNetServiceBrowser.GetDomains((scanTime != default(TimeSpan)) ? scanTime : TimeSpan.FromSeconds(2), cancellationToken));
326330
}
331+
return domainList;
332+
#else
333+
return Task.FromResult((IReadOnlyList<string>)new List<string>());
327334
#endif
328335

329-
return domainList;
330336
}
331337
}
332338
}

Zeroconf/ZeroconfResolver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static byte[] GetRequestBytes(ZeroconfOptions options)
8989

9090
static ZeroconfHost ResponseToZeroconf(Response response, string remoteAddress, ResolveOptions options)
9191
{
92-
List<string> ipv4Adresses = response.Answers
92+
var ipv4Adresses = response.Answers
9393
.Select(r => r.RECORD)
9494
.OfType<RecordA>()
9595
.Concat(response.Additionals
@@ -99,7 +99,7 @@ static ZeroconfHost ResponseToZeroconf(Response response, string remoteAddress,
9999
.Distinct()
100100
.ToList();
101101

102-
List<string> ipv6Adresses = response.Answers
102+
var ipv6Adresses = response.Answers
103103
.Select(r => r.RECORD)
104104
.OfType<RecordAAAA>()
105105
.Concat(response.Additionals

0 commit comments

Comments
 (0)