Skip to content

Commit 942c8bf

Browse files
committed
[fix] nullability warnings
1 parent 9eaa5a8 commit 942c8bf

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

src/Etcd.Microsoft.Extensions.Configuration/Client/EtcdKeyValueClient.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class EtcdKeyValueClient : IEtcdKeyValueClient
2525
private readonly bool _enableWatch;
2626
private readonly bool _unwatchOnDispose;
2727

28-
private readonly IList<long> _watchIDs = new List<long>();
28+
private readonly IList<long> _watchIDs = [];
2929
private readonly object _locker = new();
3030

3131
private string? _userName;
@@ -75,8 +75,7 @@ public EtcdKeyValueClient(IEtcdClientFactory clientFactory, ICredentials credent
7575
/// <summary>
7676
/// Gets all keys available to user.
7777
/// </summary>
78-
/// <returns></returns>
79-
public IDictionary<string, string> GetAllKeys()
78+
public IDictionary<string, string?> GetAllKeys()
8079
{
8180
CheckIsAuthenticated();
8281

@@ -108,7 +107,6 @@ public IDictionary<string, string> GetAllKeys()
108107
/// Gets the value.
109108
/// </summary>
110109
/// <param name="key">The key.</param>
111-
/// <returns></returns>
112110
public string? GetValue(string key)
113111
{
114112
CheckIsAuthenticated();
@@ -172,10 +170,7 @@ private IEnumerable<Permission> GetPermissions(string role) =>
172170
}, GetMetadata()).Perm;
173171

174172
private Metadata GetMetadata() =>
175-
new()
176-
{
177-
new("token", _token!)
178-
};
173+
[new Metadata.Entry("token", _token!)];
179174

180175
private void CheckIsAuthenticated()
181176
{

src/Etcd.Microsoft.Extensions.Configuration/Client/IEtcdKeyValueClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public interface IEtcdKeyValueClient : IDisposable
2727
/// Gets all keys available to user.
2828
/// </summary>
2929
/// <returns></returns>
30-
IDictionary<string, string> GetAllKeys();
30+
IDictionary<string, string?> GetAllKeys();
3131

3232
/// <summary>
3333
/// Gets the value.

src/Etcd.Microsoft.Extensions.Configuration/EtcdConfigurationProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using System.Collections.Generic;
3-
using Microsoft.Extensions.Configuration;
43
using Etcd.Microsoft.Extensions.Configuration.Client;
54
using Etcd.Microsoft.Extensions.Configuration.Watch;
5+
using Microsoft.Extensions.Configuration;
66

77
namespace Etcd.Microsoft.Extensions.Configuration;
88

@@ -43,7 +43,7 @@ public EtcdConfigurationProvider(IEtcdKeyValueClient client, string? keyPrefix =
4343
/// <returns>
4444
/// True if key has a value, false otherwise.
4545
/// </returns>
46-
public override bool TryGet(string key, out string value) =>
46+
public override bool TryGet(string key, out string? value) =>
4747
base.TryGet(_keyPrefix == null
4848
? key
4949
: _keyPrefix + ":" + key
@@ -53,7 +53,7 @@ public override bool TryGet(string key, out string value) =>
5353
/// <param name="earlierKeys">The earlier keys that other providers contain.</param>
5454
/// <param name="parentPath">The path for the parent IConfiguration.</param>
5555
/// <returns>The list of keys for this provider.</returns>
56-
public override IEnumerable<string> GetChildKeys(IEnumerable<string> earlierKeys, string parentPath) =>
56+
public override IEnumerable<string> GetChildKeys(IEnumerable<string> earlierKeys, string? parentPath) =>
5757
base.GetChildKeys(earlierKeys,
5858
_keyPrefix != null
5959
? _keyPrefix + ":" + parentPath

src/Etcd.Microsoft.Extensions.Configuration/Util/Convert.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ public static class Convert
1515
/// Converts the KeyValue list to dictionary.
1616
/// </summary>
1717
/// <param name="list">The list.</param>
18-
/// <returns></returns>
19-
public static IDictionary<string, string> ToDictionary(IList<KeyValue> list) => list.ToDictionary(x => x.Key.ToStringUtf8(), x => x.Value.ToStringUtf8());
18+
public static IDictionary<string, string?> ToDictionary(IList<KeyValue> list) => list.ToDictionary(x => x.Key.ToStringUtf8(), x => x.Value?.ToStringUtf8());
2019

2120
/// <summary>
2221
/// Converts dotnet-etcd EventType to to local EventType.
2322
/// </summary>
2423
/// <param name="sourceType">Type of the source.</param>
25-
/// <returns></returns>
2624
public static EventType ToEventType(Event.Types.EventType sourceType) =>
2725
sourceType switch
2826
{

0 commit comments

Comments
 (0)