Skip to content

Commit 982f47f

Browse files
authored
Update src deps to latest minor. Update test deps. Run code cleanup. (#52)
1 parent 77d2b28 commit 982f47f

22 files changed

Lines changed: 174 additions & 154 deletions

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ matrix:
1212
include:
1313
- os: linux
1414
sudo: required
15-
dotnet: 2.0.0
15+
dotnet: 2.1.403
1616
- os: osx
1717
osx_image: xcode9 # OSX 10.12
18-
dotnet: 2.0.0
18+
dotnet: 2.1.403
1919
before_install:
2020
- ulimit -n 4096
2121
script:

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set -e
44

55
# Build
66
dotnet build src/Winton.Extensions.Configuration.Consul --configuration Release --framework netstandard2.0
7-
dotnet build test/Winton.Extensions.Configuration.Consul.Test --configuration Release --framework netcoreapp2.0
8-
dotnet build test/Website --configuration Release --framework netcoreapp2.0
7+
dotnet build test/Winton.Extensions.Configuration.Consul.Test --configuration Release --framework netcoreapp2.1
8+
dotnet build test/Website --configuration Release --framework netcoreapp2.1
99

1010
# Unit Test
1111
dotnet test test/Winton.Extensions.Configuration.Consul.Test/ --no-build --no-restore --configuration Release

src/Winton.Extensions.Configuration.Consul/ConsulConfigurationClient.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the Apache License, Version 2.0. See LICENCE in the project root for license information.
33

44
using System;
5-
using System.Collections.Generic;
65
using System.Net;
76
using System.Threading;
87
using System.Threading.Tasks;
@@ -32,13 +31,19 @@ public async Task<QueryResult<KVPair[]>> GetConfig(string key, CancellationToken
3231
return result;
3332
}
3433

35-
public IChangeToken Watch(string key, Action<ConsulWatchExceptionContext> onException, CancellationToken cancellationToken)
34+
public IChangeToken Watch(
35+
string key,
36+
Action<ConsulWatchExceptionContext> onException,
37+
CancellationToken cancellationToken)
3638
{
3739
Task.Run(() => PollForChanges(key, onException, cancellationToken));
3840
return _reloadToken;
3941
}
4042

41-
private async Task<QueryResult<KVPair[]>> GetKvPairs(string key, CancellationToken cancellationToken, QueryOptions queryOptions = null)
43+
private async Task<QueryResult<KVPair[]>> GetKvPairs(
44+
string key,
45+
CancellationToken cancellationToken,
46+
QueryOptions queryOptions = null)
4247
{
4348
using (IConsulClient consulClient = _consulClientFactory.Create())
4449
{
@@ -72,7 +77,10 @@ private async Task<bool> HasValueChanged(string key, CancellationToken cancellat
7277
return result != null && UpdateLastIndex(result);
7378
}
7479

75-
private async Task PollForChanges(string key, Action<ConsulWatchExceptionContext> onException, CancellationToken cancellationToken)
80+
private async Task PollForChanges(
81+
string key,
82+
Action<ConsulWatchExceptionContext> onException,
83+
CancellationToken cancellationToken)
7684
{
7785
while (!cancellationToken.IsCancellationRequested)
7886
{

src/Winton.Extensions.Configuration.Consul/ConsulConfigurationProvider.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Licensed under the Apache License, Version 2.0. See LICENCE in the project root for license information.
33

44
using System;
5-
using System.Collections.Generic;
6-
using System.IO;
75
using System.Linq;
86
using System.Threading.Tasks;
97
using Consul;

src/Winton.Extensions.Configuration.Consul/ConsulWatchExceptionContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ internal ConsulWatchExceptionContext(CancellationToken cancellationToken, Except
1818
}
1919

2020
/// <summary>
21-
/// Gets the <see cref="Exception" /> that occured.
21+
/// Gets the <see cref="CancellationToken" /> for the watch task which can be used to terminate it.
2222
/// </summary>
23-
public Exception Exception { get; }
23+
public CancellationToken CancellationToken { get; }
2424

2525
/// <summary>
26-
/// Gets the <see cref="CancellationToken" /> for the watch task which can be used to terminate it.
26+
/// Gets the <see cref="Exception" /> that occured.
2727
/// </summary>
28-
public CancellationToken CancellationToken { get; }
28+
public Exception Exception { get; }
2929
}
3030
}

src/Winton.Extensions.Configuration.Consul/Extensions/KVPairExtensions.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Winton. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENCE in the project root for license information.
33

4-
using System;
54
using System.Collections.Generic;
65
using System.IO;
76
using System.Linq;
@@ -21,21 +20,22 @@ internal static IEnumerable<KeyValuePair<string, string>> ConvertToConfig(
2120
{
2221
return parser
2322
.Parse(stream)
24-
.Select(pair =>
25-
{
26-
var key = $"{kvPair.Key.TrimEnd('/')}:{pair.Key}"
27-
.Replace('/', ':')
28-
.TrimStart(rootKey.ToCharArray())
29-
.TrimStart(':')
30-
.TrimEnd(':');
31-
if (string.IsNullOrEmpty(key))
23+
.Select(
24+
pair =>
3225
{
33-
throw new InvalidKeyPairException(
34-
"The key must not be null or empty. Ensure that there is at least one key under the root of the config or that the data there contains more than just a single value.");
35-
}
26+
string key = $"{kvPair.Key.TrimEnd('/')}:{pair.Key}"
27+
.Replace('/', ':')
28+
.TrimStart(rootKey.ToCharArray())
29+
.TrimStart(':')
30+
.TrimEnd(':');
31+
if (string.IsNullOrEmpty(key))
32+
{
33+
throw new InvalidKeyPairException(
34+
"The key must not be null or empty. Ensure that there is at least one key under the root of the config or that the data there contains more than just a single value.");
35+
}
3636

37-
return new KeyValuePair<string, string>(key, pair.Value);
38-
});
37+
return new KeyValuePair<string, string>(key, pair.Value);
38+
});
3939
}
4040
}
4141

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
// Copyright (c) Winton. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENCE in the project root for license information.
33

4-
using System;
5-
using System.Collections.Generic;
64
using System.Linq;
75
using System.Net;
86
using Consul;
9-
using Winton.Extensions.Configuration.Consul.Parsers;
107

118
namespace Winton.Extensions.Configuration.Consul.Extensions
129
{
@@ -15,9 +12,9 @@ internal static class KVPairQueryResultExtensions
1512
internal static bool HasValue(this QueryResult<KVPair[]> queryResult)
1613
{
1714
return queryResult != null
18-
&& queryResult.StatusCode != HttpStatusCode.NotFound
19-
&& queryResult.Response != null
20-
&& queryResult.Response.Any(kvp => kvp.HasValue());
15+
&& queryResult.StatusCode != HttpStatusCode.NotFound
16+
&& queryResult.Response != null
17+
&& queryResult.Response.Any(kvp => kvp.HasValue());
2118
}
2219
}
2320
}

src/Winton.Extensions.Configuration.Consul/IConsulConfigurationClient.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ internal interface IConsulConfigurationClient
2323
/// <param name="onException">An action to be invoked if an exception occurs during the watch.</param>
2424
/// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
2525
/// <returns>An <see cref="IChangeToken" /> that will indicated when changes have occured.</returns>
26-
IChangeToken Watch(string key, Action<ConsulWatchExceptionContext> onException, CancellationToken cancellationToken);
26+
IChangeToken Watch(
27+
string key,
28+
Action<ConsulWatchExceptionContext> onException,
29+
CancellationToken cancellationToken);
2730
}
2831
}

src/Winton.Extensions.Configuration.Consul/Winton.Extensions.Configuration.Consul.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
</ItemGroup>
3232

3333
<ItemGroup>
34-
<PackageReference Include="Consul" Version="0.7.2.4" />
34+
<PackageReference Include="Consul" Version="0.7.2.6" />
3535
<PackageReference Include="GitVersionTask" Version="4.0.0-beta0012" PrivateAssets="All" />
36-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.1" />
36+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.2" />
3737
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="All" />
3838
</ItemGroup>
3939

stylecop.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
2-
"$schema":
3-
"https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/1.0.2/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
4-
"settings": {
5-
"documentationRules": {
6-
"companyName": "Winton",
7-
"copyrightText":
8-
"Copyright (c) {companyName}. All rights reserved.\nLicensed under the Apache License, Version 2.0. See LICENCE in the project root for license information.",
9-
"documentInternalElements": false,
10-
"xmlHeader": false
11-
},
12-
"maintainabilityRules": {
13-
"topLevelTypes": [
14-
"class",
15-
"enum",
16-
"interface",
17-
"struct"
18-
]
19-
},
20-
"orderingRules": {
21-
"blankLinesBetweenUsingGroups": "omit",
22-
"usingDirectivesPlacement": "outsideNamespace"
2+
"$schema":
3+
"https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/1.0.2/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
4+
"settings": {
5+
"documentationRules": {
6+
"companyName": "Winton",
7+
"copyrightText":
8+
"Copyright (c) {companyName}. All rights reserved.\nLicensed under the Apache License, Version 2.0. See LICENCE in the project root for license information.",
9+
"documentInternalElements": false,
10+
"xmlHeader": false
11+
},
12+
"maintainabilityRules": {
13+
"topLevelTypes": [
14+
"class",
15+
"enum",
16+
"interface",
17+
"struct"
18+
]
19+
},
20+
"orderingRules": {
21+
"blankLinesBetweenUsingGroups": "omit",
22+
"usingDirectivesPlacement": "outsideNamespace"
23+
}
2324
}
24-
}
2525
}

0 commit comments

Comments
 (0)