Skip to content

Commit 00d89a0

Browse files
feat: Set nullable for generated model classes (#93)
Co-authored-by: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com>
1 parent 170ea15 commit 00d89a0

301 files changed

Lines changed: 1758 additions & 1443 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Docker.DotNet/Endpoints/ContainerOperations.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ public async Task<CreateContainerResponse> CreateContainerAsync(CreateContainerP
4545
throw new ArgumentNullException(nameof(parameters));
4646
}
4747

48-
IQueryString? queryParameters = null;
49-
if (!string.IsNullOrEmpty(parameters.Name))
50-
{
51-
queryParameters = new QueryString<CreateContainerParameters>(parameters);
52-
}
48+
var queryParameters = new QueryString<CreateContainerParameters>(parameters);
5349

5450
var data = new JsonRequestContent<CreateContainerParameters>(parameters, DockerClient.JsonSerializer);
5551

@@ -130,10 +126,13 @@ public async Task<MultiplexedStream> GetContainerLogsAsync(string id, ContainerL
130126
var containerInspectResponse = await InspectContainerAsync(id, cancellationToken)
131127
.ConfigureAwait(false);
132128

129+
var containerConfig = containerInspectResponse.Config
130+
?? throw new InvalidOperationException("Container inspect response did not include container configuration.");
131+
133132
var response = await _client.MakeRequestForStreamAsync([NoSuchContainerHandler], HttpMethod.Get, $"containers/{id}/logs", queryParameters, null, null, cancellationToken)
134133
.ConfigureAwait(false);
135134

136-
return new MultiplexedStream(response, !containerInspectResponse.Config.Tty);
135+
return new MultiplexedStream(response, !containerConfig.Tty);
137136
}
138137

139138
public async Task<IList<ContainerFileSystemChangeResponse>> InspectChangesAsync(string id, CancellationToken cancellationToken = default)
@@ -350,10 +349,13 @@ public async Task<MultiplexedStream> AttachContainerAsync(string id, ContainerAt
350349
var containerInspectResponse = await InspectContainerAsync(id, cancellationToken)
351350
.ConfigureAwait(false);
352351

352+
var containerConfig = containerInspectResponse.Config
353+
?? throw new InvalidOperationException("Container inspect response did not include container configuration.");
354+
353355
var response = await _client.MakeRequestForHijackedStreamAsync([NoSuchContainerHandler], HttpMethod.Post, $"containers/{id}/attach", queryParameters, null, null, cancellationToken)
354356
.ConfigureAwait(false);
355357

356-
return new MultiplexedStream(response, !containerInspectResponse.Config.Tty);
358+
return new MultiplexedStream(response, !containerConfig.Tty);
357359
}
358360

359361
public async Task<ContainerWaitResponse> WaitContainerAsync(string id, CancellationToken cancellationToken = default)

src/Docker.DotNet/Endpoints/ImageOperations.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,25 @@ private static Dictionary<string, string> RegistryAuthHeaders(AuthConfig? authCo
305305
};
306306
}
307307

308-
private static Dictionary<string, string> RegistryConfigHeaders(IEnumerable<AuthConfig>? authConfig)
308+
private static Dictionary<string, string> RegistryConfigHeaders(IEnumerable<AuthConfig>? authConfigs)
309309
{
310-
var configDictionary = (authConfig ?? Array.Empty<AuthConfig>()).ToDictionary(e => e.ServerAddress, e => e);
310+
var registryAuthConfigurations = new Dictionary<string, AuthConfig>();
311+
312+
foreach (var registryAuthConfiguration in authConfigs ?? Array.Empty<AuthConfig>())
313+
{
314+
var registryAddress = registryAuthConfiguration.ServerAddress;
315+
316+
if (!string.IsNullOrEmpty(registryAddress))
317+
{
318+
registryAuthConfigurations[registryAddress] = registryAuthConfiguration;
319+
}
320+
}
321+
311322
return new Dictionary<string, string>
312323
{
313324
{
314325
RegistryConfigHeaderKey,
315-
Convert.ToBase64String(DockerClient.JsonSerializer.SerializeToUtf8Bytes(configDictionary))
326+
Convert.ToBase64String(DockerClient.JsonSerializer.SerializeToUtf8Bytes(registryAuthConfigurations))
316327
}
317328
};
318329
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
#nullable enable
12
namespace Docker.DotNet.Models
23
{
34
public class Actor // (events.Actor)
45
{
56
[JsonPropertyName("ID")]
6-
public string ID { get; set; }
7+
public string ID { get; set; } = default!;
78

89
[JsonPropertyName("Attributes")]
9-
public IDictionary<string, string> Attributes { get; set; }
10+
public IDictionary<string, string> Attributes { get; set; } = default!;
1011
}
1112
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
#nullable enable
12
namespace Docker.DotNet.Models
23
{
34
public class Annotations // (swarm.Annotations)
45
{
56
[JsonPropertyName("Name")]
6-
public string Name { get; set; }
7+
public string? Name { get; set; }
78

89
[JsonPropertyName("Labels")]
9-
public IDictionary<string, string> Labels { get; set; }
10+
public IDictionary<string, string> Labels { get; set; } = default!;
1011
}
1112
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
#nullable enable
12
namespace Docker.DotNet.Models
23
{
34
public class AppArmorOpts // (swarm.AppArmorOpts)
45
{
56
[JsonPropertyName("Mode")]
6-
public string Mode { get; set; }
7+
public string? Mode { get; set; }
78
}
89
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
#nullable enable
12
namespace Docker.DotNet.Models
23
{
34
public class AttestationProperties // (image.AttestationProperties)
45
{
56
[JsonPropertyName("For")]
6-
public string For { get; set; }
7+
public string For { get; set; } = default!;
78
}
89
}
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1+
#nullable enable
12
namespace Docker.DotNet.Models
23
{
34
public class AuthConfig // (registry.AuthConfig)
45
{
56
[JsonPropertyName("username")]
6-
public string Username { get; set; }
7+
public string? Username { get; set; }
78

89
[JsonPropertyName("password")]
9-
public string Password { get; set; }
10+
public string? Password { get; set; }
1011

1112
[JsonPropertyName("auth")]
12-
public string Auth { get; set; }
13+
public string? Auth { get; set; }
1314

1415
[JsonPropertyName("serveraddress")]
15-
public string ServerAddress { get; set; }
16+
public string? ServerAddress { get; set; }
1617

1718
[JsonPropertyName("identitytoken")]
18-
public string IdentityToken { get; set; }
19+
public string? IdentityToken { get; set; }
1920

2021
[JsonPropertyName("registrytoken")]
21-
public string RegistryToken { get; set; }
22+
public string? RegistryToken { get; set; }
2223
}
2324
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
#nullable enable
12
namespace Docker.DotNet.Models
23
{
34
public class AuthResponse // (registry.AuthResponse)
45
{
56
[JsonPropertyName("IdentityToken")]
6-
public string IdentityToken { get; set; }
7+
public string? IdentityToken { get; set; }
78

89
[JsonPropertyName("Status")]
9-
public string Status { get; set; }
10+
public string Status { get; set; } = default!;
1011
}
1112
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1+
#nullable enable
12
namespace Docker.DotNet.Models
23
{
34
public class BindOptions // (mount.BindOptions)
45
{
56
[JsonPropertyName("Propagation")]
6-
public string Propagation { get; set; }
7+
public string? Propagation { get; set; }
78

89
[JsonPropertyName("NonRecursive")]
9-
public bool NonRecursive { get; set; }
10+
public bool? NonRecursive { get; set; }
1011

1112
[JsonPropertyName("CreateMountpoint")]
12-
public bool CreateMountpoint { get; set; }
13+
public bool? CreateMountpoint { get; set; }
1314

1415
[JsonPropertyName("ReadOnlyNonRecursive")]
15-
public bool ReadOnlyNonRecursive { get; set; }
16+
public bool? ReadOnlyNonRecursive { get; set; }
1617

1718
[JsonPropertyName("ReadOnlyForceRecursive")]
18-
public bool ReadOnlyForceRecursive { get; set; }
19+
public bool? ReadOnlyForceRecursive { get; set; }
1920
}
2021
}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
#nullable enable
12
namespace Docker.DotNet.Models
23
{
34
public class BlkioStatEntry // (container.BlkioStatEntry)
45
{
56
[JsonPropertyName("major")]
6-
public ulong Major { get; set; }
7+
public ulong Major { get; set; } = default!;
78

89
[JsonPropertyName("minor")]
9-
public ulong Minor { get; set; }
10+
public ulong Minor { get; set; } = default!;
1011

1112
[JsonPropertyName("op")]
12-
public string Op { get; set; }
13+
public string Op { get; set; } = default!;
1314

1415
[JsonPropertyName("value")]
15-
public ulong Value { get; set; }
16+
public ulong Value { get; set; } = default!;
1617
}
1718
}

0 commit comments

Comments
 (0)